query
stringlengths
7
3.85k
document
stringlengths
11
430k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
WithPrevious adds the previous to the artifact lister o k response
func (o *ArtifactListerOK) WithPrevious(previous string) *ArtifactListerOK { o.Previous = previous return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) SetPrevious(previous string) {\n\to.Previous = previous\n}", "func (o *ArtifactListerPartialContent) WithPrevious(previous string) *ArtifactListerPartialContent {\n\to.Previous = previous\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetPrevious(previous string) {\n\to.Previous = previous\n}", "func (c *Client) PlaylistPrevious() error {\n\t_, err := c.Exec(\"playlist-prev\", \"weak\")\n\treturn err\n}", "func (h *History) Previous() {\n\tload := h.Load()\n\n\tif len(load) <= 1 {\n\t\tfmt.Println(\"history empty\")\n\t\tos.Exit(0)\n\t}\n\n\titem := make([]string, 1)\n\tcopy(item, load[len(load)-2:len(load)-1])\n\n\tprompt := promptui.Select{\n\t\tLabel: \"Prvious\",\n\t\tItems: item,\n\t}\n\n\t_, result, err := prompt.Run()\n\n\tif err != nil {\n\t\tlog.Fatalln(\"Prompt failed: \\n\", err)\n\t}\n\th.Write(result)\n\tExecuteItem(h.binary, result)\n}", "func (applications *Applications) Previous() (*Result, error) {\n\tif applications.PreviousURL != \"\" {\n\t\tbody, err := applications.getCursor(applications.PreviousURL)\n\t\tif err != nil {\n\t\t\tresult := &Result{}\n\t\t\tjson.Unmarshal(body, result)\n\t\t\treturn result, err\n\t\t}\n\t\treturn nil, nil\n\t}\n\treturn nil, errors.New(\"previous cursor not available\")\n}", "func (r Response) Prev() Command {\n\treturn Command{\n\t\tJID: r.IQ.From,\n\t\tSID: r.SID,\n\t\tNode: r.Node,\n\t\tAction: \"prev\",\n\t}\n}", "func WithPrev(prev *url.URL) Opt {\n\treturn func(opts *Options) {\n\t\topts.Prev = prev\n\t}\n}", "func (obj *MessengerCloudFsFileInfoList) Prev() *MessengerCloudFsFileInfoList {\n\tproxyResult := /*pr4*/ C.vssq_messenger_cloud_fs_file_info_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewMessengerCloudFsFileInfoListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (it *Iterator) Prev() {\n\tit.listIter.Prev()\n}", "func (as appendStrategy) previous() error {\n\treturn as.previousErr\n}", "func (e *RepoEntity) PreviousRemote() error {\n\te.Remote = e.Remotes[(len(e.Remotes)+e.currentRemoteIndex()-1)%len(e.Remotes)]\n\te.Remote.SyncBranches(e.Branch.Name)\n\treturn e.Publish(RepositoryUpdated, nil)\n}", "func (a *Art) SavePrevious(b *Buf) {\n\tif a.Page.AnsSave == \"on\" {\n\t\tb.ArrStr1 = append(append(b.ArrStr1, \" \"), a.Page.AnsWeb...)\n\t\tb.ArrStr2 = append(append(b.ArrStr2, \" \"), a.Page.AnsFile...)\n\t}\n\ta.Page.AnsWeb = b.ArrStr1\n\ta.Page.AnsFile = b.ArrStr2\n}", "func NextPrev(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Received Request: /MediaControls\")\n\taction := strings.TrimPrefix(r.URL.Path, \"/MediaControls/\")\n\tfmt.Println(\"Action:\", action)\n\n\tvar URL *url.URL\n\tURL, err := url.Parse(\"https://api.spotify.com\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tURL.Path += \"/v1/me/player\"\n\n\tclient := &http.Client{}\n\n\tswitch action {\n\tcase \"Next\":\n\t\tURL.Path += \"/next\"\n\tcase \"Previous\":\n\t\tURL.Path += \"/previous\"\n\t}\n\n\treq, err := http.NewRequest(\"POST\", URL.String(), nil)\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", \"Bearer \"+sAcsTok.AccessToken)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_, err = client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n}", "func (l *Linenoise) historyPrev(ls *linestate) string {\n\tif len(l.history) == 0 {\n\t\treturn \"\"\n\t}\n\t// update the current history entry with the line buffer\n\tl.historySet(ls.historyIndex, ls.String())\n\tls.historyIndex++\n\t// previous history item\n\tif ls.historyIndex >= len(l.history) {\n\t\tls.historyIndex = len(l.history) - 1\n\t}\n\treturn l.historyGet(ls.historyIndex)\n}", "func (app *folderNameBuilder) IsPrevious() FolderNameBuilder {\n\tapp.isPrevious = true\n\treturn app\n}", "func (p *Player) Previous() { p.Player.Call(INTERFACE+\".Player.Previous\", 0) }", "func WithPreviousImage(imageName string) ImageOption {\n\treturn func(opts *options) error {\n\t\topts.prevImageRepoName = imageName\n\t\treturn nil\n\t}\n}", "func WithPreviousImage(imageName string) ImageOption {\n\treturn func(i *options) error {\n\t\ti.prevImageRepoName = imageName\n\t\treturn nil\n\t}\n}", "func (s Shop) GetPreviousNamesAsString() (result string) {\n\tif len(s.PreviousNames) > 0 {\n\t\tresult = strings.Join(s.PreviousNames, \",\")\n\t}\n\treturn\n}", "func (player *Player) Previous() {\n\tplayer.obj.Call(\"org.mpris.MediaPlayer2.Player.Previous\", 0)\n}", "func (it *insertIterator) previous() *types.Header {\n\tif it.index < 1 {\n\t\treturn nil\n\t}\n\treturn it.chain[it.index-1].Header()\n}", "func (k *KVAsset) PreviousPayload() (*protobuffer.PBKVAsset, error) {\n\tif k == nil {\n\t\treturn nil, errors.New(\"KVAsset is nil\")\n\t}\n\tif k.CurrentAsset.Asset == nil {\n\t\treturn nil, errors.New(\"KVAsset has no asset\")\n\t}\n\tsignatureAsset := k.PreviousAsset.Asset\n\tkv := signatureAsset.GetKVAsset()\n\treturn kv, nil\n}", "func (i treapIter) prev() treapIter {\n\ti.t = i.t.pred(i.f)\n\treturn i\n}", "func (r *Raft) setPreviousLog(req *pb.AppendEntriesRequest, nextIndex uint64) error {\n\t// Guard for the first index, since there is no 0 log entry\n\t// Guard against the previous index being a snapshot as well\n\tlastSnapIdx, lastSnapTerm := r.getLastSnapshot()\n\tif nextIndex == 1 {\n\t\treq.PrevLogIndex = 0\n\t\treq.PrevLogTerm = 0\n\t} else if (nextIndex - 1) == lastSnapIdx {\n\t\treq.PrevLogIndex = lastSnapIdx\n\t\treq.PrevLogTerm = lastSnapTerm\n\t} else {\n\t\tvar l pb.Log\n\t\tif err := r.logs.GetLog(nextIndex-1, &l); err != nil {\n\t\t\tklog.Errorf(fmt.Sprintf(\"failed to get log index:%d err:%v\", nextIndex-1, err))\n\t\t\treturn err\n\t\t}\n\n\t\t// Set the previous index and term (0 if nextIndex is 1)\n\t\treq.PrevLogIndex = l.Index\n\t\treq.PrevLogTerm = l.Term\n\t}\n\treturn nil\n}", "func (cycle *Cycle) Prev() {\n\tif !cycle.showing {\n\t\treturn\n\t}\n\n\tif cycle.selected == -1 {\n\t\tcycle.selected = len(cycle.items) - 1\n\t} else {\n\t\tcycle.selected--\n\t}\n\n\tcycle.selected = misc.Mod(cycle.selected, len(cycle.items))\n\tcycle.highlight()\n}", "func (wr *WatchList) Prev() (w *Watch) {\n\tif wr.current != nil {\n\t\twr.current = wr.current.Prev\n\t}\n\tw = wr.current\n\treturn\n}", "func (i *Item) Prev() *Item {\n\treturn i.prev\n}", "func (p *PodsWidget) SelectPrev() {\n\tp.ScrollUp()\n}", "func (ref *UIElement) PreviousContents() []*UIElement {\n\treturn ref.SliceOfUIElementAttr(PreviousContentsAttribute)\n}", "func getPreviousDeployment(ctx context.Context, clientset kubernetes.Interface, controllerResource *piraeusv1.LinstorController, log logr.Logger) (string, error) {\n\tlog = log.WithValues(\n\t\t\"name\", controllerResource.Name,\n\t\t\"namespace\", controllerResource.Namespace,\n\t)\n\n\tmeta := getObjectMeta(controllerResource, \"%s-controller\")\n\n\tlog.V(DEBUG).Info(\"fetching existing deployment\", \"meta\", meta)\n\n\tdeployment, err := clientset.AppsV1().Deployments(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})\n\tif err != nil && !errors.IsNotFound(err) {\n\t\treturn \"\", fmt.Errorf(\"failed to check on existing deployment: %w\", err)\n\t}\n\n\tif deployment == nil {\n\t\tlog.V(DEBUG).Info(\"no deployment found, previous deployment unknown\")\n\n\t\treturn \"unknown\", nil\n\t}\n\n\tlog.V(DEBUG).Info(\"got deployment\")\n\n\tcontainers := deployment.Spec.Template.Spec.Containers\n\n\tfor i := range containers {\n\t\tif containers[i].Name == \"linstor-controller\" {\n\t\t\treturn containers[i].Image, nil\n\t\t}\n\t}\n\n\treturn \"\", nil\n}", "func (c *CompletionManager) Previous() {\n\tif c.verticalScroll == c.selected && c.selected > 0 {\n\t\tc.verticalScroll--\n\t}\n\tc.selected--\n\tc.update()\n}", "func (m *MockRepository) Previous(arg0 []bigmapdiff.BigMapDiff, arg1 int64, arg2 string) ([]bigmapdiff.BigMapDiff, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Previous\", arg0, arg1, arg2)\n\tret0, _ := ret[0].([]bigmapdiff.BigMapDiff)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (h *HandlersApp01sqVendor) ListPrev(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tvar offset int\n\tvar begin int\n\tvar cTable int\n\n\tlog.Printf(\"hndlrVendor.ListPrev(%s, %s)\\n\", r.Method, r.FormValue(\"offset\"))\n\n\tif r.Method != \"GET\" {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListPrev(Error:405) - Not GET\\n\")\n\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Calculate the offset.\n\tcTable, err = h.db.TableCount()\n\tif err != nil {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListLast(Error:400) - %s\\n\", util.ErrorString(err))\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t}\n\tbegin, _ = strconv.Atoi(r.FormValue(\"offset\"))\n\toffset = begin - h.rowsPerPage\n\tif offset < 0 {\n\t\tif begin > 0 {\n\t\t\toffset = 0\n\t\t} else {\n\t\t\toffset = cTable - h.rowsPerPage\n\t\t\tif offset < 0 {\n\t\t\t\toffset = 0\n\t\t\t}\n\t\t}\n\t}\n\n\t// Display the row in the form.\n\th.ListShow(w, offset, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.ListPrev()\\n\")\n\n}", "func (iter *SliceIterator) Prev() iterator.ConstBidIterator {\n\tif iter.position >= 0 {\n\t\titer.position--\n\t}\n\treturn iter\n}", "func (w *Window) Previous() error {\n\trawurl, err := w.history.Previous()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar u *url.URL\n\tif u, err = url.Parse(rawurl); err != nil {\n\t\treturn err\n\t}\n\treturn w.load(u)\n}", "func (eb EBlock) Prev() EBlock {\n\tif eb.IsFirst() {\n\t\treturn eb\n\t}\n\treturn EBlock{ChainID: eb.ChainID, KeyMR: eb.PrevKeyMR}\n}", "func (r *versionResolver) PreviousVersion(ctx context.Context, obj *restModel.APIVersion) (*restModel.APIVersion, error) {\n\tif !obj.IsPatchRequester() {\n\t\tpreviousVersion, err := model.VersionFindOne(model.VersionByProjectIdAndOrder(utility.FromStringPtr(obj.Project), obj.Order-1))\n\t\tif err != nil {\n\t\t\treturn nil, InternalServerError.Send(ctx, fmt.Sprintf(\"Error finding previous version for '%s': %s\", *obj.Id, err.Error()))\n\t\t}\n\t\tif previousVersion == nil {\n\t\t\treturn nil, nil\n\t\t}\n\t\tapiVersion := restModel.APIVersion{}\n\t\tapiVersion.BuildFromService(*previousVersion)\n\t\treturn &apiVersion, nil\n\t} else {\n\t\treturn nil, nil\n\t}\n}", "func (m *Mutation) SetPrevious(oldValueRevision uint64, oldValue []byte, copyPrevious bool) error {\n\tprevSignedEntry, err := FromLeafValue(oldValue)\n\tif err != nil {\n\t\treturn err\n\t}\n\tm.prevRev = oldValueRevision\n\tm.prevSignedEntry = prevSignedEntry\n\n\thash := sha256.Sum256(prevSignedEntry.GetEntry())\n\tm.entry.Previous = hash[:]\n\n\tvar prevEntry pb.Entry\n\tif err := proto.Unmarshal(prevSignedEntry.GetEntry(), &prevEntry); err != nil {\n\t\treturn err\n\t}\n\tif copyPrevious {\n\t\tm.entry.AuthorizedKeyset = prevEntry.GetAuthorizedKeyset()\n\t\tm.entry.Commitment = prevEntry.GetCommitment()\n\t}\n\treturn nil\n}", "func (s *State) FocusPrevious() {\n\ts.focused = s.lastFocusable\n\ts.update = true\n}", "func (this ActivityStreamsImagePropertyIterator) Prev() vocab.ActivityStreamsImagePropertyIterator {\n\tif this.myIdx-1 < 0 {\n\t\treturn nil\n\t} else {\n\t\treturn this.parent.At(this.myIdx - 1)\n\t}\n}", "func (m *Menu) SelectPrev() {\n\tm.selected--\n\n\tif m.selected < 0 {\n\t\tm.selected = len(m.items) - 1\n\t}\n\n\tm.updateVisibility()\n}", "func (o *MovableObject) Prev() {\n\to.point.X -= o.Arrow.X\n\to.point.Y -= o.Arrow.Y\n}", "func (i Item) Prev() *Item {\n\treturn i.prev\n}", "func (it *Skip_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func (l *List) AwayPrev() *Element {\n\treturn l.root.AwayPrev()\n}", "func (it *KeyAccess_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func WithPrevKV() OpOption {\n\treturn OpOption(etcd.WithPrevKV())\n}", "func (n *snode) previous() *snode {\n\treturn n.backward\n}", "func (nuo *NodeUpdateOne) ClearPrev() *NodeUpdateOne {\n\tnuo.clearedPrev = true\n\treturn nuo\n}", "func (h *History) Older(buf *Buffer) (new *Buffer, changed bool) {\n\tif len(h.tmp) == 1 || h.selected == 0 {\n\t\treturn buf, false\n\t}\n\th.tmp[h.selected] = buf.Text()\n\n\th.selected--\n\tnew = NewBuffer()\n\tnew.InsertText(h.tmp[h.selected], false, true)\n\treturn new, true\n}", "func (folderWatcher *FolderWatcher) getPreviousEntryList() []string {\n\treturn folderWatcher.previousEntries\n}", "func (nu *NodeUpdate) SetPrev(n *Node) *NodeUpdate {\n\treturn nu.SetPrevID(n.ID)\n}", "func (chunk *ResultNodeListChunk) Prev() *ResultNodeListChunk {\n\treturn chunk.prev\n}", "func (h *HandlersApp01sqVendor) RowPrev(w http.ResponseWriter, r *http.Request) {\n\tvar rcd App01sqVendor.App01sqVendor\n\tvar err error\n\tvar i int\n\tvar key string\n\n\tlog.Printf(\"hndlrVendor.RowPrev(%s)\\n\", r.Method)\n\n\tif r.Method != \"GET\" {\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Get the prior key(s).\n\ti = 0\n\tkey = r.FormValue(fmt.Sprintf(\"key%d\", i))\n\trcd.Id, _ = strconv.ParseInt(key, 0, 64)\n\n\ti++\n\n\t// Get the next row and display it.\n\terr = h.db.RowPrev(&rcd)\n\tif err != nil {\n\n\t\tlog.Printf(\"...end Vendor.RowNext(Error:400) - No Key\\n\")\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t\treturn\n\t}\n\th.RowDisplay(w, &rcd, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.RowPrev()\\n\")\n\n}", "func (_p *ArticlePage) Previous() ([]Article, error) {\n\tif _p.PageNum == 0 {\n\t\treturn nil, errors.New(\"This's the first page, no previous page yet\")\n\t}\n\tif _, exist := _p.Order[\"id\"]; !exist {\n\t\treturn nil, errors.New(\"No id order specified in Order map\")\n\t}\n\terr := _p.buildPageCount()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Calculate page count error: %v\", err)\n\t}\n\tif _p.orderStr == \"\" {\n\t\t_p.buildOrder()\n\t}\n\tidStr, idParams := _p.buildIdRestrict(\"previous\")\n\twhereStr := fmt.Sprintf(\"%s %s %s LIMIT %v\", _p.WhereString, idStr, _p.orderStr, _p.PerPage)\n\twhereParams := []interface{}{}\n\twhereParams = append(append(whereParams, _p.WhereParams...), idParams...)\n\tarticles, err := FindArticlesWhere(whereStr, whereParams...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(articles) != 0 {\n\t\t_p.FirstId, _p.LastId = articles[0].Id, articles[len(articles)-1].Id\n\t}\n\t_p.PageNum -= 1\n\treturn articles, nil\n}", "func (nuo *NodeUpdateOne) SetPrev(n *Node) *NodeUpdateOne {\n\treturn nuo.SetPrevID(n.ID)\n}", "func (el *Element) MustPrevious() *Element {\n\tparent, err := el.Previous()\n\tel.e(err)\n\treturn parent\n}", "func UsePreviousTemplate(params *cfn.UpdateStackInput) {\n\tparams.UsePreviousTemplate = aws.Bool(true)\n}", "func (obj *KeyHandlerList) Prev() *KeyHandlerList {\n\tproxyResult := /*pr4*/ C.vssc_key_handler_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewKeyHandlerListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (builder *Builder) PreviousLine(n uint) *Builder {\n\treturn builder.With(PreviousLine(n))\n}", "func (tm *Term) FilesPrev() error {\n\tnf := len(TheFiles)\n\ttm.FileSt = ints.MaxInt(tm.FileSt-1, 0)\n\ttm.FileSt = ints.MinInt(tm.FileSt, nf-tm.NFiles)\n\treturn tm.Draw()\n}", "func (nu *NodeUpdate) ClearPrev() *NodeUpdate {\n\tnu.clearedPrev = true\n\treturn nu\n}", "func (c *Counter) UpdatePrev() {\n\tc.prev = c.cur\n\tc.prevBytes = c.curBytes\n\tc.prevActiveSecs = c.curActiveSecs\n\tc.t = time.Now()\n}", "func (a *API) SetWidgetStatusCueListPrev(id int) error {\n\treturn a.setWidgetStatus(id, \"PREV\")\n}", "func (n *Node) setPrev(newPrev shared.NodeInfo) {\n\tn.prevLock.Lock()\n\n\tn.prev = newPrev\n\n\tn.prevLock.Unlock()\n\t//Used for visulization\n\t//n.updateState()\n}", "func (t *SkipList) Prev(e *SkipListElement) *SkipListElement {\n\tif e.prev == nil {\n\t\treturn t.endLevels[0]\n\t}\n\treturn e.prev\n}", "func (w *ListWidget) GoBack() {\n\teventing.Publish(\"list.prenavigate\", \"GOBACK\")\n\n\tif w.filterString != \"\" {\n\t\t// initial Back action is to clear filter, subsequent Back actions are normal\n\t\tw.ClearFilter()\n\t\treturn\n\t}\n\tpreviousPage := w.navStack.Pop()\n\tif previousPage == nil {\n\t\teventing.Publish(\"list.navigated\", ListNavigatedEventState{Success: false})\n\t\treturn\n\t}\n\tw.contentView.SetContent(previousPage.ExpandedNodeItem, previousPage.Data, previousPage.DataType, \"Response\")\n\tw.selected = 0\n\tw.items = previousPage.Value\n\tw.title = previousPage.Title\n\tw.selected = previousPage.Selection\n\tw.expandedNodeItem = previousPage.ExpandedNodeItem\n\n\teventing.Publish(\"list.navigated\", ListNavigatedEventState{\n\t\tSuccess: true,\n\t\tNewNodes: w.items,\n\t\tParentNodeID: w.expandedNodeItem.Parentid,\n\t\tIsBack: true,\n\t})\n}", "func (c *Comic) PrevComic() error {\n\tc.num, _ = strconv.Atoi(strings.ReplaceAll(c.PrevText(), \"/\", \"\"))\n\tresp, err := soup.Get(c.URL())\n\tdoc := soup.HTMLParse(resp)\n\tif err != nil {\n\t\treturn errNoInternet\n\t}\n\n\tc.html = doc\n\treturn nil\n}", "func (b *Build) PreviousActivated(project string, requester string) (*Build, error) {\n\treturn FindOne(ByRecentlyActivatedForProjectAndVariant(\n\t\tb.RevisionOrderNumber, project, b.BuildVariant, requester))\n}", "func (player *musicPlayer) previous() (string, error) {\n\tplayer.Lock()\n\tvar songToResume string\n\tif player.state.current > 0 {\n\t\tif player.state.status == playing {\n\t\t\tplayer.stopFlow()\n\t\t}\n\t\tplayer.state.current -= 1\n\t\tsongToResume = player.state.queue[player.state.current]\n\t} else {\n\t\tplayer.Unlock()\n\t\treturn songToResume, errors.New(cannot_previous_msg)\n\t}\n\n\tplayer.Unlock()\n\tch := make(chan error)\n\tdefer close(ch)\n\tgo player.playQueue(0, ch)\n\terr := <-ch\n\n\treturn songToResume, err\n}", "func (c *Cursor) Previous() {\n\tc.pos--\n}", "func (c *Collection) SetPrevSpec(s types.Spec) {\n\tc.writeTxn(func() error {\n\t\tcopy := s\n\t\tc.previous = &copy\n\t\treturn nil\n\t})\n}", "func (e *Element) ForEachPrev(f func(*Element)) {\n\tfor i := e.prev; i != e; i = i.prev {\n\t\tif i.list == nil || i != &e.list.root {\n\t\t\tf(i)\n\t\t}\n\t}\n}", "func (u *UserProfile) PreviousOrders(n int) ([]*EasyOrder, error) {\n\treturn u.ordersMeta.CustomerOrders, u.initOrdersMeta(n)\n}", "func (p *parser) previous() lexer.Token {\n\treturn p.tokens[p.current-1]\n}", "func (o *Links) SetPrev(v string) {\n\to.Prev = &v\n}", "func (obj *MessengerCloudFsFileInfoList) HasPrev() bool {\n\tproxyResult := /*pr4*/ C.vssq_messenger_cloud_fs_file_info_list_has_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn bool(proxyResult) /* r9 */\n}", "func (d *Driver) getPreviousEntry(ctx context.Context, entry nats.KeyValueEntry) (result *nats.KeyValueEntry, e error) {\n\tdefer func() {\n\t\tif result != nil {\n\t\t\tlogrus.Debugf(\"getPreviousEntry %s:%d found=true %d\", entry.Key(), entry.Revision(), (*result).Revision())\n\t\t} else {\n\t\t\tlogrus.Debugf(\"getPreviousEntry %s:%d found=false\", entry.Key(), entry.Revision())\n\t\t}\n\t}()\n\tfound := false\n\tentries, err := d.kv.History(entry.Key(), nats.Context(ctx))\n\tif err == nil {\n\t\tfor idx := len(entries) - 1; idx >= 0; idx-- {\n\t\t\tif found {\n\t\t\t\tif entries[idx].Operation() == nats.KeyValuePut {\n\t\t\t\t\treturn &entries[idx], nil\n\t\t\t\t}\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\tif entries[idx].Revision() == entry.Revision() {\n\t\t\t\tfound = true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, nil\n}", "func (r ApiListImagesRequest) History(history bool) ApiListImagesRequest {\n\tr.history = &history\n\treturn r\n}", "func (o OffsetPaginator) Prev() OffsetPaginator {\n\tprev := o\n\tprev.Offset = 0\n\tif prev.Offset > prev.Limit {\n\t\tprev.Offset = prev.Offset - prev.Limit\n\t}\n\treturn prev\n}", "func (w *ScrollWidget) PreviousLine() error {\n\terr := MoveLines(w.view, w.current, w.max, -1)\n\tw.current = GetLine(w.view)\n\treturn err\n}", "func (d *Decoder) prev(name string) (int64, error) {\n\tname = strings.TrimPrefix(name, \"prev.\")\n\n\t// TODO Instead of using a map, recurse up the d.stack/tree\n\n\tv, ok := d.prevMap[name]\n\tif !ok {\n\t\treturn -1, fmt.Errorf(\"no previous element named %q found\", name)\n\t}\n\n\tn, ok := v.Element.(*Number)\n\tif !ok {\n\t\treturn -1, fmt.Errorf(\"previous element %q must be a Number\", name)\n\t}\n\n\treturn n.Int(d.f, v)\n}", "func MessagePrevious(vm *VM, target, locals Interface, msg *Message) Interface {\n\tm := target.(*Message)\n\tif m.Prev == nil {\n\t\treturn vm.Nil\n\t}\n\treturn m.Prev\n}", "func (n *NodeConn) GetAsPrev() (prev *NodeComm) {\n\tprev = new(NodeComm)\n\tnext.in = n.comm[1]\n\tnext.out = n.comm[0]\n\tprev.dir = \"<-Prev\"\n\treturn prev\n}", "func (l *List) ForEachPrev(f func(*Element)) {\n\tfor e := l.root.prev; e != &l.root; e = e.prev {\n\t\tf(e)\n\t}\n}", "func (s *Select) GetPrevious(qe QueryExecer, dst interface{}, cursor string) error {\n\tif err := s.setCursor(cursor); err != nil {\n\t\treturn err\n\t}\n\ts.offset -= s.limit\n\tquery, args := s.Query()\n\trow := qe.QueryRow(query, args...)\n\terr := scanWithReflection(s.t.Fields(), row, dst)\n\treturn err\n}", "func (iter *ListIterator) Prev() iterator.ConstBidIterator {\n\tif iter.node != nil {\n\t\titer.node = iter.node.Prev()\n\t}\n\treturn iter\n}", "func (t *SpotifyDevice) PrevTrack() {\n\tif t.client == nil {\n\t\treturn\n\t}\n\tlog.Println(\"Previous track on Spotify device\")\n\tif err := t.client.PreviousOpt(t.playOpts); err != nil {\n\t\tlog.Println(err)\n\t}\n}", "func (lexto *LongLexto) Previous() Token {\n\tif lexto.HasPrevious() {\n\t\tresult := lexto.tokens[lexto.current]\n\t\tlexto.current -= 1\n\t\treturn result\n\t}\n\treturn Token{}\n}", "func (iter *SkipListIterator) Prev() {\n\told := iter.cursor\n\titer.cursor = C.skiplist_prev(iter.sl.csl, iter.cursor)\n\tif old != nil {\n\t\tC.skiplist_release_node(old)\n\t}\n}", "func (e *Element) Prev() *Element {\n\tif e != nil && e.prev != nil {\n\t\treturn e.prev\n\t}\n\treturn nil\n}", "func (tree *Tree23) Previous(t TreeNodeIndex) (TreeNodeIndex, error) {\n\tif tree.IsEmpty(t) {\n\t\treturn -1, errors.New(\"Previous() does not work for empty trees\")\n\t}\n\tif tree.IsLeaf(t) {\n\t\treturn tree.treeNodes[t].prev, nil\n\t}\n\treturn -1, errors.New(\"Previous() only works for leaf nodes!\")\n}", "func (li *List) selPrev(sel bool, update bool) *ListItem {\n\n\t// Check for empty list\n\tif len(li.items) == 0 {\n\t\treturn nil\n\t}\n\n\t// Find first selected item\n\tvar pos int\n\tif sel {\n\t\tpos = li.selected()\n\t} else {\n\t\tpos = li.highlighted()\n\t}\n\n\tvar newItem *ListItem\n\tnewSel := true\n\t// If no item found, returns first.\n\tif pos < 0 {\n\t\tnewItem = li.items[0].(*ListItem)\n\t\tif sel {\n\t\t\tnewItem.SetSelected(true)\n\t\t} else {\n\t\t\tnewItem.SetHighlighted(true)\n\t\t}\n\t} else {\n\t\titem := li.items[pos].(*ListItem)\n\t\tif pos == 0 {\n\t\t\tnewItem = item\n\t\t\tnewSel = false\n\t\t} else {\n\t\t\tnewItem = li.items[pos-1].(*ListItem)\n\t\t\tif sel {\n\t\t\t\titem.SetSelected(false)\n\t\t\t\tnewItem.SetSelected(true)\n\t\t\t} else {\n\t\t\t\titem.SetHighlighted(false)\n\t\t\t\tnewItem.SetHighlighted(true)\n\t\t\t}\n\t\t\tif (pos - 1) < li.first {\n\t\t\t\tli.ScrollUp()\n\t\t\t}\n\t\t}\n\t}\n\tif update {\n\t\tli.update()\n\t}\n\tif sel && newSel {\n\t\tli.Dispatch(OnChange, nil)\n\t}\n\treturn newItem\n}", "func (o ChangeSetOutput) UsePreviousParameters() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *ChangeSet) pulumi.BoolPtrOutput { return v.UsePreviousParameters }).(pulumi.BoolPtrOutput)\n}", "func (e *idElement) Prev() *idElement {\n\tif p := e.prev; e.list != nil && p != &e.list.root {\n\t\treturn p\n\t}\n\treturn nil\n}", "func (c Comic) PrevText() string {\n\treturn c.html.Find(\"a\", \"rel\", \"prev\").Attrs()[\"href\"]\n}", "func TestMergeWithPreviousBuilds(t *testing.T) {\n\tbuilds := MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img1\", \"tag1_1\"), artifact(\"img2\", \"tag2_1\")}, nil)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_1,img2:tag2_1\", tags(builds))\n\n\tbuilds = MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img1\", \"tag1_2\")}, builds)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_2,img2:tag2_1\", tags(builds))\n\n\tbuilds = MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img2\", \"tag2_2\")}, builds)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_2,img2:tag2_2\", tags(builds))\n\n\tbuilds = MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img1\", \"tag1_3\"), artifact(\"img2\", \"tag2_3\")}, builds)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_3,img2:tag2_3\", tags(builds))\n}", "func (e MoveObjectPreviousResponseValidationError) Reason() string { return e.reason }", "func (p PlayerIndex) Previous(state State) PlayerIndex {\n\tif p == AdminPlayerIndex || p == ObserverPlayerIndex {\n\t\treturn p\n\t}\n\tp--\n\tif int(p) < 0 {\n\t\tp = PlayerIndex(len(state.PlayerStates()) - 1)\n\t}\n\treturn p\n}" ]
[ "0.76308", "0.6955441", "0.68752134", "0.6169351", "0.6020429", "0.5993091", "0.59885836", "0.5842263", "0.58317107", "0.5777413", "0.5720675", "0.5687227", "0.5680128", "0.5671869", "0.5661059", "0.56137663", "0.5610555", "0.55352676", "0.55333525", "0.55176044", "0.5497521", "0.54953444", "0.5485639", "0.5480244", "0.5474756", "0.54702", "0.54640746", "0.5419354", "0.53895545", "0.53888077", "0.53759205", "0.5370675", "0.53706175", "0.53496385", "0.53456044", "0.53402144", "0.5333953", "0.5320546", "0.5310183", "0.5308808", "0.52939874", "0.52874196", "0.52844423", "0.5273026", "0.5246369", "0.52249855", "0.5224832", "0.5200511", "0.5196966", "0.5196346", "0.5189016", "0.51848257", "0.5170192", "0.516927", "0.51615804", "0.51588625", "0.5158421", "0.5152464", "0.51462865", "0.5128653", "0.51276875", "0.51247525", "0.5123406", "0.51117647", "0.51084036", "0.51021546", "0.50993496", "0.50924945", "0.5075177", "0.5071685", "0.50713736", "0.50566375", "0.5053395", "0.5045611", "0.50445616", "0.5043889", "0.5042668", "0.5030771", "0.50282836", "0.50260127", "0.500677", "0.49904463", "0.4989417", "0.4981428", "0.49710408", "0.49654773", "0.4963603", "0.49591413", "0.49588478", "0.49577227", "0.4956699", "0.49470782", "0.4939776", "0.49372765", "0.49349886", "0.4924924", "0.49233815", "0.49185896", "0.49089006", "0.49035707" ]
0.7789683
0
SetPrevious sets the previous to the artifact lister o k response
func (o *ArtifactListerOK) SetPrevious(previous string) { o.Previous = previous }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerPartialContent) SetPrevious(previous string) {\n\to.Previous = previous\n}", "func (o *ArtifactListerOK) WithPrevious(previous string) *ArtifactListerOK {\n\to.Previous = previous\n\treturn o\n}", "func (h *History) Previous() {\n\tload := h.Load()\n\n\tif len(load) <= 1 {\n\t\tfmt.Println(\"history empty\")\n\t\tos.Exit(0)\n\t}\n\n\titem := make([]string, 1)\n\tcopy(item, load[len(load)-2:len(load)-1])\n\n\tprompt := promptui.Select{\n\t\tLabel: \"Prvious\",\n\t\tItems: item,\n\t}\n\n\t_, result, err := prompt.Run()\n\n\tif err != nil {\n\t\tlog.Fatalln(\"Prompt failed: \\n\", err)\n\t}\n\th.Write(result)\n\tExecuteItem(h.binary, result)\n}", "func (o *ArtifactListerPartialContent) WithPrevious(previous string) *ArtifactListerPartialContent {\n\to.Previous = previous\n\treturn o\n}", "func (m *Mutation) SetPrevious(oldValueRevision uint64, oldValue []byte, copyPrevious bool) error {\n\tprevSignedEntry, err := FromLeafValue(oldValue)\n\tif err != nil {\n\t\treturn err\n\t}\n\tm.prevRev = oldValueRevision\n\tm.prevSignedEntry = prevSignedEntry\n\n\thash := sha256.Sum256(prevSignedEntry.GetEntry())\n\tm.entry.Previous = hash[:]\n\n\tvar prevEntry pb.Entry\n\tif err := proto.Unmarshal(prevSignedEntry.GetEntry(), &prevEntry); err != nil {\n\t\treturn err\n\t}\n\tif copyPrevious {\n\t\tm.entry.AuthorizedKeyset = prevEntry.GetAuthorizedKeyset()\n\t\tm.entry.Commitment = prevEntry.GetCommitment()\n\t}\n\treturn nil\n}", "func (r Response) Prev() Command {\n\treturn Command{\n\t\tJID: r.IQ.From,\n\t\tSID: r.SID,\n\t\tNode: r.Node,\n\t\tAction: \"prev\",\n\t}\n}", "func (c *Client) PlaylistPrevious() error {\n\t_, err := c.Exec(\"playlist-prev\", \"weak\")\n\treturn err\n}", "func (e *RepoEntity) PreviousRemote() error {\n\te.Remote = e.Remotes[(len(e.Remotes)+e.currentRemoteIndex()-1)%len(e.Remotes)]\n\te.Remote.SyncBranches(e.Branch.Name)\n\treturn e.Publish(RepositoryUpdated, nil)\n}", "func (n *Node) setPrev(newPrev shared.NodeInfo) {\n\tn.prevLock.Lock()\n\n\tn.prev = newPrev\n\n\tn.prevLock.Unlock()\n\t//Used for visulization\n\t//n.updateState()\n}", "func (r *Raft) setPreviousLog(req *pb.AppendEntriesRequest, nextIndex uint64) error {\n\t// Guard for the first index, since there is no 0 log entry\n\t// Guard against the previous index being a snapshot as well\n\tlastSnapIdx, lastSnapTerm := r.getLastSnapshot()\n\tif nextIndex == 1 {\n\t\treq.PrevLogIndex = 0\n\t\treq.PrevLogTerm = 0\n\t} else if (nextIndex - 1) == lastSnapIdx {\n\t\treq.PrevLogIndex = lastSnapIdx\n\t\treq.PrevLogTerm = lastSnapTerm\n\t} else {\n\t\tvar l pb.Log\n\t\tif err := r.logs.GetLog(nextIndex-1, &l); err != nil {\n\t\t\tklog.Errorf(fmt.Sprintf(\"failed to get log index:%d err:%v\", nextIndex-1, err))\n\t\t\treturn err\n\t\t}\n\n\t\t// Set the previous index and term (0 if nextIndex is 1)\n\t\treq.PrevLogIndex = l.Index\n\t\treq.PrevLogTerm = l.Term\n\t}\n\treturn nil\n}", "func (applications *Applications) Previous() (*Result, error) {\n\tif applications.PreviousURL != \"\" {\n\t\tbody, err := applications.getCursor(applications.PreviousURL)\n\t\tif err != nil {\n\t\t\tresult := &Result{}\n\t\t\tjson.Unmarshal(body, result)\n\t\t\treturn result, err\n\t\t}\n\t\treturn nil, nil\n\t}\n\treturn nil, errors.New(\"previous cursor not available\")\n}", "func (p *Player) Previous() { p.Player.Call(INTERFACE+\".Player.Previous\", 0) }", "func (player *Player) Previous() {\n\tplayer.obj.Call(\"org.mpris.MediaPlayer2.Player.Previous\", 0)\n}", "func (nu *NodeUpdate) SetPrev(n *Node) *NodeUpdate {\n\treturn nu.SetPrevID(n.ID)\n}", "func (a *Art) SavePrevious(b *Buf) {\n\tif a.Page.AnsSave == \"on\" {\n\t\tb.ArrStr1 = append(append(b.ArrStr1, \" \"), a.Page.AnsWeb...)\n\t\tb.ArrStr2 = append(append(b.ArrStr2, \" \"), a.Page.AnsFile...)\n\t}\n\ta.Page.AnsWeb = b.ArrStr1\n\ta.Page.AnsFile = b.ArrStr2\n}", "func (nuo *NodeUpdateOne) SetPrev(n *Node) *NodeUpdateOne {\n\treturn nuo.SetPrevID(n.ID)\n}", "func (c *CompletionManager) Previous() {\n\tif c.verticalScroll == c.selected && c.selected > 0 {\n\t\tc.verticalScroll--\n\t}\n\tc.selected--\n\tc.update()\n}", "func (c *Collection) SetPrevSpec(s types.Spec) {\n\tc.writeTxn(func() error {\n\t\tcopy := s\n\t\tc.previous = &copy\n\t\treturn nil\n\t})\n}", "func (s *State) FocusPrevious() {\n\ts.focused = s.lastFocusable\n\ts.update = true\n}", "func (l *Linenoise) historyPrev(ls *linestate) string {\n\tif len(l.history) == 0 {\n\t\treturn \"\"\n\t}\n\t// update the current history entry with the line buffer\n\tl.historySet(ls.historyIndex, ls.String())\n\tls.historyIndex++\n\t// previous history item\n\tif ls.historyIndex >= len(l.history) {\n\t\tls.historyIndex = len(l.history) - 1\n\t}\n\treturn l.historyGet(ls.historyIndex)\n}", "func (it *Iterator) Prev() {\n\tit.listIter.Prev()\n}", "func (m *NodeMutation) ResetPrev() {\n\tm.prev = nil\n\tm.clearedprev = false\n}", "func (obj *MessengerCloudFsFileInfoList) Prev() *MessengerCloudFsFileInfoList {\n\tproxyResult := /*pr4*/ C.vssq_messenger_cloud_fs_file_info_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewMessengerCloudFsFileInfoListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (cycle *Cycle) Prev() {\n\tif !cycle.showing {\n\t\treturn\n\t}\n\n\tif cycle.selected == -1 {\n\t\tcycle.selected = len(cycle.items) - 1\n\t} else {\n\t\tcycle.selected--\n\t}\n\n\tcycle.selected = misc.Mod(cycle.selected, len(cycle.items))\n\tcycle.highlight()\n}", "func (player *musicPlayer) previous() (string, error) {\n\tplayer.Lock()\n\tvar songToResume string\n\tif player.state.current > 0 {\n\t\tif player.state.status == playing {\n\t\t\tplayer.stopFlow()\n\t\t}\n\t\tplayer.state.current -= 1\n\t\tsongToResume = player.state.queue[player.state.current]\n\t} else {\n\t\tplayer.Unlock()\n\t\treturn songToResume, errors.New(cannot_previous_msg)\n\t}\n\n\tplayer.Unlock()\n\tch := make(chan error)\n\tdefer close(ch)\n\tgo player.playQueue(0, ch)\n\terr := <-ch\n\n\treturn songToResume, err\n}", "func (w *Window) Previous() error {\n\trawurl, err := w.history.Previous()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar u *url.URL\n\tif u, err = url.Parse(rawurl); err != nil {\n\t\treturn err\n\t}\n\treturn w.load(u)\n}", "func (m *MockRepository) Previous(arg0 []bigmapdiff.BigMapDiff, arg1 int64, arg2 string) ([]bigmapdiff.BigMapDiff, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Previous\", arg0, arg1, arg2)\n\tret0, _ := ret[0].([]bigmapdiff.BigMapDiff)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (o *Links) SetPrev(v string) {\n\to.Prev = &v\n}", "func (wr *WatchList) Prev() (w *Watch) {\n\tif wr.current != nil {\n\t\twr.current = wr.current.Prev\n\t}\n\tw = wr.current\n\treturn\n}", "func (o *MovableObject) Prev() {\n\to.point.X -= o.Arrow.X\n\to.point.Y -= o.Arrow.Y\n}", "func (k *KVAsset) PreviousPayload() (*protobuffer.PBKVAsset, error) {\n\tif k == nil {\n\t\treturn nil, errors.New(\"KVAsset is nil\")\n\t}\n\tif k.CurrentAsset.Asset == nil {\n\t\treturn nil, errors.New(\"KVAsset has no asset\")\n\t}\n\tsignatureAsset := k.PreviousAsset.Asset\n\tkv := signatureAsset.GetKVAsset()\n\treturn kv, nil\n}", "func (i treapIter) prev() treapIter {\n\ti.t = i.t.pred(i.f)\n\treturn i\n}", "func (mc *Chain) SetPreviousBlock(r round.RoundI, b *block.Block, pb *block.Block) {\n\tb.SetPreviousBlock(pb)\n\tmc.SetRoundRank(r, b)\n\tb.ComputeChainWeight()\n}", "func (p PlayerIndex) Previous(state State) PlayerIndex {\n\tif p == AdminPlayerIndex || p == ObserverPlayerIndex {\n\t\treturn p\n\t}\n\tp--\n\tif int(p) < 0 {\n\t\tp = PlayerIndex(len(state.PlayerStates()) - 1)\n\t}\n\treturn p\n}", "func (eb EBlock) Prev() EBlock {\n\tif eb.IsFirst() {\n\t\treturn eb\n\t}\n\treturn EBlock{ChainID: eb.ChainID, KeyMR: eb.PrevKeyMR}\n}", "func (app *folderNameBuilder) IsPrevious() FolderNameBuilder {\n\tapp.isPrevious = true\n\treturn app\n}", "func NextPrev(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Received Request: /MediaControls\")\n\taction := strings.TrimPrefix(r.URL.Path, \"/MediaControls/\")\n\tfmt.Println(\"Action:\", action)\n\n\tvar URL *url.URL\n\tURL, err := url.Parse(\"https://api.spotify.com\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tURL.Path += \"/v1/me/player\"\n\n\tclient := &http.Client{}\n\n\tswitch action {\n\tcase \"Next\":\n\t\tURL.Path += \"/next\"\n\tcase \"Previous\":\n\t\tURL.Path += \"/previous\"\n\t}\n\n\treq, err := http.NewRequest(\"POST\", URL.String(), nil)\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", \"Bearer \"+sAcsTok.AccessToken)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_, err = client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n}", "func (as appendStrategy) previous() error {\n\treturn as.previousErr\n}", "func (m *Menu) SelectPrev() {\n\tm.selected--\n\n\tif m.selected < 0 {\n\t\tm.selected = len(m.items) - 1\n\t}\n\n\tm.updateVisibility()\n}", "func getPreviousDeployment(ctx context.Context, clientset kubernetes.Interface, controllerResource *piraeusv1.LinstorController, log logr.Logger) (string, error) {\n\tlog = log.WithValues(\n\t\t\"name\", controllerResource.Name,\n\t\t\"namespace\", controllerResource.Namespace,\n\t)\n\n\tmeta := getObjectMeta(controllerResource, \"%s-controller\")\n\n\tlog.V(DEBUG).Info(\"fetching existing deployment\", \"meta\", meta)\n\n\tdeployment, err := clientset.AppsV1().Deployments(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})\n\tif err != nil && !errors.IsNotFound(err) {\n\t\treturn \"\", fmt.Errorf(\"failed to check on existing deployment: %w\", err)\n\t}\n\n\tif deployment == nil {\n\t\tlog.V(DEBUG).Info(\"no deployment found, previous deployment unknown\")\n\n\t\treturn \"unknown\", nil\n\t}\n\n\tlog.V(DEBUG).Info(\"got deployment\")\n\n\tcontainers := deployment.Spec.Template.Spec.Containers\n\n\tfor i := range containers {\n\t\tif containers[i].Name == \"linstor-controller\" {\n\t\t\treturn containers[i].Image, nil\n\t\t}\n\t}\n\n\treturn \"\", nil\n}", "func (this ActivityStreamsImagePropertyIterator) Prev() vocab.ActivityStreamsImagePropertyIterator {\n\tif this.myIdx-1 < 0 {\n\t\treturn nil\n\t} else {\n\t\treturn this.parent.At(this.myIdx - 1)\n\t}\n}", "func (nuo *NodeUpdateOne) ClearPrev() *NodeUpdateOne {\n\tnuo.clearedPrev = true\n\treturn nuo\n}", "func (c *Cursor) Previous() {\n\tc.pos--\n}", "func (it *Skip_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func (ref *UIElement) PreviousContents() []*UIElement {\n\treturn ref.SliceOfUIElementAttr(PreviousContentsAttribute)\n}", "func (n *snode) previous() *snode {\n\treturn n.backward\n}", "func (mr *MockRepositoryMockRecorder) Previous(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Previous\", reflect.TypeOf((*MockRepository)(nil).Previous), arg0, arg1, arg2)\n}", "func (i *Item) Prev() *Item {\n\treturn i.prev\n}", "func (c *Counter) UpdatePrev() {\n\tc.prev = c.cur\n\tc.prevBytes = c.curBytes\n\tc.prevActiveSecs = c.curActiveSecs\n\tc.t = time.Now()\n}", "func WithPreviousImage(imageName string) ImageOption {\n\treturn func(i *options) error {\n\t\ti.prevImageRepoName = imageName\n\t\treturn nil\n\t}\n}", "func (it *KeyAccess_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func (nu *NodeUpdate) ClearPrev() *NodeUpdate {\n\tnu.clearedPrev = true\n\treturn nu\n}", "func WithPreviousImage(imageName string) ImageOption {\n\treturn func(opts *options) error {\n\t\topts.prevImageRepoName = imageName\n\t\treturn nil\n\t}\n}", "func (iter *SkipListIterator) Prev() {\n\told := iter.cursor\n\titer.cursor = C.skiplist_prev(iter.sl.csl, iter.cursor)\n\tif old != nil {\n\t\tC.skiplist_release_node(old)\n\t}\n}", "func (iter *radixIterator) Prev() {\n\tif iter.resIter == nil {\n\t\treturn\n\t}\n\tif !iter.isReverser {\n\t\titer.SeekForPrev(iter.Key())\n\t\tif iter.err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\t// for reverse iterator, prev is just next\n\titer.cursorKey, iter.cursor = iter.resIter.Next()\n}", "func (el *Element) MustPrevious() *Element {\n\tparent, err := el.Previous()\n\tel.e(err)\n\treturn parent\n}", "func (o ChangeSetOutput) UsePreviousParameters() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *ChangeSet) pulumi.BoolPtrOutput { return v.UsePreviousParameters }).(pulumi.BoolPtrOutput)\n}", "func (a *API) SetWidgetStatusCueListPrev(id int) error {\n\treturn a.setWidgetStatus(id, \"PREV\")\n}", "func (r *versionResolver) PreviousVersion(ctx context.Context, obj *restModel.APIVersion) (*restModel.APIVersion, error) {\n\tif !obj.IsPatchRequester() {\n\t\tpreviousVersion, err := model.VersionFindOne(model.VersionByProjectIdAndOrder(utility.FromStringPtr(obj.Project), obj.Order-1))\n\t\tif err != nil {\n\t\t\treturn nil, InternalServerError.Send(ctx, fmt.Sprintf(\"Error finding previous version for '%s': %s\", *obj.Id, err.Error()))\n\t\t}\n\t\tif previousVersion == nil {\n\t\t\treturn nil, nil\n\t\t}\n\t\tapiVersion := restModel.APIVersion{}\n\t\tapiVersion.BuildFromService(*previousVersion)\n\t\treturn &apiVersion, nil\n\t} else {\n\t\treturn nil, nil\n\t}\n}", "func (b *Build) PreviousActivated(project string, requester string) (*Build, error) {\n\treturn FindOne(ByRecentlyActivatedForProjectAndVariant(\n\t\tb.RevisionOrderNumber, project, b.BuildVariant, requester))\n}", "func (folderWatcher *FolderWatcher) getPreviousEntryList() []string {\n\treturn folderWatcher.previousEntries\n}", "func (iter *SliceIterator) Prev() iterator.ConstBidIterator {\n\tif iter.position >= 0 {\n\t\titer.position--\n\t}\n\treturn iter\n}", "func (p *PodsWidget) SelectPrev() {\n\tp.ScrollUp()\n}", "func (t *SkipList) Prev(e *SkipListElement) *SkipListElement {\n\tif e.prev == nil {\n\t\treturn t.endLevels[0]\n\t}\n\treturn e.prev\n}", "func (tm *Term) FilesPrev() error {\n\tnf := len(TheFiles)\n\ttm.FileSt = ints.MaxInt(tm.FileSt-1, 0)\n\ttm.FileSt = ints.MinInt(tm.FileSt, nf-tm.NFiles)\n\treturn tm.Draw()\n}", "func (c *Comic) PrevComic() error {\n\tc.num, _ = strconv.Atoi(strings.ReplaceAll(c.PrevText(), \"/\", \"\"))\n\tresp, err := soup.Get(c.URL())\n\tdoc := soup.HTMLParse(resp)\n\tif err != nil {\n\t\treturn errNoInternet\n\t}\n\n\tc.html = doc\n\treturn nil\n}", "func UsePreviousTemplate(params *cfn.UpdateStackInput) {\n\tparams.UsePreviousTemplate = aws.Bool(true)\n}", "func (w *ScrollWidget) PreviousLine() error {\n\terr := MoveLines(w.view, w.current, w.max, -1)\n\tw.current = GetLine(w.view)\n\treturn err\n}", "func (_p *ArticlePage) Previous() ([]Article, error) {\n\tif _p.PageNum == 0 {\n\t\treturn nil, errors.New(\"This's the first page, no previous page yet\")\n\t}\n\tif _, exist := _p.Order[\"id\"]; !exist {\n\t\treturn nil, errors.New(\"No id order specified in Order map\")\n\t}\n\terr := _p.buildPageCount()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Calculate page count error: %v\", err)\n\t}\n\tif _p.orderStr == \"\" {\n\t\t_p.buildOrder()\n\t}\n\tidStr, idParams := _p.buildIdRestrict(\"previous\")\n\twhereStr := fmt.Sprintf(\"%s %s %s LIMIT %v\", _p.WhereString, idStr, _p.orderStr, _p.PerPage)\n\twhereParams := []interface{}{}\n\twhereParams = append(append(whereParams, _p.WhereParams...), idParams...)\n\tarticles, err := FindArticlesWhere(whereStr, whereParams...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(articles) != 0 {\n\t\t_p.FirstId, _p.LastId = articles[0].Id, articles[len(articles)-1].Id\n\t}\n\t_p.PageNum -= 1\n\treturn articles, nil\n}", "func (it *insertIterator) previous() *types.Header {\n\tif it.index < 1 {\n\t\treturn nil\n\t}\n\treturn it.chain[it.index-1].Header()\n}", "func (e *Element) Prev() *Element {\n\tif e != nil && e.prev != nil {\n\t\treturn e.prev\n\t}\n\treturn nil\n}", "func (tree *Tree23) Previous(t TreeNodeIndex) (TreeNodeIndex, error) {\n\tif tree.IsEmpty(t) {\n\t\treturn -1, errors.New(\"Previous() does not work for empty trees\")\n\t}\n\tif tree.IsLeaf(t) {\n\t\treturn tree.treeNodes[t].prev, nil\n\t}\n\treturn -1, errors.New(\"Previous() only works for leaf nodes!\")\n}", "func (d *Decoder) prev(name string) (int64, error) {\n\tname = strings.TrimPrefix(name, \"prev.\")\n\n\t// TODO Instead of using a map, recurse up the d.stack/tree\n\n\tv, ok := d.prevMap[name]\n\tif !ok {\n\t\treturn -1, fmt.Errorf(\"no previous element named %q found\", name)\n\t}\n\n\tn, ok := v.Element.(*Number)\n\tif !ok {\n\t\treturn -1, fmt.Errorf(\"previous element %q must be a Number\", name)\n\t}\n\n\treturn n.Int(d.f, v)\n}", "func (chunk *ResultNodeListChunk) Prev() *ResultNodeListChunk {\n\treturn chunk.prev\n}", "func (i Item) Prev() *Item {\n\treturn i.prev\n}", "func (w *ScrollWidget) PreviousPage() error {\n\tif w.view != nil {\n\t\t_, sy := w.view.Size()\n\t\terr := MoveLines(w.view, w.current, w.max, -sy)\n\t\tw.current = GetLine(w.view)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s Shop) GetPreviousNamesAsString() (result string) {\n\tif len(s.PreviousNames) > 0 {\n\t\tresult = strings.Join(s.PreviousNames, \",\")\n\t}\n\treturn\n}", "func (m *GroupPolicyDefinition) SetPreviousVersionDefinition(value GroupPolicyDefinitionable)() {\n err := m.GetBackingStore().Set(\"previousVersionDefinition\", value)\n if err != nil {\n panic(err)\n }\n}", "func (s *Select) GetPrevious(qe QueryExecer, dst interface{}, cursor string) error {\n\tif err := s.setCursor(cursor); err != nil {\n\t\treturn err\n\t}\n\ts.offset -= s.limit\n\tquery, args := s.Query()\n\trow := qe.QueryRow(query, args...)\n\terr := scanWithReflection(s.t.Fields(), row, dst)\n\treturn err\n}", "func (t *SpotifyDevice) PrevTrack() {\n\tif t.client == nil {\n\t\treturn\n\t}\n\tlog.Println(\"Previous track on Spotify device\")\n\tif err := t.client.PreviousOpt(t.playOpts); err != nil {\n\t\tlog.Println(err)\n\t}\n}", "func (w *ListWidget) GoBack() {\n\teventing.Publish(\"list.prenavigate\", \"GOBACK\")\n\n\tif w.filterString != \"\" {\n\t\t// initial Back action is to clear filter, subsequent Back actions are normal\n\t\tw.ClearFilter()\n\t\treturn\n\t}\n\tpreviousPage := w.navStack.Pop()\n\tif previousPage == nil {\n\t\teventing.Publish(\"list.navigated\", ListNavigatedEventState{Success: false})\n\t\treturn\n\t}\n\tw.contentView.SetContent(previousPage.ExpandedNodeItem, previousPage.Data, previousPage.DataType, \"Response\")\n\tw.selected = 0\n\tw.items = previousPage.Value\n\tw.title = previousPage.Title\n\tw.selected = previousPage.Selection\n\tw.expandedNodeItem = previousPage.ExpandedNodeItem\n\n\teventing.Publish(\"list.navigated\", ListNavigatedEventState{\n\t\tSuccess: true,\n\t\tNewNodes: w.items,\n\t\tParentNodeID: w.expandedNodeItem.Parentid,\n\t\tIsBack: true,\n\t})\n}", "func (q *QuestionnaireT) Prev() int {\n\tpg, _ := q.prevInNavi()\n\treturn pg\n}", "func (_Vault *VaultCaller) PrevVault(opts *bind.CallOpts) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Vault.contract.Call(opts, out, \"prevVault\")\n\treturn *ret0, err\n}", "func (m *Model) PrevPage() {\n\tif m.Page > 0 {\n\t\tm.Page--\n\t}\n}", "func (resp *BytesWatchPutResp) GetPrevValue() []byte {\n\treturn resp.prevValue\n}", "func (k Keeper) SetPreviousSavingsDistribution(ctx sdk.Context, distTime time.Time) {\n\tstore := prefix.NewStore(ctx.KVStore(k.key), types.PreviousDistributionTimeKey)\n\tstore.Set([]byte{}, k.cdc.MustMarshalBinaryLengthPrefixed(distTime))\n}", "func (c *Collection) GetPrevSpec() (s *types.Spec) {\n\tc.readTxn(func() error {\n\t\ts = c.previous\n\t\treturn nil\n\t})\n\treturn\n}", "func (lexto *LongLexto) Previous() Token {\n\tif lexto.HasPrevious() {\n\t\tresult := lexto.tokens[lexto.current]\n\t\tlexto.current -= 1\n\t\treturn result\n\t}\n\treturn Token{}\n}", "func (e *idElement) Prev() *idElement {\n\tif p := e.prev; e.list != nil && p != &e.list.root {\n\t\treturn p\n\t}\n\treturn nil\n}", "func (e *Enumerator) Prev() (k []byte, v []byte, err error) {\n\tif err = e.err; err != nil {\n\t\treturn\n\t}\n\tif e.ver != e.t.ver {\n\t\tf, hit := e.t.Seek(e.k)\n\t\tif !e.hit && hit {\n\t\t\tif err = f.prev(); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\t*e = *f\n\t\tf.Close()\n\t}\n\tif e.q == nil {\n\t\te.err, err = io.EOF, io.EOF\n\t\treturn\n\t}\n\tif e.i >= e.q.c {\n\t\tif err = e.next(); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\ti := e.q.d[e.i]\n\tk, v = i.k, i.v\n\te.k, e.hit = k, false\n\te.prev()\n\treturn\n}", "func (obj *KeyHandlerList) Prev() *KeyHandlerList {\n\tproxyResult := /*pr4*/ C.vssc_key_handler_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewKeyHandlerListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (e MoveObjectPreviousResponseValidationError) Reason() string { return e.reason }", "func MessagePrevious(vm *VM, target, locals Interface, msg *Message) Interface {\n\tm := target.(*Message)\n\tif m.Prev == nil {\n\t\treturn vm.Nil\n\t}\n\treturn m.Prev\n}", "func (m *NodeMutation) ClearPrev() {\n\tm.clearedprev = true\n}", "func (o *ModifyProxyConfigInternalParams) SetPreviousProxyConfigCrn(previousProxyConfigCrn *string) {\n\to.PreviousProxyConfigCrn = previousProxyConfigCrn\n}", "func (ts *TokenScanner) previous() Token {\n\tif ts.i <= 0 {\n\t\treturn ts.tokens[0]\n\t}\n\n\treturn ts.tokens[ts.i-1]\n}", "func (u *UserProfile) PreviousOrders(n int) ([]*EasyOrder, error) {\n\treturn u.ordersMeta.CustomerOrders, u.initOrdersMeta(n)\n}", "func (resp *BytesWatchDelResp) GetPrevValue() []byte {\n\treturn nil\n}", "func (p *parser) previous() lexer.Token {\n\treturn p.tokens[p.current-1]\n}", "func (iter *ListIterator) Prev() iterator.ConstBidIterator {\n\tif iter.node != nil {\n\t\titer.node = iter.node.Prev()\n\t}\n\treturn iter\n}" ]
[ "0.77181244", "0.71131843", "0.65698516", "0.6438215", "0.64082676", "0.628293", "0.62722445", "0.6237737", "0.6235969", "0.62080115", "0.6201952", "0.6166058", "0.6163214", "0.61596376", "0.6144202", "0.61367834", "0.60615146", "0.6043462", "0.60110754", "0.5901605", "0.5887038", "0.5876553", "0.58578914", "0.5848773", "0.5804715", "0.5800428", "0.5795833", "0.5775326", "0.5750205", "0.5745143", "0.5715033", "0.5691819", "0.5646687", "0.56337184", "0.5630578", "0.56228733", "0.5601451", "0.55633944", "0.5559347", "0.55346894", "0.55254173", "0.55241936", "0.55165046", "0.550541", "0.5492688", "0.5483592", "0.54660857", "0.5463978", "0.5461941", "0.5461345", "0.54603595", "0.54567045", "0.54378617", "0.5420037", "0.54189277", "0.5418754", "0.5407686", "0.5407358", "0.5388453", "0.5365895", "0.536062", "0.5356223", "0.5343075", "0.53386533", "0.5331052", "0.5320337", "0.5316207", "0.531025", "0.530866", "0.5306898", "0.53061074", "0.5305669", "0.52936065", "0.5291474", "0.5290466", "0.5286085", "0.5282575", "0.528034", "0.52779496", "0.5272145", "0.5270557", "0.52581257", "0.524409", "0.52438873", "0.522527", "0.5217375", "0.52173585", "0.52163255", "0.521233", "0.5208395", "0.51986575", "0.5175107", "0.51737666", "0.51735336", "0.5149648", "0.513975", "0.5130358", "0.51247764", "0.51169264", "0.5113541" ]
0.84276
0
WithTotalRecords adds the totalRecords to the artifact lister o k response
func (o *ArtifactListerOK) WithTotalRecords(totalRecords uint64) *ArtifactListerOK { o.TotalRecords = totalRecords return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerPartialContent) WithTotalRecords(totalRecords uint64) *ArtifactListerPartialContent {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (g *GlobalResponse) Sum() {\n\tsum := 0\n\n\tfor _, v := range g.Records {\n\t\tsum += v.Fields.NumBikesAvailable\n\t}\n\n\tg.Total = sum\n}", "func outputRecordsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsCalled(int) {}", "func (rb *ShardsRecordBuilder) FlushTotal(flushtotal string) *ShardsRecordBuilder {\n\trb.v.FlushTotal = &flushtotal\n\treturn rb\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsCalled(count int) {\n\tdsc.GetRecordsCalled.Inc(int64(count))\n}", "func (bguo *BarGroupUpdateOne) AddRecords(b ...*BarRecord) *BarGroupUpdateOne {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bguo.AddRecordIDs(ids...)\n}", "func (k Keeper) RecordsAll(c context.Context, req *types.RecordsAllRequest) (*types.RecordsAllResponse, error) {\n\tdefer telemetry.MeasureSince(time.Now(), types.ModuleName, \"query\", \"RecordsAll\")\n\tretval := types.RecordsAllResponse{Request: req}\n\n\tpageRequest := getPageRequest(req)\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tkvStore := ctx.KVStore(k.storeKey)\n\tprefixStore := prefix.NewStore(kvStore, types.RecordKeyPrefix)\n\n\tpageRes, err := query.Paginate(prefixStore, pageRequest, func(key, value []byte) error {\n\t\tvar record types.Record\n\t\tvErr := record.Unmarshal(value)\n\t\tif vErr == nil {\n\t\t\tretval.Records = append(retval.Records, types.WrapRecord(&record))\n\t\t\treturn nil\n\t\t}\n\t\t// Something's wrong. Let's do what we can to give indications of it.\n\t\tvar addr types.MetadataAddress\n\t\tkErr := addr.Unmarshal(key)\n\t\tif kErr == nil {\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record\", \"address\", addr, \"error\", vErr)\n\t\t\tretval.Records = append(retval.Records, types.WrapRecordNotFound(addr))\n\t\t} else {\n\t\t\tk64 := b64.StdEncoding.EncodeToString(key)\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record key and value\",\n\t\t\t\t\"key error\", kErr, \"value error\", vErr, \"key (base64)\", k64)\n\t\t\tretval.Records = append(retval.Records, &types.RecordWrapper{})\n\t\t}\n\t\treturn nil // Still want to move on to the next.\n\t})\n\tif err != nil {\n\t\treturn &retval, status.Error(codes.Unavailable, err.Error())\n\t}\n\tretval.Pagination = pageRes\n\treturn &retval, nil\n}", "func getTotals(snapshots []Snapshot) TotalResponse {\n reports := len(snapshots)\n days := make(map[string]int)\n people := make(map[string]int)\n locations := make(map[string]int)\n activities:= make(map[string]int)\n coffees := 0\n\n for _, snapshot := range snapshots {\n // Count people\n date := snapshot.Date[:10]\n days[date]++\n\n for _, response := range snapshot.Responses {\n question := response.QuestionPrompt\n // Count people\n if question == \"Who are you with?\" {\n for _, token := range response.Tokens {\n people[token.Text]++\n }\n } else if question == \"Where are you?\" {\n // count locations\n locations[response.LocationResponse.Text]++\n } else if question == \"How many coffees did you have today?\" {\n // count coffees\n amount, err := strconv.Atoi(response.NumericResponse)\n if err == nil {\n coffees += amount\n }\n } else if question == \"What are you doing?\" {\n for _, token := range response.Tokens {\n activities[token.Text]++\n }\n }\n }\n }\n\n return TotalResponse{\n TotalDays: len(days),\n TotalReports: reports,\n TotalPeople: len(people),\n TotalLocations: len(locations),\n AvgPerDay: float32(reports)/float32(len(days)),\n TotalCoffees: coffees,\n CoffeesPerDay: float32(coffees)/float32(len(days)),\n PeopleList: people,\n LocationList: locations,\n ActivityList: activities,\n }\n}", "func (o *ArtifactListerPartialContent) WithRemainingRecords(remainingRecords uint64) *ArtifactListerPartialContent {\n\to.RemainingRecords = remainingRecords\n\treturn o\n}", "func (d *DBClient) RecordsCount(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\tcount, err := d.Cache.RecordsCount()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordsCount\n\t\tresponse.Count = count\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (bgu *BarGroupUpdate) AddRecords(b ...*BarRecord) *BarGroupUpdate {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bgu.AddRecordIDs(ids...)\n}", "func (rest *RestController) All(w http.ResponseWriter, r *http.Request) (Response, error) {\n\tresources := reflect.New(reflect.SliceOf(reflect.TypeOf(rest.Table).Elem()))\n\tcount, err := rest.Table.List(resources.Interface(), models.NewDBQuery(r.URL.Query(), nil))\n\tif err != nil {\n\t\treturn nil, &httpError{err, \"\", 500}\n\t}\n\tw.Header().Set(\"Total\", strconv.FormatInt(count, 10))\n\treturn &JSONResponse{resources.Interface(), 200}, nil\n}", "func (m *MonitoringAlertRecordsRequestBuilder) Count()(*MonitoringAlertRecordsCountRequestBuilder) {\n return NewMonitoringAlertRecordsCountRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func (fc *FileControl) TotalRecordCountField() string {\n\treturn fc.numericField(fc.TotalRecordCount, 8)\n}", "func (o *ArtifactListerPartialContent) SetRemainingRecords(remainingRecords uint64) {\n\to.RemainingRecords = remainingRecords\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsTimeout(int) {}", "func (r *SubscriptionsListServerResponse) Total(value int) *SubscriptionsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (r *MachinePoolsListServerResponse) Total(value int) *MachinePoolsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (r ApiGetBulkSubRequestObjListRequest) Count(count bool) ApiGetBulkSubRequestObjListRequest {\n\tr.count = &count\n\treturn r\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsTimeout(count int) {\n\tdsc.GetRecordsTimeout.Inc(int64(count))\n}", "func (resp *DomainRecordsPagedResponse) appendData(r *DomainRecordsPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func (o ServerEndpointSyncActivityStatusResponseOutput) TotalItemCount() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointSyncActivityStatusResponse) float64 { return v.TotalItemCount }).(pulumi.Float64Output)\n}", "func (ac *AppContext) totalMessages(w http.ResponseWriter, r *http.Request) {\n\tcnt, err := ac.r.TotalMessages()\n\tif err != nil {\n\t\tlogrus.WithError(err).Error(\"Failed getting total messages\")\n\t\tWriteError(w, ErrInternalServer)\n\t\treturn\n\t}\n\tjson.NewEncoder(w).Encode(messageCount{cnt})\n}", "func (b *block) addAggregateResults(\n\tctx context.Context,\n\tresults AggregateResults,\n\tbatch []AggregateResultsEntry,\n\tsource []byte,\n) ([]AggregateResultsEntry, int, int, error) {\n\t_, sp := ctx.StartTraceSpan(tracepoint.NSIdxBlockAggregateQueryAddDocuments)\n\tdefer sp.Finish()\n\t// try to add the docs to the resource.\n\tsize, docsCount := results.AddFields(batch)\n\n\taggDocs := len(batch)\n\tfor i := range batch {\n\t\taggDocs += len(batch[i].Terms)\n\t}\n\n\t// update recently queried docs to monitor memory.\n\tif results.EnforceLimits() {\n\t\tif err := b.aggDocsLimit.Inc(aggDocs, source); err != nil {\n\t\t\treturn batch, 0, 0, err\n\t\t}\n\t}\n\n\t// reset batch.\n\tvar emptyField AggregateResultsEntry\n\tfor i := range batch {\n\t\tbatch[i] = emptyField\n\t}\n\tbatch = batch[:0]\n\n\t// return results.\n\treturn batch, size, docsCount, nil\n}", "func (r *MachinePoolsListResponse) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func (r ApiGetBulkResultListRequest) Count(count bool) ApiGetBulkResultListRequest {\n\tr.count = &count\n\treturn r\n}", "func ReportTotalHandler(writer http.ResponseWriter, request *http.Request) {\n session, err := mgo.Dial(\"10.11.12.13:27017\")\n check(err)\n defer session.Close()\n\n snapshots := make([]Snapshot, 1)\n\n c := session.DB(\"reports\").C(\"snapshots\")\n c.Find(bson.M{}).All(&snapshots)\n\n resp := getTotals(snapshots)\n\n writeJSONResp(writer, resp, 200)\n}", "func (r ApiGetBulkExportListRequest) Count(count bool) ApiGetBulkExportListRequest {\n\tr.count = &count\n\treturn r\n}", "func (s *Service) Records(c context.Context, types []int64, mid, stime, etime int64, order, sort string, pn, ps int32) (res []*model.Record, total int32, err error) {\n\tvar midAts []int64\n\tif res, total, err = s.search.RecordPaginate(c, types, mid, stime, etime, order, sort, pn, ps); err != nil {\n\t\tlog.Error(\"s.search.RecordPaginate(%d,%d,%d,%d,%s,%s) error(%v)\", mid, sort, pn, ps, stime, etime, err)\n\t\treturn\n\t}\n\tif res == nil {\n\t\tres = _emptyRecords\n\t\treturn\n\t}\n\tfor _, r := range res {\n\t\tr.Message = template.HTMLEscapeString(r.Message)\n\t\tif len(r.Ats) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tvar ats []int64\n\t\tif ats, err = xstr.SplitInts(r.Ats); err != nil {\n\t\t\tlog.Error(\"xstr.SplitInts(%s) error(%v)\", r.Ats, err)\n\t\t\terr = nil\n\t\t}\n\t\tmidAts = append(midAts, ats...)\n\t}\n\tif len(midAts) == 0 {\n\t\treturn\n\t}\n\taccMap, _ := s.getAccInfo(c, midAts)\n\tfor _, r := range res {\n\t\tr.FillAts(accMap)\n\t}\n\treturn\n}", "func TotalRetention(amount float64, values []RetValue) float64 {\n\ttotal := 0.0\n\tfor _, v := range values {\n\t\ttotal += PartialRetention(amount, v)\n\t}\n\treturn total\n}", "func TotalCount(resp *http.Response) int {\n\tif resp == nil {\n\t\treturn 0\n\t}\n\n\ttotalCountHeader := resp.Header.Get(totalCountHeaderKey)\n\ttotalCount, err := strconv.ParseInt(totalCountHeader, 10, 64)\n\tif err != nil {\n\t\treturn 0\n\t}\n\n\treturn int(totalCount)\n}", "func (r ApiGetBulkExportedItemListRequest) Count(count bool) ApiGetBulkExportedItemListRequest {\n\tr.count = &count\n\treturn r\n}", "func (o *IscsiInterfaceGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (_obj *DataService) GetActivityRecords(index int32, batch int32, activity_id string, nextIndex *int32, recordList *[]ActivityRecord, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(activity_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*recordList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *recordList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\ttarsCtx := context.Background()\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getActivityRecords\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*recordList) = make([]ActivityRecord, length)\n\t\tfor i20, e20 := int32(0), length; i20 < e20; i20++ {\n\n\t\t\terr = (*recordList)[i20].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *CountResult) Total() int {\n\tvar t int\n\tfor k := range c.m {\n\t\tt += c.m[k]\n\t}\n\treturn t\n}", "func (t File_summary_by_instance) TotalRowContent() string {\n\treturn t.totals.row_content(t.totals)\n}", "func (rb *ShardsRecordBuilder) GetTotal(gettotal string) *ShardsRecordBuilder {\n\trb.v.GetTotal = &gettotal\n\treturn rb\n}", "func outputRecordSpecsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordSpecificationsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordSpecificationsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func WithTotalItems(totalItems int) Opt {\n\treturn func(opts *Options) {\n\t\topts.TotalItems = totalItems\n\t}\n}", "func addIncludeRecordsFlag(cmd *cobra.Command) {\n\tcmd.Flags().BoolVar(&includeRecords, \"include-records\", false, \"include records in the output\")\n}", "func (s *Suite) Aggregate() {\n\t//totals := Totals{Tests: len(s.Tests)}\n\ttotals := &pb.TestTotal{\n\t\tTests: int64(len(s.Tests)),\n\t\tStatuses: make(map[string]int64),\n\t}\n\n\tfor _, test := range s.Tests {\n\t\ttotals.Duration += test.Duration\n\t\tswitch test.Status {\n\t\tcase string(apistructs.TestStatusPassed):\n\t\t\ttotals.Statuses[string(apistructs.TestStatusPassed)] += 1\n\t\tcase string(apistructs.TestStatusSkipped):\n\t\t\ttotals.Statuses[string(apistructs.TestStatusSkipped)] += 1\n\t\tcase string(apistructs.TestStatusFailed):\n\t\t\ttotals.Statuses[string(apistructs.TestStatusFailed)] += 1\n\t\tcase string(apistructs.TestStatusError):\n\t\t\ttotals.Statuses[string(apistructs.TestStatusError)] += 1\n\t\t}\n\t}\n\n\ts.Totals = totals\n}", "func (r apiGetCustomerActivityReportsWithoutTotalCountRequest) Execute() (InlineResponse20025, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue InlineResponse20025\n\t)\n\n\tlocalBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, \"ManagementApiService.GetCustomerActivityReportsWithoutTotalCount\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/v1/applications/{applicationId}/customer_activity_reports/no_total\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"applicationId\"+\"}\", _neturl.QueryEscape(parameterToString(r.applicationId, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif r.rangeStart == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"rangeStart is required and must be specified\")\n\t}\n\n\tif r.rangeEnd == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"rangeEnd is required and must be specified\")\n\t}\n\n\tif r.pageSize != nil {\n\t\tlocalVarQueryParams.Add(\"pageSize\", parameterToString(*r.pageSize, \"\"))\n\t}\n\tif r.skip != nil {\n\t\tlocalVarQueryParams.Add(\"skip\", parameterToString(*r.skip, \"\"))\n\t}\n\tif r.sort != nil {\n\t\tlocalVarQueryParams.Add(\"sort\", parameterToString(*r.sort, \"\"))\n\t}\n\tlocalVarQueryParams.Add(\"rangeStart\", parameterToString(*r.rangeStart, \"\"))\n\tlocalVarQueryParams.Add(\"rangeEnd\", parameterToString(*r.rangeEnd, \"\"))\n\tif r.name != nil {\n\t\tlocalVarQueryParams.Add(\"name\", parameterToString(*r.name, \"\"))\n\t}\n\tif r.integrationId != nil {\n\t\tlocalVarQueryParams.Add(\"integrationId\", parameterToString(*r.integrationId, \"\"))\n\t}\n\tif r.campaignName != nil {\n\t\tlocalVarQueryParams.Add(\"campaignName\", parameterToString(*r.campaignName, \"\"))\n\t}\n\tif r.advocateName != nil {\n\t\tlocalVarQueryParams.Add(\"advocateName\", parameterToString(*r.advocateName, \"\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\treq, err := r.apiService.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := r.apiService.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\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 == 200 {\n\t\t\tvar v InlineResponse20025\n\t\t\terr = r.apiService.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\tnewErr.model = v\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = r.apiService.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 (d *DBClient) AllRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\trecords, err := d.Cache.GetAllRequests()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordedRequests\n\t\tresponse.Data = records\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (m *ItemItemsItemWorkbookTablesWorkbookTableItemRequestBuilder) TotalRowRange()(*ItemItemsItemWorkbookTablesItemTotalRowRangeRequestBuilder) {\n return NewItemItemsItemWorkbookTablesItemTotalRowRangeRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func (r ApiGetBulkRequestListRequest) Count(count bool) ApiGetBulkRequestListRequest {\n\tr.count = &count\n\treturn r\n}", "func outputRecords(cmd *cobra.Command, recordAddr string, scopeID string, sessionID string, name string) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq := types.RecordsRequest{\n\t\tRecordAddr: recordAddr,\n\t\tScopeId: scopeID,\n\t\tSessionId: sessionID,\n\t\tName: name,\n\t\tIncludeScope: includeScope,\n\t\tIncludeSessions: includeSessions,\n\t}\n\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.Records(context.Background(), &req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func ListAssetSummaries(settings *playfab.Settings, postData *ListAssetSummariesRequestModel, entityToken string) (*ListAssetSummariesResponseModel, error) {\n if entityToken == \"\" {\n return nil, playfab.NewCustomError(\"entityToken should not be an empty string\", playfab.ErrorGeneric)\n }\n b, errMarshal := json.Marshal(postData)\n if errMarshal != nil {\n return nil, playfab.NewCustomError(errMarshal.Error(), playfab.ErrorMarshal)\n }\n\n sourceMap, err := playfab.Request(settings, b, \"/MultiplayerServer/ListAssetSummaries\", \"X-EntityToken\", entityToken)\n if err != nil {\n return nil, err\n }\n \n result := &ListAssetSummariesResponseModel{}\n\n config := mapstructure.DecoderConfig{\n DecodeHook: playfab.StringToDateTimeHook,\n Result: result,\n }\n \n decoder, errDecoding := mapstructure.NewDecoder(&config)\n if errDecoding != nil {\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\n }\n \n errDecoding = decoder.Decode(sourceMap)\n if errDecoding != nil {\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\n }\n\n return result, nil\n}", "func (rb *ShardsRecordBuilder) WarmerTotal(warmertotal string) *ShardsRecordBuilder {\n\trb.v.WarmerTotal = &warmertotal\n\treturn rb\n}", "func (f Fortune) Total() decimal.Decimal { return f.active.Add(f.saving) }", "func (o *IscsiInitiatorGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (r ApiGetHyperflexConfigResultEntryListRequest) Count(count bool) ApiGetHyperflexConfigResultEntryListRequest {\n\tr.count = &count\n\treturn r\n}", "func WriteSummary(index_name string, fields []string) {\n\n // Setting font as needed\n pdf.SetFont(\"Helvetica\",\"\",10)\n\n // a slice of Summary{} that will hold Summary{} structure for each field\n response_struct := []Summary{}\n\n // Looping through each fields requestd\n for index := range fields {\n url := fmt.Sprintf(`https://127.0.0.1:9200/%s/_search?`, index_name)\n queries := fmt.Sprintf(`\n {\n \"size\":\"0\",\n \"aggs\" : {\n \"uniq_gender\" : {\n \"terms\" : { \"field\" : \"%s.keyword\" }\n }\n }\n }`, fields[index])\n\n p, err := es.Query(\"GET\", url, queries)\n if err != nil {\n fmt.Println(\"Report Generation error ERROR: Could not get response from Elasticsearch server \", err, \"Trying to connect again\")\n return\n }\n\n temp := Summary{}\n\n err = json.Unmarshal(p, &temp)\n if (err != nil) {\n fmt.Println(\"Error unmarshalling json\",err);\n }\n\n response_struct = append(response_struct,temp);\n }\n for i :=0; i < len(response_struct); i++ {\n pdf.Write(10,fmt.Sprintf(`%s Count\\n`,fields[i]))\n //DrawLine();\n for _, v := range(response_struct[i].Aggregations.Uniq.Buck){\n pdf.Write(10,fmt.Sprintf(`%s %d\\n`,v.Key,v.Count))\n }\n }\n}", "func (o ServerEndpointSyncActivityStatusResponseOutput) TotalBytes() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointSyncActivityStatusResponse) float64 { return v.TotalBytes }).(pulumi.Float64Output)\n}", "func (u *UserResultsPage) setTotalPages(p int) {\n\tu.TotalPages = p\n}", "func (m *JobManager) Total() (int64, error) {\n\treturn m.table.Count()\n}", "func (bg *BarGroup) QueryRecords() *BarRecordQuery {\n\treturn (&BarGroupClient{config: bg.config}).QueryRecords(bg)\n}", "func (result *FedoraResult) AllRecordsSucceeded() bool {\n\tfor _, record := range result.MetadataRecords {\n\t\tif false == record.Succeeded() {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (w *Wrapper) WithTotalCount() *Wrapper {\n\tw.SetQueryOption(\"SQL_CALC_FOUND_ROWS\")\n\treturn w\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsReadTimeout(int) {}", "func (r apiGetAccessLogsWithoutTotalCountRequest) Execute() (InlineResponse20018, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue InlineResponse20018\n\t)\n\n\tlocalBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, \"ManagementApiService.GetAccessLogsWithoutTotalCount\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/v1/applications/{applicationId}/access_logs/no_total\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"applicationId\"+\"}\", _neturl.QueryEscape(parameterToString(r.applicationId, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif r.rangeStart == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"rangeStart is required and must be specified\")\n\t}\n\n\tif r.rangeEnd == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"rangeEnd is required and must be specified\")\n\t}\n\n\tif r.path != nil {\n\t\tlocalVarQueryParams.Add(\"path\", parameterToString(*r.path, \"\"))\n\t}\n\tif r.method != nil {\n\t\tlocalVarQueryParams.Add(\"method\", parameterToString(*r.method, \"\"))\n\t}\n\tif r.status != nil {\n\t\tlocalVarQueryParams.Add(\"status\", parameterToString(*r.status, \"\"))\n\t}\n\tlocalVarQueryParams.Add(\"rangeStart\", parameterToString(*r.rangeStart, \"\"))\n\tlocalVarQueryParams.Add(\"rangeEnd\", parameterToString(*r.rangeEnd, \"\"))\n\tif r.pageSize != nil {\n\t\tlocalVarQueryParams.Add(\"pageSize\", parameterToString(*r.pageSize, \"\"))\n\t}\n\tif r.skip != nil {\n\t\tlocalVarQueryParams.Add(\"skip\", parameterToString(*r.skip, \"\"))\n\t}\n\tif r.sort != nil {\n\t\tlocalVarQueryParams.Add(\"sort\", parameterToString(*r.sort, \"\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\treq, err := r.apiService.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := r.apiService.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\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 == 200 {\n\t\t\tvar v InlineResponse20018\n\t\t\terr = r.apiService.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\tnewErr.model = v\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = r.apiService.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 (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (tt *TransactionTransformer) transformCollection(request *http.Request, data interface{}, totalData int, limit string) *TransactionResponse {\n\ttransactionResponse := &TransactionResponse{}\n\ttransactionResponse.TotalCount = totalData\n\ttransactionResponse.Data = data\n\n\t// Convert limit to int if not empty\n\tif limit != \"\" {\n\t\tlimitInt, _ := strconv.Atoi(limit)\n\n\t\tif limitInt != -1 && limitInt != 0 {\n\t\t\t// If limit not euqal to `-1` and `0' set transaction links. Transaction links contain link to current page,\n\t\t\t// first page, next page and last page.\n\t\t\ttransactionResponse.Links = PaginationReponse.BuildPaginationLinks(request, totalData)\n\t\t}\n\t}\n\n\treturn transactionResponse\n}", "func (records AggregationRecords) Add(raw map[string]interface{}) {\n\tts, ok := raw[\"Timestamp\"]\n\tif !ok {\n\t\treturn\n\t}\n\n\tkey, keys := buildAggregationKey(raw)\n\n\trecord, ok := records[key]\n\tif !ok {\n\t\trecord = NewAggregationRecord()\n\n\t\tms := int64(ts.(float64))\n\t\tt := time.Unix(ms/msToSec, (ms%msToSec)*msToNs)\n\t\t// TODO: 60 is the default. Will eventually be overriden by configuration\n\n\t\trecord.Timestamp = t\n\t\trecord.Keys = keys\n\t}\n\n\taggIntervalEnd := record.Timestamp.Add(defaultIntervalPeriod)\n\trecord.Expiry = max(time.Now(), aggIntervalEnd).Add(transformAggregationRecordDelay)\n\tcfg := providers.Config.RetrieveAgentConfig()\n\n\teventType, ok := raw[\"Type\"].(string)\n\tif !ok {\n\t\tlog.Println(fmt.Sprintf(\"E! 'Type' needs to be a string: %T\", raw[\"Type\"]))\n\t}\n\n\teventDef, hasEventDef := cfg.Definitions.Events.Get(eventType)\n\tfor k, v := range raw {\n\t\tif hasEventDef && record.Samples.ShouldAdd(eventDef.SampleRate) {\n\t\t\tsignature := getSampleSignature(cfg.Definitions, raw)\n\t\t\tif ok := record.Samples.Count(signature); !ok && record.Samples.Len() < eventDef.MaxSampleCount {\n\t\t\t\trecord.Samples.Add(raw)\n\t\t\t}\n\t\t}\n\n\t\tdef, ok := cfg.Definitions.Entries.Get(k)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tif def.Type.IsFrequency() {\n\t\t\tswitch val := v.(type) {\n\t\t\tcase string:\n\t\t\t\trecord.addFrequency(k, val)\n\t\t\tcase float64:\n\t\t\t\trecord.addFrequency(k, strconv.Itoa(int(val)))\n\t\t\tdefault:\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else if def.Type.IsSEH() {\n\t\t\tswitch val := v.(type) {\n\t\t\tcase int:\n\t\t\t\trecord.addSEH(k, float64(val), defaultSEHMetricWeight)\n\t\t\tcase float64:\n\t\t\t\trecord.addSEH(k, val, defaultSEHMetricWeight)\n\t\t\t}\n\t\t}\n\n\t}\n\n\trecords[key] = record\n}", "func TestListRecordings(t *testing.T) {\n\tif !haveArchive {\n\t\treturn\n\t}\n\n\tif testing.Verbose() && DEBUG {\n\t\tlogging.SetLevel(logging.DEBUG, \"archive\")\n\t}\n\n\trecordings, err := archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tinitial := len(recordings)\n\tt.Logf(\"Initial count is %d\", initial)\n\n\t// Add a recording\n\tsubscriptionID, err := archive.StartRecording(testCases[0].sampleChannel, testCases[0].sampleStream, true, true)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tt.Logf(\"SubscriptionID is %d\", subscriptionID)\n\n\t// Add a publication on that\n\tpublication, err := archive.AddPublication(testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif testing.Verbose() && DEBUG {\n\t\tt.Logf(\"Publication is %#v\", publication)\n\t}\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif len(recordings) == 0 {\n\t\tt.Log(\"No Recordings!\")\n\t\tt.FailNow()\n\t}\n\n\t// Grab the recordingID\n\trecordingID := recordings[len(recordings)-1].RecordingId\n\tt.Logf(\"Working count is %d, recordingID is %d\", len(recordings), recordingID)\n\n\t// Cleanup\n\tres, err := archive.StopRecordingByIdentity(recordingID)\n\tif err != nil {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed: %s\", recordingID, err.Error())\n\t} else if !res {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed\", recordingID)\n\t}\n\tif err := archive.PurgeRecording(recordingID); err != nil {\n\t\tt.Logf(\"PurgeRecording(%d) failed: %s\", recordingID, err.Error())\n\t}\n\tpublication.Close()\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tfinal := len(recordings)\n\tt.Logf(\"Final count is %d\", final)\n\n\tif initial != final {\n\t\tt.Logf(\"Number of recordings changed from %d to %d\", initial, final)\n\t\tt.Fail()\n\t}\n}", "func (m *Iterator) Total(ctx context.Context) (int, error) {\n\tif m.totalGot {\n\t\treturn m.count, nil\n\t}\n\n\treturn m.FetchTotal(ctx)\n}", "func displayAllRecords(records []Record) {\n\tfmt.Printf(\"\\nDisplaying all records...\\n\\n\")\n\n\tfor i := 0; i < len(records); i++ {\n\t\tfmt.Printf(\"Record ID: %d: %+v\\n\", i, records[i])\n\t\ttime.Sleep(5 * time.Millisecond) // 5ms between records\n\t}\n}", "func (m *Iterator) FetchTotal(ctx context.Context) (int, error) {\n\tr, err := m.query.Query(ctx, Request{\n\t\tLimit: 1,\n\t\tOffsetPeer: &tg.InputPeerEmpty{},\n\t})\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"fetch total\")\n\t}\n\n\tswitch msgs := r.(type) {\n\tcase *tg.MessagesMessages: // messages.messages#8c718e87\n\t\tm.count = len(msgs.Messages)\n\tcase *tg.MessagesMessagesSlice: // messages.messagesSlice#3a54685e\n\t\tm.count = msgs.Count\n\tcase *tg.MessagesChannelMessages: // messages.channelMessages#64479808\n\t\tm.count = msgs.Count\n\tdefault: // messages.messagesNotModified#74535f21\n\t\treturn 0, errors.Errorf(\"unexpected type %T\", r)\n\t}\n\n\tm.totalGot = true\n\treturn m.count, nil\n}", "func calculateTotals(totals logbookTotalRecord, record logbookRecord) logbookTotalRecord {\n\n\ttotals.time.se.time += record.time.se.time\n\ttotals.time.me.time += record.time.me.time\n\ttotals.time.mcc.time += record.time.mcc.time\n\ttotals.time.night.time += record.time.night.time\n\ttotals.time.ifr.time += record.time.ifr.time\n\ttotals.time.pic.time += record.time.pic.time\n\ttotals.time.copilot.time += record.time.copilot.time\n\ttotals.time.dual.time += record.time.dual.time\n\ttotals.time.instructor.time += record.time.instructor.time\n\ttotals.time.total.time += record.time.total.time\n\n\ttotals.landings.day += record.landings.day\n\ttotals.landings.night += record.landings.night\n\n\ttotals.sim.time.time += record.sim.time.time\n\n\treturn totals\n}", "func (rb *ShardsRecordBuilder) RefreshExternalTotal(refreshexternaltotal string) *ShardsRecordBuilder {\n\trb.v.RefreshExternalTotal = &refreshexternaltotal\n\treturn rb\n}", "func IncrementSuccessfulList(counts int) {\n\tincSuccessfulRequestByHandler(\"list\", counts)\n}", "func (o *GetSellerServicesUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (m *MultiInstances) Total() int {\n\ttotal := 0\n\tfor _, instances := range m.m {\n\t\ttotal += len(instances)\n\t}\n\treturn total\n}", "func (me *I16HEXFile) AddRecords(r ...Record) error {\n\tfor _, record := range r {\n\t\tif err := me.Add(record); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (o *GetAllPublicIPUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (r *ListDNSZoneVersionRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneVersionRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (page *Page) SetTotal(rowCount, pageSize uint64) {\n\tpage.Total = int64(math.Ceil(float64(rowCount) / float64(pageSize)))\n\tpage.TotalRows = int64(rowCount)\n}", "func (o GetSrvRecordResultOutput) Records() GetSrvRecordRecordArrayOutput {\n\treturn o.ApplyT(func(v GetSrvRecordResult) []GetSrvRecordRecord { return v.Records }).(GetSrvRecordRecordArrayOutput)\n}", "func (rb *ShardsRecordBuilder) SearchFetchTotal(searchfetchtotal string) *ShardsRecordBuilder {\n\trb.v.SearchFetchTotal = &searchfetchtotal\n\treturn rb\n}", "func (r Receipt) Total() float64 {\n\tvar total float64\n\tfor _, li := range r.LineItems {\n\t\ttotal += li.Subtotal()\n\t\tfmt.Println(li)\n\t}\n\treturn total\n}", "func (r ApiGetHyperflexFeatureLimitExternalListRequest) Count(count bool) ApiGetHyperflexFeatureLimitExternalListRequest {\n\tr.count = &count\n\treturn r\n}", "func (client DatasetClient) listNextResults(ctx context.Context, lastResults DatasetListResponse) (result DatasetListResponse, err error) {\n req, err := lastResults.datasetListResponsePreparer(ctx)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", nil , \"Failure preparing next results request\")\n }\n if req == nil {\n return\n }\n resp, err := client.ListSender(req)\n if err != nil {\n result.Response = autorest.Response{Response: resp}\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n }\n result, err = client.ListResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n }\n return\n }", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsDuration(time.Duration) {}", "func (k Keeper) RecordSpecificationsAll(c context.Context, req *types.RecordSpecificationsAllRequest) (*types.RecordSpecificationsAllResponse, error) {\n\tdefer telemetry.MeasureSince(time.Now(), types.ModuleName, \"query\", \"RecordSpecificationsAll\")\n\tretval := types.RecordSpecificationsAllResponse{Request: req}\n\n\tpageRequest := getPageRequest(req)\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tkvStore := ctx.KVStore(k.storeKey)\n\tprefixStore := prefix.NewStore(kvStore, types.RecordSpecificationKeyPrefix)\n\n\tpageRes, err := query.Paginate(prefixStore, pageRequest, func(key, value []byte) error {\n\t\tvar recordSpec types.RecordSpecification\n\t\tvErr := recordSpec.Unmarshal(value)\n\t\tif vErr == nil {\n\t\t\tretval.RecordSpecifications = append(retval.RecordSpecifications, types.WrapRecordSpec(&recordSpec))\n\t\t\treturn nil\n\t\t}\n\t\t// Something's wrong. Let's do what we can to give indications of it.\n\t\tvar addr types.MetadataAddress\n\t\tkErr := addr.Unmarshal(key)\n\t\tif kErr == nil {\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record spec\", \"address\", addr, \"error\", vErr)\n\t\t\tretval.RecordSpecifications = append(retval.RecordSpecifications, types.WrapRecordSpecNotFound(addr))\n\t\t} else {\n\t\t\tk64 := b64.StdEncoding.EncodeToString(key)\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record spec key and value\",\n\t\t\t\t\"key error\", kErr, \"value error\", vErr, \"key (base64)\", k64)\n\t\t\tretval.RecordSpecifications = append(retval.RecordSpecifications, &types.RecordSpecificationWrapper{})\n\t\t}\n\t\treturn nil // Still want to move on to the next.\n\t})\n\tif err != nil {\n\t\treturn &retval, status.Error(codes.Unavailable, err.Error())\n\t}\n\tretval.Pagination = pageRes\n\treturn &retval, nil\n}", "func (u updates) Total(l UpdateLabels) prometheus.Counter {\n\treturn u.total.WithLabelValues(l.Values()...)\n}", "func (fa *FindAndCountAll) Result(records interface{}, count int) {\n\tfa.Arguments[1] = mock.AnythingOfType(fmt.Sprintf(\"*%T\", records))\n\n\tfa.Run(func(args mock.Arguments) {\n\t\treflect.ValueOf(args[1]).Elem().Set(reflect.ValueOf(records))\n\t}).Return(count, nil)\n}", "func (dc *DatadogCollector) UpdateTotalDuration(timeSinceStart time.Duration) {\n\tms := float64(timeSinceStart.Nanoseconds() / 1000000)\n\t_ = dc.client.TimeInMilliseconds(dmTotalDuration, ms, dc.tags, 1.0)\n}", "func (ms *Sales) setRecords() (err error) {\n\n\tsales, err := ms.DB.GetMonthlySales(ms.dates)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thst := (float64(ms.cfg.HST)/100 + 1)\n\tstationMap, err := ms.DB.GetStationMap()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, s := range sales {\n\n\t\temployee, err := ms.DB.GetEmployee(s.Attendant.ID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// set HST\n\t\tfuelSalesNoHST := s.Summary.FuelDollar / hst\n\t\tfuelSalesHST := s.Summary.FuelDollar - fuelSalesNoHST\n\n\t\trecord := &model.MonthlySales{\n\t\t\tBankAmex: model.SetFloat(s.CreditCard.Amex),\n\t\t\tBankDiscover: model.SetFloat(s.CreditCard.Discover),\n\t\t\tBankGales: model.SetFloat(s.CreditCard.Gales),\n\t\t\tBankMC: model.SetFloat(s.CreditCard.MC),\n\t\t\tBankVisa: model.SetFloat(s.CreditCard.Visa),\n\t\t\tBobsGiftCertificates: model.SetFloat(s.OtherNonFuelBobs.BobsGiftCerts),\n\t\t\tBobsNonFuelAdjustments: model.SetFloat(s.Summary.BobsFuelAdj),\n\t\t\tBobsSales: model.SetFloat(s.OtherNonFuel.Bobs),\n\t\t\tCashBills: model.SetFloat(s.Cash.Bills),\n\t\t\tCashDebit: model.SetFloat(s.Cash.Debit),\n\t\t\tCashDieselDiscount: model.SetFloat(s.Cash.DieselDiscount),\n\t\t\tCashDriveOffNSF: model.SetFloat(s.Cash.DriveOffNSF),\n\t\t\tCashGiftCertRedeem: model.SetFloat(s.Cash.GiftCertRedeem),\n\t\t\tCashLotteryPayout: model.SetFloat(s.Cash.LotteryPayout),\n\t\t\tCashOSAdjusted: model.SetFloat(s.Cash.OSAdjusted),\n\t\t\tCashOther: model.SetFloat(s.Cash.Other),\n\t\t\tCashPayout: model.SetFloat(s.Cash.Payout),\n\t\t\tCashWriteOff: model.SetFloat(s.Cash.WriteOff),\n\t\t\tEmployee: employee,\n\t\t\tFuelSales: fuelSalesNoHST,\n\t\t\tFuelSalesHST: fuelSalesHST,\n\t\t\tFuelSalesOther: model.SetFloat(s.Summary.OtherFuelDollar),\n\t\t\tFuelSalesTotal: model.SetFloat(s.Summary.FuelDollar),\n\t\t\tGiftCertificates: model.SetFloat(s.OtherNonFuel.GiftCerts),\n\t\t\tNonFuelTotal: model.SetFloat(s.Summary.TotalNonFuel),\n\t\t\tRecordNumber: s.RecordNum,\n\t\t\tShiftOvershort: model.SetFloat(s.Overshort.Amount),\n\t\t\tStationID: s.StationID,\n\t\t\tStationName: stationMap[s.StationID].Name,\n\t\t}\n\t\tms.Sales = append(ms.Sales, record)\n\t}\n\n\treturn err\n}", "func ListEndpointGroupResults(r *http.Request, cfg config.Config) (int, http.Header, []byte, error) {\n\n\t//STANDARD DECLARATIONS START\n\tcode := http.StatusOK\n\th := http.Header{}\n\toutput := []byte(\"\")\n\terr := error(nil)\n\tcontentType := \"application/xml\"\n\tcharset := \"utf-8\"\n\t//STANDARD DECLARATIONS END\n\n\tcontentType, err = respond.ParseAcceptHeader(r)\n\th.Set(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\tif err != nil {\n\t\tcode = http.StatusNotAcceptable\n\t\toutput, _ = respond.MarshalContent(respond.NotAcceptableContentType, contentType, \"\", \" \")\n\t\treturn code, h, output, err\n\t}\n\n\t// Parse the request into the input\n\turlValues := r.URL.Query()\n\tvars := mux.Vars(r)\n\n\ttenantDbConfig, err := authentication.AuthenticateTenant(r.Header, cfg)\n\tif err != nil {\n\t\tif err.Error() == \"Unauthorized\" {\n\t\t\tcode = http.StatusUnauthorized\n\t\t\tout := respond.UnauthorizedMessage\n\t\t\toutput = out.MarshalTo(contentType)\n\t\t\treturn code, h, output, err\n\t\t}\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\tsession, err := mongo.OpenSession(tenantDbConfig)\n\tdefer mongo.CloseSession(session)\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\treport := reports.MongoInterface{}\n\terr = mongo.FindOne(session, tenantDbConfig.Db, \"reports\", bson.M{\"info.name\": vars[\"report_name\"]}, &report)\n\n\tif err != nil {\n\t\tcode = http.StatusBadRequest\n\t\tmessage := \"The report with the name \" + vars[\"report_name\"] + \" does not exist\"\n\t\toutput, err := createErrorMessage(message, contentType) //Render the response into XML or JSON\n\t\th.Set(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\t\treturn code, h, output, err\n\t}\n\n\tinput := endpointGroupResultQuery{\n\t\tbasicQuery{\n\t\t\tName: vars[\"lgroup_name\"],\n\t\t\tGranularity: urlValues.Get(\"granularity\"),\n\t\t\tFormat: contentType,\n\t\t\tStartTime: urlValues.Get(\"start_time\"),\n\t\t\tEndTime: urlValues.Get(\"end_time\"),\n\t\t\tReport: report,\n\t\t\tVars: vars,\n\t\t}, \"\",\n\t}\n\n\ttenantDB := session.DB(tenantDbConfig.Db)\n\terrs := input.Validate(tenantDB)\n\tif len(errs) > 0 {\n\t\tout := respond.BadRequestSimple\n\t\tout.Errors = errs\n\t\toutput = out.MarshalTo(contentType)\n\t\tcode = 400\n\t\treturn code, h, output, err\n\t}\n\n\tif vars[\"lgroup_type\"] != report.GetEndpointGroupType() {\n\t\tcode = http.StatusBadRequest\n\t\tmessage := \"The report \" + vars[\"report_name\"] + \" does not define endpoint group type: \" + vars[\"lgroup_type\"] + \". Try using \" + report.GetEndpointGroupType() + \" instead.\"\n\t\toutput, err := createErrorMessage(message, contentType) //Render the response into XML or JSON\n\t\th.Set(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\t\treturn code, h, output, err\n\t}\n\n\tresults := []EndpointGroupInterface{}\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\t// Construct the query to mongodb based on the input\n\tfilter := bson.M{\n\t\t\"date\": bson.M{\"$gte\": input.StartTimeInt, \"$lte\": input.EndTimeInt},\n\t\t\"report\": report.ID,\n\t}\n\n\tif input.Name != \"\" {\n\t\tfilter[\"name\"] = input.Name\n\t}\n\n\t// Select the granularity of the search daily/monthly\n\tif input.Granularity == \"daily\" {\n\t\tcustomForm[0] = \"20060102\"\n\t\tcustomForm[1] = \"2006-01-02\"\n\t\tquery := DailyEndpointGroup(filter)\n\t\terr = mongo.Pipe(session, tenantDbConfig.Db, \"endpoint_group_ar\", query, &results)\n\t} else if input.Granularity == \"monthly\" {\n\t\tcustomForm[0] = \"200601\"\n\t\tcustomForm[1] = \"2006-01\"\n\t\tquery := MonthlyEndpointGroup(filter)\n\t\terr = mongo.Pipe(session, tenantDbConfig.Db, \"endpoint_group_ar\", query, &results)\n\t}\n\n\t// mongo.Find(session, tenantDbConfig.Db, \"endpoint_group_ar\", bson.M{}, \"_id\", &results)\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\toutput, err = createEndpointGroupResultView(results, report, input.Format)\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\treturn code, h, output, err\n}", "func (r *SubscriptionsListServerRequest) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func ToTestRecords(searchResp *frontend.SearchResponse, imgBaseURL string) []*TestRecord {\n\t// Group the results by test.\n\tretMap := map[types.TestName]*TestRecord{}\n\tfor _, oneDigest := range searchResp.Digests {\n\t\ttestNameVal := oneDigest.ParamSet[types.PRIMARY_KEY_FIELD]\n\t\tif len(testNameVal) == 0 {\n\t\t\tsklog.Errorf(\"Error: Digest '%s' has no primaryKey in paramset\", oneDigest.Digest)\n\t\t\tcontinue\n\t\t}\n\n\t\tdigestInfo := &DigestInfo{\n\t\t\tSRDigest: oneDigest,\n\t\t\tURL: DigestUrl(imgBaseURL, oneDigest.Digest),\n\t\t}\n\n\t\ttestName := types.TestName(oneDigest.ParamSet[types.PRIMARY_KEY_FIELD][0])\n\t\tif found, ok := retMap[testName]; ok {\n\t\t\tfound.Digests = append(found.Digests, digestInfo)\n\t\t} else {\n\t\t\tretMap[testName] = &TestRecord{\n\t\t\t\tTestName: testName,\n\t\t\t\tDigests: []*DigestInfo{digestInfo},\n\t\t\t}\n\t\t}\n\t}\n\n\t// Put the records into an array and return them.\n\tret := make([]*TestRecord, 0, len(retMap))\n\tfor _, oneTestRec := range retMap {\n\t\tret = append(ret, oneTestRec)\n\t}\n\n\treturn ret\n}", "func ExampleSavingsPlanClient_NewListAllPager() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armbillingbenefits.NewClientFactory(cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tpager := clientFactory.NewSavingsPlanClient().NewListAllPager(&armbillingbenefits.SavingsPlanClientListAllOptions{Filter: to.Ptr(\"(properties%2farchived+eq+false)\"),\n\t\tOrderby: to.Ptr(\"properties/displayName asc\"),\n\t\tRefreshSummary: nil,\n\t\tSkiptoken: to.Ptr[float32](50),\n\t\tSelectedState: nil,\n\t\tTake: to.Ptr[float32](1),\n\t})\n\tfor pager.More() {\n\t\tpage, err := pager.NextPage(ctx)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed to advance page: %v\", err)\n\t\t}\n\t\tfor _, v := range page.Value {\n\t\t\t// You could use page here. We use blank identifier for just demo purposes.\n\t\t\t_ = v\n\t\t}\n\t\t// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t\t// page.SavingsPlanModelListResult = armbillingbenefits.SavingsPlanModelListResult{\n\t\t// \tAdditionalProperties: []*armbillingbenefits.SavingsPlanSummary{\n\t\t// \t\t{\n\t\t// \t\t\tName: to.Ptr(\"summary\"),\n\t\t// \t\t\tValue: &armbillingbenefits.SavingsPlanSummaryCount{\n\t\t// \t\t\t\tCancelledCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tExpiredCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tExpiringCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tFailedCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tNoBenefitCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tPendingCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tProcessingCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tSucceededCount: to.Ptr[float32](1),\n\t\t// \t\t\t\tWarningCount: to.Ptr[float32](0),\n\t\t// \t\t\t},\n\t\t// \t}},\n\t\t// \tValue: []*armbillingbenefits.SavingsPlanModel{\n\t\t// \t\t{\n\t\t// \t\t\tName: to.Ptr(\"20000000-0000-0000-0000-000000000000/30000000-0000-0000-0000-000000000000\"),\n\t\t// \t\t\tType: to.Ptr(\"Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans\"),\n\t\t// \t\t\tID: to.Ptr(\"/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000\"),\n\t\t// \t\t\tProperties: &armbillingbenefits.SavingsPlanModelProperties{\n\t\t// \t\t\t\tAppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{\n\t\t// \t\t\t\t\tDisplayName: to.Ptr(\"Azure subscription 1\"),\n\t\t// \t\t\t\t\tSubscriptionID: to.Ptr(\"/subscriptions/20000000-0000-0000-0000-000000000005\"),\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tAppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle),\n\t\t// \t\t\t\tBillingAccountID: to.Ptr(\"/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31\"),\n\t\t// \t\t\t\tBillingProfileID: to.Ptr(\"/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB\"),\n\t\t// \t\t\t\tBillingScopeID: to.Ptr(\"/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000009\"),\n\t\t// \t\t\t\tCommitment: &armbillingbenefits.Commitment{\n\t\t// \t\t\t\t\tAmount: to.Ptr[float64](0.001),\n\t\t// \t\t\t\t\tCurrencyCode: to.Ptr(\"USD\"),\n\t\t// \t\t\t\t\tGrain: to.Ptr(armbillingbenefits.CommitmentGrainHourly),\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tDisplayName: to.Ptr(\"Compute_SavingsPlan_10-19-2022_11-03\"),\n\t\t// \t\t\t\tDisplayProvisioningState: to.Ptr(\"Succeeded\"),\n\t\t// \t\t\t\tEffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2022-10-19T18:05:37.1034288Z\"); return t}()),\n\t\t// \t\t\t\tExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2023-10-19T18:05:36.5252231Z\"); return t}()),\n\t\t// \t\t\t\tProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded),\n\t\t// \t\t\t\tPurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2022-10-19T18:03:56.4032132Z\"); return t}()),\n\t\t// \t\t\t\tRenew: to.Ptr(false),\n\t\t// \t\t\t\tTerm: to.Ptr(armbillingbenefits.TermP1Y),\n\t\t// \t\t\t\tUserFriendlyAppliedScopeType: to.Ptr(\"Single\"),\n\t\t// \t\t\t\tUtilization: &armbillingbenefits.Utilization{\n\t\t// \t\t\t\t\tAggregates: []*armbillingbenefits.UtilizationAggregates{\n\t\t// \t\t\t\t\t\t{\n\t\t// \t\t\t\t\t\t\tGrain: to.Ptr[float32](1),\n\t\t// \t\t\t\t\t\t\tGrainUnit: to.Ptr(\"days\"),\n\t\t// \t\t\t\t\t\t\tValue: to.Ptr[float32](100),\n\t\t// \t\t\t\t\t\t\tValueUnit: to.Ptr(\"percentage\"),\n\t\t// \t\t\t\t\t\t},\n\t\t// \t\t\t\t\t\t{\n\t\t// \t\t\t\t\t\t\tGrain: to.Ptr[float32](7),\n\t\t// \t\t\t\t\t\t\tGrainUnit: to.Ptr(\"days\"),\n\t\t// \t\t\t\t\t\t\tValue: to.Ptr[float32](78),\n\t\t// \t\t\t\t\t\t\tValueUnit: to.Ptr(\"percentage\"),\n\t\t// \t\t\t\t\t\t},\n\t\t// \t\t\t\t\t\t{\n\t\t// \t\t\t\t\t\t\tGrain: to.Ptr[float32](30),\n\t\t// \t\t\t\t\t\t\tGrainUnit: to.Ptr(\"days\"),\n\t\t// \t\t\t\t\t\t\tValue: to.Ptr[float32](78.12),\n\t\t// \t\t\t\t\t\t\tValueUnit: to.Ptr(\"percentage\"),\n\t\t// \t\t\t\t\t}},\n\t\t// \t\t\t\t\tTrend: to.Ptr(\"\"),\n\t\t// \t\t\t\t},\n\t\t// \t\t\t},\n\t\t// \t\t\tSKU: &armbillingbenefits.SKU{\n\t\t// \t\t\t\tName: to.Ptr(\"Compute_Savings_Plan\"),\n\t\t// \t\t\t},\n\t\t// \t}},\n\t\t// }\n\t}\n}", "func WithIncludeFinal(includeFinal bool) ListDealRecordsOption {\n\treturn func(c *rpc.ListDealRecordsConfig) {\n\t\tc.IncludeFinal = includeFinal\n\t}\n}", "func (o *GetLowBalanceTotalAggCountOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.AggTimeInt, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (b *ClusterNodesBuilder) Total(value int) *ClusterNodesBuilder {\n\tb.total = &value\n\treturn b\n}", "func (mp MassPayment) Total() float64 {\n\ttotal := 0.0\n\tfor _, item := range mp.Items {\n\t\ttotal += item.Amount\n\t}\n\n\treturn total\n}", "func (a *kinesisFirehoseWriter) toRecords(msg message.Batch) ([]*firehose.Record, error) {\n\tentries := make([]*firehose.Record, msg.Len())\n\n\terr := msg.Iter(func(i int, p *message.Part) error {\n\t\tentry := firehose.Record{\n\t\t\tData: p.AsBytes(),\n\t\t}\n\n\t\tif len(entry.Data) > mebibyte {\n\t\t\ta.log.Errorf(\"part %d exceeds the maximum Kinesis Firehose payload limit of 1 MiB\\n\", i)\n\t\t\treturn component.ErrMessageTooLarge\n\t\t}\n\n\t\tentries[i] = &entry\n\t\treturn nil\n\t})\n\n\treturn entries, err\n}" ]
[ "0.7082838", "0.6644841", "0.65511394", "0.59687066", "0.5265039", "0.52637076", "0.51604646", "0.5144401", "0.49985495", "0.49891698", "0.49746624", "0.49441192", "0.4920693", "0.4915378", "0.4912611", "0.49113533", "0.48780045", "0.4875096", "0.48719037", "0.48052523", "0.47637305", "0.47534427", "0.47523528", "0.4726272", "0.47208667", "0.4716728", "0.47105205", "0.4686598", "0.4675715", "0.4662088", "0.4634563", "0.46012616", "0.45940873", "0.45940697", "0.45705658", "0.45624155", "0.45558074", "0.45500618", "0.4542465", "0.4534649", "0.4527107", "0.4525891", "0.4525451", "0.45136234", "0.45005915", "0.44839817", "0.4483285", "0.4477399", "0.44743776", "0.4473397", "0.44668248", "0.44275272", "0.44182238", "0.44166428", "0.44158724", "0.44129542", "0.43978634", "0.43971342", "0.43924645", "0.4390458", "0.43763185", "0.43746465", "0.43728882", "0.43653122", "0.43653122", "0.43537152", "0.4352122", "0.43515494", "0.4346364", "0.43453956", "0.43343675", "0.43334365", "0.43312502", "0.43300444", "0.43283325", "0.43242148", "0.43225533", "0.43173", "0.431114", "0.43100667", "0.43069363", "0.42969698", "0.42949855", "0.42877796", "0.42806178", "0.42786717", "0.4269625", "0.42677966", "0.4266344", "0.42659232", "0.42620593", "0.4261146", "0.42607912", "0.42586586", "0.42555133", "0.42472264", "0.42462656", "0.4240425", "0.42396998", "0.4239566" ]
0.7237572
0
SetTotalRecords sets the totalRecords to the artifact lister o k response
func (o *ArtifactListerOK) SetTotalRecords(totalRecords uint64) { o.TotalRecords = totalRecords }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerPartialContent) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerOK) WithTotalRecords(totalRecords uint64) *ArtifactListerOK {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) WithTotalRecords(totalRecords uint64) *ArtifactListerPartialContent {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetRemainingRecords(remainingRecords uint64) {\n\to.RemainingRecords = remainingRecords\n}", "func (page *Page) SetTotal(rowCount, pageSize uint64) {\n\tpage.Total = int64(math.Ceil(float64(rowCount) / float64(pageSize)))\n\tpage.TotalRows = int64(rowCount)\n}", "func (u *UserResultsPage) setTotalPages(p int) {\n\tu.TotalPages = p\n}", "func (g *GlobalResponse) Sum() {\n\tsum := 0\n\n\tfor _, v := range g.Records {\n\t\tsum += v.Fields.NumBikesAvailable\n\t}\n\n\tg.Total = sum\n}", "func (ms *Sales) setRecords() (err error) {\n\n\tsales, err := ms.DB.GetMonthlySales(ms.dates)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thst := (float64(ms.cfg.HST)/100 + 1)\n\tstationMap, err := ms.DB.GetStationMap()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, s := range sales {\n\n\t\temployee, err := ms.DB.GetEmployee(s.Attendant.ID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// set HST\n\t\tfuelSalesNoHST := s.Summary.FuelDollar / hst\n\t\tfuelSalesHST := s.Summary.FuelDollar - fuelSalesNoHST\n\n\t\trecord := &model.MonthlySales{\n\t\t\tBankAmex: model.SetFloat(s.CreditCard.Amex),\n\t\t\tBankDiscover: model.SetFloat(s.CreditCard.Discover),\n\t\t\tBankGales: model.SetFloat(s.CreditCard.Gales),\n\t\t\tBankMC: model.SetFloat(s.CreditCard.MC),\n\t\t\tBankVisa: model.SetFloat(s.CreditCard.Visa),\n\t\t\tBobsGiftCertificates: model.SetFloat(s.OtherNonFuelBobs.BobsGiftCerts),\n\t\t\tBobsNonFuelAdjustments: model.SetFloat(s.Summary.BobsFuelAdj),\n\t\t\tBobsSales: model.SetFloat(s.OtherNonFuel.Bobs),\n\t\t\tCashBills: model.SetFloat(s.Cash.Bills),\n\t\t\tCashDebit: model.SetFloat(s.Cash.Debit),\n\t\t\tCashDieselDiscount: model.SetFloat(s.Cash.DieselDiscount),\n\t\t\tCashDriveOffNSF: model.SetFloat(s.Cash.DriveOffNSF),\n\t\t\tCashGiftCertRedeem: model.SetFloat(s.Cash.GiftCertRedeem),\n\t\t\tCashLotteryPayout: model.SetFloat(s.Cash.LotteryPayout),\n\t\t\tCashOSAdjusted: model.SetFloat(s.Cash.OSAdjusted),\n\t\t\tCashOther: model.SetFloat(s.Cash.Other),\n\t\t\tCashPayout: model.SetFloat(s.Cash.Payout),\n\t\t\tCashWriteOff: model.SetFloat(s.Cash.WriteOff),\n\t\t\tEmployee: employee,\n\t\t\tFuelSales: fuelSalesNoHST,\n\t\t\tFuelSalesHST: fuelSalesHST,\n\t\t\tFuelSalesOther: model.SetFloat(s.Summary.OtherFuelDollar),\n\t\t\tFuelSalesTotal: model.SetFloat(s.Summary.FuelDollar),\n\t\t\tGiftCertificates: model.SetFloat(s.OtherNonFuel.GiftCerts),\n\t\t\tNonFuelTotal: model.SetFloat(s.Summary.TotalNonFuel),\n\t\t\tRecordNumber: s.RecordNum,\n\t\t\tShiftOvershort: model.SetFloat(s.Overshort.Amount),\n\t\t\tStationID: s.StationID,\n\t\t\tStationName: stationMap[s.StationID].Name,\n\t\t}\n\t\tms.Sales = append(ms.Sales, record)\n\t}\n\n\treturn err\n}", "func (rb *ShardsRecordBuilder) FlushTotal(flushtotal string) *ShardsRecordBuilder {\n\trb.v.FlushTotal = &flushtotal\n\treturn rb\n}", "func (u *UserResultsPage) setTotalMatches(m int) {\n\tu.TotalMatches = m\n}", "func (o *IscsiInterfaceGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (suite *TestPagingSuite) TestSetTotalCount(c *C) {\n\ttestCases := []*struct {\n\t\ttotalCount int32\n\t\texpected bool\n\t}{\n\t\t{21, true},\n\t\t{20, false},\n\t\t{19, false},\n\t\t{0, false},\n\t}\n\n\tfor i, testCase := range testCases {\n\t\tcomment := ocheck.TestCaseComment(i)\n\t\tocheck.LogTestCase(c, testCase)\n\n\t\ttestedPaging := NewUndefinedPaging()\n\t\ttestedPaging.Position = 2\n\t\ttestedPaging.Size = 10\n\n\t\ttestedPaging.SetTotalCount(testCase.totalCount)\n\n\t\tc.Assert(testedPaging.PageMore, Equals, testCase.expected, comment)\n\t}\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsCalled(int) {}", "func (o *IscsiInitiatorGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (r *MachinePoolsListServerResponse) Total(value int) *MachinePoolsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (r *Records) SetRecords() error {\n\turl := fmt.Sprintf(\"%s/v1/domains/%s/records/%s/%s\", r.Config.GetAPI(), r.Domain, r.Records[0].Type, r.Records[0].Name)\n\tclient := &http.Client{}\n\n\tdata, err := json.Marshal(r.Records)\n\treq, _ := http.NewRequest(\"PUT\", url, bytes.NewBuffer(data))\n\treq.Header.Set(r.Config.GetAuth())\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.StatusCode != 200 {\n\t\treturn errors.New(string(res.StatusCode))\n\t}\n\n\treturn nil\n}", "func (fc *FileControl) TotalRecordCountField() string {\n\treturn fc.numericField(fc.TotalRecordCount, 8)\n}", "func (b BarReaderProxy) SetTotal(total int64) {\n\tb.Bar.SetTotal(total, false)\n}", "func (m *CloudPcBulkActionSummary) SetSuccessfulCount(value *int32)() {\n err := m.GetBackingStore().Set(\"successfulCount\", value)\n if err != nil {\n panic(err)\n }\n}", "func outputRecordsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (d *DBClient) RecordsCount(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\tcount, err := d.Cache.RecordsCount()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordsCount\n\t\tresponse.Count = count\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (r *SubscriptionsListServerResponse) Total(value int) *SubscriptionsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (m *Model) SetTotalPages(items int) int {\n\tif items < 1 {\n\t\treturn m.TotalPages\n\t}\n\tn := items / m.PerPage\n\tif items%m.PerPage > 0 {\n\t\tn++\n\t}\n\tm.TotalPages = n\n\treturn n\n}", "func (i *InsertRecordsInput) SetRecords(records []*Record) {\n\ti.Data = make([]map[int]*InsertRecordsInputData, len(records))\n\tfor n, r := range records {\n\t\tdata := make(map[int]*InsertRecordsInputData)\n\t\tfor fid, val := range r.Fields {\n\t\t\tdata[fid] = &InsertRecordsInputData{Value: val}\n\t\t}\n\t\ti.Data[n] = data\n\t}\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsCalled(count int) {\n\tdsc.GetRecordsCalled.Inc(int64(count))\n}", "func (i *Invoice) SetTotal() {\n\t// recorre la cantidad de datos que tenga items\n\t// item1 alamacena el valor de un item\n\t// luego se extrae su precio con el getter value() de invoiceitem\n\tfor _, item1 := range i.items {\n\t\ti.total += item1.Value()\n\t}\n}", "func (m *CloudPcBulkActionSummary) SetFailedCount(value *int32)() {\n err := m.GetBackingStore().Set(\"failedCount\", value)\n if err != nil {\n panic(err)\n }\n}", "func (n *resPool) SetTotalAllocatedResources(allocation *scalar.Resources) {\n\tn.Lock()\n\tdefer n.Unlock()\n\tn.allocation.Value[scalar.TotalAllocation] = allocation\n}", "func (o *ArtifactListerPartialContent) WithRemainingRecords(remainingRecords uint64) *ArtifactListerPartialContent {\n\to.RemainingRecords = remainingRecords\n\treturn o\n}", "func (r *MachinePoolsListResponse) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func (o *IscsiInterfaceGetIterResponseResult) SetNumRecords(newValue int) *IscsiInterfaceGetIterResponseResult {\n\to.NumRecordsPtr = &newValue\n\treturn o\n}", "func (p *Pagination) SetTotal(total uint) {\n\tp.total = total\n}", "func ReportTotalHandler(writer http.ResponseWriter, request *http.Request) {\n session, err := mgo.Dial(\"10.11.12.13:27017\")\n check(err)\n defer session.Close()\n\n snapshots := make([]Snapshot, 1)\n\n c := session.DB(\"reports\").C(\"snapshots\")\n c.Find(bson.M{}).All(&snapshots)\n\n resp := getTotals(snapshots)\n\n writeJSONResp(writer, resp, 200)\n}", "func (r ApiGetBulkSubRequestObjListRequest) Count(count bool) ApiGetBulkSubRequestObjListRequest {\n\tr.count = &count\n\treturn r\n}", "func (o ServerEndpointSyncActivityStatusResponseOutput) TotalItemCount() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointSyncActivityStatusResponse) float64 { return v.TotalItemCount }).(pulumi.Float64Output)\n}", "func (bguo *BarGroupUpdateOne) AddRecords(b ...*BarRecord) *BarGroupUpdateOne {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bguo.AddRecordIDs(ids...)\n}", "func (k Keeper) RecordsAll(c context.Context, req *types.RecordsAllRequest) (*types.RecordsAllResponse, error) {\n\tdefer telemetry.MeasureSince(time.Now(), types.ModuleName, \"query\", \"RecordsAll\")\n\tretval := types.RecordsAllResponse{Request: req}\n\n\tpageRequest := getPageRequest(req)\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tkvStore := ctx.KVStore(k.storeKey)\n\tprefixStore := prefix.NewStore(kvStore, types.RecordKeyPrefix)\n\n\tpageRes, err := query.Paginate(prefixStore, pageRequest, func(key, value []byte) error {\n\t\tvar record types.Record\n\t\tvErr := record.Unmarshal(value)\n\t\tif vErr == nil {\n\t\t\tretval.Records = append(retval.Records, types.WrapRecord(&record))\n\t\t\treturn nil\n\t\t}\n\t\t// Something's wrong. Let's do what we can to give indications of it.\n\t\tvar addr types.MetadataAddress\n\t\tkErr := addr.Unmarshal(key)\n\t\tif kErr == nil {\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record\", \"address\", addr, \"error\", vErr)\n\t\t\tretval.Records = append(retval.Records, types.WrapRecordNotFound(addr))\n\t\t} else {\n\t\t\tk64 := b64.StdEncoding.EncodeToString(key)\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record key and value\",\n\t\t\t\t\"key error\", kErr, \"value error\", vErr, \"key (base64)\", k64)\n\t\t\tretval.Records = append(retval.Records, &types.RecordWrapper{})\n\t\t}\n\t\treturn nil // Still want to move on to the next.\n\t})\n\tif err != nil {\n\t\treturn &retval, status.Error(codes.Unavailable, err.Error())\n\t}\n\tretval.Pagination = pageRes\n\treturn &retval, nil\n}", "func (s *Service) Records(c context.Context, types []int64, mid, stime, etime int64, order, sort string, pn, ps int32) (res []*model.Record, total int32, err error) {\n\tvar midAts []int64\n\tif res, total, err = s.search.RecordPaginate(c, types, mid, stime, etime, order, sort, pn, ps); err != nil {\n\t\tlog.Error(\"s.search.RecordPaginate(%d,%d,%d,%d,%s,%s) error(%v)\", mid, sort, pn, ps, stime, etime, err)\n\t\treturn\n\t}\n\tif res == nil {\n\t\tres = _emptyRecords\n\t\treturn\n\t}\n\tfor _, r := range res {\n\t\tr.Message = template.HTMLEscapeString(r.Message)\n\t\tif len(r.Ats) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tvar ats []int64\n\t\tif ats, err = xstr.SplitInts(r.Ats); err != nil {\n\t\t\tlog.Error(\"xstr.SplitInts(%s) error(%v)\", r.Ats, err)\n\t\t\terr = nil\n\t\t}\n\t\tmidAts = append(midAts, ats...)\n\t}\n\tif len(midAts) == 0 {\n\t\treturn\n\t}\n\taccMap, _ := s.getAccInfo(c, midAts)\n\tfor _, r := range res {\n\t\tr.FillAts(accMap)\n\t}\n\treturn\n}", "func (o *IscsiInitiatorGetIterResponseResult) SetNumRecords(newValue int) *IscsiInitiatorGetIterResponseResult {\n\to.NumRecordsPtr = &newValue\n\treturn o\n}", "func (rest *RestController) All(w http.ResponseWriter, r *http.Request) (Response, error) {\n\tresources := reflect.New(reflect.SliceOf(reflect.TypeOf(rest.Table).Elem()))\n\tcount, err := rest.Table.List(resources.Interface(), models.NewDBQuery(r.URL.Query(), nil))\n\tif err != nil {\n\t\treturn nil, &httpError{err, \"\", 500}\n\t}\n\tw.Header().Set(\"Total\", strconv.FormatInt(count, 10))\n\treturn &JSONResponse{resources.Interface(), 200}, nil\n}", "func (m *BarGroupMutation) ResetRecords() {\n\tm.records = nil\n\tm.clearedrecords = false\n\tm.removedrecords = nil\n}", "func TotalCount(resp *http.Response) int {\n\tif resp == nil {\n\t\treturn 0\n\t}\n\n\ttotalCountHeader := resp.Header.Get(totalCountHeaderKey)\n\ttotalCount, err := strconv.ParseInt(totalCountHeader, 10, 64)\n\tif err != nil {\n\t\treturn 0\n\t}\n\n\treturn int(totalCount)\n}", "func (o GetSrvRecordResultOutput) Records() GetSrvRecordRecordArrayOutput {\n\treturn o.ApplyT(func(v GetSrvRecordResult) []GetSrvRecordRecord { return v.Records }).(GetSrvRecordRecordArrayOutput)\n}", "func (pb *Bar) SetTotal(value int64) *Bar {\n\tatomic.StoreInt64(&pb.total, value)\n\tif pb.current >= pb.total && pb.total != -1 {\n\t\tpb.Finish()\n\t}\n\treturn pb\n}", "func (records *Records) NumRecords() int {\n\treturn len(records.Passwords)\n}", "func (p *Pagination) SetTotalPage(total int32) *Pagination {\n\ttotalPages := int32(1)\n\n\tif p.PageSize == limitPage {\n\t\tp.PageSize = total\n\t} else {\n\t\td := float64(total) / float64(p.PageSize)\n\t\ttotalPages = int32(math.Ceil(d))\n\t}\n\n\tp.TotalPage = totalPages\n\tp.TotalResult = total\n\treturn p\n}", "func (bgu *BarGroupUpdate) AddRecords(b ...*BarRecord) *BarGroupUpdate {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bgu.AddRecordIDs(ids...)\n}", "func (m *MonitoringAlertRecordsRequestBuilder) Count()(*MonitoringAlertRecordsCountRequestBuilder) {\n return NewMonitoringAlertRecordsCountRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func getTotals(snapshots []Snapshot) TotalResponse {\n reports := len(snapshots)\n days := make(map[string]int)\n people := make(map[string]int)\n locations := make(map[string]int)\n activities:= make(map[string]int)\n coffees := 0\n\n for _, snapshot := range snapshots {\n // Count people\n date := snapshot.Date[:10]\n days[date]++\n\n for _, response := range snapshot.Responses {\n question := response.QuestionPrompt\n // Count people\n if question == \"Who are you with?\" {\n for _, token := range response.Tokens {\n people[token.Text]++\n }\n } else if question == \"Where are you?\" {\n // count locations\n locations[response.LocationResponse.Text]++\n } else if question == \"How many coffees did you have today?\" {\n // count coffees\n amount, err := strconv.Atoi(response.NumericResponse)\n if err == nil {\n coffees += amount\n }\n } else if question == \"What are you doing?\" {\n for _, token := range response.Tokens {\n activities[token.Text]++\n }\n }\n }\n }\n\n return TotalResponse{\n TotalDays: len(days),\n TotalReports: reports,\n TotalPeople: len(people),\n TotalLocations: len(locations),\n AvgPerDay: float32(reports)/float32(len(days)),\n TotalCoffees: coffees,\n CoffeesPerDay: float32(coffees)/float32(len(days)),\n PeopleList: people,\n LocationList: locations,\n ActivityList: activities,\n }\n}", "func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\tp.mutex.Lock()\n\tdefer p.mutex.Unlock()\n\n\tclient := &http.Client{}\n\n\tvar updatedRecords []libdns.Record\n\n\tvar resourceRecordSets []LeasewebRecordSet\n\n\tfor _, record := range records {\n\n\t\trecordSet := LeasewebRecordSet{\n\t\t\tName: record.Name,\n\t\t\tType: record.Type,\n\t\t\tContent: []string{record.Value},\n\t\t\tTTL: int(record.TTL.Seconds()),\n\t\t}\n\n\t\tresourceRecordSets = append(resourceRecordSets, recordSet)\n\n\t\tupdatedRecords = append(updatedRecords, record)\n\t}\n\n\tbody := &LeasewebRecordSets{\n\t\tResourceRecordSets: resourceRecordSets,\n\t}\n\n\tbodyBuffer := new(bytes.Buffer)\n\tjson.NewEncoder(bodyBuffer).Encode(body)\n\n\treq, err := http.NewRequest(http.MethodPut, fmt.Sprintf(\"https://api.leaseweb.com/hosting/v2/domains/%s/resourceRecordSets\", zone), bodyBuffer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(LeasewebApiKeyHeader, p.APIKey)\n\n\tres, err := client.Do(req)\n\tdefer res.Body.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\treturn nil, fmt.Errorf(\"Received StatusCode %d from Leaseweb API\", res.StatusCode)\n\t}\n\n\treturn updatedRecords, nil\n}", "func SetTotalURLs(total int) (err error) {\n\tclient := getClient()\n\terr = client.Set(\"TotalUrls\", total, 0).Err()\n\treturn\n}", "func (r ApiGetBulkResultListRequest) Count(count bool) ApiGetBulkResultListRequest {\n\tr.count = &count\n\treturn r\n}", "func TotalRetention(amount float64, values []RetValue) float64 {\n\ttotal := 0.0\n\tfor _, v := range values {\n\t\ttotal += PartialRetention(amount, v)\n\t}\n\treturn total\n}", "func (result *FedoraResult) AllRecordsSucceeded() bool {\n\tfor _, record := range result.MetadataRecords {\n\t\tif false == record.Succeeded() {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (m *JobManager) Total() (int64, error) {\n\treturn m.table.Count()\n}", "func (o *GetSellerServicesUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (r ApiGetBulkExportListRequest) Count(count bool) ApiGetBulkExportListRequest {\n\tr.count = &count\n\treturn r\n}", "func (d *DBClient) AllRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\trecords, err := d.Cache.GetAllRequests()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordedRequests\n\t\tresponse.Data = records\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (o *GetAllPublicIPUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (m *Iterator) FetchTotal(ctx context.Context) (int, error) {\n\tr, err := m.query.Query(ctx, Request{\n\t\tLimit: 1,\n\t\tOffsetPeer: &tg.InputPeerEmpty{},\n\t})\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"fetch total\")\n\t}\n\n\tswitch msgs := r.(type) {\n\tcase *tg.MessagesMessages: // messages.messages#8c718e87\n\t\tm.count = len(msgs.Messages)\n\tcase *tg.MessagesMessagesSlice: // messages.messagesSlice#3a54685e\n\t\tm.count = msgs.Count\n\tcase *tg.MessagesChannelMessages: // messages.channelMessages#64479808\n\t\tm.count = msgs.Count\n\tdefault: // messages.messagesNotModified#74535f21\n\t\treturn 0, errors.Errorf(\"unexpected type %T\", r)\n\t}\n\n\tm.totalGot = true\n\treturn m.count, nil\n}", "func (tt *TransactionTransformer) transformCollection(request *http.Request, data interface{}, totalData int, limit string) *TransactionResponse {\n\ttransactionResponse := &TransactionResponse{}\n\ttransactionResponse.TotalCount = totalData\n\ttransactionResponse.Data = data\n\n\t// Convert limit to int if not empty\n\tif limit != \"\" {\n\t\tlimitInt, _ := strconv.Atoi(limit)\n\n\t\tif limitInt != -1 && limitInt != 0 {\n\t\t\t// If limit not euqal to `-1` and `0' set transaction links. Transaction links contain link to current page,\n\t\t\t// first page, next page and last page.\n\t\t\ttransactionResponse.Links = PaginationReponse.BuildPaginationLinks(request, totalData)\n\t\t}\n\t}\n\n\treturn transactionResponse\n}", "func (resource *billingInfoList) setResponse(res *ResponseMetadata) {\n\tresource.recurlyResponse = res\n}", "func (resp *DomainRecordsPagedResponse) appendData(r *DomainRecordsPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsReadResponseDuration(time.Duration) {}", "func (ac *AppContext) totalMessages(w http.ResponseWriter, r *http.Request) {\n\tcnt, err := ac.r.TotalMessages()\n\tif err != nil {\n\t\tlogrus.WithError(err).Error(\"Failed getting total messages\")\n\t\tWriteError(w, ErrInternalServer)\n\t\treturn\n\t}\n\tjson.NewEncoder(w).Encode(messageCount{cnt})\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsTimeout(int) {}", "func (fa *FindAndCountAll) Result(records interface{}, count int) {\n\tfa.Arguments[1] = mock.AnythingOfType(fmt.Sprintf(\"*%T\", records))\n\n\tfa.Run(func(args mock.Arguments) {\n\t\treflect.ValueOf(args[1]).Elem().Set(reflect.ValueOf(records))\n\t}).Return(count, nil)\n}", "func (o *PrivilegeUsersResponse) SetTotal(v int32) {\n\to.Total = &v\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsTimeout(count int) {\n\tdsc.GetRecordsTimeout.Inc(int64(count))\n}", "func (m *MultiInstances) Total() int {\n\ttotal := 0\n\tfor _, instances := range m.m {\n\t\ttotal += len(instances)\n\t}\n\treturn total\n}", "func (r ApiGetBulkRequestListRequest) Count(count bool) ApiGetBulkRequestListRequest {\n\tr.count = &count\n\treturn r\n}", "func (m *BarGroupMutation) ClearRecords() {\n\tm.clearedrecords = true\n}", "func (rb *ShardsRecordBuilder) RefreshExternalTotal(refreshexternaltotal string) *ShardsRecordBuilder {\n\trb.v.RefreshExternalTotal = &refreshexternaltotal\n\treturn rb\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (p *Pagination) SetTotalPage(total int32) *Pagination {\n\ttotalPages := int32(1)\n\tif p.PageSize > 0 {\n\t\td := float64(total) / float64(p.PageSize)\n\t\ttotalPages = int32(math.Ceil(d))\n\t}\n\tp.TotalPage = totalPages\n\tp.TotalResult = total\n\treturn p\n}", "func (r ApiGetBulkExportedItemListRequest) Count(count bool) ApiGetBulkExportedItemListRequest {\n\tr.count = &count\n\treturn r\n}", "func (rb *ShardsRecordBuilder) WarmerTotal(warmertotal string) *ShardsRecordBuilder {\n\trb.v.WarmerTotal = &warmertotal\n\treturn rb\n}", "func (o *FileInfoCollectionGetParams) SetMaxRecords(maxRecords *int64) {\n\to.MaxRecords = maxRecords\n}", "func (o *IscsiInitiatorGetIterRequest) MaxRecords() int {\n\tvar r int\n\tif o.MaxRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.MaxRecordsPtr\n\treturn r\n}", "func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\treturn p.updateRecords(ctx, zone, records)\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsDuration(time.Duration) {}", "func (d *Dataset) RecordCount() int {\n\tcount := 0\n\tif d.BlockCount() > 0 {\n\t\tfor _, block := range d.blocks {\n\t\t\tcount += block.RecordCount()\n\t\t}\n\t}\n\n\treturn count\n}", "func (m *MailTips) SetTotalMemberCount(value *int32)() {\n err := m.GetBackingStore().Set(\"totalMemberCount\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *MockMetaDataMgmtService) TotalContentCount(resourceId, contentType, providerName, catalogType, entityStatus, pageNumber, pageSize string) (int, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"TotalContentCount\", resourceId, contentType, providerName, catalogType, entityStatus, pageNumber, pageSize)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (bguo *BarGroupUpdateOne) ClearRecords() *BarGroupUpdateOne {\n\tbguo.mutation.ClearRecords()\n\treturn bguo\n}", "func updateRecords(conf *Configuration, slicev reflect.Value, c *mgo.Collection) error {\n\tids := fetchIds(conf, slicev)\n\t// update all matching documents to processing\n\t_, err := c.UpdateAll(\n\t\tbson.M{\"_id\": bson.M{\"$in\": ids}},\n\t\tbson.M{\"$set\": bson.M{conf.StateFld: conf.ProcessedState, conf.ProcessedTimeFld: time.Now().Unix()}},\n\t)\n\treturn err\n}", "func (r *SubscriptionsListServerRequest) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func (bgu *BarGroupUpdate) ClearRecords() *BarGroupUpdate {\n\tbgu.mutation.ClearRecords()\n\treturn bgu\n}", "func (c *CountResult) Total() int {\n\tvar t int\n\tfor k := range c.m {\n\t\tt += c.m[k]\n\t}\n\treturn t\n}", "func displayAllRecords(records []Record) {\n\tfmt.Printf(\"\\nDisplaying all records...\\n\\n\")\n\n\tfor i := 0; i < len(records); i++ {\n\t\tfmt.Printf(\"Record ID: %d: %+v\\n\", i, records[i])\n\t\ttime.Sleep(5 * time.Millisecond) // 5ms between records\n\t}\n}", "func (rb *ShardsRecordBuilder) SearchFetchTotal(searchfetchtotal string) *ShardsRecordBuilder {\n\trb.v.SearchFetchTotal = &searchfetchtotal\n\treturn rb\n}", "func (o *PortsetCollectionGetParams) SetMaxRecords(maxRecords *int64) {\n\to.MaxRecords = maxRecords\n}", "func (s *sink) errorAllRecordsInAllRecordBuffersInRequest(\n\treq *produceRequest,\n\terr error,\n) {\n\tfor _, partitions := range req.batches {\n\t\ts.errorAllRecordsInAllRecordBuffersInPartitions(\n\t\t\tpartitions,\n\t\t\terr,\n\t\t)\n\t}\n}", "func SetChainlinkAPIPageSize(nodes []client.Chainlink, pageSize int) {\n\tfor _, n := range nodes {\n\t\tn.SetPageSize(pageSize)\n\t}\n}", "func (s *CheckpointManager) UpdateTotal(taskID int, added int, last bool) {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tcp := s.checkpoints[taskID]\n\tcp.totalKeys += added\n\tcp.lastBatchSent = last\n}", "func IncrementSuccessfulList(counts int) {\n\tincSuccessfulRequestByHandler(\"list\", counts)\n}", "func (d *Dataset) BadRecordsCount() int {\n\tif len(d.badRecords) == 0 {\n\t\td.RecordCount() //hack to get records loaded so errors can be populated in dataset\n\t}\n\n\treturn len(d.badRecords)\n}", "func (o *AnalysisArchiveSummary) SetTotalDataBytes(v int32) {\n\to.TotalDataBytes = &v\n}", "func (m *Iterator) Total(ctx context.Context) (int, error) {\n\tif m.totalGot {\n\t\treturn m.count, nil\n\t}\n\n\treturn m.FetchTotal(ctx)\n}" ]
[ "0.7411211", "0.68853676", "0.6527963", "0.55671", "0.54397994", "0.5403986", "0.53291595", "0.5215049", "0.5191748", "0.50850916", "0.5069385", "0.5031457", "0.50241286", "0.5012421", "0.49860403", "0.4947973", "0.49434286", "0.48956817", "0.48902997", "0.48888567", "0.48390478", "0.48359305", "0.48339027", "0.4825823", "0.48204148", "0.48185432", "0.47832236", "0.47753838", "0.47076127", "0.4697439", "0.46928155", "0.46762493", "0.46742043", "0.46731433", "0.4656648", "0.46309084", "0.46295702", "0.46066338", "0.4578835", "0.45707643", "0.4566993", "0.45651472", "0.45444643", "0.45402905", "0.45209622", "0.45155978", "0.4507609", "0.44995055", "0.449625", "0.449612", "0.44921273", "0.44827944", "0.44794542", "0.4452753", "0.44480145", "0.44353014", "0.44331038", "0.44330728", "0.4424896", "0.4395936", "0.4389988", "0.43887708", "0.4381882", "0.43731257", "0.436946", "0.4368981", "0.4363844", "0.43630955", "0.4361843", "0.4356825", "0.43540022", "0.43431008", "0.4335122", "0.43281174", "0.43281174", "0.43250304", "0.4322344", "0.43223214", "0.43161997", "0.43030977", "0.42981192", "0.42895013", "0.42835394", "0.4282439", "0.4279029", "0.427735", "0.42709124", "0.4267867", "0.42655778", "0.42603984", "0.42571816", "0.42478576", "0.42467546", "0.4241402", "0.4238964", "0.4237089", "0.42341945", "0.4226079", "0.4223417", "0.42180827" ]
0.7904642
0
WithPayload adds the payload to the artifact lister o k response
func (o *ArtifactListerOK) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerOK { o.Payload = payload return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerInternalServerError) WithPayload(payload *weles.ErrResponse) *ArtifactListerInternalServerError {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerPartialContent) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerPartialContent {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) WithPayload(payload *weles.ErrResponse) *ArtifactListerBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetAssetsListOK) SetPayload(payload []*models.TokenAssetRow) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) WithPayload(payload *weles.ErrResponse) *ArtifactListerNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *ListAppsV1NamespacedDeploymentOK) SetPayload(payload *models.IoK8sAPIAppsV1DeploymentList) {\n\to.Payload = payload\n}", "func (o *GetImagesListOK) SetPayload(payload []*models.Image) {\n\to.Payload = payload\n}", "func (o *GetCoreAPIVersionsOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1APIVersions) {\n\to.Payload = payload\n}", "func (o *ObjectsListOK) SetPayload(payload *models.ObjectsListResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesCreated) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ListStorageV1alpha1VolumeAttachmentOK) SetPayload(payload *models.IoK8sAPIStorageV1alpha1VolumeAttachmentList) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesOK) SetPayload(payload models.PackageManifest) {\n\to.Payload = payload\n}", "func (o *GetChartsInfoOK) SetPayload(payload []*models.ChartsData) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetImagesListDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoOK) SetPayload(payload *models.RepositoryInfo) {\n\to.Payload = payload\n}", "func (o *AddItemOK) SetPayload(payload *models.CartSuccessResponse) {\n\to.Payload = payload\n}", "func (o *DeleteApiextensionsV1CollectionCustomResourceDefinitionOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1Status) {\n\to.Payload = payload\n}", "func (o *GetMarketsGroupsOK) SetPayload(payload []int32) {\n\to.Payload = payload\n}", "func (o *GetGistsOK) SetPayload(payload models.Gists) {\n\to.Payload = payload\n}", "func (o *GetApisOK) SetPayload(payload *models.APIMeta) {\n\to.Payload = payload\n}", "func (o *AddItemAccepted) SetPayload(payload *models.AddResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *WatchApiregistrationV1APIServiceOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1WatchEvent) {\n\to.Payload = payload\n}", "func (o *GetfeedsOK) SetPayload(payload []string) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ListVsphereResourceOK) SetPayload(payload *ListVsphereResourceOKBody) {\n\to.Payload = payload\n}", "func (o *PetUploadImageOK) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsOK) SetPayload(payload []*models.Item) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetAccountsListOK) SetPayload(payload []*models.AccountsRow) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsOK) SetPayload(payload []*models.AviServiceEngineGroup) {\n\to.Payload = payload\n}", "func (o *PostOperationsGetNetworkElementListOK) SetPayload(payload *models.TapiNetworkElementGetNetworkElementListOutput) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetAllReposOK) SetPayload(payload *models.ResourceArrayData) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationOK) SetPayload(payload *models.DeletedResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesOK) SetPayload(payload []*models.VSphereManagementObject) {\n\to.Payload = payload\n}", "func (o *PatchApiextensionsV1beta1CustomResourceDefinitionStatusOK) SetPayload(payload *models.IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinition) {\n\to.Payload = payload\n}", "func (o *ListOfDevicesOK) SetPayload(payload models.Devices) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostOK) SetPayload(payload *models.ID) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchOK) SetPayload(payload *models.ActionGetResponse) {\n\to.Payload = payload\n}", "func (o *GetTweetsOK) SetPayload(payload *models.TweetDetailsListResponse) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddKeypairConflict) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetIdentityEndpointsOK) SetPayload(payload []*models.IdentityEndpoints) {\n\to.Payload = payload\n}", "func (o *ActivityListJoinedOK) SetPayload(payload *models.InlineResponse2004) {\n\to.Payload = payload\n}", "func (o *GetVersionsOK) SetPayload(payload *GetVersionsOKBody) {\n\to.Payload = payload\n}", "func (o *ShopGetProductOK) SetPayload(payload *models.ShopProductResponse) {\n\to.Payload = payload\n}", "func (o *ActivityListFavOK) SetPayload(payload *models.InlineResponse2004) {\n\to.Payload = payload\n}", "func (o *GetProjectProjectNameServiceServiceNameResourceOK) SetPayload(payload *models.Resources) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetAllGroupsOK) SetPayload(payload *models.PageGroupList) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetCapabilityOK) SetPayload(payload []*models.Capability) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetReposOwnerRepoTagsOK) SetPayload(payload *models.Tags) {\n\to.Payload = payload\n}", "func (o *PatchFoldersIDOK) SetPayload(payload *models.CreateFolderResp) {\n\to.Payload = payload\n}", "func (o *AddRegionAZOK) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ActivityListSuggestOK) SetPayload(payload *models.InlineResponse2004) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1NotFound) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *ListBatchV1NamespacedJobOK) SetPayload(payload *models.IoK8sAPIBatchV1JobList) {\n\to.Payload = payload\n}", "func (o *GetS3BackupOK) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *UpdateClusterUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDOK) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetGistsIDCommentsOK) SetPayload(payload models.Comments) {\n\to.Payload = payload\n}", "func (o *PostGistsCreated) SetPayload(payload *models.Gist) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetOK) SetPayload(payload *models.LastOperationResource) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeleteAllRevisionsOK) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetPreEnrollmentsForFacilityOK) SetPayload(payload []*models.Enrollment) {\n\to.Payload = payload\n}", "func (o *GetSchedulingV1APIResourcesOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1APIResourceList) {\n\to.Payload = payload\n}", "func (o *GetAllStorageOK) SetPayload(payload *models.PageStorageList) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDNotFound) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigOK) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *SpareListOK) SetPayload(payload *models.InlineResponse20013) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationNotFound) SetPayload(payload *models.MissingResponse) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1Unauthorized) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *GetAPIV1GamesOK) SetPayload(payload []*models.Game) {\n\to.Payload = payload\n}", "func (o *GraphqlPostOK) SetPayload(payload *models.GraphQLResponse) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetIdentityIDOK) SetPayload(payload *models.Identity) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1InternalServerError) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *GetFleetsFleetIDMembersOK) SetPayload(payload models.GetFleetsFleetIDMembersOKBody) {\n\to.Payload = payload\n}", "func (o *AddKeypairCreated) SetPayload(payload models.ULID) {\n\to.Payload = payload\n}", "func (o *AddKeypairInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *WatchNetworkingV1IngressClassListOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1WatchEvent) {\n\to.Payload = payload\n}", "func (o *GetAppsOK) SetPayload(payload *models.GetAppsOKBody) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDUnauthorized) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDInternalServerError) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *SearchTournamentsOK) SetPayload(payload []*models.Tournament) {\n\to.Payload = payload\n}", "func (o *GetProjectSummaryOK) SetPayload(payload models.ProjectSummary) {\n\to.Payload = payload\n}" ]
[ "0.6866891", "0.66566706", "0.6601299", "0.6497717", "0.64683825", "0.62051743", "0.6182859", "0.61026436", "0.6092998", "0.6023159", "0.59868246", "0.5975534", "0.59724355", "0.5956259", "0.5928238", "0.5864594", "0.5844204", "0.58379173", "0.5822459", "0.5804906", "0.5781097", "0.5769008", "0.5741549", "0.5725845", "0.57193524", "0.57179534", "0.5714044", "0.56935924", "0.56925726", "0.56923085", "0.5680205", "0.56700176", "0.56644905", "0.56574154", "0.56380826", "0.56365377", "0.56344205", "0.5632641", "0.5628603", "0.5628198", "0.5616077", "0.5611041", "0.5605508", "0.5599497", "0.55978304", "0.55954903", "0.55908245", "0.55890113", "0.55762416", "0.5575081", "0.556956", "0.55692947", "0.5565238", "0.5563796", "0.55619615", "0.5560762", "0.5560125", "0.5557215", "0.5551851", "0.55410844", "0.55253404", "0.552292", "0.5517399", "0.55151993", "0.5512548", "0.550985", "0.55078566", "0.55068094", "0.55046684", "0.5502053", "0.5499352", "0.5488923", "0.5487945", "0.5487637", "0.5487025", "0.5482625", "0.5478744", "0.547286", "0.5470187", "0.54621536", "0.54541093", "0.54457563", "0.5442747", "0.54409415", "0.5438817", "0.54370743", "0.5436783", "0.5425803", "0.54246074", "0.5423685", "0.5422018", "0.54154295", "0.5415038", "0.541226", "0.54117113", "0.5409934", "0.5408149", "0.5405281", "0.54051435", "0.5404318" ]
0.7198307
0
SetPayload sets the payload to the artifact lister o k response
func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) { o.Payload = payload }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetAssetsListOK) SetPayload(payload []*models.TokenAssetRow) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetChartsInfoOK) SetPayload(payload []*models.ChartsData) {\n\to.Payload = payload\n}", "func (o *UpdateClusterUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesOK) SetPayload(payload []*models.VSphereManagementObject) {\n\to.Payload = payload\n}", "func (o *AddReleasesCreated) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchOK) SetPayload(payload *models.ActionGetResponse) {\n\to.Payload = payload\n}", "func (o *ListAppsV1NamespacedDeploymentOK) SetPayload(payload *models.IoK8sAPIAppsV1DeploymentList) {\n\to.Payload = payload\n}", "func (o *GetCoreAPIVersionsOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1APIVersions) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddKeypairConflict) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetImagesListOK) SetPayload(payload []*models.Image) {\n\to.Payload = payload\n}", "func (o *AddKeypairInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *PetUploadImageOK) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsOK) SetPayload(payload []*models.Item) {\n\to.Payload = payload\n}", "func (o *GetMarketsGroupsOK) SetPayload(payload []int32) {\n\to.Payload = payload\n}", "func (o *PostOperationsGetNetworkElementListOK) SetPayload(payload *models.TapiNetworkElementGetNetworkElementListOutput) {\n\to.Payload = payload\n}", "func (o *GetS3BackupOK) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *UpdateCatalogInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *AddItemOK) SetPayload(payload *models.CartSuccessResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoOK) SetPayload(payload *models.RepositoryInfo) {\n\to.Payload = payload\n}", "func (o *GetApisOK) SetPayload(payload *models.APIMeta) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetfeedsOK) SetPayload(payload []string) {\n\to.Payload = payload\n}", "func (o *GetTweetsOK) SetPayload(payload *models.TweetDetailsListResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListOK) SetPayload(payload *models.ObjectsListResponse) {\n\to.Payload = payload\n}", "func (o *GetAccountsListOK) SetPayload(payload []*models.AccountsRow) {\n\to.Payload = payload\n}", "func (o *AddRegionAZInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostOK) SetPayload(payload *models.ID) {\n\to.Payload = payload\n}", "func (o *UpdateMovieUnauthorized) SetPayload(payload *models.Result) {\n\to.Payload = payload\n}", "func (o *GetPreEnrollmentsForFacilityOK) SetPayload(payload []*models.Enrollment) {\n\to.Payload = payload\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationUnauthorized) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDInternalServerError) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *UpdateClusterInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksUnauthorized) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresOK) SetPayload(payload []*models.VSphereDatastore) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetTaskTaskIDOK) SetPayload(payload *models.ResponseTask) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDUnauthorized) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetAllReposOK) SetPayload(payload *models.ResourceArrayData) {\n\to.Payload = payload\n}", "func (o *GetImagesListDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationNotFound) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *AddRegionAZOK) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1InternalServerError) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1Unauthorized) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDOK) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *UpdateMovieOK) SetPayload(payload *models.Result) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsNotFound) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationInternalServerError) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PutSlideLikeCreated) SetPayload(payload models.Success) {\n\to.Payload = payload\n}", "func (o *ShopGetProductOK) SetPayload(payload *models.ShopProductResponse) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateMovieNotFound) SetPayload(payload *models.Result) {\n\to.Payload = payload\n}", "func (o *GetIdentityEndpointsOK) SetPayload(payload []*models.IdentityEndpoints) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesOK) SetPayload(payload models.PackageManifest) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDInternalServerError) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *ListVsphereResourceOK) SetPayload(payload *ListVsphereResourceOKBody) {\n\to.Payload = payload\n}", "func (o *UpdateRecordOK) SetPayload(payload *models.RecordOutput) {\n\to.Payload = payload\n}", "func (o *GetHealthzInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *ObjectsListUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPetByIDOK) SetPayload(payload *models.Pet) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetAllStorageOK) SetPayload(payload *models.PageStorageList) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesOK) SetPayload(payload *models.Presigned) {\n\to.Payload = payload\n}", "func (o *ObjectsListForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ListStorageV1alpha1VolumeAttachmentOK) SetPayload(payload *models.IoK8sAPIStorageV1alpha1VolumeAttachmentList) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDNotFound) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetSectionOK) SetPayload(payload *models.SectionResponse) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationOK) SetPayload(payload *models.DeletedResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostUserIDF2aUnauthorized) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *SpareListOK) SetPayload(payload *models.InlineResponse20013) {\n\to.Payload = payload\n}", "func (o *GraphqlPostOK) SetPayload(payload *models.GraphQLResponse) {\n\to.Payload = payload\n}", "func (o *AddNamespaceToGroupUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigOK) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *SearchTournamentsOK) SetPayload(payload []*models.Tournament) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsOK) SetPayload(payload []*models.AviServiceEngineGroup) {\n\to.Payload = payload\n}" ]
[ "0.80036867", "0.78599703", "0.7637977", "0.7551845", "0.751056", "0.73339987", "0.73249924", "0.7306623", "0.7282951", "0.7273448", "0.7267256", "0.72652704", "0.72629154", "0.7250694", "0.7237921", "0.72156614", "0.72121644", "0.7205217", "0.72041637", "0.719303", "0.7183207", "0.7157557", "0.7156598", "0.7155535", "0.71523225", "0.71512157", "0.7150824", "0.71449333", "0.71416533", "0.7136307", "0.7130671", "0.7128302", "0.71234345", "0.71220076", "0.71219474", "0.71165925", "0.7112007", "0.711088", "0.709546", "0.70844877", "0.70787704", "0.7069976", "0.7065886", "0.70622826", "0.70580673", "0.70534545", "0.7051969", "0.70493054", "0.7047121", "0.70470476", "0.70457387", "0.704478", "0.7043347", "0.7042731", "0.70396143", "0.7038257", "0.7038232", "0.70365804", "0.70343363", "0.7032672", "0.7032325", "0.70283306", "0.70243585", "0.7016728", "0.7014454", "0.7013814", "0.7005349", "0.7003214", "0.6998401", "0.69918704", "0.6988873", "0.69886047", "0.6987867", "0.6987484", "0.6986817", "0.698345", "0.69832", "0.6981795", "0.69815904", "0.6978843", "0.69746226", "0.69716924", "0.6969807", "0.6965374", "0.6964081", "0.6961238", "0.69609755", "0.6957996", "0.6955716", "0.69551927", "0.6954063", "0.6953731", "0.69518673", "0.6948186", "0.69470125", "0.6943801", "0.6942714", "0.69331354", "0.69297224", "0.6928661" ]
0.8145345
0
WriteResponse to the client
func (o *ArtifactListerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { // response header Next next := o.Next if next != "" { rw.Header().Set("Next", next) } // response header Previous previous := o.Previous if previous != "" { rw.Header().Set("Previous", previous) } // response header TotalRecords totalRecords := swag.FormatUint64(o.TotalRecords) if totalRecords != "" { rw.Header().Set("TotalRecords", totalRecords) } rw.WriteHeader(200) payload := o.Payload if payload == nil { payload = make([]*weles.ArtifactInfo, 0, 50) } if err := producer.Produce(rw, payload); err != nil { panic(err) // let the recovery middleware deal with this } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Response) Write(w io.Writer) error", "func (c *Operation) writeResponse(rw http.ResponseWriter, status int, data []byte) { // nolint: unparam\n\trw.WriteHeader(status)\n\n\tif _, err := rw.Write(data); err != nil {\n\t\tlogger.Errorf(\"Unable to send error message, %s\", err)\n\t}\n}", "func WriteResponse(w http.ResponseWriter, mensaje string, code int) {\n\tmessage := myTypes.Respuesta{\n\t\tMessage: mensaje,\n\t}\n\tresponse, _ := json.Marshal(message)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(response)\n}", "func WriteResponse(w http.ResponseWriter, object interface{}, rerr *irma.RemoteError) {\n\tstatus, bts := JsonResponse(object, rerr)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\t_, err := w.Write(bts)\n\tif err != nil {\n\t\tLogWarning(errors.WrapPrefix(err, \"failed to write response\", 0))\n\t}\n}", "func (o *PingOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, v interface{}, statusCode int) {\n\tresBody, err := json.Marshal(v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\t_, _ = w.Write(resBody)\n}", "func WriteResponse(w http.ResponseWriter, code int, object interface{}) {\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func (o *GetPingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(body []byte, w *http.ResponseWriter) {\n\t(*w).Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t_, err := (*w).Write(body)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\t(*w).WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func WriteResponse(w http.ResponseWriter, code int, resp interface{}) error {\n\tj, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\n\t_, err = w.Write(j)\n\treturn err\n}", "func writeResponse(w *http.ResponseWriter, res responseData, status int) {\n\tresJSON, err := json.Marshal(res)\n\tif err != nil {\n\t\thttp.Error(*w, \"Failed to parse struct `responseData` into JSON object\", http.StatusInternalServerError)\n\t}\n\n\t(*w).Header().Set(\"Content-Type\", \"application/json\")\n\t(*w).WriteHeader(status)\n\t(*w).Write(resJSON)\n}", "func WriteResponse(w http.ResponseWriter, d string) {\n\tw.WriteHeader(200)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.Write([]byte(d))\n\treturn\n}", "func (o *CreateFacilityUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(w http.ResponseWriter, response Response) {\n\tjson, err := json.Marshal(&response)\n\n\tif err != nil {\n\t\tfmt.Fprint(w, \"There was an error processing the request.\")\n\t}\n\n\tcommon.Log(fmt.Sprintf(\"Returning response %s\", json))\n\tfmt.Fprintf(w, \"%s\", json)\n}", "func (o *CreateProgramOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DepositNewFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMedicineOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *CreateTaskCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Location\n\n\tlocation := o.Location.String()\n\tif location != \"\" {\n\t\trw.Header().Set(\"Location\", location)\n\t}\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(r *http.Request, w http.ResponseWriter, code int, resp interface{}) {\n\n\t// Deal with CORS\n\tif origin := r.Header.Get(\"Origin\"); origin != \"\" {\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", origin)\n\t\tw.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE, GET, HEAD, OPTIONS, POST, PUT\")\n\t\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\t\t// Allow any headers\n\t\tif wantedHeaders := r.Header.Get(\"Access-Control-Request-Headers\"); wantedHeaders != \"\" {\n\t\t\tw.Header().Set(\"Access-Control-Allow-Headers\", wantedHeaders)\n\t\t}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\n\tb, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintln(w, `{\"error\":\"failed to marshal json\"}`)\n\t\treturn\n\t}\n\n\tw.WriteHeader(code)\n\tfmt.Fprintln(w, string(b))\n}", "func (o *VerifyAccountCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(w http.ResponseWriter, h int, p interface{}) {\n\t// I set the content type...\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t// ... I write the specified status code...\n\tw.WriteHeader(h)\n\t// ... and I write the response\n\tb, _ := json.Marshal(p)\n\tw.Write(b)\n}", "func (o *UpdateCatalogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (c *SwitchVersion) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postSwitchVersion(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *PutRecordingsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *BofaChkUpdateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *VerifyHealthCredentialOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, code int, err error, data interface{}, t0 time.Time) {\n\tw.WriteHeader(code)\n\tresp := &Response{Data: data, Dur: fmt.Sprint(time.Since(t0)), OK: false}\n\tif code < 300 {\n\t\tresp.OK = true\n\t}\n\tif err != nil {\n\t\tresp.Err = err.Error()\n\t}\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Infof(\"failed to json encode response: %v\", err)\n\t\tif _, err = w.Write([]byte(spew.Sdump(resp))); err != nil {\n\t\t\tlog.Infof(\"failed to write dump of response: %v\", err)\n\t\t}\n\t}\n}", "func (o *NewDiscoveryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(data []byte, size int64, ctype string, w http.ResponseWriter) {\n\tw.Header().Set(\"Content-Type\", ctype)\n\tw.Header().Set(\"Content-Length\", fmt.Sprintf(\"%d\", size))\n\tw.Header().Set(\"Cache-Control\", \"no-transform,public,max-age=86400,s-maxage=2592000\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, code int, object interface{}) {\n\tfmt.Println(\"writing response:\", code, object)\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, authZRes *authorization.Response) {\n\n\tdata, err := json.Marshal(authZRes)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to marshel authz response %q\", err.Error())\n\t} else {\n\t\tw.Write(data)\n\t}\n\n\tif authZRes == nil || authZRes.Err != \"\" {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t}\n}", "func (o *GetCharactersCharacterIDOpportunitiesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetCharactersCharacterIDOpportunitiesOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *WeaviateThingsGetNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *UpdateLinkInPostOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetChatroomsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetEchoNameOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetUIContentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *ListVsphereResourceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func ResponseWrite(w http.ResponseWriter, responseCode int, responseData interface{}) {\n\t// Write Response\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(responseCode)\n\n\t// Write JSON to Response\n\tjson.NewEncoder(w).Encode(responseData)\n}", "func writeHTTPResponseInWriter(httpRes http.ResponseWriter, httpReq *http.Request, nobelPrizeWinnersResponse []byte, err error) {\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(httpRes, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tlog.Printf(\"Request %s Succesfully Completed\", httpReq.RequestURI)\n\thttpRes.Header().Set(\"Content-Type\", \"application/json\")\n\thttpRes.Write(nobelPrizeWinnersResponse)\n}", "func (o *PostKeysKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlog.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func writeResponse(data interface{}, w http.ResponseWriter) error {\n\tvar (\n\t\tenc []byte\n\t\terr error\n\t)\n\tenc, err = json.Marshal(data)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to marshal, err = %s\", err)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tn, err := w.Write(enc)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to write, err = %s\", err)\n\t}\n\tif n != len(enc) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Short write sent = %d, wrote = %d\", len(enc), n)\n\t}\n\treturn nil\n}", "func (o *CreateUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func WriteResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PutQuestionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (r *response) Write(b []byte) (n int, err error) {\n\tif !r.headersSend {\n\t\tif r.status == 0 {\n\t\t\tr.status = http.StatusOK\n\t\t}\n\t\tr.WriteHeader(r.status)\n\t}\n\tn, err = r.ResponseWriter.Write(b)\n\tr.size += int64(n)\n\treturn\n}", "func (o *PostOperationsDeleteP2PPathCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *HealthGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsPatchNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (o *VerifyEmailTokenOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DeleteServiceIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\t// as of now, just log errors for writing response\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PostOperationsGetNodeEdgePointDetailsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *UserEditOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviatePeersAnnounceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *CertifyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(writer http.ResponseWriter, response *http.Response) (int64, error) {\n\tdefer response.Body.Close()\n\twriteResponseHeaders(writer, response, false)\n\treturn io.Copy(writer, response.Body)\n}", "func (o *PutMeetupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *FingerPathsPostCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *PostPlaybookOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateHostIgnitionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *GetCharactersCharacterIDLocationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostManagementKubernetesIoV1NodesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *PutPerformancesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *StopAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(202)\n}", "func (o *GetFleetsFleetIDMembersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Content-Language\n\n\tcontentLanguage := o.ContentLanguage\n\tif contentLanguage != \"\" {\n\t\trw.Header().Set(\"Content-Language\", contentLanguage)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetFleetsFleetIDMembersOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *GetMeetupsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostEventCreated) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(201)\n}", "func (o *GetTaskTaskIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateTCPCheckAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Reload-ID\n\n\treloadID := o.ReloadID\n\tif reloadID != \"\" {\n\t\trw.Header().Set(\"Reload-ID\", reloadID)\n\t}\n\n\trw.WriteHeader(202)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *PostOperationsGetNetworkElementListCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ServiceInstanceLastOperationGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header RetryAfter\n\n\tretryAfter := o.RetryAfter\n\tif retryAfter != \"\" {\n\t\trw.Header().Set(\"RetryAfter\", retryAfter)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPiecesIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetTaskDetailsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *UpdateClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetDetailOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\trw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetServicesHaproxyRuntimeAclsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (r *responseInfoRecorder) Write(b []byte) (int, error) {\n\tr.ContentLength += int64(len(b))\n\tif r.statusCode == 0 {\n\t\tr.statusCode = http.StatusOK\n\t}\n\treturn r.ResponseWriter.Write(b)\n}", "func (o *LogoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UploadFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, data interface{}) error {\n\tenv := map[string]interface{}{\n\t\t\"meta\": map[string]interface{}{\n\t\t\t\"code\": http.StatusOK,\n\t\t},\n\t\t\"data\": data,\n\t}\n\treturn jsonResponse(w, env)\n}", "func (o *WeaviateThingTemplatesCreateNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (r *Responder) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\tfor k, v := range r.headers {\n\t\tfor _, val := range v {\n\t\t\trw.Header().Add(k, val)\n\t\t}\n\t}\n\n\trw.WriteHeader(r.code)\n\n\tif r.response != nil {\n\t\tif err := producer.Produce(rw, r.response); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "func (o *GetGateSourceByGateNameAndMntOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateSpoeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tpayload := o.Payload\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *Output) writeResponse(response string) error {\r\n\t// write the response\r\n\tif _, err := o.writer.WriteString(response + \"\\n\"); err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (o *GetTransportByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *TransferOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateUserCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ViewOneOrderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetVisiblePruebasFromQuestionTestInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(500)\n}", "func (o *GetWhaleTranfersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.OperationsRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *SearchTournamentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*models.Tournament, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateTCPCheckCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (s *Server) writeInfoResponse(\n\tw http.ResponseWriter,\n\tr *http.Request,\n\tmessage []byte,\n\tstatus int,\n\theaders map[string]string,\n) {\n\tfor k, v := range headers {\n\t\tw.Header().Add(k, v)\n\t}\n\n\tw.WriteHeader(status)\n\tw.Write(message)\n}" ]
[ "0.81303823", "0.7882039", "0.77722245", "0.7771901", "0.7753117", "0.7740585", "0.76670325", "0.7638451", "0.76095873", "0.75798", "0.7579178", "0.7567389", "0.7560546", "0.75579476", "0.75447774", "0.7542929", "0.75416607", "0.753386", "0.7531158", "0.75192654", "0.75191355", "0.7513389", "0.7512029", "0.75050455", "0.7503395", "0.74984574", "0.74875605", "0.74839836", "0.74772394", "0.7467842", "0.746699", "0.7465759", "0.7464175", "0.746404", "0.746404", "0.7461224", "0.7460309", "0.74595356", "0.74463046", "0.7443478", "0.7435917", "0.7426582", "0.7425581", "0.74186546", "0.7413175", "0.7407469", "0.74063516", "0.74048966", "0.7398737", "0.7389631", "0.738607", "0.73806983", "0.7360552", "0.7360491", "0.7355327", "0.7354953", "0.73532444", "0.7347445", "0.734586", "0.732798", "0.732577", "0.73178244", "0.7316643", "0.7316071", "0.7315527", "0.7312546", "0.73114824", "0.7310336", "0.7309039", "0.73007035", "0.7297214", "0.7291373", "0.7291277", "0.72884554", "0.72845477", "0.72835207", "0.7281928", "0.7281033", "0.72751075", "0.7274423", "0.7273193", "0.72730565", "0.72695094", "0.7269139", "0.72690886", "0.7265927", "0.72615093", "0.72529227", "0.7251764", "0.72490144", "0.72479355", "0.72469014", "0.72407585", "0.72390425", "0.72367245", "0.7234706", "0.722777", "0.722197", "0.7215153", "0.72140837", "0.7213089" ]
0.0
-1
NewArtifactListerPartialContent creates ArtifactListerPartialContent with default headers values
func NewArtifactListerPartialContent() *ArtifactListerPartialContent { return &ArtifactListerPartialContent{} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func responderArtifact206(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerPartialContent) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\n\tresponder = artifacts.NewArtifactListerPartialContent()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tresponder.SetRemainingRecords(listInfo.RemainingRecords)\n\n\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\tartifactListerURL.After = &tmp\n\n\tif defaultPageLimit != paginator.Limit {\n\t\ttmp := paginator.Limit\n\t\tartifactListerURL.Limit = &tmp\n\t}\n\tresponder.SetNext(artifactListerURL.String())\n\n\tif paginator.ID != 0 { //... and not the first\n\t\t//paginator.ID is from query parameter not artifactmanager\n\t\tvar artifactListerURL artifacts.ArtifactListerURL\n\t\ttmp = artifactInfoReturned[0].ID\n\t\tartifactListerURL.Before = &tmp\n\t\tif defaultPageLimit != paginator.Limit {\n\t\t\ttmp := paginator.Limit\n\t\t\tartifactListerURL.Limit = &tmp\n\t\t}\n\t\tresponder.SetPrevious(artifactListerURL.String())\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (o *ArtifactListerPartialContent) WithRemainingRecords(remainingRecords uint64) *ArtifactListerPartialContent {\n\to.RemainingRecords = remainingRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Next\n\n\tnext := o.Next\n\tif next != \"\" {\n\t\trw.Header().Set(\"Next\", next)\n\t}\n\n\t// response header Previous\n\n\tprevious := o.Previous\n\tif previous != \"\" {\n\t\trw.Header().Set(\"Previous\", previous)\n\t}\n\n\t// response header RemainingRecords\n\n\tremainingRecords := swag.FormatUint64(o.RemainingRecords)\n\tif remainingRecords != \"\" {\n\t\trw.Header().Set(\"RemainingRecords\", remainingRecords)\n\t}\n\n\t// response header TotalRecords\n\n\ttotalRecords := swag.FormatUint64(o.TotalRecords)\n\tif totalRecords != \"\" {\n\t\trw.Header().Set(\"TotalRecords\", totalRecords)\n\t}\n\n\trw.WriteHeader(206)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*weles.ArtifactInfo, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *ArtifactListerPartialContent) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerPartialContent {\n\to.Payload = payload\n\treturn o\n}", "func (a *APIDefaults) ArtifactLister(params artifacts.ArtifactListerParams) middleware.Responder {\n\tpaginator := weles.ArtifactPagination{}\n\tif a.PageLimit != 0 {\n\t\tif (params.After != nil) && (params.Before != nil) {\n\t\t\treturn artifacts.NewArtifactListerBadRequest().WithPayload(&weles.ErrResponse{\n\t\t\t\tMessage: weles.ErrBeforeAfterNotAllowed.Error()})\n\t\t}\n\t\tpaginator = setArtifactPaginator(params, a.PageLimit)\n\t}\n\tfilter := setArtifactFilter(params.ArtifactFilterAndSort.Filter)\n\tsorter := setArtifactSorter(params.ArtifactFilterAndSort.Sorter)\n\n\tartifactInfoReceived, listInfo, err := a.Managers.AM.ListArtifact(filter, sorter, paginator)\n\n\tswitch err {\n\tdefault:\n\t\treturn artifacts.NewArtifactListerInternalServerError().WithPayload(\n\t\t\t&weles.ErrResponse{Message: err.Error()})\n\tcase weles.ErrArtifactNotFound:\n\t\treturn artifacts.NewArtifactListerNotFound().WithPayload(\n\t\t\t&weles.ErrResponse{Message: weles.ErrArtifactNotFound.Error()})\n\tcase nil:\n\t}\n\n\tartifactInfoReturned := artifactInfoReceivedToReturn(artifactInfoReceived)\n\n\tif (listInfo.RemainingRecords == 0) || (a.PageLimit == 0) { //last page...\n\t\treturn responderArtifact200(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n\t} //not last page...\n\treturn responderArtifact206(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n}", "func responderArtifact200(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerOK) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\tresponder = artifacts.NewArtifactListerOK()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tif paginator.ID != 0 { //not the first page\n\t\t// keep in mind that ArtifactPath in paginator is taken from query parameter,\n\t\t// not ArtifactManager\n\t\tif paginator.Forward {\n\t\t\ttmp := artifactInfoReturned[0].ID\n\t\t\tartifactListerURL.Before = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp\n\t\t\t}\n\t\t\tresponder.SetPrevious(artifactListerURL.String())\n\t\t} else {\n\t\t\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\t\t\tartifactListerURL.After = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp2 := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp2\n\t\t\t}\n\t\t\tresponder.SetNext(artifactListerURL.String())\n\t\t}\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func repoList(w http.ResponseWriter, r *http.Request) {}", "func NewActionResultPart()(*ActionResultPart) {\n m := &ActionResultPart{\n }\n m.SetAdditionalData(make(map[string]interface{}));\n return m\n}", "func NewContents (rawContents []map[string]interface{}) []Content {\n newContents := make ([]Content, len (rawContents))\n\n for i, rawContent := range rawContents {\n newContents[i] = NewContent (rawContent)\n }\n\n return newContents\n}", "func (o *ArtifactListerPartialContent) WithNext(next string) *ArtifactListerPartialContent {\n\to.Next = next\n\treturn o\n}", "func (dr downloadResponse) NewMetadata() Metadata {\n\tmd := Metadata{}\n\tfor k, v := range dr.rawResponse.Header {\n\t\tif len(k) > mdPrefixLen {\n\t\t\tif prefix := k[0:mdPrefixLen]; strings.EqualFold(prefix, mdPrefix) {\n\t\t\t\tmd[strings.ToLower(k[mdPrefixLen:])] = v[0]\n\t\t\t}\n\t\t}\n\t}\n\treturn md\n}", "func (a *DefaultApiService) ListFileContentSearchResults(ctx _context.Context, imageDigest string) ([]FileContentSearchResult, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue []FileContentSearchResult\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/images/{imageDigest}/artifacts/file_content_search\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"imageDigest\"+\"}\", _neturl.QueryEscape(parameterToString(imageDigest, \"\")) , -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\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\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 (fm *FileManager) BuildResponse() *plugin.Response {\n\tres := plugin.NewResponse()\n\tfor _, f := range fm.files {\n\t\tcontent := f.Content\n\t\tfor _, p := range fm.patch[f.GetName()] {\n\t\t\tpos := plugin.InsertionPoint(p.GetInsertionPoint())\n\t\t\ttxt := p.Content + pos\n\t\t\tcontent = strings.Replace(content, pos, txt, -1)\n\t\t\tfm.log.Info(fmt.Sprintf(\"patch %q at %q with size %d\", f.GetName(), p.GetInsertionPoint(), len(p.Content)))\n\t\t}\n\n\t\tg := &plugin.Generated{\n\t\t\tName: f.Name,\n\t\t\tContent: stripInsertionPoint(content),\n\t\t}\n\t\tres.Contents = append(res.Contents, g)\n\t}\n\treturn res\n}", "func (a *app) List(w http.ResponseWriter, request provider.Request, message rendererModel.Message) {\n\tfiles, err := a.storage.List(request.GetFilepath(\"\"))\n\tif err != nil {\n\t\ta.renderer.Error(w, request, provider.NewError(http.StatusInternalServerError, err))\n\t\treturn\n\t}\n\n\turi := request.GetURI(\"\")\n\n\titems := make([]provider.RenderItem, len(files))\n\tfor index, file := range files {\n\t\titems[index] = provider.RenderItem{\n\t\t\tID: sha.Sha1(file.Name),\n\t\t\tURI: uri,\n\t\t\tStorageItem: file,\n\t\t}\n\t}\n\n\tcontent := map[string]interface{}{\n\t\t\"Paths\": getPathParts(uri),\n\t\t\"Files\": items,\n\t\t\"Cover\": a.getCover(files),\n\t}\n\n\tif request.CanShare {\n\t\tcontent[\"Shares\"] = a.metadatas\n\t}\n\n\ta.renderer.Directory(w, request, content, message)\n}", "func (cgpr ContainersGetPropertiesResponse) NewMetadata() Metadata {\n\tmd := Metadata{}\n\tfor k, v := range cgpr.rawResponse.Header {\n\t\tif len(k) > mdPrefixLen {\n\t\t\tif prefix := k[0:mdPrefixLen]; strings.EqualFold(prefix, mdPrefix) {\n\t\t\t\tmd[strings.ToLower(k[mdPrefixLen:])] = v[0]\n\t\t\t}\n\t\t}\n\t}\n\treturn md\n}", "func (o *ArtifactListerPartialContent) WithPrevious(previous string) *ArtifactListerPartialContent {\n\to.Previous = previous\n\treturn o\n}", "func newContentTypes(f interface{}, pkg *PackageInfo) *ContentTypes {\n\tcontent := &ContentTypes{\n\t\tpkg: pkg,\n\t}\n\n\tcontent.file = NewPackageFile(pkg, f, &content.ml, nil)\n\tcontent.file.LoadIfRequired(nil)\n\treturn content\n}", "func generateListVersionsResponse(bucket, prefix, marker, delimiter, encodingType string, maxKeys int, resp ListObjectsInfo) ListVersionsResponse {\n\tvar versions []ObjectVersion\n\tvar prefixes []CommonPrefix\n\tvar owner = Owner{}\n\tvar data = ListVersionsResponse{}\n\n\towner.ID = globalMinioDefaultOwnerID\n\tfor _, object := range resp.Objects {\n\t\tvar content = ObjectVersion{}\n\t\tif object.Name == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tcontent.Key = s3EncodeName(object.Name, encodingType)\n\t\tcontent.LastModified = object.ModTime.UTC().Format(timeFormatAMZLong)\n\t\tif object.ETag != \"\" {\n\t\t\tcontent.ETag = \"\\\"\" + object.ETag + \"\\\"\"\n\t\t}\n\t\tcontent.Size = object.Size\n\t\tcontent.StorageClass = object.StorageClass\n\t\tcontent.Owner = owner\n\t\tcontent.VersionID = \"null\"\n\t\tcontent.IsLatest = true\n\t\tversions = append(versions, content)\n\t}\n\tdata.Name = bucket\n\tdata.Versions = versions\n\n\tdata.EncodingType = encodingType\n\tdata.Prefix = s3EncodeName(prefix, encodingType)\n\tdata.KeyMarker = s3EncodeName(marker, encodingType)\n\tdata.Delimiter = s3EncodeName(delimiter, encodingType)\n\tdata.MaxKeys = maxKeys\n\n\tdata.NextKeyMarker = s3EncodeName(resp.NextMarker, encodingType)\n\tdata.IsTruncated = resp.IsTruncated\n\n\tfor _, prefix := range resp.Prefixes {\n\t\tvar prefixItem = CommonPrefix{}\n\t\tprefixItem.Prefix = s3EncodeName(prefix, encodingType)\n\t\tprefixes = append(prefixes, prefixItem)\n\t}\n\tdata.CommonPrefixes = prefixes\n\treturn data\n}", "func (bgpr BlobsGetPropertiesResponse) NewMetadata() Metadata {\n\tmd := Metadata{}\n\tfor k, v := range bgpr.rawResponse.Header {\n\t\tif len(k) > mdPrefixLen {\n\t\t\tif prefix := k[0:mdPrefixLen]; strings.EqualFold(prefix, mdPrefix) {\n\t\t\t\tmd[strings.ToLower(k[mdPrefixLen:])] = v[0]\n\t\t\t}\n\t\t}\n\t}\n\treturn md\n}", "func (a *ContentApiService) AllContentMetadatas(ctx _context.Context, parentId int64, localVarOptionals *AllContentMetadatasOpts) ([]ContentMeta, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue []ContentMeta\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/content_metadata\"\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tlocalVarQueryParams.Add(\"parent_id\", parameterToString(parentId, \"\"))\n\tif localVarOptionals != nil && localVarOptionals.Fields.IsSet() {\n\t\tlocalVarQueryParams.Add(\"fields\", parameterToString(localVarOptionals.Fields.Value(), \"\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\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 == 200 {\n\t\t\tvar v []ContentMeta\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\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 400 {\n\t\t\tvar v Error\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\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v Error\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\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 (*ListArtifactsResponse) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_aiplatform_v1_metadata_service_proto_rawDescGZIP(), []int{10}\n}", "func listHandler(w http.ResponseWriter, r *http.Request, opts config.CookieSettings, isOverlay bool) {\n\tif gallery.ContainsDotFile(r.URL.Path) {\n\t\tfail404(w, r)\n\t\treturn\n\t}\n\tvar (\n\t\tparentUrl string\n\t\ttitle string\n\t\terr error\n\t\tcontents []os.FileInfo\n\t\tfolderPath string\n\t)\n\tfolderPath = strings.TrimPrefix(r.URL.Path, urlPrefix)\n\tif isOverlay {\n\t\tfolderPath = filepath.Dir(folderPath)\n\t}\n\tfs, err := storage.Root.Open(folderPath)\n\tif err != nil {\n\t\tfail500(w, err, r)\n\t\treturn\n\t}\n\tdefer fs.Close()\n\tcontents, err = fs.Readdir(-1)\n\tif err != nil {\n\t\tfail500(w, err, r)\n\t\treturn\n\t}\n\n\tfolderInfo, _ := fs.Stat()\n\tif folderPath != \"/\" && folderPath != \"\" {\n\t\ttitle = filepath.Base(r.URL.Path)\n\t\tparentUrl = path.Join(urlPrefix, folderPath, \"..\")\n\t} else if config.Global.PublicHost != \"\" {\n\t\ttitle = config.Global.PublicHost\n\t}\n\n\tchildren := make([]templates.ListItem, 0, len(contents))\n\tfor _, child := range contents {\n\t\tif gallery.ContainsDotFile(child.Name()) {\n\t\t\tcontinue\n\t\t}\n\t\tmediaClass := gallery.GetMediaClass(child.Name())\n\t\tif !child.IsDir() && mediaClass == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tchildPath := filepath.Join(urlPrefix, folderPath, child.Name())\n\t\tchildPath = gallery.EscapePath(filepath.ToSlash(childPath))\n\t\tthumb := urlPrefix + \"/?static=folder.svg\"\n\t\tclass := \"folder\"\n\t\tif !child.IsDir() {\n\t\t\tthumb = gallery.EscapePath(filepath.Join(urlPrefix, folderPath, child.Name())) + \"?thumb\"\n\t\t\tclass = mediaClass\n\t\t\tif config.Global.Ffmpeg == \"\" {\n\t\t\t\tclass += \" nothumb\"\n\t\t\t}\n\t\t}\n\t\tif child.ModTime().Before(faultyDate) {\n\t\t\t// TODO: find the reason for afero bad dates and remove this fix\n\t\t\tlogger.Printf(\"Invalid date detected for %s\", childPath)\n\t\t\tchild, _ = storage.Root.Stat(filepath.Join(folderPath, child.Name()))\n\t\t}\n\t\tchildren = append(children, templates.ListItem{\n\t\t\tId: gallery.EscapePath(child.Name()),\n\t\t\tModTime: child.ModTime(),\n\t\t\tUrl: childPath,\n\t\t\tName: child.Name(),\n\t\t\tThumb: thumb,\n\t\t\tClass: class,\n\t\t\tW: config.Global.ThumbWidth,\n\t\t\tH: config.Global.ThumbHeight,\n\t\t})\n\t}\n\tif opts.Sort == \"date\" {\n\t\tsort.Slice(children, func(i, j int) bool {\n\t\t\tif opts.Order {\n\t\t\t\tj, i = i, j\n\t\t\t}\n\t\t\treturn children[i].ModTime.Before(children[j].ModTime)\n\t\t})\n\t} else { // Sort by name\n\t\tsort.Slice(children, func(i, j int) bool {\n\t\t\tif opts.Order {\n\t\t\t\tj, i = i, j\n\t\t\t}\n\t\t\treturn gallery.NaturalLess(\n\t\t\t\tstrings.ToLower(children[i].Name),\n\t\t\t\tstrings.ToLower(children[j].Name))\n\t\t})\n\t}\n\tpUrl, _ := url.Parse(folderPath)\n\tcrumbs := splitUrlToBreadCrumbs(pUrl)\n\tw.Header().Set(\"Date\", folderInfo.ModTime().UTC().Format(http.TimeFormat))\n\titemCount := \"\"\n\tif folderPath != \"/\" && folderPath != \"\" && len(children) > 0 {\n\t\titemCount = fmt.Sprintf(\"%v \", len(children))\n\t}\n\terr = templates.Html.ExecuteTemplate(w, \"layout\", &templates.List{\n\t\tPage: templates.Page{\n\t\t\tTitle: title,\n\t\t\tPrefix: urlPrefix,\n\t\t\tAppVersion: BuildVersion,\n\t\t\tAppBuildTime: BuildTimestamp,\n\t\t\tShowOverlay: isOverlay,\n\t\t},\n\t\tBreadCrumbs: crumbs,\n\t\tItemCount: itemCount,\n\t\tSortedBy: opts.Sort,\n\t\tIsReversed: opts.Order,\n\t\tDisplayMode: opts.Show,\n\t\tParentUrl: parentUrl,\n\t\tItems: children,\n\t})\n\tif err != nil {\n\t\tfail500(w, err, r)\n\t\treturn\n\t}\n}", "func (o *ArtifactListerPartialContent) WithTotalRecords(totalRecords uint64) *ArtifactListerPartialContent {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (a *DefaultApiService) ListRetrievedFiles(ctx _context.Context, imageDigest string) ([]RetrievedFile, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue []RetrievedFile\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/images/{imageDigest}/artifacts/retrieved_files\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"imageDigest\"+\"}\", _neturl.QueryEscape(parameterToString(imageDigest, \"\")) , -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\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\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 NewArtifactListerOK() *ArtifactListerOK {\n\n\treturn &ArtifactListerOK{}\n}", "func getEverything(endpoint string) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\n\t\t//Read text box from HTML and assign it to search.Query\n\t\tsearch := &Search{\n\t\t\tQuery: c.Query(\"q\"),\n\t\t}\n\n\t\tr.LoadHTMLGlob(\"templates/*\")\n\n\t\tif search.Query == \"\" {\n\t\t\tc.HTML(http.StatusOK, \"header_everything.tmpl.html\", gin.H{\n\t\t\t\t\"title\": \"News Aggregation\",\n\t\t\t\t\"query\": search.Query,\n\t\t\t})\n\t\t\tc.HTML(http.StatusOK, \"footer.tmpl.html\", gin.H{})\n\n\t\t} else {\n\n\t\t\turl := endpoint + search.Query + apiKey\n\n\t\t\tclient := http.Client{\n\t\t\t\tTimeout: time.Second * 10,\n\t\t\t}\n\n\t\t\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tres, err := client.Do(req)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tif res.Body != nil {\n\t\t\t\tdefer res.Body.Close()\n\t\t\t}\n\n\t\t\tbody, err := ioutil.ReadAll(res.Body)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tjsonErr := json.Unmarshal(body, &NewsResultsVar)\n\t\t\tif jsonErr != nil {\n\t\t\t\tpanic(jsonErr)\n\t\t\t}\n\n\t\t\tc.HTML(http.StatusOK, \"header_everything.tmpl.html\", gin.H{\n\t\t\t\t\"title\": \"News Aggregation | \" + search.Query,\n\t\t\t\t\"query\": search.Query,\n\t\t\t\t\"status\": NewsResultsVar.Status,\n\t\t\t\t\"code\": NewsResultsVar.Code,\n\t\t\t\t\"message\": NewsResultsVar.Message,\n\t\t\t})\n\t\t\tc.HTML(http.StatusOK, \"articles_container.tmpl.html\", gin.H{})\n\t\t\tfor _, article := range NewsResultsVar.Articles {\n\t\t\t\tc.HTML(http.StatusOK, \"articles.tmpl.html\", gin.H{\n\t\t\t\t\t\"articleSource\": article.Source.Name,\n\t\t\t\t\t\"articlePubDate\": article.PublishedAt.Format(\"January 2, 2006\"),\n\t\t\t\t\t\"articleTitle\": article.Title,\n\t\t\t\t\t\"articleDescription\": article.Description,\n\t\t\t\t\t\"articleImage\": article.UrlToImage,\n\t\t\t\t\t\"articleUrl\": article.Url,\n\t\t\t\t})\n\t\t\t}\n\t\t\tc.HTML(http.StatusOK, \"footer.tmpl.html\", gin.H{})\n\t\t}\n\t}\n}", "func NewHeaders()(*Headers) {\n m := &Headers{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func setHeaders(w http.ResponseWriter, h http.Header, u *users.User) {\n\tw.Header().Set(\"Docker-Distribution-Api-Version\", \"registry/2.0\")\n\tfor k, v := range h {\n\t\tif strings.ToLower(k) == \"content-length\" {\n\t\t\tcontinue\n\t\t}\n\t\tw.Header().Set(k, strings.Join(v, \",\"))\n\t}\n}", "func (*GetArtifact_Response) Descriptor() ([]byte, []int) {\n\treturn file_artifactstore_ArtifactStore_proto_rawDescGZIP(), []int{2, 0}\n}", "func newHead(vres *salesviews.HeadView) *Head {\n\tres := &Head{}\n\tif vres.ID != nil {\n\t\tres.ID = *vres.ID\n\t}\n\tif vres.Name != nil {\n\t\tres.Name = *vres.Name\n\t}\n\treturn res\n}", "func setArtifactPaginator(params artifacts.ArtifactListerParams, defaultPageLimit int32,\n) (paginator weles.ArtifactPagination) {\n\tpaginator.Forward = true\n\tif params.After != nil {\n\t\tpaginator.ID = *params.After\n\t} else if params.Before != nil {\n\t\tpaginator.ID = *params.Before\n\t\tpaginator.Forward = false\n\t}\n\tif params.Limit == nil {\n\t\tpaginator.Limit = defaultPageLimit\n\t} else {\n\t\tpaginator.Limit = *params.Limit\n\t}\n\treturn paginator\n}", "func NewContent (rawContent map[string]interface{}) Content {\n if nil == rawContent {\n return Content{}\n }\n\n id, _ := rawContent[\"id\"].(string)\n parentId, _ := rawContent[\"parentId\"].(string)\n body, _ := rawContent[\"body\"].(string)\n title, _ := rawContent[\"title\"].(string)\n rawCreated, _ := rawContent[\"created\"].(string)\n rawModified, _ := rawContent[\"modified\"].(string)\n launchInNewWindow, _ := rawContent[\"launchInNewWindow\"].(bool)\n reviewable, _ := rawContent[\"reviewable\"].(bool)\n\n created, _ := time.Parse (time.RFC3339, rawCreated)\n modified, _ := time.Parse (time.RFC3339, rawModified)\n\n hasChildren, _ := rawContent[\"hasChildren\"].(bool)\n hasGradebookColumns, _ := rawContent[\"hasGradebookColumns\"].(bool)\n hasAssociatedGroups, _ := rawContent[\"hasAssociatedGroups\"].(bool)\n\n contentHandler, _ := rawContent[\"contentHandler\"].(map[string]interface{})\n\n return Content {\n Id: id,\n ParentId: parentId,\n Title: title,\n Body: body,\n Created: created,\n Modified: modified,\n Position: _parsePosition (rawContent[\"position\"]),\n HasChildren: hasChildren,\n HasGradebookColumn: hasGradebookColumns,\n HasAssociatedGroups: hasAssociatedGroups,\n LaunchInNewWindow: launchInNewWindow,\n Reviewable: reviewable,\n ContentHandler: NewContentHandler (contentHandler),\n Availability:\n _parseAvailability (rawContent[\"availability\"].(map[string]interface{})),\n }\n}", "func ListLicensesForContent(w http.ResponseWriter, r *http.Request, s Server) {\n\tvars := mux.Vars(r)\n\tvar page int64\n\tvar per_page int64\n\tvar err error\n\tcontentId := vars[\"key\"]\n\t//check if license exists\n\t_, err = s.Index().Get(contentId)\n\tif err == index.NotFound {\n\t\tproblem.Error(w, r, problem.Problem{Detail: err.Error()}, http.StatusNotFound)\n\t\treturn\n\t} //other errors pass, but will probably reoccur\n\tif r.FormValue(\"page\") != \"\" {\n\t\tpage, err = strconv.ParseInt(r.FormValue(\"page\"), 10, 32)\n\t\tif err != nil {\n\t\t\tproblem.Error(w, r, problem.Problem{Detail: err.Error()}, http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tpage = 1\n\t}\n\n\tif r.FormValue(\"per_page\") != \"\" {\n\t\tper_page, err = strconv.ParseInt((r).FormValue(\"per_page\"), 10, 32)\n\t\tif err != nil {\n\t\t\tproblem.Error(w, r, problem.Problem{Detail: err.Error()}, http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tper_page = 30\n\t}\n\tif page > 0 {\n\t\tpage-- //pagenum starting at 0 in code, but user interface starting at 1\n\t}\n\tif page < 0 {\n\t\tproblem.Error(w, r, problem.Problem{Detail: \"page must be positive integer\"}, http.StatusBadRequest)\n\t\treturn\n\t}\n\tlicenses := make([]license.LicenseReport, 0)\n\t//log.Println(\"List(\" + contentId + \",\" + strconv.Itoa(int(per_page)) + \",\" + strconv.Itoa(int(page)) + \")\")\n\tfn := s.Licenses().List(contentId, int(per_page), int(page))\n\tfor it, err := fn(); err == nil; it, err = fn() {\n\t\tlicenses = append(licenses, it)\n\t}\n\tif len(licenses) > 0 {\n\t\tnextPage := strconv.Itoa(int(page) + 1)\n\t\tw.Header().Set(\"Link\", \"</licenses/?page=\"+nextPage+\">; rel=\\\"next\\\"; title=\\\"next\\\"\")\n\t}\n\tif page > 1 {\n\t\tpreviousPage := strconv.Itoa(int(page) - 1)\n\t\tw.Header().Set(\"Link\", \"</licenses/?page=\"+previousPage+\">; rel=\\\"previous\\\"; title=\\\"previous\\\"\")\n\t}\n\tw.Header().Set(\"Content-Type\", api.ContentType_JSON)\n\tenc := json.NewEncoder(w)\n\terr = enc.Encode(licenses)\n\tif err != nil {\n\t\tproblem.Error(w, r, problem.Problem{Detail: err.Error()}, http.StatusBadRequest)\n\t\treturn\n\t}\n\n}", "func buildHeader(header restful.Header) spec.Header {\n\tresponseHeader := spec.Header{}\n\tresponseHeader.Type = header.Type\n\tresponseHeader.Description = header.Description\n\tresponseHeader.Format = header.Format\n\tresponseHeader.Default = header.Default\n\n\t// If type is \"array\" items field is required\n\tif header.Type == arrayType {\n\t\tresponseHeader.CollectionFormat = header.CollectionFormat\n\t\tresponseHeader.Items = buildHeadersItems(header.Items)\n\t}\n\n\treturn responseHeader\n}", "func TestNewResponse(t *testing.T) {\n\n\tyml := `description: this is a response\nheaders:\n someHeader:\n description: a header\ncontent:\n something/thing:\n description: a thing\nx-pizza-man: pizza!\nlinks:\n someLink:\n description: a link! `\n\n\tvar idxNode yaml.Node\n\t_ = yaml.Unmarshal([]byte(yml), &idxNode)\n\tidx := index.NewSpecIndexWithConfig(&idxNode, index.CreateOpenAPIIndexConfig())\n\n\tvar n v3.Response\n\t_ = low.BuildModel(idxNode.Content[0], &n)\n\t_ = n.Build(idxNode.Content[0], idx)\n\n\tr := NewResponse(&n)\n\n\tassert.Len(t, r.Headers, 1)\n\tassert.Len(t, r.Content, 1)\n\tassert.Equal(t, \"pizza!\", r.Extensions[\"x-pizza-man\"])\n\tassert.Len(t, r.Links, 1)\n\tassert.Equal(t, 1, r.GoLow().Description.KeyNode.Line)\n\n}", "func (*CommitMultipartVersionedBlobArtifact_Response) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_versioning_VersioningService_proto_rawDescGZIP(), []int{39, 0}\n}", "func (*GetCommittedVersionedBlobArtifactParts_Response) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_versioning_VersioningService_proto_rawDescGZIP(), []int{38, 0}\n}", "func (*ListArtifactsRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_aiplatform_v1_metadata_service_proto_rawDescGZIP(), []int{9}\n}", "func Create(\n\tctx context.Context,\n\tcfg config.Config,\n\tdc downloads.DatasetClient,\n\tfc downloads.FilterClient,\n\tic downloads.ImageClient,\n\ts3 content.S3Client,\n\tvc content.VaultClient,\n\tzc *health.Client,\n\thc *healthcheck.HealthCheck) Download {\n\n\trouter := mux.NewRouter()\n\n\tdownloader := downloads.Downloader{\n\t\tFilterCli: fc,\n\t\tDatasetCli: dc,\n\t\tImageCli: ic,\n\t}\n\n\ts3c := content.NewStreamWriter(s3, vc, cfg.VaultPath, cfg.EncryptionDisabled)\n\n\td := handlers.Download{\n\t\tDownloader: downloader,\n\t\tS3Content: s3c,\n\t\tIsPublishing: cfg.IsPublishing,\n\t}\n\n\trouter.Path(\"/downloads/datasets/{datasetID}/editions/{edition}/versions/{version}.csv\").HandlerFunc(d.DoDatasetVersion(\"csv\", cfg.ServiceAuthToken, cfg.DownloadServiceToken))\n\trouter.Path(\"/downloads/datasets/{datasetID}/editions/{edition}/versions/{version}.csv-metadata.json\").HandlerFunc(d.DoDatasetVersion(\"csvw\", cfg.ServiceAuthToken, cfg.DownloadServiceToken))\n\trouter.Path(\"/downloads/datasets/{datasetID}/editions/{edition}/versions/{version}.xlsx\").HandlerFunc(d.DoDatasetVersion(\"xls\", cfg.ServiceAuthToken, cfg.DownloadServiceToken))\n\trouter.Path(\"/downloads/filter-outputs/{filterOutputID}.csv\").HandlerFunc(d.DoFilterOutput(\"csv\", cfg.ServiceAuthToken, cfg.DownloadServiceToken))\n\trouter.Path(\"/downloads/filter-outputs/{filterOutputID}.xlsx\").HandlerFunc(d.DoFilterOutput(\"xls\", cfg.ServiceAuthToken, cfg.DownloadServiceToken))\n\trouter.Path(\"/images/{imageID}/{variant}/{filename}\").HandlerFunc(d.DoImage(cfg.ServiceAuthToken, cfg.DownloadServiceToken))\n\trouter.HandleFunc(\"/health\", hc.Handler)\n\n\t// Create new middleware chain with whitelisted handler for /health endpoint\n\tmiddlewareChain := alice.New(middleware.Whitelist(middleware.HealthcheckFilter(hc.Handler)))\n\n\t// For non-whitelisted endpoints, do identityHandler or corsHandler\n\tif cfg.IsPublishing {\n\t\tlog.Event(ctx, \"private endpoints are enabled. using identity middleware\", log.INFO)\n\t\tidentityHandler := dphandlers.IdentityWithHTTPClient(clientsidentity.NewWithHealthClient(zc))\n\t\tmiddlewareChain = middlewareChain.Append(identityHandler)\n\t} else {\n\t\tcorsHandler := gorillahandlers.CORS(gorillahandlers.AllowedMethods([]string{\"GET\"}))\n\t\tmiddlewareChain = middlewareChain.Append(corsHandler)\n\t}\n\n\tr := middlewareChain.\n\t\tAppend(dphandlers.CheckHeader(dphandlers.UserAccess)).\n\t\tAppend(dphandlers.CheckHeader(dphandlers.CollectionID)).\n\t\tThen(router)\n\thttpServer := dphttp.NewServer(cfg.BindAddr, r)\n\n\treturn Download{\n\t\tfilterClient: fc,\n\t\timageClient: ic,\n\t\tdatasetClient: dc,\n\t\tvaultClient: vc,\n\t\trouter: router,\n\t\tserver: httpServer,\n\t\tshutdown: cfg.GracefulShutdownTimeout,\n\t\thealthCheck: hc,\n\t}\n}", "func (*InitMultiPartResponse) Descriptor() ([]byte, []int) {\n\treturn file_s3_proto_s3_proto_rawDescGZIP(), []int{8}\n}", "func (client ArtifactsClient) listGenericArtifacts(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/generic/artifacts\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListGenericArtifactsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\tapiReferenceLink := \"https://docs.oracle.com/iaas/api/#/en/registry/20160918/GenericArtifact/ListGenericArtifacts\"\n\t\terr = common.PostProcessServiceError(err, \"Artifacts\", \"ListGenericArtifacts\", apiReferenceLink)\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (t *targetrunner) httpecget(w http.ResponseWriter, r *http.Request) {\n\tvar (\n\t\tconfig = cmn.GCO.Get()\n\t)\n\tapiItems, err := t.checkRESTItems(w, r, 2, false, cmn.Version, cmn.EC)\n\tif err != nil {\n\t\treturn\n\t}\n\tbucket, objName := apiItems[0], apiItems[1]\n\tbck, err := newBckFromQuery(bucket, r.URL.Query())\n\tif err != nil {\n\t\tt.invalmsghdlr(w, r, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\tlom := &cluster.LOM{T: t, ObjName: objName}\n\tif err = lom.Init(bck.Bck, config); err != nil {\n\t\tif _, ok := err.(*cmn.ErrorRemoteBucketDoesNotExist); ok {\n\t\t\tt.BMDVersionFixup(r, cmn.Bck{}, true /* sleep */)\n\t\t\terr = lom.Init(bck.Bck, config)\n\t\t}\n\t\tif err != nil {\n\t\t\tt.invalmsghdlr(w, r, err.Error())\n\t\t\treturn\n\t\t}\n\t}\n\tsliceFQN := lom.ParsedFQN.MpathInfo.MakePathFQN(bck.Bck, ec.SliceType, objName)\n\tfinfo, err := os.Stat(sliceFQN)\n\tif err != nil {\n\t\tt.invalmsghdlr(w, r, err.Error(), http.StatusNotFound)\n\t\treturn\n\t}\n\tfile, err := os.Open(sliceFQN)\n\tif err != nil {\n\t\tt.fshc(err, sliceFQN)\n\t\tt.invalmsghdlr(w, r, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer file.Close()\n\n\tbuf, slab := t.gmm.Alloc(finfo.Size())\n\tw.Header().Set(\"Content-Length\", strconv.FormatInt(finfo.Size(), 10))\n\t_, err = io.CopyBuffer(w, file, buf)\n\tslab.Free(buf)\n\tfile.Close()\n\tif err != nil {\n\t\tglog.Errorf(\"Failed to send slice %s/%s: %v\", bck, objName, err)\n\t}\n}", "func (*ListActorsResponse_ResponseItem) Descriptor() ([]byte, []int) {\n\treturn file_service_proto_rawDescGZIP(), []int{10, 0}\n}", "func mainHandler(w http.ResponseWriter, req *http.Request) {\n\tif req.Method != \"GET\" {\n\t\tw.Header().Set(\"Allow\", \"GET\")\n\t\thttp.Error(w, \"method should be GET\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\tw.Header().Set(\"X-Content-Type-Options\", \"nosniff\")\n\n\tdata := struct {\n\t\tProduction bool\n\t\tHTTPAddr string\n\t}{\n\t\tProduction: production,\n\t\tHTTPAddr: *httpFlag,\n\t}\n\terr := t.ExecuteTemplate(w, \"head.html.tmpl\", data)\n\tif err != nil {\n\t\tlog.Println(\"ExecuteTemplate head.html.tmpl:\", err)\n\t\treturn\n\t}\n\n\tflusher := w.(http.Flusher)\n\tflusher.Flush()\n\n\tvar updatesAvailable = 0\n\tvar wroteInstalledUpdatesHeader bool\n\n\tfor repoPresentation := range c.pipeline.RepoPresentations() {\n\t\tif !repoPresentation.Updated {\n\t\t\tupdatesAvailable++\n\t\t}\n\n\t\tif repoPresentation.Updated && !wroteInstalledUpdatesHeader {\n\t\t\t// Make 'Installed Updates' header visible now.\n\t\t\tio.WriteString(w, `<div id=\"installed_updates\"><h3 style=\"text-align: center;\">Installed Updates</h3></div>`)\n\n\t\t\twroteInstalledUpdatesHeader = true\n\t\t}\n\n\t\terr := t.ExecuteTemplate(w, \"repo.html.tmpl\", repoPresentation)\n\t\tif err != nil {\n\t\t\tlog.Println(\"ExecuteTemplate repo.html.tmpl:\", err)\n\t\t\treturn\n\t\t}\n\n\t\tflusher.Flush()\n\t}\n\n\tif !wroteInstalledUpdatesHeader {\n\t\t// TODO: Make installed_updates available before all packages finish loading, so that it works when you update a package early. This will likely require a fully dynamically rendered frontend.\n\t\t// Append 'Installed Updates' header, but keep it hidden.\n\t\tio.WriteString(w, `<div id=\"installed_updates\" style=\"display: none;\"><h3 style=\"text-align: center;\">Installed Updates</h3></div>`)\n\t}\n\n\tif updatesAvailable == 0 {\n\t\tio.WriteString(w, `<script>document.getElementById(\"no_updates\").style.display = \"\";</script>`)\n\t}\n\n\terr = t.ExecuteTemplate(w, \"tail.html.tmpl\", nil)\n\tif err != nil {\n\t\tlog.Println(\"ExecuteTemplate tail.html.tmpl:\", err)\n\t\treturn\n\t}\n}", "func (m *ItemSpecialDriveItemItemRequestBuilder) Content()(*ItemSpecialItemContentRequestBuilder) {\n return NewItemSpecialItemContentRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func newFileFetcher() *fileFetcherExtender {\n\treturn &fileFetcherExtender{new(DefaultExtender)}\n}", "func suggestLayoutWithProjectId(req *restful.Request, res *restful.Response) {\n // this projectId should be saved later on...\n // TODO: (caching by \"projectId\" and \"suggestionId\" etc)\n dataModel := NewTemplateDataModel(req.Request.Form)\n fmt.Println(dataModel.PickedImageList[0][\"image\"])\n fmt.Println(len(dataModel.PickedImageList))\n\n // TODO: pretend AI / ML => to generate the suggestion\n\n res.WriteHeaderAndJson(200,\n NewModuleResponse( fmt.Sprintf(\"testing only %v\", dataModel)),\n restful.MIME_JSON)\n}", "func (ix *Search) ContentSearchResult(fnames []uint32, re *regexp.Regexp, _ string) ([]output.Entry, error) {\n\t// Search inside the files.\n\tmatches := multiFile(fnames, re, ix)\n\n\tbn := make([]string, 0, len(matches))\n\tfor _, m := range matches {\n\t\tbn = append(bn, filepath.Dir(m.fn))\n\t}\n\ttrimpoint := findLongestPrefix(bn)\n\n\too := make([]output.Entry, 0, len(matches))\n\n\tfor _, m := range matches {\n\t\tname := m.fn\n\t\t// It would be nice if Alfred supported styled strings. Then, I\n\t\t// could highlight the search results.\n\t\ttitle := fmt.Sprintf(\"%d %s\", m.lineno, m.matchLine)\n\t\targ := fmt.Sprintf(\"/%s:%d%s\", base.Prefix, m.lineno, name)\n\n\t\too = append(oo, output.Entry{\n\t\t\tUid: fmt.Sprintf(\"%s:%d\", name, m.lineno),\n\t\t\tArg: arg,\n\t\t\tTitle: title,\n\t\t\tSubTitle: fmt.Sprintf(\"%s:%d %s\", ix.nicelyTrimPath([]byte(name), trimpoint), m.lineno, m.matchLine),\n\t\t\tType: \"file\",\n\t\t\tIcon: output.AlfredIcon{\n\t\t\t\tFilename: determineIconString(name),\n\t\t\t},\n\t\t})\n\n\t\t// TODO(rjk): make icons for C++ etc. work correctly here.\n\t\t// The golang icons work? They do. They're part of the workflow.\n\t\t// I can make custom icons, put in the workflow and save the copies.\n\t\t// This will simplify the \"remote-i-fying\"\n\t\t// Copy the content to the prefix so that icons work properly.\n\t\t// TODO(rjk): this doesn't work right for remote?\n\t\tdir := filepath.Dir(arg)\n\t\tif err := os.MkdirAll(dir, 0700); err != nil {\n\t\t\tlog.Println(dir, err)\n\t\t\tcontinue\n\t\t}\n\t\tif err := fileCopy(name, arg); err != nil {\n\t\t\tlog.Println(name, arg, err)\n\t\t\tcontinue\n\t\t}\n\t}\n\treturn oo, nil\n}", "func (lens Lens) Header(artifacts []lenses.Artifact, resourceDir string) string {\n\tt, err := template.ParseFiles(filepath.Join(resourceDir, \"template.html\"))\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"<!-- FAILED LOADING HEADER: %v -->\", err)\n\t}\n\tvar buf bytes.Buffer\n\tif err := t.ExecuteTemplate(&buf, \"header\", nil); err != nil {\n\t\treturn fmt.Sprintf(\"<!-- FAILED EXECUTING HEADER TEMPLATE: %v -->\", err)\n\t}\n\treturn buf.String()\n}", "func New(filename string, format string, tmplValue interface{}, idGen items.IIDGen, reload chan bool) (items.IItems, error) {\n\tf := fileItems{\n\t\tfilename: filename,\n\t\titemDataType: reflect.TypeOf(tmplValue),\n\t\tidGen: idGen,\n\t\titemList: []items.IItem{},\n\t\titemByID: map[string]items.IItem{},\n\t\treload: reload,\n\t}\n\tif f.idGen == nil {\n\t\tf.idGen = &incIDGen{last: 0}\n\t}\n\t//dereference pointer types\n\tfor f.itemDataType != nil && f.itemDataType.Kind() == reflect.Ptr {\n\t\tf.itemDataType = f.itemDataType.Elem()\n\t}\n\n\tswitch strings.ToUpper(format) {\n\t// case \"XML\":\n\t// \tf.encoder = xmlFileEncoder{filename: filename}\n\tcase \"JSON\":\n\t\tf.encoder = jsonFileEncoder{filename: filename}\n\tdefault:\n\t\treturn nil, errors.Errorf(\"unknown format:%s, expecting json|xml\", format)\n\t}\n\t//read item list from file then populate id index\n\tif err := f.Reload(); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to load\")\n\t}\n\n\tif f.reload != nil {\n\t\tgo func(f *fileItems) {\n\t\t\tfor <-f.reload {\n\t\t\t\tlog.Debugf(\"Reloading...\")\n\t\t\t\tif f.closed {\n\t\t\t\t\tlog.Debugf(\"Reloading...\")\n\t\t\t\t\tbreak //terminate when flag is set\n\t\t\t\t}\n\t\t\t\tif err := f.Reload(); err != nil {\n\t\t\t\t\tlog.Debugf(\"Reloading...\")\n\t\t\t\t\tlog.Errorf(\"failed to reload: %v\", err)\n\t\t\t\t}\n\t\t\t\tlog.Debugf(\"Reloading...\")\n\t\t\t}\n\t\t\tlog.Debugf(\"Reloading...\")\n\t\t}(&f)\n\t}\n\treturn &f, nil\n}", "func catalog_Get(t *testing.T, opts ...configOpt) {\n\tenv := newTestEnv(t, opts...)\n\tdefer env.Shutdown()\n\n\tsortedRepos := []string{\n\t\t\"2j2ar\",\n\t\t\"asj9e/ieakg\",\n\t\t\"dcsl6/xbd1z/9t56s\",\n\t\t\"hpgkt/bmawb\",\n\t\t\"jyi7b\",\n\t\t\"jyi7b/sgv2q/d5a2f\",\n\t\t\"jyi7b/sgv2q/fxt1v\",\n\t\t\"kb0j5/pic0i\",\n\t\t\"n343n\",\n\t\t\"sb71y\",\n\t}\n\n\t// shuffle repositories to make sure results are consistent regardless of creation order (it matters when running\n\t// against the metadata database)\n\tshuffledRepos := shuffledCopy(sortedRepos)\n\n\tfor _, repo := range shuffledRepos {\n\t\tcreateRepository(t, env, repo, \"latest\")\n\t}\n\n\ttt := []struct {\n\t\tname string\n\t\tqueryParams url.Values\n\t\texpectedBody catalogAPIResponse\n\t\texpectedLinkHeader string\n\t}{\n\t\t{\n\t\t\tname: \"no query parameters\",\n\t\t\texpectedBody: catalogAPIResponse{Repositories: sortedRepos},\n\t\t},\n\t\t{\n\t\t\tname: \"empty last query parameter\",\n\t\t\tqueryParams: url.Values{\"last\": []string{\"\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: sortedRepos},\n\t\t},\n\t\t{\n\t\t\tname: \"empty n query parameter\",\n\t\t\tqueryParams: url.Values{\"n\": []string{\"\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: sortedRepos},\n\t\t},\n\t\t{\n\t\t\tname: \"empty last and n query parameters\",\n\t\t\tqueryParams: url.Values{\"last\": []string{\"\"}, \"n\": []string{\"\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: sortedRepos},\n\t\t},\n\t\t{\n\t\t\tname: \"non integer n query parameter\",\n\t\t\tqueryParams: url.Values{\"n\": []string{\"foo\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: sortedRepos},\n\t\t},\n\t\t{\n\t\t\tname: \"1st page\",\n\t\t\tqueryParams: url.Values{\"n\": []string{\"4\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: []string{\n\t\t\t\t\"2j2ar\",\n\t\t\t\t\"asj9e/ieakg\",\n\t\t\t\t\"dcsl6/xbd1z/9t56s\",\n\t\t\t\t\"hpgkt/bmawb\",\n\t\t\t}},\n\t\t\texpectedLinkHeader: `</v2/_catalog?last=hpgkt%2Fbmawb&n=4>; rel=\"next\"`,\n\t\t},\n\t\t{\n\t\t\tname: \"nth page\",\n\t\t\tqueryParams: url.Values{\"last\": []string{\"hpgkt/bmawb\"}, \"n\": []string{\"4\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: []string{\n\t\t\t\t\"jyi7b\",\n\t\t\t\t\"jyi7b/sgv2q/d5a2f\",\n\t\t\t\t\"jyi7b/sgv2q/fxt1v\",\n\t\t\t\t\"kb0j5/pic0i\",\n\t\t\t}},\n\t\t\texpectedLinkHeader: `</v2/_catalog?last=kb0j5%2Fpic0i&n=4>; rel=\"next\"`,\n\t\t},\n\t\t{\n\t\t\tname: \"last page\",\n\t\t\tqueryParams: url.Values{\"last\": []string{\"kb0j5/pic0i\"}, \"n\": []string{\"4\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: []string{\n\t\t\t\t\"n343n\",\n\t\t\t\t\"sb71y\",\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"zero page size\",\n\t\t\tqueryParams: url.Values{\"n\": []string{\"0\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: sortedRepos},\n\t\t},\n\t\t{\n\t\t\tname: \"page size bigger than full list\",\n\t\t\tqueryParams: url.Values{\"n\": []string{\"100\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: sortedRepos},\n\t\t},\n\t\t{\n\t\t\tname: \"after marker\",\n\t\t\tqueryParams: url.Values{\"last\": []string{\"kb0j5/pic0i\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: []string{\n\t\t\t\t\"n343n\",\n\t\t\t\t\"sb71y\",\n\t\t\t}},\n\t\t},\n\t\t{\n\t\t\tname: \"after non existent marker\",\n\t\t\tqueryParams: url.Values{\"last\": []string{\"does-not-exist\"}},\n\t\t\texpectedBody: catalogAPIResponse{Repositories: []string{\n\t\t\t\t\"hpgkt/bmawb\",\n\t\t\t\t\"jyi7b\",\n\t\t\t\t\"jyi7b/sgv2q/d5a2f\",\n\t\t\t\t\"jyi7b/sgv2q/fxt1v\",\n\t\t\t\t\"kb0j5/pic0i\",\n\t\t\t\t\"n343n\",\n\t\t\t\t\"sb71y\",\n\t\t\t}},\n\t\t},\n\t}\n\n\tfor _, test := range tt {\n\t\tt.Run(test.name, func(t *testing.T) {\n\t\t\tcatalogURL, err := env.builder.BuildCatalogURL(test.queryParams)\n\t\t\trequire.NoError(t, err)\n\n\t\t\tresp, err := http.Get(catalogURL)\n\t\t\trequire.NoError(t, err)\n\t\t\tdefer resp.Body.Close()\n\n\t\t\trequire.Equal(t, http.StatusOK, resp.StatusCode)\n\n\t\t\tvar body catalogAPIResponse\n\t\t\tdec := json.NewDecoder(resp.Body)\n\t\t\terr = dec.Decode(&body)\n\t\t\trequire.NoError(t, err)\n\n\t\t\trequire.Equal(t, test.expectedBody, body)\n\t\t\trequire.Equal(t, test.expectedLinkHeader, resp.Header.Get(\"Link\"))\n\t\t})\n\t}\n\n\t// If the database is enabled, disable it and rerun the tests again with the\n\t// database to check that the filesystem mirroring worked correctly.\n\tif env.config.Database.Enabled && !env.config.Migration.DisableMirrorFS {\n\t\tenv.config.Database.Enabled = false\n\t\tdefer func() { env.config.Database.Enabled = true }()\n\n\t\tfor _, test := range tt {\n\t\t\tt.Run(fmt.Sprintf(\"%s filesystem mirroring\", test.name), func(t *testing.T) {\n\t\t\t\tcatalogURL, err := env.builder.BuildCatalogURL(test.queryParams)\n\t\t\t\trequire.NoError(t, err)\n\n\t\t\t\tresp, err := http.Get(catalogURL)\n\t\t\t\trequire.NoError(t, err)\n\t\t\t\tdefer resp.Body.Close()\n\n\t\t\t\trequire.Equal(t, http.StatusOK, resp.StatusCode)\n\n\t\t\t\tvar body catalogAPIResponse\n\t\t\t\tdec := json.NewDecoder(resp.Body)\n\t\t\t\terr = dec.Decode(&body)\n\t\t\t\trequire.NoError(t, err)\n\n\t\t\t\trequire.Equal(t, test.expectedBody, body)\n\t\t\t\trequire.Equal(t, test.expectedLinkHeader, resp.Header.Get(\"Link\"))\n\t\t\t})\n\t\t}\n\t}\n}", "func (this *HttpClient) newBucket(resp *http.Response) (*Bucket, error) {\n\tlog.Println(\"Extracting keys from the response body\")\n\n\tbucket := &Bucket{}\n\n\terr := ffjson.NewDecoder().DecodeReader(resp.Body, bucket)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Error decoding JSON\")\n\t}\n\n\tlog.Println(\"Fetched bucket \", bucket)\n\n\t// fetch and decode keys\n\treturn bucket, nil\n}", "func (*ListRepositoryRes) Descriptor() ([]byte, []int) {\n\treturn file_api_ops_proto_rawDescGZIP(), []int{4}\n}", "func ViewHandler(artifacts []viewers.Artifact, raw string) string {\n\tbuildLogsView := BuildLogsView{\n\t\tLogViews: []LogArtifactView{},\n\t\tGetAllRequests: make(map[string]LogViewerRequest),\n\t\tGetMoreRequests: make(map[string]LogViewerRequest),\n\t\tRawGetAllRequests: make(map[string]string),\n\t\tRawGetMoreRequests: make(map[string]string),\n\t}\n\tviewReq := LogViewerRequest{\n\t\tRequests: make(map[string]LogViewData),\n\t}\n\tif err := json.Unmarshal([]byte(raw), &viewReq); err != nil {\n\t\tlogrus.WithError(err).Error(\"Error unmarshaling log view request data.\")\n\t}\n\n\tgetAllReq := LogViewerRequest{\n\t\tRequests: make(map[string]LogViewData),\n\t}\n\n\tgetMoreReq := LogViewerRequest{\n\t\tRequests: make(map[string]LogViewData),\n\t}\n\n\t// Read log artifacts and construct template structs\n\tfor _, a := range artifacts {\n\t\tviewData, ok := viewReq.Requests[a.JobPath()]\n\t\tif !ok {\n\t\t\tviewData = LogViewData{\n\t\t\t\tUseBytes: false,\n\t\t\t\tHeadBytes: 0,\n\t\t\t\tTailLines: 0,\n\t\t\t\tOperation: \"more\",\n\t\t\t}\n\t\t}\n\n\t\tlogView, logViewData := nextViewData(a, viewData)\n\n\t\tbuildLogsView.LogViews = append(buildLogsView.LogViews, logView)\n\t\tgetAllReq.Requests[a.JobPath()] = logViewData\n\t\tgetMoreReq.Requests[a.JobPath()] = logViewData\n\n\t}\n\n\t// Build individualized requests for stateless callbacks\n\tfor _, a := range artifacts {\n\t\taName := a.JobPath()\n\n\t\tbuildLogsView.GetAllRequests[aName] = getAllReq\n\t\treqAll := buildLogsView.GetAllRequests[aName]\n\n\t\treqAllData := reqAll.Requests[aName]\n\t\treqAllData.Operation = \"all\"\n\t\treqAll.Requests[aName] = reqAllData\n\t\traw, err := json.Marshal(reqAll)\n\t\tif err != nil {\n\t\t\tlogrus.WithError(err).Error(\"Failed to marshal build log more lines request object.\")\n\t\t}\n\t\tbuildLogsView.RawGetAllRequests[aName] = string(raw)\n\n\t\tbuildLogsView.GetMoreRequests[aName] = getMoreReq\n\t\treqMore := buildLogsView.GetMoreRequests[aName]\n\n\t\treqMoreData := reqMore.Requests[aName]\n\t\treqMoreData.Operation = \"more\"\n\t\treqMore.Requests[aName] = reqMoreData\n\t\traw, err = json.Marshal(reqMore)\n\t\tif err != nil {\n\t\t\tlogrus.WithError(err).Error(\"Failed to marshal build log more lines request object.\")\n\t\t}\n\t\tbuildLogsView.RawGetMoreRequests[aName] = string(raw)\n\t}\n\n\treturn LogViewTemplate(buildLogsView)\n}", "func (*ListItemsResponse) Descriptor() ([]byte, []int) {\n\treturn file_user_proto_rawDescGZIP(), []int{12}\n}", "func (a LearningApi) GetLearningModules(isArchived bool, types []string, pageSize int, pageNumber int, sortOrder string, sortBy string, searchTerm string, expand []string, isPublished string, statuses []string) (*Learningmodulesdomainentitylisting, *APIResponse, error) {\n\tvar httpMethod = \"GET\"\n\t// create path and map variables\n\tpath := a.Configuration.BasePath + \"/api/v2/learning/modules\"\n\tdefaultReturn := new(Learningmodulesdomainentitylisting)\n\tif true == false {\n\t\treturn defaultReturn, nil, errors.New(\"This message brought to you by the laws of physics being broken\")\n\t}\n\n\n\theaderParams := make(map[string]string)\n\tqueryParams := make(map[string]string)\n\tformParams := url.Values{}\n\tvar postBody interface{}\n\tvar postFileName string\n\tvar fileBytes []byte\n\t// authentication (PureCloud OAuth) required\n\n\t// oauth required\n\tif a.Configuration.AccessToken != \"\"{\n\t\theaderParams[\"Authorization\"] = \"Bearer \" + a.Configuration.AccessToken\n\t}\n\t// add default headers if any\n\tfor key := range a.Configuration.DefaultHeader {\n\t\theaderParams[key] = a.Configuration.DefaultHeader[key]\n\t}\n\t\n\tqueryParams[\"isArchived\"] = a.Configuration.APIClient.ParameterToString(isArchived, \"\")\n\t\n\tqueryParams[\"types\"] = a.Configuration.APIClient.ParameterToString(types, \"multi\")\n\t\n\tqueryParams[\"pageSize\"] = a.Configuration.APIClient.ParameterToString(pageSize, \"\")\n\t\n\tqueryParams[\"pageNumber\"] = a.Configuration.APIClient.ParameterToString(pageNumber, \"\")\n\t\n\tqueryParams[\"sortOrder\"] = a.Configuration.APIClient.ParameterToString(sortOrder, \"\")\n\t\n\tqueryParams[\"sortBy\"] = a.Configuration.APIClient.ParameterToString(sortBy, \"\")\n\t\n\tqueryParams[\"searchTerm\"] = a.Configuration.APIClient.ParameterToString(searchTerm, \"\")\n\t\n\tqueryParams[\"expand\"] = a.Configuration.APIClient.ParameterToString(expand, \"multi\")\n\t\n\tqueryParams[\"isPublished\"] = a.Configuration.APIClient.ParameterToString(isPublished, \"\")\n\t\n\tqueryParams[\"statuses\"] = a.Configuration.APIClient.ParameterToString(statuses, \"multi\")\n\t\n\n\t// Find an replace keys that were altered to avoid clashes with go keywords \n\tcorrectedQueryParams := make(map[string]string)\n\tfor k, v := range queryParams {\n\t\tif k == \"varType\" {\n\t\t\tcorrectedQueryParams[\"type\"] = v\n\t\t\tcontinue\n\t\t}\n\t\tcorrectedQueryParams[k] = v\n\t}\n\tqueryParams = correctedQueryParams\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{ \"application/json\", }\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\theaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/json\",\n\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\theaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tvar successPayload *Learningmodulesdomainentitylisting\n\tresponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, postFileName, fileBytes)\n\tif err != nil {\n\t\t// Nothing special to do here, but do avoid processing the response\n\t} else if err == nil && response.Error != nil {\n\t\terr = errors.New(response.ErrorMessage)\n\t} else if response.HasBody {\n\t\tif \"Learningmodulesdomainentitylisting\" == \"string\" {\n\t\t\tcopy(response.RawBody, &successPayload)\n\t\t} else {\n\t\t\terr = json.Unmarshal(response.RawBody, &successPayload)\n\t\t}\n\t}\n\treturn successPayload, response, err\n}", "func (s AssertionSection) NewContent(n int32) (Obj_List, error) {\n\tl, err := NewObj_List(s.Struct.Segment(), n)\n\tif err != nil {\n\t\treturn Obj_List{}, err\n\t}\n\terr = s.Struct.SetPtr(4, l.List.ToPtr())\n\treturn l, err\n}", "func newFetch(g *Goproxy, name, tempDir string) (*fetch, error) {\n\tf := &fetch{\n\t\tg: g,\n\t\tname: name,\n\t\ttempDir: tempDir,\n\t}\n\n\tvar escapedModulePath string\n\tif strings.HasSuffix(name, \"/@latest\") {\n\t\tescapedModulePath = strings.TrimSuffix(name, \"/@latest\")\n\t\tf.ops = fetchOpsResolve\n\t\tf.moduleVersion = \"latest\"\n\t\tf.contentType = \"application/json; charset=utf-8\"\n\t} else if strings.HasSuffix(name, \"/@v/list\") {\n\t\tescapedModulePath = strings.TrimSuffix(name, \"/@v/list\")\n\t\tf.ops = fetchOpsList\n\t\tf.moduleVersion = \"latest\"\n\t\tf.contentType = \"text/plain; charset=utf-8\"\n\t} else {\n\t\tnameParts := strings.SplitN(name, \"/@v/\", 2)\n\t\tif len(nameParts) != 2 {\n\t\t\treturn nil, errors.New(\"missing /@v/\")\n\t\t}\n\n\t\tescapedModulePath = nameParts[0]\n\n\t\tnameExt := path.Ext(nameParts[1])\n\t\tescapedModuleVersion := strings.TrimSuffix(\n\t\t\tnameParts[1],\n\t\t\tnameExt,\n\t\t)\n\t\tswitch nameExt {\n\t\tcase \".info\":\n\t\t\tf.ops = fetchOpsDownloadInfo\n\t\t\tf.contentType = \"application/json; charset=utf-8\"\n\t\tcase \".mod\":\n\t\t\tf.ops = fetchOpsDownloadMod\n\t\t\tf.contentType = \"text/plain; charset=utf-8\"\n\t\tcase \".zip\":\n\t\t\tf.ops = fetchOpsDownloadZip\n\t\t\tf.contentType = \"application/zip\"\n\t\tcase \"\":\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"no file extension in filename %q\",\n\t\t\t\tescapedModuleVersion,\n\t\t\t)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"unexpected extension %q\",\n\t\t\t\tnameExt,\n\t\t\t)\n\t\t}\n\n\t\tvar err error\n\t\tf.moduleVersion, err = module.UnescapeVersion(\n\t\t\tescapedModuleVersion,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif f.moduleVersion == \"latest\" {\n\t\t\treturn nil, errors.New(\"invalid version\")\n\t\t} else if !semver.IsValid(f.moduleVersion) {\n\t\t\tif f.ops == fetchOpsDownloadInfo {\n\t\t\t\tf.ops = fetchOpsResolve\n\t\t\t} else {\n\t\t\t\treturn nil, errors.New(\"unrecognized version\")\n\t\t\t}\n\t\t}\n\t}\n\n\tvar err error\n\tf.modulePath, err = module.UnescapePath(escapedModulePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tf.modAtVer = fmt.Sprint(f.modulePath, \"@\", f.moduleVersion)\n\tf.requiredToVerify = g.goBinEnvGOSUMDB != \"off\" &&\n\t\t!globsMatchPath(g.goBinEnvGONOSUMDB, f.modulePath)\n\n\treturn f, nil\n}", "func (*CommonFileSearchResponse) Descriptor() ([]byte, []int) {\n\treturn file_box_search_proto_rawDescGZIP(), []int{21}\n}", "func (*CommitVersionedBlobArtifactPart_Response) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_versioning_VersioningService_proto_rawDescGZIP(), []int{37, 0}\n}", "func CreateFilterOverview(req *http.Request, bp core.Page, dimensions []filter.ModelDimension, datasetDims dataset.VersionDimensionItems, fm filter.Model, dst dataset.DatasetDetails, filterID, datasetID, apiRouterVersion, lang, serviceMessage string, emergencyBannerContent zebedee.EmergencyBanner) model.Overview {\n\tp := model.Overview{\n\t\tPage: bp,\n\t}\n\tp.BetaBannerEnabled = true\n\tp.FeatureFlags.SixteensVersion = sixteensVersion\n\tp.RemoveGalleryBackground = true\n\n\tmapCookiePreferences(req, &p.CookiesPreferencesSet, &p.CookiesPolicy)\n\n\tctx := req.Context()\n\tlog.Info(ctx, \"mapping api response models into filter overview page model\", log.Data{\"filterID\": filterID, \"datasetID\": datasetID})\n\n\tp.FilterID = filterID\n\tp.DatasetTitle = dst.Title\n\tp.Metadata.Title = \"Filter Options\"\n\tp.DatasetId = datasetID\n\tp.Language = lang\n\tp.URI = req.URL.Path\n\tp.ServiceMessage = serviceMessage\n\tp.EmergencyBanner = mapEmergencyBanner(emergencyBannerContent)\n\n\tfor i := range dimensions {\n\t\tvar fod model.Dimension\n\n\t\tif dimensions[i].Name == \"time\" {\n\t\t\tfor j := range datasetDims {\n\t\t\t\tif datasetDims[j].Name == dimensions[i].Name {\n\t\t\t\t\tfod.Filter = helpers.TitleCaseStr(datasetDims[j].Name)\n\t\t\t\t\tif len(datasetDims[j].Label) > 0 {\n\t\t\t\t\t\tfod.Filter = datasetDims[j].Label\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttimes, err := dates.ConvertToReadable(dimensions[i].Values)\n\t\t\tif err != nil {\n\t\t\t\tlog.Warn(ctx, \"unable to convert dates to human readable values\", log.FormatErrors([]error{err}))\n\t\t\t\tfod.AddedCategories = append(fod.AddedCategories, dimensions[i].Values...)\n\t\t\t}\n\n\t\t\tfor _, time := range times {\n\t\t\t\tfod.AddedCategories = append(fod.AddedCategories, time.Format(\"January 2006\"))\n\t\t\t}\n\t\t} else {\n\t\t\tfod.AddedCategories = append(fod.AddedCategories, dimensions[i].Values...)\n\n\t\t\tfor j := range datasetDims {\n\t\t\t\tif datasetDims[j].Name == dimensions[i].Name {\n\t\t\t\t\tfod.Filter = helpers.TitleCaseStr(datasetDims[j].Name)\n\t\t\t\t\tif len(datasetDims[j].Label) > 0 {\n\t\t\t\t\t\tfod.Filter = datasetDims[j].Label\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfod.Link.URL = fmt.Sprintf(\"/filters/%s/dimensions/%s\", filterID, dimensions[i].Name)\n\n\t\tif len(fod.AddedCategories) > 0 {\n\t\t\tfod.Link.Label = \"Edit\"\n\t\t} else {\n\t\t\tfod.Link.Label = \"Add\"\n\t\t\tfod.HasNoCategory = true\n\t\t\tp.Data.UnsetDimensions = append(p.Data.UnsetDimensions, fod.Filter)\n\t\t}\n\n\t\tp.Data.Dimensions = append(p.Data.Dimensions, fod)\n\t}\n\n\tp.Data.Cancel.URL = \"/\"\n\tp.Data.ClearAll.URL = fmt.Sprintf(\"/filters/%s/dimensions/clear-all\", filterID)\n\tp.SearchDisabled = true\n\n\tversionURL, err := url.Parse(fm.Links.Version.HRef)\n\tif err != nil {\n\t\tlog.Warn(ctx, \"unable to parse version url\", log.FormatErrors([]error{err}))\n\t}\n\tversionPath := strings.TrimPrefix(versionURL.Path, apiRouterVersion)\n\n\tp.IsInFilterBreadcrumb = true\n\n\t_, edition, _, err := helpers.ExtractDatasetInfoFromPath(ctx, versionPath)\n\tif err != nil {\n\t\tlog.Warn(ctx, \"unable to extract edition from url\", log.FormatErrors([]error{err}))\n\t}\n\n\tp.Breadcrumb = append(\n\t\tp.Breadcrumb,\n\t\tcore.TaxonomyNode{\n\t\t\tTitle: dst.Title,\n\t\t\tURI: fmt.Sprintf(\"/datasets/%s/editions\", dst.ID),\n\t\t}, core.TaxonomyNode{\n\t\t\tTitle: edition,\n\t\t\tURI: versionPath,\n\t\t}, core.TaxonomyNode{\n\t\t\tTitle: \"Filter options\",\n\t\t})\n\n\treturn p\n}", "func FilesDownloadHTTP(mgr *manager.Manager, filepath, version, arch string) error {\n\tkkzone := os.Getenv(\"KKZONE\")\n\tetcd := files.KubeBinary{Name: \"etcd\", Arch: arch, Version: kubekeyapiv1alpha1.DefaultEtcdVersion}\n\tkubeadm := files.KubeBinary{Name: \"kubeadm\", Arch: arch, Version: version}\n\tkubelet := files.KubeBinary{Name: \"kubelet\", Arch: arch, Version: version}\n\tkubectl := files.KubeBinary{Name: \"kubectl\", Arch: arch, Version: version}\n\tkubecni := files.KubeBinary{Name: \"kubecni\", Arch: arch, Version: kubekeyapiv1alpha1.DefaultCniVersion}\n\thelm := files.KubeBinary{Name: \"helm\", Arch: arch, Version: kubekeyapiv1alpha1.DefaultHelmVersion}\n\n\tetcd.Path = fmt.Sprintf(\"%s/etcd-%s-linux-%s.tar.gz\", filepath, kubekeyapiv1alpha1.DefaultEtcdVersion, arch)\n\tkubeadm.Path = fmt.Sprintf(\"%s/kubeadm\", filepath)\n\tkubelet.Path = fmt.Sprintf(\"%s/kubelet\", filepath)\n\tkubectl.Path = fmt.Sprintf(\"%s/kubectl\", filepath)\n\tkubecni.Path = fmt.Sprintf(\"%s/cni-plugins-linux-%s-%s.tgz\", filepath, arch, kubekeyapiv1alpha1.DefaultCniVersion)\n\thelm.Path = fmt.Sprintf(\"%s/helm\", filepath)\n\n\tif kkzone == \"cn\" {\n\t\tetcd.Url = fmt.Sprintf(\"https://kubernetes-release.pek3b.qingstor.com/etcd/release/download/%s/etcd-%s-linux-%s.tar.gz\", etcd.Version, etcd.Version, etcd.Arch)\n\t\tkubeadm.Url = fmt.Sprintf(\"https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubeadm\", kubeadm.Version, kubeadm.Arch)\n\t\tkubelet.Url = fmt.Sprintf(\"https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubelet\", kubelet.Version, kubelet.Arch)\n\t\tkubectl.Url = fmt.Sprintf(\"https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubectl\", kubectl.Version, kubectl.Arch)\n\t\tkubecni.Url = fmt.Sprintf(\"https://containernetworking.pek3b.qingstor.com/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz\", kubecni.Version, kubecni.Arch, kubecni.Version)\n\t\thelm.Url = fmt.Sprintf(\"https://kubernetes-helm.pek3b.qingstor.com/linux-%s/%s/helm\", helm.Arch, helm.Version)\n\t\thelm.GetCmd = fmt.Sprintf(\"curl -o %s %s\", helm.Path, helm.Url)\n\t} else {\n\t\tetcd.Url = fmt.Sprintf(\"https://github.com/coreos/etcd/releases/download/%s/etcd-%s-linux-%s.tar.gz\", etcd.Version, etcd.Version, etcd.Arch)\n\t\tkubeadm.Url = fmt.Sprintf(\"https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubeadm\", kubeadm.Version, kubeadm.Arch)\n\t\tkubelet.Url = fmt.Sprintf(\"https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubelet\", kubelet.Version, kubelet.Arch)\n\t\tkubectl.Url = fmt.Sprintf(\"https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubectl\", kubectl.Version, kubectl.Arch)\n\t\tkubecni.Url = fmt.Sprintf(\"https://github.com/containernetworking/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz\", kubecni.Version, kubecni.Arch, kubecni.Version)\n\t\thelm.Url = fmt.Sprintf(\"https://get.helm.sh/helm-%s-linux-%s.tar.gz\", helm.Version, helm.Arch)\n\t\thelm.GetCmd = fmt.Sprintf(\"curl -o %s/helm-%s-linux-%s.tar.gz %s && cd %s && tar -zxf helm-%s-linux-%s.tar.gz && mv linux-%s/helm . && rm -rf *linux-%s*\", filepath, helm.Version, helm.Arch, helm.Url, filepath, helm.Version, helm.Arch, helm.Arch, helm.Arch)\n\t}\n\n\tkubeadm.GetCmd = fmt.Sprintf(\"curl -L -o %s %s\", kubeadm.Path, kubeadm.Url)\n\tkubelet.GetCmd = fmt.Sprintf(\"curl -L -o %s %s\", kubelet.Path, kubelet.Url)\n\tkubectl.GetCmd = fmt.Sprintf(\"curl -L -o %s %s\", kubectl.Path, kubectl.Url)\n\tkubecni.GetCmd = fmt.Sprintf(\"curl -L -o %s %s\", kubecni.Path, kubecni.Url)\n\tetcd.GetCmd = fmt.Sprintf(\"curl -L -o %s %s\", etcd.Path, etcd.Url)\n\n\tbinaries := []files.KubeBinary{kubeadm, kubelet, kubectl, helm, kubecni, etcd}\n\n\tfor _, binary := range binaries {\n\t\tif binary.Name == \"etcd\" && mgr.EtcdContainer {\n\t\t\tcontinue\n\t\t}\n\t\tmgr.Logger.Infoln(fmt.Sprintf(\"Downloading %s ...\", binary.Name))\n\t\tif util.IsExist(binary.Path) == false {\n\t\t\tfor i := 5; i > 0; i-- {\n\t\t\t\tif output, err := exec.Command(\"/bin/sh\", \"-c\", binary.GetCmd).CombinedOutput(); err != nil {\n\t\t\t\t\tfmt.Println(string(output))\n\n\t\t\t\t\tif kkzone != \"cn\" {\n\t\t\t\t\t\tmgr.Logger.Warningln(\"Having a problem with accessing https://storage.googleapis.com? You can try again after setting environment 'export KKZONE=cn'\")\n\t\t\t\t\t}\n\t\t\t\t\treturn errors.New(fmt.Sprintf(\"Failed to download %s binary: %s\", binary.Name, binary.GetCmd))\n\t\t\t\t}\n\n\t\t\t\tif err := SHA256Check(binary, version); err != nil {\n\t\t\t\t\tif i == 1 {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\t_ = exec.Command(\"/bin/sh\", \"-c\", fmt.Sprintf(\"rm -f %s\", binary.Path)).Run()\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\tif err := SHA256Check(binary, version); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif mgr.Cluster.KubeSphere.Version == \"v2.1.1\" {\n\t\tmgr.Logger.Infoln(fmt.Sprintf(\"Downloading %s ...\", \"helm2\"))\n\t\tif util.IsExist(fmt.Sprintf(\"%s/helm2\", filepath)) == false {\n\t\t\tcmd := fmt.Sprintf(\"curl -o %s/helm2 %s\", filepath, fmt.Sprintf(\"https://kubernetes-helm.pek3b.qingstor.com/linux-%s/%s/helm\", helm.Arch, \"v2.16.9\"))\n\t\t\tif output, err := exec.Command(\"/bin/sh\", \"-c\", cmd).CombinedOutput(); err != nil {\n\t\t\t\tfmt.Println(string(output))\n\t\t\t\treturn errors.Wrap(err, \"Failed to download helm2 binary\")\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *ArtifactListerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Next\n\n\tnext := o.Next\n\tif next != \"\" {\n\t\trw.Header().Set(\"Next\", next)\n\t}\n\n\t// response header Previous\n\n\tprevious := o.Previous\n\tif previous != \"\" {\n\t\trw.Header().Set(\"Previous\", previous)\n\t}\n\n\t// response header TotalRecords\n\n\ttotalRecords := swag.FormatUint64(o.TotalRecords)\n\tif totalRecords != \"\" {\n\t\trw.Header().Set(\"TotalRecords\", totalRecords)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*weles.ArtifactInfo, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func getItems(repoIndex *index.Index, url string) []FileInfo {\n\tvar items []FileInfo\n\n\tfor _, os := range repoIndex.Data.Keys() {\n\t\tfor _, arch := range repoIndex.Data[os].Keys() {\n\t\t\tfor _, category := range repoIndex.Data[os][arch].Keys() {\n\t\t\t\tfor _, version := range repoIndex.Data[os][arch][category] {\n\t\t\t\t\titems = append(items, FileInfo{\n\t\t\t\t\t\tFile: version.File,\n\t\t\t\t\t\tURL: url + \"/\" + version.Path + \"/\" + version.File,\n\t\t\t\t\t\tOS: os,\n\t\t\t\t\t\tArch: arch,\n\t\t\t\t\t\tSize: version.Size,\n\t\t\t\t\t})\n\n\t\t\t\t\tif len(version.Variations) != 0 {\n\t\t\t\t\t\tfor _, subVersion := range version.Variations {\n\t\t\t\t\t\t\titems = append(items, FileInfo{\n\t\t\t\t\t\t\t\tFile: subVersion.File,\n\t\t\t\t\t\t\t\tURL: url + \"/\" + subVersion.Path + \"/\" + subVersion.File,\n\t\t\t\t\t\t\t\tOS: os,\n\t\t\t\t\t\t\t\tArch: arch,\n\t\t\t\t\t\t\t\tSize: subVersion.Size,\n\t\t\t\t\t\t\t})\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 items\n}", "func (lens Lens) Header(artifacts []api.Artifact, resourceDir string, config json.RawMessage, spyglassConfig config.Spyglass) string {\n\tt, err := template.ParseFiles(filepath.Join(resourceDir, \"template.html\"))\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"<!-- FAILED LOADING HEADER: %v -->\", err)\n\t}\n\tvar buf bytes.Buffer\n\tif err := t.ExecuteTemplate(&buf, \"header\", nil); err != nil {\n\t\treturn fmt.Sprintf(\"<!-- FAILED EXECUTING HEADER TEMPLATE: %v -->\", err)\n\t}\n\treturn buf.String()\n}", "func RenderInitialChoices(resp http.ResponseWriter, req *http.Request, ext string, fileSeeker io.ReadSeeker) {\n\top := []OptStruct{\n\t\t{22, primitive.TriangleMode},\n\t\t{22, primitive.CircleMode},\n\t\t{22, primitive.ComboMode},\n\t\t{22, primitive.PolygonMode},\n\t}\n\topFileList, err := GenImgList(ext, fileSeeker, op...)\n\tif err != nil {\n http.Error(resp, err.Error(), http.StatusInternalServerError)\n return\n\t}\n\thtmlist := `<html>\n <body>\n {{range .}}\n <a href=\"/modify/{{.Name}}?mode={{.Mode}}\">\n <img style =\"width 30%\" src=\"/pics/{{.Name}}\">\n {{end}}\n </body>\n </html>\n `\n\ttempl := template.Must(template.New(\"\").Parse(htmlist))\n \ntype Opts struct {\n Name string\n Mode primitive.Mode\n}\n\tvar opts []Opts\n\tfor index, val := range opFileList {\n\t\topts = append(opts, Opts{Name: filepath.Base(val), Mode: op[index].mode})\n\t}\n\n\t// err = templ.Execute(resp, opts)\n\t// if err != nil {\n\t// \tpanic(err)\n // }\n checkError(templ.Execute(resp, opts))\n \n\n}", "func (o *ArtifactListerOK) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerOK {\n\to.Payload = payload\n\treturn o\n}", "func (*ListArticlesResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_article_proto_rawDescGZIP(), []int{3}\n}", "func (*CreateArtifactRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_aiplatform_v1_metadata_service_proto_rawDescGZIP(), []int{7}\n}", "func newHeadView(res *Head) *salesviews.HeadView {\n\tvres := &salesviews.HeadView{\n\t\tID: &res.ID,\n\t\tName: &res.Name,\n\t}\n\treturn vres\n}", "func (hrsi *SubscriberItem) getHelmRepoIndex(client rest.HTTPClient, repoURL string) (indexFile *repo.IndexFile, hash string, err error) {\n\tcleanRepoURL := strings.TrimSuffix(repoURL, \"/\") + \"/index.yaml\"\n\treq, err := http.NewRequest(http.MethodGet, cleanRepoURL, nil)\n\n\tif err != nil {\n\t\tklog.Error(err, \"Can not build request: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\tif hrsi.ChannelSecret != nil && hrsi.ChannelSecret.Data != nil {\n\t\tif authHeader, ok := hrsi.ChannelSecret.Data[\"authHeader\"]; ok {\n\t\t\treq.Header.Set(\"Authorization\", string(authHeader))\n\t\t} else if user, ok := hrsi.ChannelSecret.Data[\"user\"]; ok {\n\t\t\tif password, ok := hrsi.ChannelSecret.Data[\"password\"]; ok {\n\t\t\t\treq.SetBasicAuth(string(user), string(password))\n\t\t\t} else {\n\t\t\t\treturn nil, \"\", fmt.Errorf(\"password not found in secret for basic authentication\")\n\t\t\t}\n\t\t}\n\t}\n\n\tklog.V(5).Info(req)\n\tresp, err := client.Do(req)\n\n\tif err != nil {\n\t\tklog.Error(err, \"Http request failed: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\tklog.V(5).Info(\"Get succeeded: \", cleanRepoURL)\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tklog.Error(err, \"Unable to read body: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\tdefer resp.Body.Close()\n\n\thash = hashKey(body)\n\tindexfile, err := loadIndex(body)\n\n\tif err != nil {\n\t\tklog.Error(err, \"Unable to parse the indexfile: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\terr = utils.FilterCharts(hrsi.Subscription, indexfile)\n\n\treturn indexfile, hash, err\n}", "func (m *ItemItemsDriveItemItemRequestBuilder) Content()(*ItemItemsItemContentRequestBuilder) {\n return NewItemItemsItemContentRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func (hrsi *SubscriberItem) getHelmRepoIndex(client rest.HTTPClient, repoURL string) (indexFile *repo.IndexFile, hash string, err error) {\n\tcleanRepoURL := strings.TrimSuffix(repoURL, \"/\")\n\treq, err := http.NewRequest(http.MethodGet, cleanRepoURL+\"/index.yaml\", nil)\n\n\tif err != nil {\n\t\tklog.Error(err, \"Can not build request: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\tif hrsi.ChannelSecret != nil && hrsi.ChannelSecret.Data != nil {\n\t\tif authHeader, ok := hrsi.ChannelSecret.Data[\"authHeader\"]; ok {\n\t\t\treq.Header.Set(\"Authorization\", string(authHeader))\n\t\t} else if user, ok := hrsi.ChannelSecret.Data[\"user\"]; ok {\n\t\t\tif password, ok := hrsi.ChannelSecret.Data[\"password\"]; ok {\n\t\t\t\treq.SetBasicAuth(string(user), string(password))\n\t\t\t} else {\n\t\t\t\treturn nil, \"\", fmt.Errorf(\"password not found in secret for basic authentication\")\n\t\t\t}\n\t\t}\n\t}\n\n\tklog.V(5).Info(req)\n\tresp, err := client.Do(req)\n\n\tif err != nil {\n\t\tklog.Error(err, \"Http request failed: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\tklog.V(5).Info(\"Get succeeded: \", cleanRepoURL)\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tklog.Error(err, \"Unable to read body: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\tdefer resp.Body.Close()\n\n\thash = hashKey(body)\n\tindexfile, err := loadIndex(body)\n\n\tif err != nil {\n\t\tklog.Error(err, \"Unable to parse the indexfile: \", cleanRepoURL)\n\t\treturn nil, \"\", err\n\t}\n\n\terr = hrsi.filterCharts(indexfile)\n\n\treturn indexfile, hash, err\n}", "func (*ListArticleResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_api_article_proto_rawDescGZIP(), []int{3}\n}", "func (*DefaultArchiveConfigResponse) Descriptor() ([]byte, []int) {\n\treturn file_api_bucketsd_pb_bucketsd_proto_rawDescGZIP(), []int{41}\n}", "func (this *Artifact) addDebianHeaders(req *http.Request) {\n\tif len(this.Distr) == 0 || len(this.Component) == 0 || len(this.Arch) == 0 {\n\t\tfmt.Printf(\"ERROR Cannot process package %s - Missing Debian argument(s):\\n\", this.Artifact)\n\n\t\tif len(this.Distr) == 0 {\n\t\t\tfmt.Printf(\" distr not defined in yaml config\\n\")\n\t\t}\n\n\t\tif len(this.Component) == 0 {\n\t\t\tfmt.Printf(\" component not defined in yaml config\\n\")\n\t\t}\n\n\t\tif len(this.Arch) == 0 {\n\t\t\tfmt.Printf(\" arch not defined in yaml config\\n\")\n\t\t}\n\n\t\tos.Exit(1)\n\t}\n\n\treq.Header.Add(\"X-Bintray-Debian-Distribution\", this.Distr)\n\treq.Header.Add(\"X-Bintray-Debian-Component\", this.Component)\n\treq.Header.Add(\"X-Bintray-Debian-Architecture\", strings.Join(this.Arch, \",\"))\n}", "func (fl *FileList) AddRegular(h *tar.Header, size int64, content io.ReaderAt) {\n\tfl.files = append(fl.files, headerContent{\n\t\theader: h,\n\t\tsize: size,\n\t\tcontent: content,\n\t})\n}", "func NewHeader(headerEntries ...string) *Header {\n\th := &Header{}\n\th.slice = append(h.slice, headerEntries...)\n\tif len(h.slice)%2 != 0 {\n\t\th.slice = append(h.slice, \"\")\n\t}\n\treturn h\n}", "func generateListPartsResponse(partsInfo ListPartsInfo, encodingType string) ListPartsResponse {\n\tlistPartsResponse := ListPartsResponse{}\n\tlistPartsResponse.Bucket = partsInfo.Bucket\n\tlistPartsResponse.Key = s3EncodeName(partsInfo.Object, encodingType)\n\tlistPartsResponse.UploadID = partsInfo.UploadID\n\tlistPartsResponse.StorageClass = globalMinioDefaultStorageClass\n\tlistPartsResponse.Initiator.ID = globalMinioDefaultOwnerID\n\tlistPartsResponse.Owner.ID = globalMinioDefaultOwnerID\n\n\tlistPartsResponse.MaxParts = partsInfo.MaxParts\n\tlistPartsResponse.PartNumberMarker = partsInfo.PartNumberMarker\n\tlistPartsResponse.IsTruncated = partsInfo.IsTruncated\n\tlistPartsResponse.NextPartNumberMarker = partsInfo.NextPartNumberMarker\n\n\tlistPartsResponse.Parts = make([]Part, len(partsInfo.Parts))\n\tfor index, part := range partsInfo.Parts {\n\t\tnewPart := Part{}\n\t\tnewPart.PartNumber = part.PartNumber\n\t\tnewPart.ETag = \"\\\"\" + part.ETag + \"\\\"\"\n\t\tnewPart.Size = part.Size\n\t\tnewPart.LastModified = part.LastModified.UTC().Format(timeFormatAMZLong)\n\t\tlistPartsResponse.Parts[index] = newPart\n\t}\n\treturn listPartsResponse\n}", "func (*ItemsListResponse) Descriptor() ([]byte, []int) {\n\treturn file_services_grpcPb_grpc_proto_rawDescGZIP(), []int{15}\n}", "func (*ProjectSearchResponse) Descriptor() ([]byte, []int) {\n\treturn file_management_proto_rawDescGZIP(), []int{71}\n}", "func (*ListArtifactStructType) Descriptor() ([]byte, []int) {\n\treturn file_ml_metadata_proto_metadata_store_proto_rawDescGZIP(), []int{16}\n}", "func (*AddMilestoneResponse) Descriptor() ([]byte, []int) {\n\treturn file_githubcard_proto_rawDescGZIP(), []int{17}\n}", "func ArtifactContentGetHandler(appCtx *appctx.Context) http.Handler {\n\thandlerFunc := func(w http.ResponseWriter, r *http.Request) {\n\n\t\t// Get input values\n\t\tvars := mux.Vars(r)\n\t\tartifactID, err := strconv.Atoi(vars[\"artifactID\"])\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tappCtx.RequestLogger().Error(r, err)\n\t\t\treturn\n\t\t}\n\n\t\tfile, err := appCtx.ArtifactsService().GetArtifactContent(uint(artifactID))\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tappCtx.RequestLogger().Error(r, err)\n\t\t\treturn\n\t\t}\n\t\tif file == nil {\n\t\t\tw.WriteHeader(http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\n\t\tdefer file.Close()\n\t\tio.Copy(w, file)\n\t}\n\n\thandler := http.Handler(http.HandlerFunc(handlerFunc))\n\n\treturn handler\n}", "func (*RenderActorsResponse_ResponseItem) Descriptor() ([]byte, []int) {\n\treturn file_service_proto_rawDescGZIP(), []int{6, 0}\n}", "func (*ListRepositoryReq) Descriptor() ([]byte, []int) {\n\treturn file_api_ops_proto_rawDescGZIP(), []int{3}\n}", "func (*NewsPhotoGetListResponse) Descriptor() ([]byte, []int) {\n\treturn file_contents_v1_news_photo_proto_rawDescGZIP(), []int{6}\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(\"<h2>%s</h2>\", 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(\"<h3>%s</h3>\", source.Title))\n\t\t\tbuffer.WriteString(fmt.Sprintf(`<button onClick=\"hideAll('source_%d'); return false\">Mark all as read</button>`, class))\n\t\t\tbuffer.WriteString(\"<ul>\")\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(`<li id=\"entry_%d\">`, id))\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(`<button class=\"source_%d\" onClick=\"hide('entry_%d', '%s'); return false\">Mark Read</button> `, class, id, entry.Url))\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(`<a href=\"%s\">%s</a>`, entry.Url, entry.Title))\n\t\t\t\tbuffer.WriteString(\"</li>\")\n\t\t\t\tid += 1\n\t\t\t}\n\t\t\tbuffer.WriteString(\"</ul>\")\n\t\t\tclass += 1\n\t\t}\n\t}\n\tlock.Unlock()\n\tbuffer.WriteString(\"</body></html>\")\n\treturn buffer.String()\n}", "func (*CommonFileItem) Descriptor() ([]byte, []int) {\n\treturn file_box_search_proto_rawDescGZIP(), []int{0}\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 (*AvailableVersionsResponse) Descriptor() ([]byte, []int) {\n\treturn file_manager_proto_rawDescGZIP(), []int{5}\n}", "func (*StoreArtifact_Response) Descriptor() ([]byte, []int) {\n\treturn file_artifactstore_ArtifactStore_proto_rawDescGZIP(), []int{0, 0}\n}", "func (*SetDefaultArchiveConfigResponse) Descriptor() ([]byte, []int) {\n\treturn file_api_bucketsd_pb_bucketsd_proto_rawDescGZIP(), []int{43}\n}", "func (*ListDashboardResponse) Descriptor() ([]byte, []int) {\n\treturn file_data_proto_rawDescGZIP(), []int{0}\n}", "func (*DeleteArtifact_Response) Descriptor() ([]byte, []int) {\n\treturn file_artifactstore_ArtifactStore_proto_rawDescGZIP(), []int{3, 0}\n}", "func NewDefaultMetadata(owner did.DID, key []byte, ts time.Time) Metadata {\n\troles := make(map[did.DID]Role)\n\tif owner.Defined() {\n\t\tif key == nil {\n\t\t\troles[\"*\"] = ReaderRole\n\t\t}\n\t\troles[owner] = AdminRole\n\t}\n\tmd := Metadata{\n\t\tRoles: roles,\n\t\tUpdatedAt: ts.UnixNano(),\n\t}\n\tmd.SetFileEncryptionKey(key)\n\treturn md\n}", "func (*ListBuildsResponse) Descriptor() ([]byte, []int) {\n\treturn file_versions_v1_versions_proto_rawDescGZIP(), []int{13}\n}", "func (*GetArtifactRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_aiplatform_v1_metadata_service_proto_rawDescGZIP(), []int{8}\n}", "func (a *HyperflexApiService) GetHyperflexClusterBackupPolicyInventoryListExecute(r ApiGetHyperflexClusterBackupPolicyInventoryListRequest) (*HyperflexClusterBackupPolicyInventoryResponse, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t\tlocalVarReturnValue *HyperflexClusterBackupPolicyInventoryResponse\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"HyperflexApiService.GetHyperflexClusterBackupPolicyInventoryList\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/api/v1/hyperflex/ClusterBackupPolicyInventories\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\tif r.filter != nil {\n\t\tlocalVarQueryParams.Add(\"$filter\", parameterToString(*r.filter, \"\"))\n\t}\n\tif r.orderby != nil {\n\t\tlocalVarQueryParams.Add(\"$orderby\", parameterToString(*r.orderby, \"\"))\n\t}\n\tif r.top != nil {\n\t\tlocalVarQueryParams.Add(\"$top\", parameterToString(*r.top, \"\"))\n\t}\n\tif r.skip != nil {\n\t\tlocalVarQueryParams.Add(\"$skip\", parameterToString(*r.skip, \"\"))\n\t}\n\tif r.select_ != nil {\n\t\tlocalVarQueryParams.Add(\"$select\", parameterToString(*r.select_, \"\"))\n\t}\n\tif r.expand != nil {\n\t\tlocalVarQueryParams.Add(\"$expand\", parameterToString(*r.expand, \"\"))\n\t}\n\tif r.apply != nil {\n\t\tlocalVarQueryParams.Add(\"$apply\", parameterToString(*r.apply, \"\"))\n\t}\n\tif r.count != nil {\n\t\tlocalVarQueryParams.Add(\"$count\", parameterToString(*r.count, \"\"))\n\t}\n\tif r.inlinecount != nil {\n\t\tlocalVarQueryParams.Add(\"$inlinecount\", parameterToString(*r.inlinecount, \"\"))\n\t}\n\tif r.at != nil {\n\t\tlocalVarQueryParams.Add(\"at\", parameterToString(*r.at, \"\"))\n\t}\n\tif r.tags != nil {\n\t\tlocalVarQueryParams.Add(\"tags\", parameterToString(*r.tags, \"\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\", \"text/csv\", \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\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 := ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = ioutil.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 Error\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\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 401 {\n\t\t\tvar v Error\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\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 403 {\n\t\t\tvar v Error\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\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v Error\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\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tvar v Error\n\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\tif err != nil {\n\t\t\tnewErr.error = err.Error()\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tnewErr.model = v\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 (*ListArticlesRequest) Descriptor() ([]byte, []int) {\n\treturn file_openapi_proto_rawDescGZIP(), []int{1}\n}" ]
[ "0.51237345", "0.5079677", "0.48940608", "0.4778246", "0.47617704", "0.46847615", "0.45793572", "0.45420745", "0.45120734", "0.445179", "0.4426803", "0.4417869", "0.42650312", "0.4262712", "0.42211097", "0.4195483", "0.41943496", "0.4141338", "0.41383514", "0.41365728", "0.41109863", "0.4109628", "0.4092256", "0.40902856", "0.40893066", "0.40750363", "0.40660882", "0.4055811", "0.40530804", "0.40510905", "0.40492982", "0.40356138", "0.40269643", "0.40209597", "0.40131205", "0.39931744", "0.39731282", "0.394991", "0.39460042", "0.39334473", "0.39274684", "0.39246774", "0.39208126", "0.39141747", "0.39074054", "0.3906552", "0.3905276", "0.3904313", "0.3902441", "0.3902357", "0.38961002", "0.388752", "0.38845018", "0.38823262", "0.3881036", "0.38790175", "0.38765475", "0.3874919", "0.38744202", "0.38658747", "0.38636568", "0.3863086", "0.38624433", "0.38608035", "0.38508675", "0.38494295", "0.38471875", "0.38442633", "0.38363507", "0.38325077", "0.3831396", "0.3829998", "0.3829018", "0.38288784", "0.38266644", "0.3823529", "0.38231376", "0.38119727", "0.38114434", "0.38106874", "0.38020095", "0.38009065", "0.3799815", "0.3798805", "0.379723", "0.37958658", "0.37943184", "0.37867525", "0.37811863", "0.37799606", "0.3777009", "0.37759003", "0.37727925", "0.3769573", "0.3767634", "0.37670124", "0.37666234", "0.37655607", "0.3765346", "0.37650234" ]
0.6221102
0
WithNext adds the next to the artifact lister partial content response
func (o *ArtifactListerPartialContent) WithNext(next string) *ArtifactListerPartialContent { o.Next = next return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) WithNext(next string) *ArtifactListerOK {\n\to.Next = next\n\treturn o\n}", "func (rl *ResourceList) next() error {\n\tif rl.Page == rl.NumPages-1 {\n\t\treturn errors.New(\"no more new pages\")\n\t}\n\treturn common.SendGetRequest(rl.NextPageURI, *rl.act, rl)\n}", "func (o *ArtifactListerPartialContent) SetNext(next string) {\n\to.Next = next\n}", "func (o *ArtifactListerOK) SetNext(next string) {\n\to.Next = next\n}", "func (page *ResourceListResultPage) Next() error {\n\tnext, err := page.fn(page.rlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.rlr = next\n\treturn nil\n}", "func (page *AppListResultPage) Next() error {\n\tnext, err := page.fn(page.alr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.alr = next\n\treturn nil\n}", "func (page *DefinitionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *ExportTaskListResultPage) Next() error {\n\tnext, err := page.fn(page.etlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.etlr = next\n\treturn nil\n}", "func (page *JobResponseListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *ExemptionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (i *UploadShrinker) Next() *FileUpload {\n\tvar n int\n\tvar err error\n\n\tif i.Done() {\n\t\treturn nil\n\t}\n\n\tif n, err = i.f.Read(i.buff); err != nil && err != io.EOF {\n\t\ti.err = err\n\t\treturn nil\n\t}\n\n\ti.fu.Chunk = i.chunk\n\ti.fu.Content = i.buff[:n]\n\ti.chunk++\n\n\treturn i.fu\n}", "func (page *ImportTaskListResultPage) Next() error {\n\tnext, err := page.fn(page.itlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.itlr = next\n\treturn nil\n}", "func (page *AppCollectionListResultPage) Next() error {\n\tnext, err := page.fn(page.aclr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.aclr = next\n\treturn nil\n}", "func (page *SetDefinitionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (c *Client) Next() goa.Endpoint {\n\tvar (\n\t\tdecodeResponse = DecodeNextResponse(c.decoder, c.RestoreResponseBody)\n\t)\n\treturn func(ctx context.Context, v interface{}) (interface{}, error) {\n\t\treq, err := c.BuildNextRequest(ctx, v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresp, err := c.NextDoer.Do(req)\n\t\tif err != nil {\n\t\t\treturn nil, goahttp.ErrRequestError(\"spin-broker\", \"next\", err)\n\t\t}\n\t\treturn decodeResponse(resp)\n\t}\n}", "func (page *VaultListResultPage) Next() error {\n\tnext, err := page.fn(page.vlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.vlr = next\n\treturn nil\n}", "func (client DatasetClient) listNextResults(ctx context.Context, lastResults DatasetListResponse) (result DatasetListResponse, err error) {\n req, err := lastResults.datasetListResponsePreparer(ctx)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", nil , \"Failure preparing next results request\")\n }\n if req == nil {\n return\n }\n resp, err := client.ListSender(req)\n if err != nil {\n result.Response = autorest.Response{Response: resp}\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n }\n result, err = client.ListResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n }\n return\n }", "func (client PublishedBlueprintsClient) listNextResults(ctx context.Context, lastResults PublishedBlueprintList) (result PublishedBlueprintList, err error) {\n\treq, err := lastResults.publishedBlueprintListPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"blueprint.PublishedBlueprintsClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"blueprint.PublishedBlueprintsClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"blueprint.PublishedBlueprintsClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (page *ProviderOperationsMetadataListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *ListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *ListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (iter *JobResponseListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (iter *DefinitionListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (page *StorageInsightListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *StorageInsightListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *DataPolicyManifestListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (c *Client) next() (rsp *Response, err error) {\n\traw, err := c.r.Next()\n\tif err == nil {\n\t\trsp, err = raw.Parse()\n\t}\n\treturn\n}", "func (page *MonitoredResourceListResponsePage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (iter *ExemptionListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (h *HandlersApp01sqVendor) ListNext(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tvar offset int\n\tvar cTable int\n\n\tlog.Printf(\"hndlrVendor.ListNext(%s)\\n\", r.Method)\n\n\tif r.Method != \"GET\" {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListNext(Error:405) - Not GET\\n\")\n\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Calculate the offset.\n\tcTable, err = h.db.TableCount()\n\tif err != nil {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListLast(Error:400) - %s\\n\", util.ErrorString(err))\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t}\n\toffset, _ = strconv.Atoi(r.FormValue(\"offset\"))\n\toffset += h.rowsPerPage\n\tif offset < 0 || offset > cTable {\n\t\toffset = 0\n\t}\n\n\t// Display the row in the form.\n\th.ListShow(w, offset, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.ListNext()\\n\")\n\n}", "func (applications *Applications) Next() (*Result, error) {\n\tif applications.NextURL != \"\" {\n\t\tbody, err := applications.getCursor(applications.NextURL)\n\t\tif err != nil {\n\t\t\tresult := &Result{}\n\t\t\tjson.Unmarshal(body, result)\n\t\t\treturn result, err\n\t\t}\n\t\treturn nil, nil\n\t}\n\treturn nil, errors.New(\"next cursor not available\")\n}", "func (client ApplicationsClient) ListNextPreparer(ctx context.Context, nextLink string) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"nextLink\": nextLink,\n\t\t\"tenantID\": autorest.Encode(\"path\", client.TenantID),\n\t}\n\n\tconst APIVersion = \"1.6\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsGet(),\n\t\tautorest.WithBaseURL(client.BaseURI),\n\t\tautorest.WithPathParameters(\"/{tenantID}/{nextLink}\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (page *ListPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *MonitorResourceListResponsePage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (iter *ResourceListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (page *CampaignsListResultPage) Next() error {\n\tnext, err := page.fn(page.clr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.clr = next\n\treturn nil\n}", "func (s Service) Next(msg *Message, data interface{}, useMeta map[string]string) error {\n\terr := msg.RawMessage.Ack(true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif msg.Chain == nil {\n\t\treturn ErrorChainIsEmpty\n\t}\n\n\tchain := SetCurrentItemSuccess(msg.Chain)\n\n\tnextIndex := getCurrentChainIndex(chain)\n\tif nextIndex == -1 {\n\t\treturn ErrorNextIsNotDefined\n\t}\n\n\tnextElement := chain[nextIndex]\n\n\tmeta := Meta{}\n\tmeta.Merge(msg.Meta, useMeta)\n\n\tvar items []interface{}\n\n\tif nextElement.IsMultiple {\n\t\tval := reflect.ValueOf(data)\n\n\t\tif val.Kind() != reflect.Slice {\n\t\t\treturn ErrorDataIsNotArray\n\t\t}\n\n\t\tfor i := 0; i < val.Len(); i++ {\n\t\t\titems = append(items, val.Index(i).Interface())\n\t\t}\n\t} else {\n\t\titems = append(items, data)\n\t}\n\n\tfor _, item := range items {\n\t\tb, err := json.Marshal(item)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tm := InitialMessage{\n\t\t\tCatch: msg.InitialMessage.Catch,\n\t\t\tConfig: msg.Config,\n\t\t\tMeta: meta,\n\t\t\tChain: chain,\n\t\t\tData: b,\n\t\t}\n\n\t\tif err := s.Publish(m); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (iter *MonitorResourceListResponseIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (client UsageDetailsClient) listByDepartmentNextResults(ctx context.Context, lastResults UsageDetailsListResult) (result UsageDetailsListResult, err error) {\n\treq, err := lastResults.usageDetailsListResultPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listByDepartmentNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListByDepartmentSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listByDepartmentNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListByDepartmentResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listByDepartmentNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (iter *SetDefinitionListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (page * ServerListResultPage) Next() error {\n return page.NextWithContext(context.Background())\n }", "func (s *ServeSeq) Next(h http.Handler) {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\ts.handlers = append(s.handlers, h)\n}", "func (iter * ServerListResultIterator) Next() error {\n return iter.NextWithContext(context.Background())\n }", "func (iter *MonitoredResourceListResponseIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (page *VirtualMachineListResultPageClient) Next() error {\n\treturn page.vmlrp.Next()\n}", "func (page *DataSourceListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (client DeploymentsClient) listNextResults(ctx context.Context, lastResults DeploymentResourceCollection) (result DeploymentResourceCollection, err error) {\n\treq, err := lastResults.deploymentResourceCollectionPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"appplatform.DeploymentsClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"appplatform.DeploymentsClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"appplatform.DeploymentsClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (r *newSelectResult) Next() (NewPartialResult, error) {\n\tre := <-r.results\n\tif re.err != nil {\n\t\treturn nil, errors.Trace(re.err)\n\t}\n\tif re.result == nil {\n\t\treturn nil, nil\n\t}\n\tpr := &newPartialResult{}\n\tpr.rowLen = r.rowLen\n\terr := pr.unmarshal(re.result)\n\treturn pr, errors.Trace(err)\n}", "func (iter *ExportTaskListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (f *FrontPage) next() *Article {\n\ta := &Article{SnapshotID: f.SnapshotID}\n\treturn a\n}", "func (l *Headers) SetNext(h http.Handler) {\n\tl.next = h\n}", "func (p *PaginatedResult) next(ctx context.Context, into interface{}) bool {\n\tif !p.first {\n\t\tif p.nextLink == \"\" {\n\t\t\treturn false\n\t\t}\n\t\tp.err = p.goTo(ctx, p.nextLink)\n\t\tif p.err != nil {\n\t\t\treturn false\n\t\t}\n\t}\n\tp.first = false\n\n\tp.err = decodeResp(p.res, into)\n\treturn p.err == nil\n}", "func (iter *RegistrationDefinitionListIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (iter *ProviderOperationsMetadataListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (page *OperationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *OperationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *OperationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *OperationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *OperationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *OperationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *OperationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *ServiceProviderListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *EndpointHealthDataListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (r *Route) Next() Backend {\n return r.Backend(r.Index())\n}", "func (iter *ImportTaskListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (iter *VMResourcesListResponseIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (client JobClient) listByAccountNextResults(ctx context.Context, lastResults JobResourceDescriptionList) (result JobResourceDescriptionList, err error) {\n req, err := lastResults.jobResourceDescriptionListPreparer(ctx)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"microsoftazuremanagementaisupercomputer.JobClient\", \"listByAccountNextResults\", nil , \"Failure preparing next results request\")\n }\n if req == nil {\n return\n }\n resp, err := client.ListByAccountSender(req)\n if err != nil {\n result.Response = autorest.Response{Response: resp}\n return result, autorest.NewErrorWithError(err, \"microsoftazuremanagementaisupercomputer.JobClient\", \"listByAccountNextResults\", resp, \"Failure sending next results request\")\n }\n result, err = client.ListByAccountResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"microsoftazuremanagementaisupercomputer.JobClient\", \"listByAccountNextResults\", resp, \"Failure responding to next results request\")\n }\n return\n }", "func responderArtifact206(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerPartialContent) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\n\tresponder = artifacts.NewArtifactListerPartialContent()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tresponder.SetRemainingRecords(listInfo.RemainingRecords)\n\n\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\tartifactListerURL.After = &tmp\n\n\tif defaultPageLimit != paginator.Limit {\n\t\ttmp := paginator.Limit\n\t\tartifactListerURL.Limit = &tmp\n\t}\n\tresponder.SetNext(artifactListerURL.String())\n\n\tif paginator.ID != 0 { //... and not the first\n\t\t//paginator.ID is from query parameter not artifactmanager\n\t\tvar artifactListerURL artifacts.ArtifactListerURL\n\t\ttmp = artifactInfoReturned[0].ID\n\t\tartifactListerURL.Before = &tmp\n\t\tif defaultPageLimit != paginator.Limit {\n\t\t\ttmp := paginator.Limit\n\t\t\tartifactListerURL.Limit = &tmp\n\t\t}\n\t\tresponder.SetPrevious(artifactListerURL.String())\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func responderArtifact200(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerOK) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\tresponder = artifacts.NewArtifactListerOK()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tif paginator.ID != 0 { //not the first page\n\t\t// keep in mind that ArtifactPath in paginator is taken from query parameter,\n\t\t// not ArtifactManager\n\t\tif paginator.Forward {\n\t\t\ttmp := artifactInfoReturned[0].ID\n\t\t\tartifactListerURL.Before = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp\n\t\t\t}\n\t\t\tresponder.SetPrevious(artifactListerURL.String())\n\t\t} else {\n\t\t\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\t\t\tartifactListerURL.After = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp2 := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp2\n\t\t\t}\n\t\t\tresponder.SetNext(artifactListerURL.String())\n\t\t}\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (client EntitiesClient) listNextResults(ctx context.Context, lastResults EntityListResult) (result EntityListResult, err error) {\n\treq, err := lastResults.entityListResultPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"managementgroups.EntitiesClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"managementgroups.EntitiesClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"managementgroups.EntitiesClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (page *SingleSignOnResourceListResponsePage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *StorageContainerListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func WithNext(next *url.URL) Opt {\n\treturn func(opts *Options) {\n\t\topts.Next = next\n\t}\n}", "func (page *MachineExtensionsListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (client VersionsClient) listNextResults(ctx context.Context, lastResults VersionsListResult) (result VersionsListResult, err error) {\n\treq, err := lastResults.versionsListResultPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"templatespecs.VersionsClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"templatespecs.VersionsClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"templatespecs.VersionsClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (b *BadRequest) SetNext(_h http.Handler) {\n}", "func (page *ServiceListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *DevicesQueryResultPage) Next() error {\n\tnext, err := page.fn(page.dqr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.dqr = next\n\treturn nil\n}", "func (iter *VaultListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (g *GZipper) SetNext(h http.Handler) {\n\tg.next = h\n}", "func (page *IotHubDescriptionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func Next(next http.HandlerFunc) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tfmt.Println(\"BeforeRequst\", r)\n\t\tnext.ServeHTTP(w, r)\n\t\tfmt.Println(\"AfterRequest\", r)\n\t})\n}", "func (iter *EndpointHealthDataListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (client MSIXPackagesClient) listNextResults(ctx context.Context, lastResults MSIXPackageList) (result MSIXPackageList, err error) {\n\treq, err := lastResults.mSIXPackageListPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"desktopvirtualization.MSIXPackagesClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"desktopvirtualization.MSIXPackagesClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"desktopvirtualization.MSIXPackagesClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (client UsageDetailsClient) listNextResults(ctx context.Context, lastResults UsageDetailsListResult) (result UsageDetailsListResult, err error) {\n\treq, err := lastResults.usageDetailsListResultPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (page *ConsumerGroupListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (client ProductsClient) listNextResults(ctx context.Context, lastResults ProductList) (result ProductList, err error) {\n\treq, err := lastResults.productListPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"azurestack.ProductsClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"azurestack.ProductsClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"azurestack.ProductsClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (page *DeletedVaultListResultPage) Next() error {\n\tnext, err := page.fn(page.dvlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.dvlr = next\n\treturn nil\n}", "func (iter *DataPolicyManifestListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (client DataControllersClient) listInGroupNextResults(ctx context.Context, lastResults PageOfDataControllerResource) (result PageOfDataControllerResource, err error) {\n\treq, err := lastResults.pageOfDataControllerResourcePreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"listInGroupNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListInGroupSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"listInGroupNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListInGroupResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"listInGroupNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (page * DatabaseListResultPage) Next() error {\n return page.NextWithContext(context.Background())\n }", "func (client IotHubResourceClient) listByResourceGroupNextResults(ctx context.Context, lastResults IotHubDescriptionListResult) (result IotHubDescriptionListResult, err error) {\n\treq, err := lastResults.iotHubDescriptionListResultPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"devices.IotHubResourceClient\", \"listByResourceGroupNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListByResourceGroupSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"devices.IotHubResourceClient\", \"listByResourceGroupNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListByResourceGroupResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"devices.IotHubResourceClient\", \"listByResourceGroupNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (page *UsageAggregationListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (iter *AppListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func NewNextResponseBody(res *spinbroker.NextResult) *NextResponseBody {\n\tbody := &NextResponseBody{\n\t\tUUID: res.UUID,\n\t\tResource: res.Resource,\n\t\tAction: res.Action,\n\t}\n\tif res.Parameters != nil {\n\t\tbody.Parameters = make(map[string]json.RawMessage, len(res.Parameters))\n\t\tfor key, val := range res.Parameters {\n\t\t\ttk := key\n\t\t\ttv := val\n\t\t\tbody.Parameters[tk] = tv\n\t\t}\n\t}\n\treturn body\n}", "func (page *VirtualMachineScaleSetListResultPageClient) Next() error {\n\treturn page.vmsslrp.Next()\n}", "func (page *ClassicAdministratorListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (pr *newPartialResult) Next() (data []types.Datum, err error) {\n\tchunk := pr.getChunk()\n\tif chunk == nil {\n\t\treturn nil, nil\n\t}\n\tdata = make([]types.Datum, pr.rowLen)\n\tfor i := 0; i < pr.rowLen; i++ {\n\t\tvar l []byte\n\t\tl, chunk.RowsData, err = codec.CutOne(chunk.RowsData)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Trace(err)\n\t\t}\n\t\tdata[i].SetRaw(l)\n\t}\n\treturn\n}", "func (c *Collection) Next(params ...interface{}) bool {\n\tif c.err != nil {\n\t\treturn false\n\t}\n\n\tif c.Name == \"ALL_MEDIA_AUTO_COLLECTION\" {\n\t\tif c.all == nil {\n\t\t\tc.all = &SavedMedia{\n\t\t\t\tinsta: c.insta,\n\t\t\t\tendpoint: urlFeedSavedPosts,\n\t\t\t}\n\t\t}\n\t\tr := c.all.Next()\n\t\tc.NextID = c.all.NextID\n\t\tc.MoreAvailable = c.all.MoreAvailable\n\t\tc.NumResults = c.all.NumResults\n\t\tc.Items = []Item{}\n\t\tfor _, i := range c.all.Items {\n\t\t\tc.Items = append(c.Items, i.Media)\n\t\t}\n\n\t\tc.err = c.all.err\n\t\treturn r\n\t}\n\tif len(c.Items) == 0 {\n\t\tif err := c.Sync(); err != nil {\n\t\t\tc.err = err\n\t\t\treturn false\n\t\t}\n\t}\n\tinsta := c.insta\n\tbody, _, err := insta.sendRequest(\n\t\t&reqOptions{\n\t\t\tEndpoint: fmt.Sprintf(urlCollectionFeedPosts, c.ID),\n\t\t\tQuery: map[string]string{\n\t\t\t\t\"next_max_id\": c.GetNextID(),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tc.err = err\n\t\treturn false\n\t}\n\ttmp := SavedMedia{}\n\terr = json.Unmarshal(body, &tmp)\n\n\tc.NextID = tmp.NextID\n\tc.MoreAvailable = tmp.MoreAvailable\n\tc.NumResults = tmp.NumResults\n\n\tc.Items = []Item{}\n\tfor _, i := range tmp.Items {\n\t\tc.Items = append(c.Items, i.Media)\n\t}\n\tc.setValues()\n\n\tif !c.MoreAvailable {\n\t\tc.err = ErrNoMore\n\t}\n\treturn c.MoreAvailable\n}", "func (ic *FilesCursor) Next() bool {\n\tif ic.itemIndex >= len(ic.currentResponse.Contents) && ic.currentResponse.NextMarker == \"\" {\n\t\treturn false\n\t}\n\n\tif ic.itemIndex < len(ic.currentResponse.Contents) {\n\t\tic.currentFile = ic.currentResponse.Contents[ic.itemIndex]\n\t\tic.itemIndex++\n\t} else {\n\t\tic.input.Marker = ic.currentResponse.NextMarker\n\t\tres, err := ic.container.GetContainerContentsSync(ic.input)\n\t\tif err != nil {\n\t\t\tic.currentError = err\n\t\t\treturn false\n\t\t}\n\t\tres.Release()\n\t\tic.currentResponse = res.Output.(*v3io.GetContainerContentsOutput)\n\t\tic.itemIndex = 0\n\t\treturn ic.Next()\n\t}\n\n\treturn true\n}" ]
[ "0.72289026", "0.645706", "0.64555925", "0.63839513", "0.60253656", "0.5970255", "0.59100014", "0.586041", "0.5832225", "0.58279544", "0.58180356", "0.58152777", "0.5741045", "0.57042944", "0.5696428", "0.5690498", "0.56730956", "0.5670502", "0.56292367", "0.5609952", "0.5609952", "0.55903953", "0.55724096", "0.5571906", "0.5571906", "0.5550437", "0.5514637", "0.54999787", "0.5477711", "0.5472438", "0.5470539", "0.5466402", "0.5465486", "0.545642", "0.54425013", "0.5437738", "0.54314256", "0.5431281", "0.54181975", "0.5414321", "0.53971905", "0.5388006", "0.5359628", "0.5356401", "0.53418195", "0.5341062", "0.534003", "0.5335189", "0.53245544", "0.5313999", "0.53136337", "0.5309721", "0.53095526", "0.53062475", "0.5294957", "0.5294957", "0.5294957", "0.5294957", "0.5294957", "0.5294957", "0.5294957", "0.529463", "0.5274913", "0.5270677", "0.52704763", "0.52476346", "0.52406955", "0.52328825", "0.5228208", "0.52278394", "0.52265614", "0.522071", "0.5216323", "0.52096397", "0.51992106", "0.51864463", "0.5185639", "0.5183992", "0.5182407", "0.5178697", "0.5178557", "0.5175337", "0.5170017", "0.5160988", "0.5157957", "0.5154785", "0.5153753", "0.5149359", "0.51487565", "0.5145197", "0.5134081", "0.5129191", "0.51280814", "0.5124965", "0.51245755", "0.51225567", "0.5113826", "0.5110405", "0.510886", "0.51078784" ]
0.7497578
0
SetNext sets the next to the artifact lister partial content response
func (o *ArtifactListerPartialContent) SetNext(next string) { o.Next = next }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) SetNext(next string) {\n\to.Next = next\n}", "func (o *ArtifactListerPartialContent) WithNext(next string) *ArtifactListerPartialContent {\n\to.Next = next\n\treturn o\n}", "func (o *ArtifactListerOK) WithNext(next string) *ArtifactListerOK {\n\to.Next = next\n\treturn o\n}", "func (rl *ResourceList) next() error {\n\tif rl.Page == rl.NumPages-1 {\n\t\treturn errors.New(\"no more new pages\")\n\t}\n\treturn common.SendGetRequest(rl.NextPageURI, *rl.act, rl)\n}", "func (h *Sagify) SetNext(next job.Handler) {\n\th.next = next\n}", "func (l *Headers) SetNext(h http.Handler) {\n\tl.next = h\n}", "func (g *GZipper) SetNext(h http.Handler) {\n\tg.next = h\n}", "func (page *ResourceListResultPage) Next() error {\n\tnext, err := page.fn(page.rlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.rlr = next\n\treturn nil\n}", "func (o *StdOutOutput) SetNext(next Output) {\n\to.next = next\n}", "func (page *ExportTaskListResultPage) Next() error {\n\tnext, err := page.fn(page.etlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.etlr = next\n\treturn nil\n}", "func (page *SetDefinitionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (f *MutateFilter) SetNext(next Filter) {\n\tf.next = next\n}", "func (page *ImportTaskListResultPage) Next() error {\n\tnext, err := page.fn(page.itlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.itlr = next\n\treturn nil\n}", "func (c *Client) Next() goa.Endpoint {\n\tvar (\n\t\tdecodeResponse = DecodeNextResponse(c.decoder, c.RestoreResponseBody)\n\t)\n\treturn func(ctx context.Context, v interface{}) (interface{}, error) {\n\t\treq, err := c.BuildNextRequest(ctx, v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresp, err := c.NextDoer.Do(req)\n\t\tif err != nil {\n\t\t\treturn nil, goahttp.ErrRequestError(\"spin-broker\", \"next\", err)\n\t\t}\n\t\treturn decodeResponse(resp)\n\t}\n}", "func (page *AppListResultPage) Next() error {\n\tnext, err := page.fn(page.alr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.alr = next\n\treturn nil\n}", "func (page *DefinitionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *AppCollectionListResultPage) Next() error {\n\tnext, err := page.fn(page.aclr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.aclr = next\n\treturn nil\n}", "func (page *JobResponseListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (b *BadRequest) SetNext(_h http.Handler) {\n}", "func (iter *ResourceListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (iter *SetDefinitionListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (client ApplicationsClient) ListNextPreparer(ctx context.Context, nextLink string) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"nextLink\": nextLink,\n\t\t\"tenantID\": autorest.Encode(\"path\", client.TenantID),\n\t}\n\n\tconst APIVersion = \"1.6\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsGet(),\n\t\tautorest.WithBaseURL(client.BaseURI),\n\t\tautorest.WithPathParameters(\"/{tenantID}/{nextLink}\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (page *VaultListResultPage) Next() error {\n\tnext, err := page.fn(page.vlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.vlr = next\n\treturn nil\n}", "func (client DatasetClient) listNextResults(ctx context.Context, lastResults DatasetListResponse) (result DatasetListResponse, err error) {\n req, err := lastResults.datasetListResponsePreparer(ctx)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", nil , \"Failure preparing next results request\")\n }\n if req == nil {\n return\n }\n resp, err := client.ListSender(req)\n if err != nil {\n result.Response = autorest.Response{Response: resp}\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n }\n result, err = client.ListResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n }\n return\n }", "func (iter *ExportTaskListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (p *Playlist) Next() {\n\tp.ch <- \"next\"\n}", "func (c *layerCache) setNext(next Layer) error {\n\tc.next = next\n\treturn nil\n}", "func (page *CampaignsListResultPage) Next() error {\n\tnext, err := page.fn(page.clr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.clr = next\n\treturn nil\n}", "func (c *Client) next() (rsp *Response, err error) {\n\traw, err := c.r.Next()\n\tif err == nil {\n\t\trsp, err = raw.Parse()\n\t}\n\treturn\n}", "func (m *BaseStatement) SetNext(next Statement) {\n\tm.next = next\n}", "func (page *MonitorResourceListResponsePage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (i *UploadShrinker) Next() *FileUpload {\n\tvar n int\n\tvar err error\n\n\tif i.Done() {\n\t\treturn nil\n\t}\n\n\tif n, err = i.f.Read(i.buff); err != nil && err != io.EOF {\n\t\ti.err = err\n\t\treturn nil\n\t}\n\n\ti.fu.Chunk = i.chunk\n\ti.fu.Content = i.buff[:n]\n\ti.chunk++\n\n\treturn i.fu\n}", "func (iter *MonitorResourceListResponseIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (page *ExemptionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (iter *ImportTaskListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (ic *FilesCursor) Next() bool {\n\tif ic.itemIndex >= len(ic.currentResponse.Contents) && ic.currentResponse.NextMarker == \"\" {\n\t\treturn false\n\t}\n\n\tif ic.itemIndex < len(ic.currentResponse.Contents) {\n\t\tic.currentFile = ic.currentResponse.Contents[ic.itemIndex]\n\t\tic.itemIndex++\n\t} else {\n\t\tic.input.Marker = ic.currentResponse.NextMarker\n\t\tres, err := ic.container.GetContainerContentsSync(ic.input)\n\t\tif err != nil {\n\t\t\tic.currentError = err\n\t\t\treturn false\n\t\t}\n\t\tres.Release()\n\t\tic.currentResponse = res.Output.(*v3io.GetContainerContentsOutput)\n\t\tic.itemIndex = 0\n\t\treturn ic.Next()\n\t}\n\n\treturn true\n}", "func (applications *Applications) Next() (*Result, error) {\n\tif applications.NextURL != \"\" {\n\t\tbody, err := applications.getCursor(applications.NextURL)\n\t\tif err != nil {\n\t\t\tresult := &Result{}\n\t\t\tjson.Unmarshal(body, result)\n\t\t\treturn result, err\n\t\t}\n\t\treturn nil, nil\n\t}\n\treturn nil, errors.New(\"next cursor not available\")\n}", "func (page *VirtualMachineListResultPageClient) Next() error {\n\treturn page.vmlrp.Next()\n}", "func (iter *JobResponseListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (page *MonitoredResourceListResponsePage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (c *Collection) Next(params ...interface{}) bool {\n\tif c.err != nil {\n\t\treturn false\n\t}\n\n\tif c.Name == \"ALL_MEDIA_AUTO_COLLECTION\" {\n\t\tif c.all == nil {\n\t\t\tc.all = &SavedMedia{\n\t\t\t\tinsta: c.insta,\n\t\t\t\tendpoint: urlFeedSavedPosts,\n\t\t\t}\n\t\t}\n\t\tr := c.all.Next()\n\t\tc.NextID = c.all.NextID\n\t\tc.MoreAvailable = c.all.MoreAvailable\n\t\tc.NumResults = c.all.NumResults\n\t\tc.Items = []Item{}\n\t\tfor _, i := range c.all.Items {\n\t\t\tc.Items = append(c.Items, i.Media)\n\t\t}\n\n\t\tc.err = c.all.err\n\t\treturn r\n\t}\n\tif len(c.Items) == 0 {\n\t\tif err := c.Sync(); err != nil {\n\t\t\tc.err = err\n\t\t\treturn false\n\t\t}\n\t}\n\tinsta := c.insta\n\tbody, _, err := insta.sendRequest(\n\t\t&reqOptions{\n\t\t\tEndpoint: fmt.Sprintf(urlCollectionFeedPosts, c.ID),\n\t\t\tQuery: map[string]string{\n\t\t\t\t\"next_max_id\": c.GetNextID(),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tc.err = err\n\t\treturn false\n\t}\n\ttmp := SavedMedia{}\n\terr = json.Unmarshal(body, &tmp)\n\n\tc.NextID = tmp.NextID\n\tc.MoreAvailable = tmp.MoreAvailable\n\tc.NumResults = tmp.NumResults\n\n\tc.Items = []Item{}\n\tfor _, i := range tmp.Items {\n\t\tc.Items = append(c.Items, i.Media)\n\t}\n\tc.setValues()\n\n\tif !c.MoreAvailable {\n\t\tc.err = ErrNoMore\n\t}\n\treturn c.MoreAvailable\n}", "func (page *DataPolicyManifestListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (c *CompletionManager) Next() {\n\tif c.verticalScroll+int(c.max)-1 == c.selected {\n\t\tc.verticalScroll++\n\t}\n\tc.selected++\n\tc.update()\n}", "func (page *VirtualMachineScaleSetListResultPageClient) Next() error {\n\treturn page.vmsslrp.Next()\n}", "func (o *Links) SetNext(v string) {\n\to.Next = &v\n}", "func (cl *APIClient) RequestNextResponsePage(rr *R.Response) (*R.Response, error) {\n\tmycmd := cl.toUpperCaseKeys(rr.GetCommand())\n\tif _, ok := mycmd[\"LAST\"]; ok {\n\t\treturn nil, errors.New(\"Parameter LAST in use. Please remove it to avoid issues in requestNextPage\")\n\t}\n\tfirst := 0\n\tif v, ok := mycmd[\"FIRST\"]; ok {\n\t\tfirst, _ = fmt.Sscan(\"%s\", v)\n\t}\n\ttotal := rr.GetRecordsTotalCount()\n\tlimit := rr.GetRecordsLimitation()\n\tfirst += limit\n\tif first < total {\n\t\tmycmd[\"FIRST\"] = fmt.Sprintf(\"%d\", first)\n\t\tmycmd[\"LIMIT\"] = fmt.Sprintf(\"%d\", limit)\n\t\treturn cl.Request(mycmd), nil\n\t}\n\treturn nil, errors.New(\"Could not find further existing pages\")\n}", "func (iter *DefinitionListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (c *Collections) Next() bool {\n\t// Check if prev returned error\n\tif c.err != nil {\n\t\treturn false\n\t}\n\n\t// No more available\n\tif len(c.Items) > 0 && !c.MoreAvailable {\n\t\treturn false\n\t}\n\tinsta := c.insta\n\tquery := map[string]string{\n\t\t\"collection_types\": \"[\\\"ALL_MEDIA_AUTO_COLLECTION\\\",\\\"PRODUCT_AUTO_COLLECTION\\\",\\\"MEDIA\\\",\\\"AUDIO_AUTO_COLLECTION\\\",\\\"GUIDES_AUTO_COLLECTION\\\"]\",\n\t}\n\tif c.NextID != \"\" {\n\t\tquery[\"next_max_id\"] = c.NextID\n\t}\n\tbody, _, err := insta.sendRequest(\n\t\t&reqOptions{\n\t\t\tEndpoint: urlCollectionsList,\n\t\t\tQuery: query,\n\t\t},\n\t)\n\tif err != nil {\n\t\tc.err = err\n\t\treturn false\n\t}\n\ttmp := Collections{}\n\terr = json.Unmarshal(body, &tmp)\n\tif err != nil {\n\t\tc.err = err\n\t\treturn false\n\t}\n\tc.MoreAvailable = tmp.MoreAvailable\n\tc.NextID = tmp.NextID\n\tc.AutoLoadMoreEnabled = tmp.AutoLoadMoreEnabled\n\tc.Status = tmp.Status\n\tc.NumResults = len(tmp.Items)\n\n\tfor _, i := range tmp.Items {\n\t\ti.insta = insta\n\t}\n\tc.Items = append(c.Items, tmp.Items...)\n\tif !c.MoreAvailable {\n\t\terr = ErrNoMore\n\t}\n\n\treturn c.MoreAvailable\n}", "func (c *Comics) Next() string {\n\tnext := c.Num + 1\n\n\treturn fmt.Sprintf(\"/?id=%d\", next)\n}", "func (tn *MergeNode) SetNext(t *TaskNode) {\n\t// make sure we have a cpy of this in the parent map\n\ttn.floe.registerNode(t)\n\ttn.next = t\n}", "func (iter *VaultListResultIterator) Next() error {\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr := iter.page.Next()\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (r *newSelectResult) Next() (NewPartialResult, error) {\n\tre := <-r.results\n\tif re.err != nil {\n\t\treturn nil, errors.Trace(re.err)\n\t}\n\tif re.result == nil {\n\t\treturn nil, nil\n\t}\n\tpr := &newPartialResult{}\n\tpr.rowLen = r.rowLen\n\terr := pr.unmarshal(re.result)\n\treturn pr, errors.Trace(err)\n}", "func (s Service) Next(msg *Message, data interface{}, useMeta map[string]string) error {\n\terr := msg.RawMessage.Ack(true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif msg.Chain == nil {\n\t\treturn ErrorChainIsEmpty\n\t}\n\n\tchain := SetCurrentItemSuccess(msg.Chain)\n\n\tnextIndex := getCurrentChainIndex(chain)\n\tif nextIndex == -1 {\n\t\treturn ErrorNextIsNotDefined\n\t}\n\n\tnextElement := chain[nextIndex]\n\n\tmeta := Meta{}\n\tmeta.Merge(msg.Meta, useMeta)\n\n\tvar items []interface{}\n\n\tif nextElement.IsMultiple {\n\t\tval := reflect.ValueOf(data)\n\n\t\tif val.Kind() != reflect.Slice {\n\t\t\treturn ErrorDataIsNotArray\n\t\t}\n\n\t\tfor i := 0; i < val.Len(); i++ {\n\t\t\titems = append(items, val.Index(i).Interface())\n\t\t}\n\t} else {\n\t\titems = append(items, data)\n\t}\n\n\tfor _, item := range items {\n\t\tb, err := json.Marshal(item)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tm := InitialMessage{\n\t\t\tCatch: msg.InitialMessage.Catch,\n\t\t\tConfig: msg.Config,\n\t\t\tMeta: meta,\n\t\t\tChain: chain,\n\t\t\tData: b,\n\t\t}\n\n\t\tif err := s.Publish(m); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (page *ProviderOperationsMetadataListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (pagedList *PagedList) GetNextPage() (*Embed, error) {\n\treturn pagedList.GetPage(pagedList.PageNumber + 1)\n}", "func (page *ListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *ListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (nu *NodeUpdate) SetNext(n *Node) *NodeUpdate {\n\treturn nu.SetNextID(n.ID)\n}", "func (h *HandlersApp01sqVendor) ListNext(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tvar offset int\n\tvar cTable int\n\n\tlog.Printf(\"hndlrVendor.ListNext(%s)\\n\", r.Method)\n\n\tif r.Method != \"GET\" {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListNext(Error:405) - Not GET\\n\")\n\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Calculate the offset.\n\tcTable, err = h.db.TableCount()\n\tif err != nil {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListLast(Error:400) - %s\\n\", util.ErrorString(err))\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t}\n\toffset, _ = strconv.Atoi(r.FormValue(\"offset\"))\n\toffset += h.rowsPerPage\n\tif offset < 0 || offset > cTable {\n\t\toffset = 0\n\t}\n\n\t// Display the row in the form.\n\th.ListShow(w, offset, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.ListNext()\\n\")\n\n}", "func (page *VirtualMachineScaleSetVMListResultPageClient) Next() error {\n\treturn page.vmssvlrp.Next()\n}", "func (iter *MonitoredResourceListResponseIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (iter * ServerListResultIterator) Next() error {\n return iter.NextWithContext(context.Background())\n }", "func (wk *WebmKeeper) Next() ([]byte, error) {\n\tel, err := next(wk.p)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = wk.handleRandomAccessPoint(el); err != nil {\n\t\treturn nil, err\n\t}\n\n\twk.elemBuf.Reset()\n\tel.WriteTo(wk.elemBuf)\n\tb := make([]byte, wk.elemBuf.Len())\n\tcopy(b, wk.elemBuf.Bytes())\n\n\twk.body.Write(b)\n\treturn b, nil\n}", "func (page *DataSourceListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (client PublishedBlueprintsClient) listNextResults(ctx context.Context, lastResults PublishedBlueprintList) (result PublishedBlueprintList, err error) {\n\treq, err := lastResults.publishedBlueprintListPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"blueprint.PublishedBlueprintsClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"blueprint.PublishedBlueprintsClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"blueprint.PublishedBlueprintsClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (iter *ExemptionListResultIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (it *PatchDeploymentIterator) Next() (*osconfigpb.PatchDeployment, error) {\n\tvar item *osconfigpb.PatchDeployment\n\tif err := it.nextFunc(); err != nil {\n\t\treturn item, err\n\t}\n\titem = it.items[0]\n\tit.items = it.items[1:]\n\treturn item, nil\n}", "func (iter *VMResourcesListResponseIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (resp *ProviderPortCollection) GetNextStart() (*string, error) {\n\tif core.IsNil(resp.Next) {\n\t\treturn nil, nil\n\t}\n\treturn resp.Next.Start, nil\n}", "func (resp *IntegrationList) GetNextOffset() (*int64, error) {\n\tif core.IsNil(resp.Next) {\n\t\treturn nil, nil\n\t}\n\toffset, err := core.GetQueryParam(resp.Next.Href, \"offset\")\n\tif err != nil || offset == nil {\n\t\treturn nil, err\n\t}\n\tvar offsetValue int64\n\toffsetValue, err = strconv.ParseInt(*offset, 10, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn core.Int64Ptr(offsetValue), nil\n}", "func (page *SingleSignOnResourceListResponsePage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (nuo *NodeUpdateOne) SetNext(n *Node) *NodeUpdateOne {\n\treturn nuo.SetNextID(n.ID)\n}", "func (iter *RegistrationDefinitionListIterator) Next() error {\n\treturn iter.NextWithContext(context.Background())\n}", "func (page * ServerListResultPage) Next() error {\n return page.NextWithContext(context.Background())\n }", "func (p *PaginatedResult) next(ctx context.Context, into interface{}) bool {\n\tif !p.first {\n\t\tif p.nextLink == \"\" {\n\t\t\treturn false\n\t\t}\n\t\tp.err = p.goTo(ctx, p.nextLink)\n\t\tif p.err != nil {\n\t\t\treturn false\n\t\t}\n\t}\n\tp.first = false\n\n\tp.err = decodeResp(p.res, into)\n\treturn p.err == nil\n}", "func (d *FTSSimulator) Next(p *redisearch.Document) bool {\n\t// Switch to the next document\n\tif d.recordIndex >= uint64(len(d.records)) {\n\t\td.recordIndex = 0\n\t}\n\treturn d.populateDocument(p)\n}", "func (media *SavedMedia) Next(params ...interface{}) bool {\n\t// Return if last pagination had errors\n\tif media.err != nil {\n\t\treturn false\n\t}\n\tif len(media.Items) == 0 {\n\t\tif err := media.Sync(); err != nil {\n\t\t\tmedia.err = err\n\t\t\treturn false\n\t\t}\n\t}\n\n\tinsta := media.insta\n\tendpoint := media.endpoint\n\n\topts := &reqOptions{\n\t\tEndpoint: endpoint,\n\t\tQuery: map[string]string{\n\t\t\t\"max_id\": media.GetNextID(),\n\t\t\t\"include_igtv_preview\": \"true\",\n\t\t},\n\t}\n\n\tbody, _, err := insta.sendRequest(opts)\n\tif err != nil {\n\t\tmedia.err = err\n\t\treturn false\n\t}\n\n\tm := SavedMedia{}\n\tif err := json.Unmarshal(body, &m); err != nil {\n\t\tmedia.err = err\n\t\treturn false\n\t}\n\n\tmedia.MoreAvailable = m.MoreAvailable\n\tmedia.NextID = m.NextID\n\tmedia.AutoLoadMoreEnabled = m.AutoLoadMoreEnabled\n\tmedia.Status = m.Status\n\tmedia.NumResults = m.NumResults\n\tmedia.Items = append(media.Items, m.Items...)\n\tmedia.setValues()\n\n\tif m.NextID == 0 || !m.MoreAvailable {\n\t\tmedia.err = ErrNoMore\n\t}\n\n\treturn m.MoreAvailable\n}", "func (c *listObjCache) next(smap *cluster.Smap, smsg cmn.SelectMsg, bck *cluster.Bck, pageSize uint) (result fetchResult) {\n\tcmn.Assert(smsg.UUID != \"\")\n\tif smap.CountTargets() == 0 {\n\t\treturn fetchResult{err: fmt.Errorf(\"no targets registered\")}\n\t}\n\tentries := c.allTargetsEntries(smsg, smap, bck)\n\tcmn.Assert(len(entries) > 0)\n\tentries[0].parent.mtx.Lock()\n\tresult = c.initResultsFromEntries(entries, smsg, pageSize, smsg.UUID)\n\tif result.allOK && result.err == nil {\n\t\tresult = c.fetchAll(entries, smsg, pageSize)\n\t}\n\tentries[0].parent.mtx.Unlock()\n\n\tc.mtx.Lock()\n\tdelete(c.reqs, smsg.ListObjectsCacheID(bck.Bck))\n\tc.mtx.Unlock()\n\treturn result\n}", "func (page *StorageInsightListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *StorageInsightListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (page *DeletedVaultListResultPage) Next() error {\n\tnext, err := page.fn(page.dvlr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.dvlr = next\n\treturn nil\n}", "func (client DeploymentsClient) listNextResults(ctx context.Context, lastResults DeploymentResourceCollection) (result DeploymentResourceCollection, err error) {\n\treq, err := lastResults.deploymentResourceCollectionPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"appplatform.DeploymentsClient\", \"listNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"appplatform.DeploymentsClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"appplatform.DeploymentsClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (o *VolumeModifyIterAsyncResponseResult) NextTag() string {\n\tvar r string\n\tif o.NextTagPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NextTagPtr\n\treturn r\n}", "func (pr *newPartialResult) Next() (data []types.Datum, err error) {\n\tchunk := pr.getChunk()\n\tif chunk == nil {\n\t\treturn nil, nil\n\t}\n\tdata = make([]types.Datum, pr.rowLen)\n\tfor i := 0; i < pr.rowLen; i++ {\n\t\tvar l []byte\n\t\tl, chunk.RowsData, err = codec.CutOne(chunk.RowsData)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Trace(err)\n\t\t}\n\t\tdata[i].SetRaw(l)\n\t}\n\treturn\n}", "func (page *DevicesQueryResultPage) Next() error {\n\tnext, err := page.fn(page.dqr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.dqr = next\n\treturn nil\n}", "func (p *RelPublisher) SetNextSlot(ns px.SlotID) {\n}", "func Next(rt http.RoundTripper) Option {\n\treturn func(p *proxy) { p.next = rt }\n}", "func NewNextResponseBody(res *spinbroker.NextResult) *NextResponseBody {\n\tbody := &NextResponseBody{\n\t\tUUID: res.UUID,\n\t\tResource: res.Resource,\n\t\tAction: res.Action,\n\t}\n\tif res.Parameters != nil {\n\t\tbody.Parameters = make(map[string]json.RawMessage, len(res.Parameters))\n\t\tfor key, val := range res.Parameters {\n\t\t\ttk := key\n\t\t\ttv := val\n\t\t\tbody.Parameters[tk] = tv\n\t\t}\n\t}\n\treturn body\n}", "func (resp *ConfigurationMetadataPaginatedCollection) GetNextOffset() (*int64, error) {\n\tif core.IsNil(resp.Next) {\n\t\treturn nil, nil\n\t}\n\toffset, err := core.GetQueryParam(resp.Next.Href, \"offset\")\n\tif err != nil || offset == nil {\n\t\treturn nil, err\n\t}\n\tvar offsetValue int64\n\toffsetValue, err = strconv.ParseInt(*offset, 10, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn core.Int64Ptr(offsetValue), nil\n}", "func (resp *SourceList) GetNextOffset() (*int64, error) {\n\tif core.IsNil(resp.Next) {\n\t\treturn nil, nil\n\t}\n\toffset, err := core.GetQueryParam(resp.Next.Href, \"offset\")\n\tif err != nil || offset == nil {\n\t\treturn nil, err\n\t}\n\tvar offsetValue int64\n\toffsetValue, err = strconv.ParseInt(*offset, 10, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn core.Int64Ptr(offsetValue), nil\n}", "func (cycle *Cycle) Next() {\n\tif !cycle.showing {\n\t\treturn\n\t}\n\n\tif cycle.selected == -1 {\n\t\tif len(cycle.items) > 1 {\n\t\t\tcycle.selected = 1\n\t\t} else {\n\t\t\tcycle.selected = 0\n\t\t}\n\t} else {\n\t\tcycle.selected++\n\t}\n\n\tcycle.selected = misc.Mod(cycle.selected, len(cycle.items))\n\tcycle.highlight()\n}", "func (s *SliceIter) Next() {\n\tval := reflect.ValueOf(s.slice)\n\tval = val.Slice(1, val.Len())\n\ts.slice = val.Interface()\n}", "func (s *ServeSeq) Next(h http.Handler) {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\ts.handlers = append(s.handlers, h)\n}", "func (resp *SecretMetadataPaginatedCollection) GetNextOffset() (*int64, error) {\n\tif core.IsNil(resp.Next) {\n\t\treturn nil, nil\n\t}\n\toffset, err := core.GetQueryParam(resp.Next.Href, \"offset\")\n\tif err != nil || offset == nil {\n\t\treturn nil, err\n\t}\n\tvar offsetValue int64\n\toffsetValue, err = strconv.ParseInt(*offset, 10, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn core.Int64Ptr(offsetValue), nil\n}", "func (p *BuildServiceBuilderClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.BuilderResourceCollection.NextLink == nil || len(*p.current.BuilderResourceCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "func (f *FrontPage) next() *Article {\n\ta := &Article{SnapshotID: f.SnapshotID}\n\treturn a\n}", "func (page *IotHubDescriptionListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (client FeatureStateClient) listStatesetNextResults(ctx context.Context, lastResults StatesetListResponse) (result StatesetListResponse, err error) {\n req, err := lastResults.statesetListResponsePreparer(ctx)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"creator.FeatureStateClient\", \"listStatesetNextResults\", nil , \"Failure preparing next results request\")\n }\n if req == nil {\n return\n }\n resp, err := client.ListStatesetSender(req)\n if err != nil {\n result.Response = autorest.Response{Response: resp}\n return result, autorest.NewErrorWithError(err, \"creator.FeatureStateClient\", \"listStatesetNextResults\", resp, \"Failure sending next results request\")\n }\n result, err = client.ListStatesetResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"creator.FeatureStateClient\", \"listStatesetNextResults\", resp, \"Failure responding to next results request\")\n }\n return\n }", "func (page *StorageContainerListResultPage) Next() error {\n\treturn page.NextWithContext(context.Background())\n}", "func (i *ResolvedProductIter) Next() bool {\n\tif i.first && i.err != nil {\n\t\ti.first = false\n\t\treturn true\n\t}\n\ti.first = false\n\ti.i++\n\treturn i.i < len(i.page)\n}" ]
[ "0.7756037", "0.72146124", "0.6890151", "0.66719323", "0.6429602", "0.6257318", "0.6213263", "0.61644214", "0.61464286", "0.61457473", "0.6136115", "0.6107888", "0.6003156", "0.5911297", "0.5861905", "0.58498603", "0.5823983", "0.5804221", "0.57927185", "0.5776159", "0.57722896", "0.57550913", "0.5751468", "0.5738864", "0.5738205", "0.5695127", "0.5688785", "0.56838906", "0.56628543", "0.565714", "0.5655057", "0.56524265", "0.5636122", "0.5626879", "0.56168646", "0.5615074", "0.56031585", "0.5599801", "0.55801916", "0.55688274", "0.5551541", "0.55380213", "0.55349624", "0.5519698", "0.5501307", "0.5500241", "0.5489924", "0.54856795", "0.5479782", "0.54743665", "0.54693335", "0.5466502", "0.5464877", "0.5461829", "0.5460981", "0.54348177", "0.54348177", "0.5420755", "0.54197764", "0.54086554", "0.54026866", "0.5400538", "0.53853816", "0.5377291", "0.5377221", "0.5372969", "0.53725195", "0.53710693", "0.53647655", "0.5363626", "0.5362622", "0.53471136", "0.5346116", "0.53434306", "0.5343305", "0.5342906", "0.5340399", "0.5333434", "0.533328", "0.533328", "0.53188676", "0.5317353", "0.531699", "0.5304414", "0.52939045", "0.52883375", "0.52833027", "0.5281746", "0.528054", "0.5280203", "0.5279044", "0.5267342", "0.52671885", "0.52579254", "0.5251905", "0.5249141", "0.52483857", "0.5225404", "0.5224112", "0.5223122" ]
0.7778235
0
WithPrevious adds the previous to the artifact lister partial content response
func (o *ArtifactListerPartialContent) WithPrevious(previous string) *ArtifactListerPartialContent { o.Previous = previous return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) WithPrevious(previous string) *ArtifactListerOK {\n\to.Previous = previous\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetPrevious(previous string) {\n\to.Previous = previous\n}", "func (o *ArtifactListerOK) SetPrevious(previous string) {\n\to.Previous = previous\n}", "func (c *Client) PlaylistPrevious() error {\n\t_, err := c.Exec(\"playlist-prev\", \"weak\")\n\treturn err\n}", "func (applications *Applications) Previous() (*Result, error) {\n\tif applications.PreviousURL != \"\" {\n\t\tbody, err := applications.getCursor(applications.PreviousURL)\n\t\tif err != nil {\n\t\t\tresult := &Result{}\n\t\t\tjson.Unmarshal(body, result)\n\t\t\treturn result, err\n\t\t}\n\t\treturn nil, nil\n\t}\n\treturn nil, errors.New(\"previous cursor not available\")\n}", "func (obj *MessengerCloudFsFileInfoList) Prev() *MessengerCloudFsFileInfoList {\n\tproxyResult := /*pr4*/ C.vssq_messenger_cloud_fs_file_info_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewMessengerCloudFsFileInfoListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (h *HandlersApp01sqVendor) ListPrev(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tvar offset int\n\tvar begin int\n\tvar cTable int\n\n\tlog.Printf(\"hndlrVendor.ListPrev(%s, %s)\\n\", r.Method, r.FormValue(\"offset\"))\n\n\tif r.Method != \"GET\" {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListPrev(Error:405) - Not GET\\n\")\n\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Calculate the offset.\n\tcTable, err = h.db.TableCount()\n\tif err != nil {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListLast(Error:400) - %s\\n\", util.ErrorString(err))\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t}\n\tbegin, _ = strconv.Atoi(r.FormValue(\"offset\"))\n\toffset = begin - h.rowsPerPage\n\tif offset < 0 {\n\t\tif begin > 0 {\n\t\t\toffset = 0\n\t\t} else {\n\t\t\toffset = cTable - h.rowsPerPage\n\t\t\tif offset < 0 {\n\t\t\t\toffset = 0\n\t\t\t}\n\t\t}\n\t}\n\n\t// Display the row in the form.\n\th.ListShow(w, offset, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.ListPrev()\\n\")\n\n}", "func NextPrev(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Received Request: /MediaControls\")\n\taction := strings.TrimPrefix(r.URL.Path, \"/MediaControls/\")\n\tfmt.Println(\"Action:\", action)\n\n\tvar URL *url.URL\n\tURL, err := url.Parse(\"https://api.spotify.com\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tURL.Path += \"/v1/me/player\"\n\n\tclient := &http.Client{}\n\n\tswitch action {\n\tcase \"Next\":\n\t\tURL.Path += \"/next\"\n\tcase \"Previous\":\n\t\tURL.Path += \"/previous\"\n\t}\n\n\treq, err := http.NewRequest(\"POST\", URL.String(), nil)\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", \"Bearer \"+sAcsTok.AccessToken)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_, err = client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n}", "func (r Response) Prev() Command {\n\treturn Command{\n\t\tJID: r.IQ.From,\n\t\tSID: r.SID,\n\t\tNode: r.Node,\n\t\tAction: \"prev\",\n\t}\n}", "func (ref *UIElement) PreviousContents() []*UIElement {\n\treturn ref.SliceOfUIElementAttr(PreviousContentsAttribute)\n}", "func (h *History) Previous() {\n\tload := h.Load()\n\n\tif len(load) <= 1 {\n\t\tfmt.Println(\"history empty\")\n\t\tos.Exit(0)\n\t}\n\n\titem := make([]string, 1)\n\tcopy(item, load[len(load)-2:len(load)-1])\n\n\tprompt := promptui.Select{\n\t\tLabel: \"Prvious\",\n\t\tItems: item,\n\t}\n\n\t_, result, err := prompt.Run()\n\n\tif err != nil {\n\t\tlog.Fatalln(\"Prompt failed: \\n\", err)\n\t}\n\th.Write(result)\n\tExecuteItem(h.binary, result)\n}", "func WithPrev(prev *url.URL) Opt {\n\treturn func(opts *Options) {\n\t\topts.Prev = prev\n\t}\n}", "func (it *Iterator) Prev() {\n\tit.listIter.Prev()\n}", "func (it *insertIterator) previous() *types.Header {\n\tif it.index < 1 {\n\t\treturn nil\n\t}\n\treturn it.chain[it.index-1].Header()\n}", "func (app *folderNameBuilder) IsPrevious() FolderNameBuilder {\n\tapp.isPrevious = true\n\treturn app\n}", "func (a *Art) SavePrevious(b *Buf) {\n\tif a.Page.AnsSave == \"on\" {\n\t\tb.ArrStr1 = append(append(b.ArrStr1, \" \"), a.Page.AnsWeb...)\n\t\tb.ArrStr2 = append(append(b.ArrStr2, \" \"), a.Page.AnsFile...)\n\t}\n\ta.Page.AnsWeb = b.ArrStr1\n\ta.Page.AnsFile = b.ArrStr2\n}", "func (as appendStrategy) previous() error {\n\treturn as.previousErr\n}", "func (e *RepoEntity) PreviousRemote() error {\n\te.Remote = e.Remotes[(len(e.Remotes)+e.currentRemoteIndex()-1)%len(e.Remotes)]\n\te.Remote.SyncBranches(e.Branch.Name)\n\treturn e.Publish(RepositoryUpdated, nil)\n}", "func (k *KVAsset) PreviousPayload() (*protobuffer.PBKVAsset, error) {\n\tif k == nil {\n\t\treturn nil, errors.New(\"KVAsset is nil\")\n\t}\n\tif k.CurrentAsset.Asset == nil {\n\t\treturn nil, errors.New(\"KVAsset has no asset\")\n\t}\n\tsignatureAsset := k.PreviousAsset.Asset\n\tkv := signatureAsset.GetKVAsset()\n\treturn kv, nil\n}", "func (chunk *ResultNodeListChunk) Prev() *ResultNodeListChunk {\n\treturn chunk.prev\n}", "func (_p *ArticlePage) Previous() ([]Article, error) {\n\tif _p.PageNum == 0 {\n\t\treturn nil, errors.New(\"This's the first page, no previous page yet\")\n\t}\n\tif _, exist := _p.Order[\"id\"]; !exist {\n\t\treturn nil, errors.New(\"No id order specified in Order map\")\n\t}\n\terr := _p.buildPageCount()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Calculate page count error: %v\", err)\n\t}\n\tif _p.orderStr == \"\" {\n\t\t_p.buildOrder()\n\t}\n\tidStr, idParams := _p.buildIdRestrict(\"previous\")\n\twhereStr := fmt.Sprintf(\"%s %s %s LIMIT %v\", _p.WhereString, idStr, _p.orderStr, _p.PerPage)\n\twhereParams := []interface{}{}\n\twhereParams = append(append(whereParams, _p.WhereParams...), idParams...)\n\tarticles, err := FindArticlesWhere(whereStr, whereParams...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(articles) != 0 {\n\t\t_p.FirstId, _p.LastId = articles[0].Id, articles[len(articles)-1].Id\n\t}\n\t_p.PageNum -= 1\n\treturn articles, nil\n}", "func UsePreviousTemplate(params *cfn.UpdateStackInput) {\n\tparams.UsePreviousTemplate = aws.Bool(true)\n}", "func (c *CompletionManager) Previous() {\n\tif c.verticalScroll == c.selected && c.selected > 0 {\n\t\tc.verticalScroll--\n\t}\n\tc.selected--\n\tc.update()\n}", "func (w *Window) Previous() error {\n\trawurl, err := w.history.Previous()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar u *url.URL\n\tif u, err = url.Parse(rawurl); err != nil {\n\t\treturn err\n\t}\n\treturn w.load(u)\n}", "func getPreviousDeployment(ctx context.Context, clientset kubernetes.Interface, controllerResource *piraeusv1.LinstorController, log logr.Logger) (string, error) {\n\tlog = log.WithValues(\n\t\t\"name\", controllerResource.Name,\n\t\t\"namespace\", controllerResource.Namespace,\n\t)\n\n\tmeta := getObjectMeta(controllerResource, \"%s-controller\")\n\n\tlog.V(DEBUG).Info(\"fetching existing deployment\", \"meta\", meta)\n\n\tdeployment, err := clientset.AppsV1().Deployments(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})\n\tif err != nil && !errors.IsNotFound(err) {\n\t\treturn \"\", fmt.Errorf(\"failed to check on existing deployment: %w\", err)\n\t}\n\n\tif deployment == nil {\n\t\tlog.V(DEBUG).Info(\"no deployment found, previous deployment unknown\")\n\n\t\treturn \"unknown\", nil\n\t}\n\n\tlog.V(DEBUG).Info(\"got deployment\")\n\n\tcontainers := deployment.Spec.Template.Spec.Containers\n\n\tfor i := range containers {\n\t\tif containers[i].Name == \"linstor-controller\" {\n\t\t\treturn containers[i].Image, nil\n\t\t}\n\t}\n\n\treturn \"\", nil\n}", "func (w *ListWidget) GoBack() {\n\teventing.Publish(\"list.prenavigate\", \"GOBACK\")\n\n\tif w.filterString != \"\" {\n\t\t// initial Back action is to clear filter, subsequent Back actions are normal\n\t\tw.ClearFilter()\n\t\treturn\n\t}\n\tpreviousPage := w.navStack.Pop()\n\tif previousPage == nil {\n\t\teventing.Publish(\"list.navigated\", ListNavigatedEventState{Success: false})\n\t\treturn\n\t}\n\tw.contentView.SetContent(previousPage.ExpandedNodeItem, previousPage.Data, previousPage.DataType, \"Response\")\n\tw.selected = 0\n\tw.items = previousPage.Value\n\tw.title = previousPage.Title\n\tw.selected = previousPage.Selection\n\tw.expandedNodeItem = previousPage.ExpandedNodeItem\n\n\teventing.Publish(\"list.navigated\", ListNavigatedEventState{\n\t\tSuccess: true,\n\t\tNewNodes: w.items,\n\t\tParentNodeID: w.expandedNodeItem.Parentid,\n\t\tIsBack: true,\n\t})\n}", "func (p *PodsWidget) SelectPrev() {\n\tp.ScrollUp()\n}", "func (m *Mutation) SetPrevious(oldValueRevision uint64, oldValue []byte, copyPrevious bool) error {\n\tprevSignedEntry, err := FromLeafValue(oldValue)\n\tif err != nil {\n\t\treturn err\n\t}\n\tm.prevRev = oldValueRevision\n\tm.prevSignedEntry = prevSignedEntry\n\n\thash := sha256.Sum256(prevSignedEntry.GetEntry())\n\tm.entry.Previous = hash[:]\n\n\tvar prevEntry pb.Entry\n\tif err := proto.Unmarshal(prevSignedEntry.GetEntry(), &prevEntry); err != nil {\n\t\treturn err\n\t}\n\tif copyPrevious {\n\t\tm.entry.AuthorizedKeyset = prevEntry.GetAuthorizedKeyset()\n\t\tm.entry.Commitment = prevEntry.GetCommitment()\n\t}\n\treturn nil\n}", "func (h *HandlersApp01sqVendor) RowPrev(w http.ResponseWriter, r *http.Request) {\n\tvar rcd App01sqVendor.App01sqVendor\n\tvar err error\n\tvar i int\n\tvar key string\n\n\tlog.Printf(\"hndlrVendor.RowPrev(%s)\\n\", r.Method)\n\n\tif r.Method != \"GET\" {\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Get the prior key(s).\n\ti = 0\n\tkey = r.FormValue(fmt.Sprintf(\"key%d\", i))\n\trcd.Id, _ = strconv.ParseInt(key, 0, 64)\n\n\ti++\n\n\t// Get the next row and display it.\n\terr = h.db.RowPrev(&rcd)\n\tif err != nil {\n\n\t\tlog.Printf(\"...end Vendor.RowNext(Error:400) - No Key\\n\")\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t\treturn\n\t}\n\th.RowDisplay(w, &rcd, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.RowPrev()\\n\")\n\n}", "func UnmarshalPaginatedCollectionPrevious(m map[string]json.RawMessage, result interface{}) (err error) {\n\tobj := new(PaginatedCollectionPrevious)\n\terr = core.UnmarshalPrimitive(m, \"href\", &obj.Href)\n\tif err != nil {\n\t\treturn\n\t}\n\treflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))\n\treturn\n}", "func (r *versionResolver) PreviousVersion(ctx context.Context, obj *restModel.APIVersion) (*restModel.APIVersion, error) {\n\tif !obj.IsPatchRequester() {\n\t\tpreviousVersion, err := model.VersionFindOne(model.VersionByProjectIdAndOrder(utility.FromStringPtr(obj.Project), obj.Order-1))\n\t\tif err != nil {\n\t\t\treturn nil, InternalServerError.Send(ctx, fmt.Sprintf(\"Error finding previous version for '%s': %s\", *obj.Id, err.Error()))\n\t\t}\n\t\tif previousVersion == nil {\n\t\t\treturn nil, nil\n\t\t}\n\t\tapiVersion := restModel.APIVersion{}\n\t\tapiVersion.BuildFromService(*previousVersion)\n\t\treturn &apiVersion, nil\n\t} else {\n\t\treturn nil, nil\n\t}\n}", "func (iter *SliceIterator) Prev() iterator.ConstBidIterator {\n\tif iter.position >= 0 {\n\t\titer.position--\n\t}\n\treturn iter\n}", "func (m *MockRepository) Previous(arg0 []bigmapdiff.BigMapDiff, arg1 int64, arg2 string) ([]bigmapdiff.BigMapDiff, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Previous\", arg0, arg1, arg2)\n\tret0, _ := ret[0].([]bigmapdiff.BigMapDiff)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (s Shop) GetPreviousNamesAsString() (result string) {\n\tif len(s.PreviousNames) > 0 {\n\t\tresult = strings.Join(s.PreviousNames, \",\")\n\t}\n\treturn\n}", "func (tm *Term) FilesPrev() error {\n\tnf := len(TheFiles)\n\ttm.FileSt = ints.MaxInt(tm.FileSt-1, 0)\n\ttm.FileSt = ints.MinInt(tm.FileSt, nf-tm.NFiles)\n\treturn tm.Draw()\n}", "func (h *History) Older(buf *Buffer) (new *Buffer, changed bool) {\n\tif len(h.tmp) == 1 || h.selected == 0 {\n\t\treturn buf, false\n\t}\n\th.tmp[h.selected] = buf.Text()\n\n\th.selected--\n\tnew = NewBuffer()\n\tnew.InsertText(h.tmp[h.selected], false, true)\n\treturn new, true\n}", "func (eb EBlock) Prev() EBlock {\n\tif eb.IsFirst() {\n\t\treturn eb\n\t}\n\treturn EBlock{ChainID: eb.ChainID, KeyMR: eb.PrevKeyMR}\n}", "func (folderWatcher *FolderWatcher) getPreviousEntryList() []string {\n\treturn folderWatcher.previousEntries\n}", "func (c *Collection) SetPrevSpec(s types.Spec) {\n\tc.writeTxn(func() error {\n\t\tcopy := s\n\t\tc.previous = &copy\n\t\treturn nil\n\t})\n}", "func (p *Player) Previous() { p.Player.Call(INTERFACE+\".Player.Previous\", 0) }", "func (obj *KeyHandlerList) Prev() *KeyHandlerList {\n\tproxyResult := /*pr4*/ C.vssc_key_handler_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewKeyHandlerListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (l *Linenoise) historyPrev(ls *linestate) string {\n\tif len(l.history) == 0 {\n\t\treturn \"\"\n\t}\n\t// update the current history entry with the line buffer\n\tl.historySet(ls.historyIndex, ls.String())\n\tls.historyIndex++\n\t// previous history item\n\tif ls.historyIndex >= len(l.history) {\n\t\tls.historyIndex = len(l.history) - 1\n\t}\n\treturn l.historyGet(ls.historyIndex)\n}", "func (player *Player) Previous() {\n\tplayer.obj.Call(\"org.mpris.MediaPlayer2.Player.Previous\", 0)\n}", "func (gui *Gui) sideViewsPreviousItem(g *gocui.Gui, v *gocui.View) error {\n\tvar err error\n\te := gui.getSelectedRepository()\n\tswitch viewName := v.Name(); viewName {\n\tcase remoteBranchViewFeature.Name:\n\t\treturn e.Remote.PreviousRemoteBranch(e)\n\tcase remoteViewFeature.Name:\n\t\treturn e.PreviousRemote()\n\tcase branchViewFeature.Name:\n\t\tif err = e.Checkout(e.PreviousBranch()); err != nil {\n\t\t\terr = gui.openErrorView(g, err.Error(),\n\t\t\t\t\"You should manually resolve this issue\",\n\t\t\t\tbranchViewFeature.Name)\n\t\t\treturn err\n\t\t}\n\tcase commitViewFeature.Name:\n\t\te.PreviousCommit()\n\t\treturn gui.renderCommits(e)\n\t}\n\treturn err\n}", "func (i *Item) Prev() *Item {\n\treturn i.prev\n}", "func (m *Menu) SelectPrev() {\n\tm.selected--\n\n\tif m.selected < 0 {\n\t\tm.selected = len(m.items) - 1\n\t}\n\n\tm.updateVisibility()\n}", "func (pagedList *PagedList) GetPreviousPage() (*Embed, error) {\n\treturn pagedList.GetPage(pagedList.PageNumber - 1)\n}", "func (obj *MessengerCloudFsFileInfoList) HasPrev() bool {\n\tproxyResult := /*pr4*/ C.vssq_messenger_cloud_fs_file_info_list_has_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn bool(proxyResult) /* r9 */\n}", "func (wr *WatchList) Prev() (w *Watch) {\n\tif wr.current != nil {\n\t\twr.current = wr.current.Prev\n\t}\n\tw = wr.current\n\treturn\n}", "func (el *Element) MustPrevious() *Element {\n\tparent, err := el.Previous()\n\tel.e(err)\n\treturn parent\n}", "func (cycle *Cycle) Prev() {\n\tif !cycle.showing {\n\t\treturn\n\t}\n\n\tif cycle.selected == -1 {\n\t\tcycle.selected = len(cycle.items) - 1\n\t} else {\n\t\tcycle.selected--\n\t}\n\n\tcycle.selected = misc.Mod(cycle.selected, len(cycle.items))\n\tcycle.highlight()\n}", "func responderArtifact206(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerPartialContent) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\n\tresponder = artifacts.NewArtifactListerPartialContent()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tresponder.SetRemainingRecords(listInfo.RemainingRecords)\n\n\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\tartifactListerURL.After = &tmp\n\n\tif defaultPageLimit != paginator.Limit {\n\t\ttmp := paginator.Limit\n\t\tartifactListerURL.Limit = &tmp\n\t}\n\tresponder.SetNext(artifactListerURL.String())\n\n\tif paginator.ID != 0 { //... and not the first\n\t\t//paginator.ID is from query parameter not artifactmanager\n\t\tvar artifactListerURL artifacts.ArtifactListerURL\n\t\ttmp = artifactInfoReturned[0].ID\n\t\tartifactListerURL.Before = &tmp\n\t\tif defaultPageLimit != paginator.Limit {\n\t\t\ttmp := paginator.Limit\n\t\t\tartifactListerURL.Limit = &tmp\n\t\t}\n\t\tresponder.SetPrevious(artifactListerURL.String())\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (resp *PharosResponse) HasPreviousPage() bool {\n\treturn resp.Previous != nil && *resp.Previous != \"\"\n}", "func (r *Raft) setPreviousLog(req *pb.AppendEntriesRequest, nextIndex uint64) error {\n\t// Guard for the first index, since there is no 0 log entry\n\t// Guard against the previous index being a snapshot as well\n\tlastSnapIdx, lastSnapTerm := r.getLastSnapshot()\n\tif nextIndex == 1 {\n\t\treq.PrevLogIndex = 0\n\t\treq.PrevLogTerm = 0\n\t} else if (nextIndex - 1) == lastSnapIdx {\n\t\treq.PrevLogIndex = lastSnapIdx\n\t\treq.PrevLogTerm = lastSnapTerm\n\t} else {\n\t\tvar l pb.Log\n\t\tif err := r.logs.GetLog(nextIndex-1, &l); err != nil {\n\t\t\tklog.Errorf(fmt.Sprintf(\"failed to get log index:%d err:%v\", nextIndex-1, err))\n\t\t\treturn err\n\t\t}\n\n\t\t// Set the previous index and term (0 if nextIndex is 1)\n\t\treq.PrevLogIndex = l.Index\n\t\treq.PrevLogTerm = l.Term\n\t}\n\treturn nil\n}", "func (o *ArtifactListerPartialContent) WithNext(next string) *ArtifactListerPartialContent {\n\to.Next = next\n\treturn o\n}", "func (builder *Builder) PreviousLine(n uint) *Builder {\n\treturn builder.With(PreviousLine(n))\n}", "func WithPreviousImage(imageName string) ImageOption {\n\treturn func(opts *options) error {\n\t\topts.prevImageRepoName = imageName\n\t\treturn nil\n\t}\n}", "func (eb EBlock) GetAllPrev(c *Client) ([]EBlock, error) {\n\tebs := []EBlock{eb}\n\tfor ; !ebs[0].IsFirst(); ebs = append([]EBlock{ebs[0].Prev()}, ebs...) {\n\t\tif err := ebs[0].Get(c); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn ebs, nil\n}", "func WithPreviousImage(imageName string) ImageOption {\n\treturn func(i *options) error {\n\t\ti.prevImageRepoName = imageName\n\t\treturn nil\n\t}\n}", "func (i Item) Prev() *Item {\n\treturn i.prev\n}", "func (r ApiGetHyperflexFeatureLimitExternalListRequest) Skip(skip int32) ApiGetHyperflexFeatureLimitExternalListRequest {\n\tr.skip = &skip\n\treturn r\n}", "func (this ActivityStreamsImagePropertyIterator) Prev() vocab.ActivityStreamsImagePropertyIterator {\n\tif this.myIdx-1 < 0 {\n\t\treturn nil\n\t} else {\n\t\treturn this.parent.At(this.myIdx - 1)\n\t}\n}", "func (a *API) SetWidgetStatusCueListPrev(id int) error {\n\treturn a.setWidgetStatus(id, \"PREV\")\n}", "func (w *ScrollWidget) PreviousPage() error {\n\tif w.view != nil {\n\t\t_, sy := w.view.Size()\n\t\terr := MoveLines(w.view, w.current, w.max, -sy)\n\t\tw.current = GetLine(w.view)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Collection) GetPrevSpec() (s *types.Spec) {\n\tc.readTxn(func() error {\n\t\ts = c.previous\n\t\treturn nil\n\t})\n\treturn\n}", "func MessagePrevious(vm *VM, target, locals Interface, msg *Message) Interface {\n\tm := target.(*Message)\n\tif m.Prev == nil {\n\t\treturn vm.Nil\n\t}\n\treturn m.Prev\n}", "func (it *KeyAccess_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func (it *Skip_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func (o *ArtifactListerOK) WithNext(next string) *ArtifactListerOK {\n\to.Next = next\n\treturn o\n}", "func (s *State) FocusPrevious() {\n\ts.focused = s.lastFocusable\n\ts.update = true\n}", "func (l *List) AwayPrev() *Element {\n\treturn l.root.AwayPrev()\n}", "func (nuo *NodeUpdateOne) ClearPrev() *NodeUpdateOne {\n\tnuo.clearedPrev = true\n\treturn nuo\n}", "func fetchPreviousBackups(\n\tctx context.Context,\n\tuser security.SQLUsername,\n\tmakeCloudStorage cloud.ExternalStorageFromURIFactory,\n\tprevBackupURIs []string,\n\tencryptionParams backupEncryptionParams,\n) ([]BackupManifest, *jobspb.BackupEncryptionOptions, error) {\n\tif len(prevBackupURIs) == 0 {\n\t\treturn nil, nil, nil\n\t}\n\n\tbaseBackup := prevBackupURIs[0]\n\tencryptionOptions, err := getEncryptionFromBase(ctx, user, makeCloudStorage, baseBackup,\n\t\tencryptionParams)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tprevBackups, err := getBackupManifests(ctx, user, makeCloudStorage, prevBackupURIs,\n\t\tencryptionOptions)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn prevBackups, encryptionOptions, nil\n}", "func (o OffsetPaginator) Prev() OffsetPaginator {\n\tprev := o\n\tprev.Offset = 0\n\tif prev.Offset > prev.Limit {\n\t\tprev.Offset = prev.Offset - prev.Limit\n\t}\n\treturn prev\n}", "func (nu *NodeUpdate) ClearPrev() *NodeUpdate {\n\tnu.clearedPrev = true\n\treturn nu\n}", "func (r ApiListImagesRequest) History(history bool) ApiListImagesRequest {\n\tr.history = &history\n\treturn r\n}", "func (page *Page) buildPrevNextLinks(recentList *PagesSlice) {\n\tfoundPage := false\n\n\tnextPage := Page{}\n\tprevPage := Page{}\n\tnextPageCat := Page{}\n\tprevPageCat := Page{}\n\tlastPageCat := Page{}\n\n\tfor i, rp := range *recentList {\n\t\tif rp.Category == page.Category {\n\t\t\tif foundPage {\n\t\t\t\tprevPageCat = rp\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif rp.Title == page.Title {\n\t\t\tfoundPage = true\n\t\t\tnextPageCat = lastPageCat\n\t\t\tif i != 0 {\n\t\t\t\tnextPage = recentList.Get(i - 1)\n\t\t\t}\n\t\t\tif i+1 < recentList.Len() {\n\t\t\t\tprevPage = recentList.Get(i + 1)\n\t\t\t}\n\t\t}\n\n\t\tif rp.Category == page.Category {\n\t\t\tlastPageCat = rp // previous page\n\t\t}\n\t}\n\n\tpage.NextUrl = nextPage.Url\n\tpage.NextTitle = nextPage.Title\n\tpage.PrevUrl = prevPage.Url\n\tpage.PrevTitle = prevPage.Title\n\n\tpage.NextCatUrl = nextPageCat.Url\n\tpage.NextCatTitle = nextPageCat.Title\n\tpage.PrevCatUrl = prevPageCat.Url\n\tpage.PrevCatTitle = prevPageCat.Title\n}", "func (e *Element) ForEachPrev(f func(*Element)) {\n\tfor i := e.prev; i != e; i = i.prev {\n\t\tif i.list == nil || i != &e.list.root {\n\t\t\tf(i)\n\t\t}\n\t}\n}", "func (w *ScrollWidget) PreviousLine() error {\n\terr := MoveLines(w.view, w.current, w.max, -1)\n\tw.current = GetLine(w.view)\n\treturn err\n}", "func (*CMsgDraftTrivia_PreviousResult) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{385, 2}\n}", "func (s *Select) GetPrevious(qe QueryExecer, dst interface{}, cursor string) error {\n\tif err := s.setCursor(cursor); err != nil {\n\t\treturn err\n\t}\n\ts.offset -= s.limit\n\tquery, args := s.Query()\n\trow := qe.QueryRow(query, args...)\n\terr := scanWithReflection(s.t.Fields(), row, dst)\n\treturn err\n}", "func (iter *ListIterator) Prev() iterator.ConstBidIterator {\n\tif iter.node != nil {\n\t\titer.node = iter.node.Prev()\n\t}\n\treturn iter\n}", "func (l *List) Prepend(i interface{}) {\n\tl = GetHead(l)\n\tl.prev = &List{next: l, value: i}\n}", "func (nu *NodeUpdate) SetPrev(n *Node) *NodeUpdate {\n\treturn nu.SetPrevID(n.ID)\n}", "func (c *Counter) UpdatePrev() {\n\tc.prev = c.cur\n\tc.prevBytes = c.curBytes\n\tc.prevActiveSecs = c.curActiveSecs\n\tc.t = time.Now()\n}", "func (c *Comic) PrevComic() error {\n\tc.num, _ = strconv.Atoi(strings.ReplaceAll(c.PrevText(), \"/\", \"\"))\n\tresp, err := soup.Get(c.URL())\n\tdoc := soup.HTMLParse(resp)\n\tif err != nil {\n\t\treturn errNoInternet\n\t}\n\n\tc.html = doc\n\treturn nil\n}", "func (r ApiGetHyperflexConfigResultEntryListRequest) Skip(skip int32) ApiGetHyperflexConfigResultEntryListRequest {\n\tr.skip = &skip\n\treturn r\n}", "func addPrevEventsToEvent(\n\tbuilder *gomatrixserverlib.ProtoEvent,\n\teventsNeeded *gomatrixserverlib.StateNeeded,\n\tqueryRes *api.QueryLatestEventsAndStateResponse,\n) error {\n\tif !queryRes.RoomExists {\n\t\treturn ErrRoomNoExists{}\n\t}\n\n\tbuilder.Depth = queryRes.Depth\n\n\tauthEvents := gomatrixserverlib.NewAuthEvents(nil)\n\n\tfor i := range queryRes.StateEvents {\n\t\terr := authEvents.AddEvent(queryRes.StateEvents[i].PDU)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"authEvents.AddEvent: %w\", err)\n\t\t}\n\t}\n\n\trefs, err := eventsNeeded.AuthEventReferences(&authEvents)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"eventsNeeded.AuthEventReferences: %w\", err)\n\t}\n\n\tbuilder.AuthEvents, builder.PrevEvents = truncateAuthAndPrevEvents(refs, queryRes.LatestEvents)\n\n\treturn nil\n}", "func (i treapIter) prev() treapIter {\n\ti.t = i.t.pred(i.f)\n\treturn i\n}", "func (resp *BytesWatchPutResp) GetPrevValue() []byte {\n\treturn resp.prevValue\n}", "func (e MoveObjectPreviousResponseValidationError) Reason() string { return e.reason }", "func (nuo *NodeUpdateOne) SetPrev(n *Node) *NodeUpdateOne {\n\treturn nuo.SetPrevID(n.ID)\n}", "func (m *Model) PrevPage() {\n\tif m.Page > 0 {\n\t\tm.Page--\n\t}\n}", "func (r PulseList) PrevPageOptions() (*ListOptions, error) {\n\tif r.PrevPageString == nil {\n\t\treturn nil, ErrNoPage\n\t}\n\topts, err := parseListOptions(*r.PrevPageString)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn opts, nil\n}", "func (r ApiGetHyperflexVolumeListRequest) Skip(skip int32) ApiGetHyperflexVolumeListRequest {\n\tr.skip = &skip\n\treturn r\n}", "func (l *List) ForEachPrev(f func(*Element)) {\n\tfor e := l.root.prev; e != &l.root; e = e.prev {\n\t\tf(e)\n\t}\n}", "func (resp *PharosResponse) ParamsForPreviousPage() url.Values {\n\tif resp.HasPreviousPage() {\n\t\tpreviousUrl, _ := url.Parse(*resp.Previous)\n\t\tif previousUrl != nil {\n\t\t\treturn previousUrl.Query()\n\t\t}\n\t}\n\treturn nil\n}", "func (li *List) selPrev(sel bool, update bool) *ListItem {\n\n\t// Check for empty list\n\tif len(li.items) == 0 {\n\t\treturn nil\n\t}\n\n\t// Find first selected item\n\tvar pos int\n\tif sel {\n\t\tpos = li.selected()\n\t} else {\n\t\tpos = li.highlighted()\n\t}\n\n\tvar newItem *ListItem\n\tnewSel := true\n\t// If no item found, returns first.\n\tif pos < 0 {\n\t\tnewItem = li.items[0].(*ListItem)\n\t\tif sel {\n\t\t\tnewItem.SetSelected(true)\n\t\t} else {\n\t\t\tnewItem.SetHighlighted(true)\n\t\t}\n\t} else {\n\t\titem := li.items[pos].(*ListItem)\n\t\tif pos == 0 {\n\t\t\tnewItem = item\n\t\t\tnewSel = false\n\t\t} else {\n\t\t\tnewItem = li.items[pos-1].(*ListItem)\n\t\t\tif sel {\n\t\t\t\titem.SetSelected(false)\n\t\t\t\tnewItem.SetSelected(true)\n\t\t\t} else {\n\t\t\t\titem.SetHighlighted(false)\n\t\t\t\tnewItem.SetHighlighted(true)\n\t\t\t}\n\t\t\tif (pos - 1) < li.first {\n\t\t\t\tli.ScrollUp()\n\t\t\t}\n\t\t}\n\t}\n\tif update {\n\t\tli.update()\n\t}\n\tif sel && newSel {\n\t\tli.Dispatch(OnChange, nil)\n\t}\n\treturn newItem\n}", "func (m Progress) AddSkipped(cont types.Container, err error) {\n\tupdate := UpdateFromContainer(cont, cont.SafeImageID(), SkippedState)\n\tupdate.error = err\n\tm.Add(update)\n}", "func (o *Links) SetPrev(v string) {\n\to.Prev = &v\n}" ]
[ "0.7339573", "0.7055601", "0.7044713", "0.5785379", "0.5747456", "0.56446016", "0.55336547", "0.55245286", "0.5484428", "0.54556274", "0.543618", "0.5434471", "0.53161204", "0.52835345", "0.5261165", "0.52551", "0.524028", "0.5193619", "0.51731586", "0.5107878", "0.50953263", "0.50805587", "0.5079868", "0.50678486", "0.5062302", "0.50545514", "0.504196", "0.5025537", "0.50091505", "0.49952328", "0.49773997", "0.49744734", "0.4972211", "0.4960209", "0.49425587", "0.49412566", "0.4938752", "0.49339157", "0.49316671", "0.49244398", "0.4914209", "0.48939085", "0.48892048", "0.488344", "0.48809657", "0.48769185", "0.48751655", "0.48355344", "0.4835483", "0.48199454", "0.48188856", "0.48091784", "0.480825", "0.48069257", "0.48032326", "0.47933048", "0.4782425", "0.47741875", "0.477176", "0.47591284", "0.47485772", "0.47230324", "0.47181836", "0.47130874", "0.46981505", "0.46885738", "0.46834567", "0.46773258", "0.46649036", "0.46568173", "0.4650476", "0.46485233", "0.46448493", "0.4640756", "0.46379068", "0.46359146", "0.4632652", "0.46254775", "0.46168274", "0.46160322", "0.46092945", "0.45977348", "0.45941702", "0.4593749", "0.458405", "0.45836848", "0.45710433", "0.45570874", "0.45531", "0.4541185", "0.4533328", "0.4524135", "0.45219597", "0.45208585", "0.45198807", "0.45028162", "0.44965613", "0.44922835", "0.44873685", "0.44846636" ]
0.76621854
0
SetPrevious sets the previous to the artifact lister partial content response
func (o *ArtifactListerPartialContent) SetPrevious(previous string) { o.Previous = previous }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) SetPrevious(previous string) {\n\to.Previous = previous\n}", "func (o *ArtifactListerPartialContent) WithPrevious(previous string) *ArtifactListerPartialContent {\n\to.Previous = previous\n\treturn o\n}", "func (o *ArtifactListerOK) WithPrevious(previous string) *ArtifactListerOK {\n\to.Previous = previous\n\treturn o\n}", "func (m *Mutation) SetPrevious(oldValueRevision uint64, oldValue []byte, copyPrevious bool) error {\n\tprevSignedEntry, err := FromLeafValue(oldValue)\n\tif err != nil {\n\t\treturn err\n\t}\n\tm.prevRev = oldValueRevision\n\tm.prevSignedEntry = prevSignedEntry\n\n\thash := sha256.Sum256(prevSignedEntry.GetEntry())\n\tm.entry.Previous = hash[:]\n\n\tvar prevEntry pb.Entry\n\tif err := proto.Unmarshal(prevSignedEntry.GetEntry(), &prevEntry); err != nil {\n\t\treturn err\n\t}\n\tif copyPrevious {\n\t\tm.entry.AuthorizedKeyset = prevEntry.GetAuthorizedKeyset()\n\t\tm.entry.Commitment = prevEntry.GetCommitment()\n\t}\n\treturn nil\n}", "func (applications *Applications) Previous() (*Result, error) {\n\tif applications.PreviousURL != \"\" {\n\t\tbody, err := applications.getCursor(applications.PreviousURL)\n\t\tif err != nil {\n\t\t\tresult := &Result{}\n\t\t\tjson.Unmarshal(body, result)\n\t\t\treturn result, err\n\t\t}\n\t\treturn nil, nil\n\t}\n\treturn nil, errors.New(\"previous cursor not available\")\n}", "func (h *History) Previous() {\n\tload := h.Load()\n\n\tif len(load) <= 1 {\n\t\tfmt.Println(\"history empty\")\n\t\tos.Exit(0)\n\t}\n\n\titem := make([]string, 1)\n\tcopy(item, load[len(load)-2:len(load)-1])\n\n\tprompt := promptui.Select{\n\t\tLabel: \"Prvious\",\n\t\tItems: item,\n\t}\n\n\t_, result, err := prompt.Run()\n\n\tif err != nil {\n\t\tlog.Fatalln(\"Prompt failed: \\n\", err)\n\t}\n\th.Write(result)\n\tExecuteItem(h.binary, result)\n}", "func (c *Client) PlaylistPrevious() error {\n\t_, err := c.Exec(\"playlist-prev\", \"weak\")\n\treturn err\n}", "func (c *Collection) SetPrevSpec(s types.Spec) {\n\tc.writeTxn(func() error {\n\t\tcopy := s\n\t\tc.previous = &copy\n\t\treturn nil\n\t})\n}", "func (r Response) Prev() Command {\n\treturn Command{\n\t\tJID: r.IQ.From,\n\t\tSID: r.SID,\n\t\tNode: r.Node,\n\t\tAction: \"prev\",\n\t}\n}", "func (e *RepoEntity) PreviousRemote() error {\n\te.Remote = e.Remotes[(len(e.Remotes)+e.currentRemoteIndex()-1)%len(e.Remotes)]\n\te.Remote.SyncBranches(e.Branch.Name)\n\treturn e.Publish(RepositoryUpdated, nil)\n}", "func (c *CompletionManager) Previous() {\n\tif c.verticalScroll == c.selected && c.selected > 0 {\n\t\tc.verticalScroll--\n\t}\n\tc.selected--\n\tc.update()\n}", "func (obj *MessengerCloudFsFileInfoList) Prev() *MessengerCloudFsFileInfoList {\n\tproxyResult := /*pr4*/ C.vssq_messenger_cloud_fs_file_info_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewMessengerCloudFsFileInfoListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (a *Art) SavePrevious(b *Buf) {\n\tif a.Page.AnsSave == \"on\" {\n\t\tb.ArrStr1 = append(append(b.ArrStr1, \" \"), a.Page.AnsWeb...)\n\t\tb.ArrStr2 = append(append(b.ArrStr2, \" \"), a.Page.AnsFile...)\n\t}\n\ta.Page.AnsWeb = b.ArrStr1\n\ta.Page.AnsFile = b.ArrStr2\n}", "func (ref *UIElement) PreviousContents() []*UIElement {\n\treturn ref.SliceOfUIElementAttr(PreviousContentsAttribute)\n}", "func (r *Raft) setPreviousLog(req *pb.AppendEntriesRequest, nextIndex uint64) error {\n\t// Guard for the first index, since there is no 0 log entry\n\t// Guard against the previous index being a snapshot as well\n\tlastSnapIdx, lastSnapTerm := r.getLastSnapshot()\n\tif nextIndex == 1 {\n\t\treq.PrevLogIndex = 0\n\t\treq.PrevLogTerm = 0\n\t} else if (nextIndex - 1) == lastSnapIdx {\n\t\treq.PrevLogIndex = lastSnapIdx\n\t\treq.PrevLogTerm = lastSnapTerm\n\t} else {\n\t\tvar l pb.Log\n\t\tif err := r.logs.GetLog(nextIndex-1, &l); err != nil {\n\t\t\tklog.Errorf(fmt.Sprintf(\"failed to get log index:%d err:%v\", nextIndex-1, err))\n\t\t\treturn err\n\t\t}\n\n\t\t// Set the previous index and term (0 if nextIndex is 1)\n\t\treq.PrevLogIndex = l.Index\n\t\treq.PrevLogTerm = l.Term\n\t}\n\treturn nil\n}", "func (player *Player) Previous() {\n\tplayer.obj.Call(\"org.mpris.MediaPlayer2.Player.Previous\", 0)\n}", "func (nu *NodeUpdate) SetPrev(n *Node) *NodeUpdate {\n\treturn nu.SetPrevID(n.ID)\n}", "func (n *Node) setPrev(newPrev shared.NodeInfo) {\n\tn.prevLock.Lock()\n\n\tn.prev = newPrev\n\n\tn.prevLock.Unlock()\n\t//Used for visulization\n\t//n.updateState()\n}", "func (it *Iterator) Prev() {\n\tit.listIter.Prev()\n}", "func (p *Player) Previous() { p.Player.Call(INTERFACE+\".Player.Previous\", 0) }", "func (w *Window) Previous() error {\n\trawurl, err := w.history.Previous()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar u *url.URL\n\tif u, err = url.Parse(rawurl); err != nil {\n\t\treturn err\n\t}\n\treturn w.load(u)\n}", "func NextPrev(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Received Request: /MediaControls\")\n\taction := strings.TrimPrefix(r.URL.Path, \"/MediaControls/\")\n\tfmt.Println(\"Action:\", action)\n\n\tvar URL *url.URL\n\tURL, err := url.Parse(\"https://api.spotify.com\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tURL.Path += \"/v1/me/player\"\n\n\tclient := &http.Client{}\n\n\tswitch action {\n\tcase \"Next\":\n\t\tURL.Path += \"/next\"\n\tcase \"Previous\":\n\t\tURL.Path += \"/previous\"\n\t}\n\n\treq, err := http.NewRequest(\"POST\", URL.String(), nil)\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", \"Bearer \"+sAcsTok.AccessToken)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_, err = client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n}", "func (k *KVAsset) PreviousPayload() (*protobuffer.PBKVAsset, error) {\n\tif k == nil {\n\t\treturn nil, errors.New(\"KVAsset is nil\")\n\t}\n\tif k.CurrentAsset.Asset == nil {\n\t\treturn nil, errors.New(\"KVAsset has no asset\")\n\t}\n\tsignatureAsset := k.PreviousAsset.Asset\n\tkv := signatureAsset.GetKVAsset()\n\treturn kv, nil\n}", "func (nuo *NodeUpdateOne) SetPrev(n *Node) *NodeUpdateOne {\n\treturn nuo.SetPrevID(n.ID)\n}", "func (m *MockRepository) Previous(arg0 []bigmapdiff.BigMapDiff, arg1 int64, arg2 string) ([]bigmapdiff.BigMapDiff, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Previous\", arg0, arg1, arg2)\n\tret0, _ := ret[0].([]bigmapdiff.BigMapDiff)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (s *State) FocusPrevious() {\n\ts.focused = s.lastFocusable\n\ts.update = true\n}", "func (m *NodeMutation) ResetPrev() {\n\tm.prev = nil\n\tm.clearedprev = false\n}", "func (_p *ArticlePage) Previous() ([]Article, error) {\n\tif _p.PageNum == 0 {\n\t\treturn nil, errors.New(\"This's the first page, no previous page yet\")\n\t}\n\tif _, exist := _p.Order[\"id\"]; !exist {\n\t\treturn nil, errors.New(\"No id order specified in Order map\")\n\t}\n\terr := _p.buildPageCount()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Calculate page count error: %v\", err)\n\t}\n\tif _p.orderStr == \"\" {\n\t\t_p.buildOrder()\n\t}\n\tidStr, idParams := _p.buildIdRestrict(\"previous\")\n\twhereStr := fmt.Sprintf(\"%s %s %s LIMIT %v\", _p.WhereString, idStr, _p.orderStr, _p.PerPage)\n\twhereParams := []interface{}{}\n\twhereParams = append(append(whereParams, _p.WhereParams...), idParams...)\n\tarticles, err := FindArticlesWhere(whereStr, whereParams...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(articles) != 0 {\n\t\t_p.FirstId, _p.LastId = articles[0].Id, articles[len(articles)-1].Id\n\t}\n\t_p.PageNum -= 1\n\treturn articles, nil\n}", "func (app *folderNameBuilder) IsPrevious() FolderNameBuilder {\n\tapp.isPrevious = true\n\treturn app\n}", "func getPreviousDeployment(ctx context.Context, clientset kubernetes.Interface, controllerResource *piraeusv1.LinstorController, log logr.Logger) (string, error) {\n\tlog = log.WithValues(\n\t\t\"name\", controllerResource.Name,\n\t\t\"namespace\", controllerResource.Namespace,\n\t)\n\n\tmeta := getObjectMeta(controllerResource, \"%s-controller\")\n\n\tlog.V(DEBUG).Info(\"fetching existing deployment\", \"meta\", meta)\n\n\tdeployment, err := clientset.AppsV1().Deployments(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})\n\tif err != nil && !errors.IsNotFound(err) {\n\t\treturn \"\", fmt.Errorf(\"failed to check on existing deployment: %w\", err)\n\t}\n\n\tif deployment == nil {\n\t\tlog.V(DEBUG).Info(\"no deployment found, previous deployment unknown\")\n\n\t\treturn \"unknown\", nil\n\t}\n\n\tlog.V(DEBUG).Info(\"got deployment\")\n\n\tcontainers := deployment.Spec.Template.Spec.Containers\n\n\tfor i := range containers {\n\t\tif containers[i].Name == \"linstor-controller\" {\n\t\t\treturn containers[i].Image, nil\n\t\t}\n\t}\n\n\treturn \"\", nil\n}", "func (chunk *ResultNodeListChunk) Prev() *ResultNodeListChunk {\n\treturn chunk.prev\n}", "func (eb EBlock) Prev() EBlock {\n\tif eb.IsFirst() {\n\t\treturn eb\n\t}\n\treturn EBlock{ChainID: eb.ChainID, KeyMR: eb.PrevKeyMR}\n}", "func (l *Linenoise) historyPrev(ls *linestate) string {\n\tif len(l.history) == 0 {\n\t\treturn \"\"\n\t}\n\t// update the current history entry with the line buffer\n\tl.historySet(ls.historyIndex, ls.String())\n\tls.historyIndex++\n\t// previous history item\n\tif ls.historyIndex >= len(l.history) {\n\t\tls.historyIndex = len(l.history) - 1\n\t}\n\treturn l.historyGet(ls.historyIndex)\n}", "func (cycle *Cycle) Prev() {\n\tif !cycle.showing {\n\t\treturn\n\t}\n\n\tif cycle.selected == -1 {\n\t\tcycle.selected = len(cycle.items) - 1\n\t} else {\n\t\tcycle.selected--\n\t}\n\n\tcycle.selected = misc.Mod(cycle.selected, len(cycle.items))\n\tcycle.highlight()\n}", "func (mc *Chain) SetPreviousBlock(r round.RoundI, b *block.Block, pb *block.Block) {\n\tb.SetPreviousBlock(pb)\n\tmc.SetRoundRank(r, b)\n\tb.ComputeChainWeight()\n}", "func (w *ListWidget) GoBack() {\n\teventing.Publish(\"list.prenavigate\", \"GOBACK\")\n\n\tif w.filterString != \"\" {\n\t\t// initial Back action is to clear filter, subsequent Back actions are normal\n\t\tw.ClearFilter()\n\t\treturn\n\t}\n\tpreviousPage := w.navStack.Pop()\n\tif previousPage == nil {\n\t\teventing.Publish(\"list.navigated\", ListNavigatedEventState{Success: false})\n\t\treturn\n\t}\n\tw.contentView.SetContent(previousPage.ExpandedNodeItem, previousPage.Data, previousPage.DataType, \"Response\")\n\tw.selected = 0\n\tw.items = previousPage.Value\n\tw.title = previousPage.Title\n\tw.selected = previousPage.Selection\n\tw.expandedNodeItem = previousPage.ExpandedNodeItem\n\n\teventing.Publish(\"list.navigated\", ListNavigatedEventState{\n\t\tSuccess: true,\n\t\tNewNodes: w.items,\n\t\tParentNodeID: w.expandedNodeItem.Parentid,\n\t\tIsBack: true,\n\t})\n}", "func (it *insertIterator) previous() *types.Header {\n\tif it.index < 1 {\n\t\treturn nil\n\t}\n\treturn it.chain[it.index-1].Header()\n}", "func (folderWatcher *FolderWatcher) getPreviousEntryList() []string {\n\treturn folderWatcher.previousEntries\n}", "func UsePreviousTemplate(params *cfn.UpdateStackInput) {\n\tparams.UsePreviousTemplate = aws.Bool(true)\n}", "func (o *Links) SetPrev(v string) {\n\to.Prev = &v\n}", "func (as appendStrategy) previous() error {\n\treturn as.previousErr\n}", "func (wr *WatchList) Prev() (w *Watch) {\n\tif wr.current != nil {\n\t\twr.current = wr.current.Prev\n\t}\n\tw = wr.current\n\treturn\n}", "func (h *HandlersApp01sqVendor) ListPrev(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tvar offset int\n\tvar begin int\n\tvar cTable int\n\n\tlog.Printf(\"hndlrVendor.ListPrev(%s, %s)\\n\", r.Method, r.FormValue(\"offset\"))\n\n\tif r.Method != \"GET\" {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListPrev(Error:405) - Not GET\\n\")\n\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Calculate the offset.\n\tcTable, err = h.db.TableCount()\n\tif err != nil {\n\n\t\tlog.Printf(\"...end hndlrVendor.ListLast(Error:400) - %s\\n\", util.ErrorString(err))\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t}\n\tbegin, _ = strconv.Atoi(r.FormValue(\"offset\"))\n\toffset = begin - h.rowsPerPage\n\tif offset < 0 {\n\t\tif begin > 0 {\n\t\t\toffset = 0\n\t\t} else {\n\t\t\toffset = cTable - h.rowsPerPage\n\t\t\tif offset < 0 {\n\t\t\t\toffset = 0\n\t\t\t}\n\t\t}\n\t}\n\n\t// Display the row in the form.\n\th.ListShow(w, offset, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.ListPrev()\\n\")\n\n}", "func (tm *Term) FilesPrev() error {\n\tnf := len(TheFiles)\n\ttm.FileSt = ints.MaxInt(tm.FileSt-1, 0)\n\ttm.FileSt = ints.MinInt(tm.FileSt, nf-tm.NFiles)\n\treturn tm.Draw()\n}", "func (c *Collection) GetPrevSpec() (s *types.Spec) {\n\tc.readTxn(func() error {\n\t\ts = c.previous\n\t\treturn nil\n\t})\n\treturn\n}", "func (player *musicPlayer) previous() (string, error) {\n\tplayer.Lock()\n\tvar songToResume string\n\tif player.state.current > 0 {\n\t\tif player.state.status == playing {\n\t\t\tplayer.stopFlow()\n\t\t}\n\t\tplayer.state.current -= 1\n\t\tsongToResume = player.state.queue[player.state.current]\n\t} else {\n\t\tplayer.Unlock()\n\t\treturn songToResume, errors.New(cannot_previous_msg)\n\t}\n\n\tplayer.Unlock()\n\tch := make(chan error)\n\tdefer close(ch)\n\tgo player.playQueue(0, ch)\n\terr := <-ch\n\n\treturn songToResume, err\n}", "func (m *Menu) SelectPrev() {\n\tm.selected--\n\n\tif m.selected < 0 {\n\t\tm.selected = len(m.items) - 1\n\t}\n\n\tm.updateVisibility()\n}", "func (el *Element) MustPrevious() *Element {\n\tparent, err := el.Previous()\n\tel.e(err)\n\treturn parent\n}", "func UnmarshalPaginatedCollectionPrevious(m map[string]json.RawMessage, result interface{}) (err error) {\n\tobj := new(PaginatedCollectionPrevious)\n\terr = core.UnmarshalPrimitive(m, \"href\", &obj.Href)\n\tif err != nil {\n\t\treturn\n\t}\n\treflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))\n\treturn\n}", "func (m *GroupPolicyDefinition) SetPreviousVersionDefinition(value GroupPolicyDefinitionable)() {\n err := m.GetBackingStore().Set(\"previousVersionDefinition\", value)\n if err != nil {\n panic(err)\n }\n}", "func (w *ScrollWidget) PreviousPage() error {\n\tif w.view != nil {\n\t\t_, sy := w.view.Size()\n\t\terr := MoveLines(w.view, w.current, w.max, -sy)\n\t\tw.current = GetLine(w.view)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (a *API) SetWidgetStatusCueListPrev(id int) error {\n\treturn a.setWidgetStatus(id, \"PREV\")\n}", "func (iter *SliceIterator) Prev() iterator.ConstBidIterator {\n\tif iter.position >= 0 {\n\t\titer.position--\n\t}\n\treturn iter\n}", "func (pagedList *PagedList) GetPreviousPage() (*Embed, error) {\n\treturn pagedList.GetPage(pagedList.PageNumber - 1)\n}", "func (r *versionResolver) PreviousVersion(ctx context.Context, obj *restModel.APIVersion) (*restModel.APIVersion, error) {\n\tif !obj.IsPatchRequester() {\n\t\tpreviousVersion, err := model.VersionFindOne(model.VersionByProjectIdAndOrder(utility.FromStringPtr(obj.Project), obj.Order-1))\n\t\tif err != nil {\n\t\t\treturn nil, InternalServerError.Send(ctx, fmt.Sprintf(\"Error finding previous version for '%s': %s\", *obj.Id, err.Error()))\n\t\t}\n\t\tif previousVersion == nil {\n\t\t\treturn nil, nil\n\t\t}\n\t\tapiVersion := restModel.APIVersion{}\n\t\tapiVersion.BuildFromService(*previousVersion)\n\t\treturn &apiVersion, nil\n\t} else {\n\t\treturn nil, nil\n\t}\n}", "func (this ActivityStreamsImagePropertyIterator) Prev() vocab.ActivityStreamsImagePropertyIterator {\n\tif this.myIdx-1 < 0 {\n\t\treturn nil\n\t} else {\n\t\treturn this.parent.At(this.myIdx - 1)\n\t}\n}", "func (p PlayerIndex) Previous(state State) PlayerIndex {\n\tif p == AdminPlayerIndex || p == ObserverPlayerIndex {\n\t\treturn p\n\t}\n\tp--\n\tif int(p) < 0 {\n\t\tp = PlayerIndex(len(state.PlayerStates()) - 1)\n\t}\n\treturn p\n}", "func (it *Skip_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func (i *Item) Prev() *Item {\n\treturn i.prev\n}", "func (resp *BytesWatchPutResp) GetPrevValue() []byte {\n\treturn resp.prevValue\n}", "func (obj *KeyHandlerList) Prev() *KeyHandlerList {\n\tproxyResult := /*pr4*/ C.vssc_key_handler_list_prev(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn NewKeyHandlerListCopy(unsafe.Pointer(proxyResult)) /* r5 */\n}", "func (c *Counter) UpdatePrev() {\n\tc.prev = c.cur\n\tc.prevBytes = c.curBytes\n\tc.prevActiveSecs = c.curActiveSecs\n\tc.t = time.Now()\n}", "func (nuo *NodeUpdateOne) ClearPrev() *NodeUpdateOne {\n\tnuo.clearedPrev = true\n\treturn nuo\n}", "func (w *ScrollWidget) PreviousLine() error {\n\terr := MoveLines(w.view, w.current, w.max, -1)\n\tw.current = GetLine(w.view)\n\treturn err\n}", "func (it *KeyAccess_Iterator) Prev() {\n\tit.list.mu.RLock()\n\tdefer it.list.mu.RUnlock()\n\n\tit.node = it.list.findLessThan(it.node.key)\n\tif it.node == it.list.head {\n\t\tit.node = nil\n\t}\n}", "func (p *PodsWidget) SelectPrev() {\n\tp.ScrollUp()\n}", "func (m *Model) PrevPage() {\n\tif m.Page > 0 {\n\t\tm.Page--\n\t}\n}", "func (nu *NodeUpdate) ClearPrev() *NodeUpdate {\n\tnu.clearedPrev = true\n\treturn nu\n}", "func (s *Select) GetPrevious(qe QueryExecer, dst interface{}, cursor string) error {\n\tif err := s.setCursor(cursor); err != nil {\n\t\treturn err\n\t}\n\ts.offset -= s.limit\n\tquery, args := s.Query()\n\trow := qe.QueryRow(query, args...)\n\terr := scanWithReflection(s.t.Fields(), row, dst)\n\treturn err\n}", "func (iter *SkipListIterator) Prev() {\n\told := iter.cursor\n\titer.cursor = C.skiplist_prev(iter.sl.csl, iter.cursor)\n\tif old != nil {\n\t\tC.skiplist_release_node(old)\n\t}\n}", "func (resp *BytesWatchDelResp) GetPrevValue() []byte {\n\treturn nil\n}", "func MessagePrevious(vm *VM, target, locals Interface, msg *Message) Interface {\n\tm := target.(*Message)\n\tif m.Prev == nil {\n\t\treturn vm.Nil\n\t}\n\treturn m.Prev\n}", "func (c *Cursor) Previous() {\n\tc.pos--\n}", "func (iter *radixIterator) Prev() {\n\tif iter.resIter == nil {\n\t\treturn\n\t}\n\tif !iter.isReverser {\n\t\titer.SeekForPrev(iter.Key())\n\t\tif iter.err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\t// for reverse iterator, prev is just next\n\titer.cursorKey, iter.cursor = iter.resIter.Next()\n}", "func (t *Table) prevPage() {\r\n\r\n\tif t.firstRow == 0 {\r\n\t\tt.rowCursor = 0\r\n\t\tt.recalc()\r\n\t\tt.Dispatch(OnChange, nil)\r\n\t\treturn\r\n\t}\r\n\tplen := t.lastRow - t.firstRow\r\n\tif plen <= 0 {\r\n\t\treturn\r\n\t}\r\n\tt.scrollUp(plen)\r\n}", "func (c *Comic) PrevComic() error {\n\tc.num, _ = strconv.Atoi(strings.ReplaceAll(c.PrevText(), \"/\", \"\"))\n\tresp, err := soup.Get(c.URL())\n\tdoc := soup.HTMLParse(resp)\n\tif err != nil {\n\t\treturn errNoInternet\n\t}\n\n\tc.html = doc\n\treturn nil\n}", "func (i treapIter) prev() treapIter {\n\ti.t = i.t.pred(i.f)\n\treturn i\n}", "func (mr *MockRepositoryMockRecorder) Previous(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Previous\", reflect.TypeOf((*MockRepository)(nil).Previous), arg0, arg1, arg2)\n}", "func (o *MovableObject) Prev() {\n\to.point.X -= o.Arrow.X\n\to.point.Y -= o.Arrow.Y\n}", "func (i Item) Prev() *Item {\n\treturn i.prev\n}", "func (e MoveObjectPreviousResponseValidationError) Reason() string { return e.reason }", "func (v *EventsWidget) SetLast(new data.Seq) {\n\tif v.last != new && v.source != nil {\n\t\tv.last = new\n\t\tv.refreshContents()\n\t}\n}", "func (m *NodeMutation) ClearPrev() {\n\tm.clearedprev = true\n}", "func (s Shop) GetPreviousNamesAsString() (result string) {\n\tif len(s.PreviousNames) > 0 {\n\t\tresult = strings.Join(s.PreviousNames, \",\")\n\t}\n\treturn\n}", "func (iter *ListIterator) Prev() iterator.ConstBidIterator {\n\tif iter.node != nil {\n\t\titer.node = iter.node.Prev()\n\t}\n\treturn iter\n}", "func (e *idElement) Prev() *idElement {\n\tif p := e.prev; e.list != nil && p != &e.list.root {\n\t\treturn p\n\t}\n\treturn nil\n}", "func (b *Build) PreviousActivated(project string, requester string) (*Build, error) {\n\treturn FindOne(ByRecentlyActivatedForProjectAndVariant(\n\t\tb.RevisionOrderNumber, project, b.BuildVariant, requester))\n}", "func (o ChangeSetOutput) UsePreviousParameters() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *ChangeSet) pulumi.BoolPtrOutput { return v.UsePreviousParameters }).(pulumi.BoolPtrOutput)\n}", "func (t *SkipList) Prev(e *SkipListElement) *SkipListElement {\n\tif e.prev == nil {\n\t\treturn t.endLevels[0]\n\t}\n\treturn e.prev\n}", "func fetchPreviousBackups(\n\tctx context.Context,\n\tuser security.SQLUsername,\n\tmakeCloudStorage cloud.ExternalStorageFromURIFactory,\n\tprevBackupURIs []string,\n\tencryptionParams backupEncryptionParams,\n) ([]BackupManifest, *jobspb.BackupEncryptionOptions, error) {\n\tif len(prevBackupURIs) == 0 {\n\t\treturn nil, nil, nil\n\t}\n\n\tbaseBackup := prevBackupURIs[0]\n\tencryptionOptions, err := getEncryptionFromBase(ctx, user, makeCloudStorage, baseBackup,\n\t\tencryptionParams)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tprevBackups, err := getBackupManifests(ctx, user, makeCloudStorage, prevBackupURIs,\n\t\tencryptionOptions)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn prevBackups, encryptionOptions, nil\n}", "func (e *Element) Prev() *Element {\n\tif e != nil && e.prev != nil {\n\t\treturn e.prev\n\t}\n\treturn nil\n}", "func (o OffsetPaginator) Prev() OffsetPaginator {\n\tprev := o\n\tprev.Offset = 0\n\tif prev.Offset > prev.Limit {\n\t\tprev.Offset = prev.Offset - prev.Limit\n\t}\n\treturn prev\n}", "func (b *MockBlock) PreviousConnection() (ret block.Connection) {\n\tif b.Prev != nil {\n\t\tret = b.Prev\n\t}\n\treturn\n}", "func (*offsetPageInfoImpl) PreviousOffset(p graphql.ResolveParams) (int, error) {\n\tpage := p.Source.(offsetPageInfo)\n\tif page.offset > 0 {\n\t\tprevOffset := page.offset - page.limit\n\t\treturn clampInt(prevOffset, 0, math.MaxInt32), nil\n\t}\n\treturn 0, nil\n}", "func (_Vault *VaultCaller) PrevVault(opts *bind.CallOpts) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Vault.contract.Call(opts, out, \"prevVault\")\n\treturn *ret0, err\n}", "func (h *HandlersApp01sqVendor) RowPrev(w http.ResponseWriter, r *http.Request) {\n\tvar rcd App01sqVendor.App01sqVendor\n\tvar err error\n\tvar i int\n\tvar key string\n\n\tlog.Printf(\"hndlrVendor.RowPrev(%s)\\n\", r.Method)\n\n\tif r.Method != \"GET\" {\n\t\thttp.Error(w, http.StatusText(405), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// Get the prior key(s).\n\ti = 0\n\tkey = r.FormValue(fmt.Sprintf(\"key%d\", i))\n\trcd.Id, _ = strconv.ParseInt(key, 0, 64)\n\n\ti++\n\n\t// Get the next row and display it.\n\terr = h.db.RowPrev(&rcd)\n\tif err != nil {\n\n\t\tlog.Printf(\"...end Vendor.RowNext(Error:400) - No Key\\n\")\n\n\t\thttp.Error(w, http.StatusText(400), http.StatusBadRequest)\n\t\treturn\n\t}\n\th.RowDisplay(w, &rcd, \"\")\n\n\tlog.Printf(\"...end hndlrVendor.RowPrev()\\n\")\n\n}", "func (lexto *LongLexto) Previous() Token {\n\tif lexto.HasPrevious() {\n\t\tresult := lexto.tokens[lexto.current]\n\t\tlexto.current -= 1\n\t\treturn result\n\t}\n\treturn Token{}\n}", "func WithPrev(prev *url.URL) Opt {\n\treturn func(opts *Options) {\n\t\topts.Prev = prev\n\t}\n}", "func (m *Mutation) EqualsPrevious(leafValue *pb.SignedEntry) bool {\n\treturn proto.Equal(leafValue, m.prevSignedEntry)\n}", "func (gui *Gui) previousPage() {\n\tcurrentPageName, _ := gui.pages.GetFrontPage()\n\tif currentPageName == \"help\" {\n\t\treturn\n\t}\n\n\tpreviousIdx := getIndex(gui.views, gui.currentLogMainView) - 1\n\tif previousIdx < 0 {\n\t\tpreviousIdx = len(gui.views) - 1\n\t}\n\n\tgui.showPage(previousIdx)\n}" ]
[ "0.7994916", "0.7187832", "0.68588996", "0.6172114", "0.61423135", "0.61087483", "0.60712993", "0.5970792", "0.5911965", "0.59103006", "0.58738756", "0.5862722", "0.58572626", "0.57138544", "0.57009304", "0.56922466", "0.5663544", "0.5663291", "0.5650287", "0.5636499", "0.563215", "0.55843633", "0.55782", "0.5576232", "0.55736077", "0.5500344", "0.5500273", "0.5436538", "0.54119956", "0.5405975", "0.53977233", "0.5395151", "0.5384756", "0.53759485", "0.5374797", "0.53590995", "0.5340213", "0.533624", "0.53199923", "0.53091705", "0.5307858", "0.53078246", "0.5296853", "0.5278591", "0.52729434", "0.5268185", "0.52629143", "0.526138", "0.52557385", "0.52505326", "0.52484167", "0.5212969", "0.5198786", "0.5196592", "0.51780814", "0.51692367", "0.5163747", "0.5146438", "0.5139846", "0.51397824", "0.5129829", "0.5126314", "0.5117371", "0.511319", "0.5106037", "0.51052713", "0.5101123", "0.5100978", "0.51002586", "0.50834554", "0.50793314", "0.507783", "0.5077375", "0.5061715", "0.505323", "0.502632", "0.50213873", "0.5015236", "0.5009635", "0.49902943", "0.49843115", "0.4982123", "0.49725744", "0.49655837", "0.4931612", "0.49248698", "0.49228716", "0.49174842", "0.4911792", "0.49026716", "0.49000233", "0.4897735", "0.48961073", "0.4887812", "0.4877381", "0.48544663", "0.48349428", "0.4826439", "0.4822702", "0.481995" ]
0.79678786
1
WithRemainingRecords adds the remainingRecords to the artifact lister partial content response
func (o *ArtifactListerPartialContent) WithRemainingRecords(remainingRecords uint64) *ArtifactListerPartialContent { o.RemainingRecords = remainingRecords return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerPartialContent) SetRemainingRecords(remainingRecords uint64) {\n\to.RemainingRecords = remainingRecords\n}", "func (o *ArtifactListerPartialContent) WithTotalRecords(totalRecords uint64) *ArtifactListerPartialContent {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Next\n\n\tnext := o.Next\n\tif next != \"\" {\n\t\trw.Header().Set(\"Next\", next)\n\t}\n\n\t// response header Previous\n\n\tprevious := o.Previous\n\tif previous != \"\" {\n\t\trw.Header().Set(\"Previous\", previous)\n\t}\n\n\t// response header RemainingRecords\n\n\tremainingRecords := swag.FormatUint64(o.RemainingRecords)\n\tif remainingRecords != \"\" {\n\t\trw.Header().Set(\"RemainingRecords\", remainingRecords)\n\t}\n\n\t// response header TotalRecords\n\n\ttotalRecords := swag.FormatUint64(o.TotalRecords)\n\tif totalRecords != \"\" {\n\t\trw.Header().Set(\"TotalRecords\", totalRecords)\n\t}\n\n\trw.WriteHeader(206)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*weles.ArtifactInfo, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *ArtifactListerOK) WithTotalRecords(totalRecords uint64) *ArtifactListerOK {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerOK) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func WithIncludeFinal(includeFinal bool) ListDealRecordsOption {\n\treturn func(c *rpc.ListDealRecordsConfig) {\n\t\tc.IncludeFinal = includeFinal\n\t}\n}", "func responderArtifact206(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerPartialContent) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\n\tresponder = artifacts.NewArtifactListerPartialContent()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tresponder.SetRemainingRecords(listInfo.RemainingRecords)\n\n\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\tartifactListerURL.After = &tmp\n\n\tif defaultPageLimit != paginator.Limit {\n\t\ttmp := paginator.Limit\n\t\tartifactListerURL.Limit = &tmp\n\t}\n\tresponder.SetNext(artifactListerURL.String())\n\n\tif paginator.ID != 0 { //... and not the first\n\t\t//paginator.ID is from query parameter not artifactmanager\n\t\tvar artifactListerURL artifacts.ArtifactListerURL\n\t\ttmp = artifactInfoReturned[0].ID\n\t\tartifactListerURL.Before = &tmp\n\t\tif defaultPageLimit != paginator.Limit {\n\t\t\ttmp := paginator.Limit\n\t\t\tartifactListerURL.Limit = &tmp\n\t\t}\n\t\tresponder.SetPrevious(artifactListerURL.String())\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (_obj *DataService) GetActivityRecords(index int32, batch int32, activity_id string, nextIndex *int32, recordList *[]ActivityRecord, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(activity_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*recordList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *recordList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\ttarsCtx := context.Background()\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getActivityRecords\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*recordList) = make([]ActivityRecord, length)\n\t\tfor i20, e20 := int32(0), length; i20 < e20; i20++ {\n\n\t\t\terr = (*recordList)[i20].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func showRemainingBalance(res http.ResponseWriter, req *http.Request) {\n\ttype balanceStruct struct {\n\t\tItem string\n\t\tQuantity float64\n\t}\n\n\tvar itemData []balanceStruct\n\n\tfor i := 0; i < len(ds.Items); i++ {\n\t\tremainingQuantity := ds.Items[i].WeeklyCapacity - ds.Items[i].WeeklyOrder\n\t\td := balanceStruct{\n\t\t\tItem: ds.Items[i].Name,\n\t\t\tQuantity: remainingQuantity}\n\t\titemData = append(itemData, d)\n\t}\n\n\terr := tpl.ExecuteTemplate(res, \"itemBalance.gohtml\", itemData)\n\tif err != nil {\n\t\thttp.Error(res, err.Error(), http.StatusBadRequest)\n\t\tlog.Error(\"Error at itemBalance template.\", err)\n\t\treturn\n\t}\n}", "func (_obj *DataService) GetActivityRecordsWithContext(tarsCtx context.Context, index int32, batch int32, activity_id string, nextIndex *int32, recordList *[]ActivityRecord, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(activity_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*recordList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *recordList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getActivityRecords\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*recordList) = make([]ActivityRecord, length)\n\t\tfor i21, e21 := int32(0), length; i21 < e21; i21++ {\n\n\t\t\terr = (*recordList)[i21].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (rs *RuleSpec) fillRemaining() {\n\tlength := len(rs.RuleParameters)\n\tfor i, rp := range rs.RuleParameters {\n\t\trp.Remaining = length - i -1\n\t}\n}", "func (*ListNSRecordsAfterVersionResponse) Descriptor() ([]byte, []int) {\n\treturn file_service_ns_record_proto_rawDescGZIP(), []int{10}\n}", "func (s *statusCollector) fillRemaining(err error) {\n\t// Amount of times certain recipient was specified is indicated by the channel\n\t// buffer size, so once we fill it, we can be confident that we sent\n\t// at least as much statuses as needed. Extra statuses will be ignored anyway.\nchLoop:\n\tfor _, ch := range s.statusMap {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase ch <- err:\n\t\t\tdefault:\n\t\t\t\tcontinue chLoop\n\t\t\t}\n\t\t}\n\t}\n}", "func (client DatasetClient) ListComplete(ctx context.Context) (result DatasetListResponseIterator, err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/DatasetClient.List\")\n defer func() {\n sc := -1\n if result.Response().Response.Response != nil {\n sc = result.page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n result.page, err = client.List(ctx)\n return\n }", "func (r *ListDNSZoneVersionRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneVersionRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (s *ContainerInstance) SetRemainingResources(v []*Resource) *ContainerInstance {\n\ts.RemainingResources = v\n\treturn s\n}", "func (o *ArtifactListerPartialContent) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerPartialContent {\n\to.Payload = payload\n\treturn o\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func RateLimitRemaining(r *http.Response) int {\n\treturn intResponseHeaderOrNegOne(r, \"X-RateLimit-Remaining\")\n}", "func outputRecordsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func WithIncludePending(includePending bool) ListDealRecordsOption {\n\treturn func(c *rpc.ListDealRecordsConfig) {\n\t\tc.IncludePending = includePending\n\t}\n}", "func TestListRecordings(t *testing.T) {\n\tif !haveArchive {\n\t\treturn\n\t}\n\n\tif testing.Verbose() && DEBUG {\n\t\tlogging.SetLevel(logging.DEBUG, \"archive\")\n\t}\n\n\trecordings, err := archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tinitial := len(recordings)\n\tt.Logf(\"Initial count is %d\", initial)\n\n\t// Add a recording\n\tsubscriptionID, err := archive.StartRecording(testCases[0].sampleChannel, testCases[0].sampleStream, true, true)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tt.Logf(\"SubscriptionID is %d\", subscriptionID)\n\n\t// Add a publication on that\n\tpublication, err := archive.AddPublication(testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif testing.Verbose() && DEBUG {\n\t\tt.Logf(\"Publication is %#v\", publication)\n\t}\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif len(recordings) == 0 {\n\t\tt.Log(\"No Recordings!\")\n\t\tt.FailNow()\n\t}\n\n\t// Grab the recordingID\n\trecordingID := recordings[len(recordings)-1].RecordingId\n\tt.Logf(\"Working count is %d, recordingID is %d\", len(recordings), recordingID)\n\n\t// Cleanup\n\tres, err := archive.StopRecordingByIdentity(recordingID)\n\tif err != nil {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed: %s\", recordingID, err.Error())\n\t} else if !res {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed\", recordingID)\n\t}\n\tif err := archive.PurgeRecording(recordingID); err != nil {\n\t\tt.Logf(\"PurgeRecording(%d) failed: %s\", recordingID, err.Error())\n\t}\n\tpublication.Close()\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tfinal := len(recordings)\n\tt.Logf(\"Final count is %d\", final)\n\n\tif initial != final {\n\t\tt.Logf(\"Number of recordings changed from %d to %d\", initial, final)\n\t\tt.Fail()\n\t}\n}", "func (sou *SubjectsOfferedUpdate) AddRemain(i int) *SubjectsOfferedUpdate {\n\tsou.mutation.AddRemain(i)\n\treturn sou\n}", "func (d *DBClient) AllRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\trecords, err := d.Cache.GetAllRequests()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordedRequests\n\t\tresponse.Data = records\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (o *ArtifactListerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Next\n\n\tnext := o.Next\n\tif next != \"\" {\n\t\trw.Header().Set(\"Next\", next)\n\t}\n\n\t// response header Previous\n\n\tprevious := o.Previous\n\tif previous != \"\" {\n\t\trw.Header().Set(\"Previous\", previous)\n\t}\n\n\t// response header TotalRecords\n\n\ttotalRecords := swag.FormatUint64(o.TotalRecords)\n\tif totalRecords != \"\" {\n\t\trw.Header().Set(\"TotalRecords\", totalRecords)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*weles.ArtifactInfo, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsCalled(int) {}", "func (souo *SubjectsOfferedUpdateOne) AddRemain(i int) *SubjectsOfferedUpdateOne {\n\tsouo.mutation.AddRemain(i)\n\treturn souo\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsReadResponseDuration(time.Duration) {}", "func (lc *localChain) AddHeadersWithRetarget(\n\toldPeriodStartHeader []uint8,\n\toldPeriodEndHeader []uint8,\n\theaders []uint8,\n) error {\n\tpanic(\"not implemented yet\")\n}", "func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\tp.mutex.Lock()\n\tdefer p.mutex.Unlock()\n\n\tclient := &http.Client{}\n\n\tvar addedRecords []libdns.Record\n\n\tfor _, record := range records {\n\t\tbody := &LeasewebRecordSet{\n\t\t\tName: record.Name,\n\t\t\tType: record.Type,\n\t\t\tContent: []string{record.Value},\n\t\t\tTTL: int(record.TTL.Seconds()),\n\t\t}\n\n\t\tbodyBuffer := new(bytes.Buffer)\n\t\tjson.NewEncoder(bodyBuffer).Encode(body)\n\n\t\treq, err := http.NewRequest(http.MethodPost, fmt.Sprintf(\"https://api.leaseweb.com/hosting/v2/domains/%s/resourceRecordSets\", zone), bodyBuffer)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treq.Header.Add(LeasewebApiKeyHeader, p.APIKey)\n\n\t\tres, err := client.Do(req)\n\t\tdefer res.Body.Close()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\t\treturn nil, fmt.Errorf(\"Received StatusCode %d from Leaseweb API\", res.StatusCode)\n\t\t}\n\n\t\taddedRecords = append(addedRecords, record)\n\t}\n\n\treturn addedRecords, nil\n}", "func (resp *DomainRecordsPagedResponse) appendData(r *DomainRecordsPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func (b *LeakyLimiter) Remaining() uint {\n\treturn b.remaining\n}", "func (*ListNSRecordsAfterVersionRequest) Descriptor() ([]byte, []int) {\n\treturn file_service_ns_record_proto_rawDescGZIP(), []int{9}\n}", "func addIncludeRecordsFlag(cmd *cobra.Command) {\n\tcmd.Flags().BoolVar(&includeRecords, \"include-records\", false, \"include records in the output\")\n}", "func (r *ListDatabaseBackupsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDatabaseBackupsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.DatabaseBackups = append(r.DatabaseBackups, results.DatabaseBackups...)\n\tr.TotalCount += uint32(len(results.DatabaseBackups))\n\treturn uint32(len(results.DatabaseBackups)), nil\n}", "func (c *Client) ResolvedRecords(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewResolvedRecordsRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}", "func responderArtifact200(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerOK) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\tresponder = artifacts.NewArtifactListerOK()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tif paginator.ID != 0 { //not the first page\n\t\t// keep in mind that ArtifactPath in paginator is taken from query parameter,\n\t\t// not ArtifactManager\n\t\tif paginator.Forward {\n\t\t\ttmp := artifactInfoReturned[0].ID\n\t\t\tartifactListerURL.Before = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp\n\t\t\t}\n\t\t\tresponder.SetPrevious(artifactListerURL.String())\n\t\t} else {\n\t\t\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\t\t\tartifactListerURL.After = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp2 := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp2\n\t\t\t}\n\t\t\tresponder.SetNext(artifactListerURL.String())\n\t\t}\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (d *DBClient) ImportRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\n\tvar requests recordedRequests\n\n\tdefer req.Body.Close()\n\tbody, err := ioutil.ReadAll(req.Body)\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tvar response messageResponse\n\n\tif err != nil {\n\t\t// failed to read response body\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Error(\"Could not read response body!\")\n\t\tresponse.Message = \"Bad request. Nothing to import!\"\n\t\thttp.Error(w, \"Failed to read request body.\", 400)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &requests)\n\n\tif err != nil {\n\t\tw.WriteHeader(422) // can't process this entity\n\t\treturn\n\t}\n\n\terr = d.ImportPayloads(requests.Data)\n\n\tif err != nil {\n\t\tresponse.Message = err.Error()\n\t\tw.WriteHeader(400)\n\t} else {\n\t\tresponse.Message = fmt.Sprintf(\"%d payloads import complete.\", len(requests.Data))\n\t}\n\n\tb, err := json.Marshal(response)\n\tw.Write(b)\n\n}", "func (c *applicationUsecaseImpl) ListRecords(ctx context.Context, appName string) (*apisv1.ListWorkflowRecordsResponse, error) {\n\tvar record = model.WorkflowRecord{\n\t\tAppPrimaryKey: appName,\n\t\tStatus: model.RevisionStatusRunning,\n\t}\n\trecords, err := c.ds.List(ctx, &record, &datastore.ListOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(records) == 0 {\n\t\trecord.Status = model.RevisionStatusComplete\n\t\trecords, err = c.ds.List(ctx, &record, &datastore.ListOptions{\n\t\t\tPage: 1,\n\t\t\tPageSize: 1,\n\t\t\tSortBy: []datastore.SortOption{{Key: \"model.createTime\", Order: datastore.SortOrderDescending}},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tresp := &apisv1.ListWorkflowRecordsResponse{\n\t\tRecords: []apisv1.WorkflowRecord{},\n\t}\n\tfor _, raw := range records {\n\t\trecord, ok := raw.(*model.WorkflowRecord)\n\t\tif ok {\n\t\t\tresp.Records = append(resp.Records, *convertFromRecordModel(record))\n\t\t}\n\t}\n\tresp.Total = int64(len(records))\n\n\treturn resp, nil\n}", "func AddShowToReponse(ctx context.Context, resp Response, image, slug, title string) Response {\n\tlogging.Startedf(ctx,\"response\", \"AddShowToResponse\",\"\")\n\ttemp := ResponseShow {Image:image,Slug:slug,Title:title}\n\tresp.Shows = append(resp.Shows, temp)\n\tlogging.Completed(ctx,\"repsonse\", \"AddShowToResponse\")\n\treturn resp\n}", "func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\treturn p.updateRecords(ctx, zone, records)\n}", "func (cl *Client) failBufferedRecords(err error) {\n\tp := &cl.producer\n\n\tfor _, partitions := range p.topics.load() {\n\t\tfor _, partition := range partitions.load().partitions {\n\t\t\trecBuf := partition.records\n\t\t\trecBuf.mu.Lock()\n\t\t\trecBuf.failAllRecords(err)\n\t\t\trecBuf.mu.Unlock()\n\t\t}\n\t}\n\n\tp.topicsMu.Lock()\n\tdefer p.topicsMu.Unlock()\n\tp.unknownTopicsMu.Lock()\n\tdefer p.unknownTopicsMu.Unlock()\n\n\ttoStore := p.topics.clone()\n\tdefer p.topics.storeData(toStore)\n\n\tvar toFail [][]promisedRec\n\tfor topic, unknown := range p.unknownTopics {\n\t\tdelete(toStore, topic)\n\t\tdelete(p.unknownTopics, topic)\n\t\tclose(unknown.wait)\n\t\ttoFail = append(toFail, unknown.buffered)\n\t}\n\n\tgo func() {\n\t\tfor _, fail := range toFail {\n\t\t\tfor _, pr := range fail {\n\t\t\t\tcl.finishRecordPromise(pr, err)\n\t\t\t}\n\t\t}\n\t}()\n}", "func (o *GetAssetsListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header X-Total-Count\n\n\txTotalCount := swag.FormatInt64(o.XTotalCount)\n\tif xTotalCount != \"\" {\n\t\trw.Header().Set(\"X-Total-Count\", xTotalCount)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.TokenAssetRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *ArtifactListerPartialContent) WithPrevious(previous string) *ArtifactListerPartialContent {\n\to.Previous = previous\n\treturn o\n}", "func (p *TBufferedReadTransport) RemainingBytes() uint64 {\n\treturn uint64(p.readBuf.Len())\n}", "func (c *MediaDownloadCall) Fields(s ...googleapi.Field) *MediaDownloadCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func (c *MediaDownloadCall) Fields(s ...googleapi.Field) *MediaDownloadCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}", "func outputRecordSpecsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordSpecificationsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordSpecificationsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (o *GetPreEnrollmentsForFacilityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.Enrollment, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (*CMsgDOTAReportsRemainingResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{10}\n}", "func (conn *Connection) GetLimitedRecords(q interface{}, n int, doc interface{}, fields ...string) error {\n\tif len(fields) == 0 {\n\t\treturn conn.collection.Find(q).Limit(n).All(doc)\n\t}\n\n\treturn conn.collection.Find(q).Sort(fields...).Limit(n).All(doc)\n}", "func (a *APIDefaults) ArtifactLister(params artifacts.ArtifactListerParams) middleware.Responder {\n\tpaginator := weles.ArtifactPagination{}\n\tif a.PageLimit != 0 {\n\t\tif (params.After != nil) && (params.Before != nil) {\n\t\t\treturn artifacts.NewArtifactListerBadRequest().WithPayload(&weles.ErrResponse{\n\t\t\t\tMessage: weles.ErrBeforeAfterNotAllowed.Error()})\n\t\t}\n\t\tpaginator = setArtifactPaginator(params, a.PageLimit)\n\t}\n\tfilter := setArtifactFilter(params.ArtifactFilterAndSort.Filter)\n\tsorter := setArtifactSorter(params.ArtifactFilterAndSort.Sorter)\n\n\tartifactInfoReceived, listInfo, err := a.Managers.AM.ListArtifact(filter, sorter, paginator)\n\n\tswitch err {\n\tdefault:\n\t\treturn artifacts.NewArtifactListerInternalServerError().WithPayload(\n\t\t\t&weles.ErrResponse{Message: err.Error()})\n\tcase weles.ErrArtifactNotFound:\n\t\treturn artifacts.NewArtifactListerNotFound().WithPayload(\n\t\t\t&weles.ErrResponse{Message: weles.ErrArtifactNotFound.Error()})\n\tcase nil:\n\t}\n\n\tartifactInfoReturned := artifactInfoReceivedToReturn(artifactInfoReceived)\n\n\tif (listInfo.RemainingRecords == 0) || (a.PageLimit == 0) { //last page...\n\t\treturn responderArtifact200(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n\t} //not last page...\n\treturn responderArtifact206(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n}", "func (resp *LongviewClientsPagedResponse) appendData(r *LongviewClientsPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func (o *GetAccountsListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header X-Total-Count\n\n\txTotalCount := swag.FormatInt64(o.XTotalCount)\n\tif xTotalCount != \"\" {\n\t\trw.Header().Set(\"X-Total-Count\", xTotalCount)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.AccountsRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (dsc *DefaultConsumerStatsCollector) UpdateGetRecordsReadResponseDuration(duration time.Duration) {\n\tdsc.GetRecordsReadResponseDuration.Update(duration.Nanoseconds())\n}", "func displayAllRecords(records []Record) {\n\tfmt.Printf(\"\\nDisplaying all records...\\n\\n\")\n\n\tfor i := 0; i < len(records); i++ {\n\t\tfmt.Printf(\"Record ID: %d: %+v\\n\", i, records[i])\n\t\ttime.Sleep(5 * time.Millisecond) // 5ms between records\n\t}\n}", "func (c *Client) FilteredRecords(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewFilteredRecordsRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}", "func (rest *Restful) getCommitted(w http.ResponseWriter, r *http.Request) {\n\n\tif rest == nil {\n\t\treturn\n\t}\n\n\tstorageCopy := rest.server.db.GetCopy()\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tvars := mux.Vars(r)\n\tlogSize := vars[\"logsize\"]\n\tlimit := DefaultLogSize\n\n\tif len(logSize) > 0 {\n\t\tif i2, err := strconv.ParseInt(logSize, 10, 64); err == nil {\n\t\t\tlimit = int(i2)\n\t\t}\n\t}\n\n\tvar resp []LogRespondEntry\n\tchunkSize := Min(len(storageCopy), limit)\n\n\tcount := 0\n\tfor k, v := range storageCopy {\n\t\tif count == chunkSize {\n\t\t\tbreak\n\t\t}\n\t\tresp = append(resp, LogRespondEntry{\n\t\t\tKey: k,\n\t\t\tValue: string(v),\n\t\t})\n\t\tcount++\n\t}\n\n\t//\n\tjs, err := json.Marshal(resp)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\trespSize, err := w.Write(js)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif respSize == 0 {\n\t\thttp.Error(w, fmt.Errorf(\"empty respond\").Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func AddItemsNoContent(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.ItemsController, payload *app.AddItemPayload) http.ResponseWriter {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\t\tresp interface{}\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\t)\n\tif service == nil {\n\t\tservice = goatest.Service(&logBuf, respSetter)\n\t} else {\n\t\tlogger := log.New(&logBuf, \"\", log.Ltime)\n\t\tservice.WithLogger(goa.NewLogger(logger))\n\t\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\t\tservice.Encoder = goa.NewHTTPEncoder() // Make sure the code ends up using this decoder\n\t\tservice.Encoder.Register(newEncoder, \"*/*\")\n\t}\n\n\t// Validate payload\n\terr := payload.Validate()\n\tif err != nil {\n\t\te, ok := err.(goa.ServiceError)\n\t\tif !ok {\n\t\t\tpanic(err) // bug\n\t\t}\n\t\tt.Errorf(\"unexpected payload validation error: %+v\", e)\n\t\treturn nil\n\t}\n\n\t// Setup request context\n\trw := httptest.NewRecorder()\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/item\"),\n\t}\n\treq, err := http.NewRequest(\"POST\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"ItemsTest\"), rw, req, prms)\n\taddCtx, err := app.NewAddItemsContext(goaCtx, req, service)\n\tif err != nil {\n\t\tpanic(\"invalid test data \" + err.Error()) // bug\n\t}\n\taddCtx.Payload = payload\n\n\t// Perform action\n\terr = ctrl.Add(addCtx)\n\n\t// Validate response\n\tif err != nil {\n\t\tt.Fatalf(\"controller returned %+v, logs:\\n%s\", err, logBuf.String())\n\t}\n\tif rw.Code != 204 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 204\", rw.Code)\n\t}\n\n\t// Return results\n\treturn rw\n}", "func outputRecords(cmd *cobra.Command, recordAddr string, scopeID string, sessionID string, name string) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq := types.RecordsRequest{\n\t\tRecordAddr: recordAddr,\n\t\tScopeId: scopeID,\n\t\tSessionId: sessionID,\n\t\tName: name,\n\t\tIncludeScope: includeScope,\n\t\tIncludeSessions: includeSessions,\n\t}\n\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.Records(context.Background(), &req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (client JobClient) ListByAccountComplete(ctx context.Context, resourceGroupName string, accountName string) (result JobResourceDescriptionListIterator, err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/JobClient.ListByAccount\")\n defer func() {\n sc := -1\n if result.Response().Response.Response != nil {\n sc = result.page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n result.page, err = client.ListByAccount(ctx, resourceGroupName, accountName)\n return\n }", "func frameForRecords(reader recordReader) (*data.Frame, error) {\n\tvar (\n\t\tframe = newFrame(reader.Schema())\n\t\trows int64\n\t)\n\tfor reader.Next() {\n\t\trecord := reader.Record()\n\t\tfor i, col := range record.Columns() {\n\t\t\tif err := copyData(frame.Fields[i], col); err != nil {\n\t\t\t\treturn frame, err\n\t\t\t}\n\t\t}\n\n\t\trows += record.NumRows()\n\t\tif rows > rowLimit {\n\t\t\tframe.AppendNotices(data.Notice{\n\t\t\t\tSeverity: data.NoticeSeverityWarning,\n\t\t\t\tText: fmt.Sprintf(\"Results have been limited to %v because the SQL row limit was reached\", rowLimit),\n\t\t\t})\n\t\t\treturn frame, nil\n\t\t}\n\n\t\tif err := reader.Err(); err != nil && !errors.Is(err, io.EOF) {\n\t\t\treturn frame, err\n\t\t}\n\t}\n\treturn frame, nil\n}", "func (o *ArtifactListerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(400)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (client JobClient) ListByAccountResponder(resp *http.Response) (result JobResourceDescriptionList, err error) {\n err = autorest.Respond(\n resp,\n azure.WithErrorUnlessStatusCode(http.StatusOK),\n autorest.ByUnmarshallingJSON(&result),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "func (nsc *NilConsumerStatsCollector) AddGetRecordsTimeout(int) {}", "func (cc *Chaincode) addBriefReport(stub shim.ChaincodeStubInterface, params []string) sc.Response {\n\t// Check Access\n\tcreatorOrg, creatorCertIssuer, err := getTxCreatorInfo(stub)\n\tif !authenticatePolice(creatorOrg, creatorCertIssuer) {\n\t\treturn shim.Error(\"{\\\"Error\\\":\\\"Access Denied!\\\",\\\"Payload\\\":{\\\"MSP\\\":\\\"\" + creatorOrg + \"\\\",\\\"CA\\\":\\\"\" + creatorCertIssuer + \"\\\"}}\")\n\t}\n\n\t// Check if sufficient Params passed\n\tif len(params) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 2+!\")\n\t}\n\n\t// Check if Params are non-empty\n\tfor a := 0; a < len(params); a++ {\n\t\tif len(params[a]) <= 0 {\n\t\t\treturn shim.Error(\"Argument must be a non-empty string\")\n\t\t}\n\t}\n\n\t// Copy the Values from params[]\n\tID := params[0]\n\tContent := params[1]\n\tvar Documents []string\n\tfor a := 2; a < len(params); a++ {\n\t\tDocuments = append(Documents, params[a])\n\t}\n\n\tNewReport := briefReport{Content, Documents}\n\n\t// Check if ChargeSheet exists with Key => ID\n\tchargeSheetAsBytes, err := stub.GetState(ID)\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to get ChargeSheet Details!\")\n\t} else if chargeSheetAsBytes == nil {\n\t\treturn shim.Error(\"Error: ChargeSheet Does NOT Exist!\")\n\t}\n\n\t// Create Update struct var\n\tchargeSheetToUpdate := chargeSheet{}\n\terr = json.Unmarshal(chargeSheetAsBytes, &chargeSheetToUpdate) //unmarshal it aka JSON.parse()\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\t// Check if Judgement is Complete or NOT\n\tif chargeSheetToUpdate.Complete {\n\t\treturn shim.Error(\"Error: ChargeSheet is Complete & Locked!\")\n\t}\n\n\t// Update ChargeSheet.BriefReport to append => NewReport\n\tchargeSheetToUpdate.BriefReport = append(chargeSheetToUpdate.BriefReport, NewReport)\n\n\t// Convert to JSON bytes\n\tchargeSheetJSONasBytes, err := json.Marshal(chargeSheetToUpdate)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\t// Put State of newly generated ChargeSheet with Key => ID\n\terr = stub.PutState(ID, chargeSheetJSONasBytes)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\t// Returned on successful execution of the function\n\treturn shim.Success(chargeSheetJSONasBytes)\n}", "func (r *ListTasksResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListTasksResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Tasks = append(r.Tasks, results.Tasks...)\n\tr.TotalCount += uint32(len(results.Tasks))\n\treturn uint32(len(results.Tasks)), nil\n}", "func (r *ListTasksResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListTasksResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Tasks = append(r.Tasks, results.Tasks...)\n\tr.TotalCount += uint32(len(results.Tasks))\n\treturn uint32(len(results.Tasks)), nil\n}", "func (lc *ActivityDumpLoadController) NextPartialDump(ad *ActivityDump) *ActivityDump {\n\tnewDump := NewActivityDump(ad.adm)\n\tnewDump.Metadata.ContainerID = ad.Metadata.ContainerID\n\tnewDump.Metadata.Comm = ad.Metadata.Comm\n\tnewDump.Metadata.DifferentiateArgs = ad.Metadata.DifferentiateArgs\n\tnewDump.Tags = ad.Tags\n\n\t// copy storage requests\n\tfor _, reqList := range ad.StorageRequests {\n\t\tfor _, req := range reqList {\n\t\t\tnewDump.AddStorageRequest(config.NewStorageRequest(\n\t\t\t\treq.Type,\n\t\t\t\treq.Format,\n\t\t\t\treq.Compression,\n\t\t\t\treq.OutputDirectory,\n\t\t\t))\n\t\t}\n\t}\n\n\t// compute the duration it took to reach the dump size threshold\n\ttimeToThreshold := ad.End.Sub(ad.Start)\n\n\t// set new load parameters\n\tnewDump.SetTimeout(ad.LoadConfig.Timeout - timeToThreshold)\n\tnewDump.LoadConfig.TracedEventTypes = make([]model.EventType, len(ad.LoadConfig.TracedEventTypes))\n\tcopy(newDump.LoadConfig.TracedEventTypes, ad.LoadConfig.TracedEventTypes)\n\tnewDump.LoadConfig.Rate = ad.LoadConfig.Rate\n\tnewDump.LoadConfigCookie = ad.LoadConfigCookie\n\n\tif timeToThreshold < lc.minDumpTimeout {\n\t\tif err := lc.reduceDumpRate(ad, newDump); err != nil {\n\t\t\tseclog.Errorf(\"%v\", err)\n\t\t}\n\t}\n\n\tif timeToThreshold < lc.minDumpTimeout/2 && ad.LoadConfig.Timeout > lc.minDumpTimeout {\n\t\tif err := lc.reduceDumpTimeout(newDump); err != nil {\n\t\t\tseclog.Errorf(\"%v\", err)\n\t\t}\n\t}\n\n\tif timeToThreshold < lc.minDumpTimeout/4 {\n\t\tif err := lc.reduceTracedEventTypes(ad, newDump); err != nil {\n\t\t\tseclog.Errorf(\"%v\", err)\n\t\t}\n\t}\n\treturn newDump\n}", "func (g *Game) Records(filter *LeaderboardFilter, embeds string) (*LeaderboardCollection, *Error) {\n\treturn fetchLeaderboardsLink(firstLink(g, \"records\"), filter, nil, embeds)\n}", "func (rest *RestController) All(w http.ResponseWriter, r *http.Request) (Response, error) {\n\tresources := reflect.New(reflect.SliceOf(reflect.TypeOf(rest.Table).Elem()))\n\tcount, err := rest.Table.List(resources.Interface(), models.NewDBQuery(r.URL.Query(), nil))\n\tif err != nil {\n\t\treturn nil, &httpError{err, \"\", 500}\n\t}\n\tw.Header().Set(\"Total\", strconv.FormatInt(count, 10))\n\treturn &JSONResponse{resources.Interface(), 200}, nil\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsUnmarshalDuration(time.Duration) {}", "func IncrementSuccessfulList(counts int) {\n\tincSuccessfulRequestByHandler(\"list\", counts)\n}", "func (*ListArtifactsResponse) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_aiplatform_v1_metadata_service_proto_rawDescGZIP(), []int{10}\n}", "func (task *ParseTask) GetRecords(content []byte) ([]wisply.Recorder, error) {\n\tmsg := \"\"\n\ttask.addContent(\"records\")\n\trecords, err := task.remote.GetRecords(content)\n\tnumber := len(records)\n\tif number == 0 {\n\t\tmsg = \"There are no new records\"\n\t} else {\n\t\tmsg = \"Success. \" + strconv.Itoa(number) + \" `records` has been identified\"\n\t}\n\ttask.finishRequest(err, msg)\n\n\treturn records, err\n}", "func (m *DeploymentsClientMock) List(ctx context.Context, resourceGroupName, filter string, top *int32) (result []resources.DeploymentExtended, err error) {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\n\tresult = make([]resources.DeploymentExtended, 0)\n\tfor i := range m.FakeStore {\n\t\tresult = append(result, m.FakeStore[i])\n\t}\n\n\treturn result, nil\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsDuration(time.Duration) {}", "func listHelper(lr listRetriever, opts *ListOptions) error {\n\tvar (\n\t\tfound, firstReportedTotal, lastReportedTotal int\n\t)\n\tfor {\n\t\tels, reportedtotal, err := lr(opts)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfound += els\n\t\tif firstReportedTotal == 0 {\n\t\t\tfirstReportedTotal = reportedtotal\n\t\t}\n\t\tlastReportedTotal = reportedtotal\n\n\t\tif reportedtotal <= opts.Offset+opts.Limit {\n\t\t\tbreak\n\t\t}\n\t\topts.Offset += opts.Limit\n\t}\n\n\t// Safety check\n\tif !opts.DisableCountValidation && (firstReportedTotal != found || lastReportedTotal != found) {\n\t\treturn fmt.Errorf(\"got %d elements total, first response indicated %d, last response indicated %d\", found, firstReportedTotal, lastReportedTotal)\n\t}\n\n\treturn nil\n}", "func (client UsageDetailsClient) ListPreparer(ctx context.Context, expand string, filter string, skiptoken string, top *int32, apply string) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"subscriptionId\": autorest.Encode(\"path\", client.SubscriptionID),\n\t}\n\n\tconst APIVersion = \"2018-06-30\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\tif len(expand) > 0 {\n\t\tqueryParameters[\"$expand\"] = autorest.Encode(\"query\", expand)\n\t}\n\tif len(filter) > 0 {\n\t\tqueryParameters[\"$filter\"] = autorest.Encode(\"query\", filter)\n\t}\n\tif len(skiptoken) > 0 {\n\t\tqueryParameters[\"$skiptoken\"] = autorest.Encode(\"query\", skiptoken)\n\t}\n\tif top != nil {\n\t\tqueryParameters[\"$top\"] = autorest.Encode(\"query\", *top)\n\t}\n\tif len(apply) > 0 {\n\t\tqueryParameters[\"$apply\"] = autorest.Encode(\"query\", apply)\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsGet(),\n\t\tautorest.WithBaseURL(client.BaseURI),\n\t\tautorest.WithPathParameters(\"/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/usageDetails\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsCalled(count int) {\n\tdsc.GetRecordsCalled.Inc(int64(count))\n}", "func (f *File) RemainingDownloadableCount() int {\n\treturn f.DownloadLimit - int(f.DownloadCount)\n}", "func youTubeMoreVideo(a *chan []byte,c *string,e *int64){\n\n\n client := &http.Client{\n Transport: &transport.APIKey{Key: developerKey},\n }\n\n service, err := youtube.New(client)\n if err != nil {\n panic(err)\n }\n\n // Make the API call to YouTube.\n call := service.Search.List(\"id,snippet\").\n Q(*c).\n MaxResults(*e)\n response, err := call.Do()\n if err != nil {\n panic(err)\n }\n\n // Group video, channel, and playlist results in separate lists.\n videos := make(map[string]string)\n channels := make(map[string]string)\n playlists := make(map[string]string)\n sArr:=make([]YouTube,0)\n // Iterate through each item and add it to the correct list.\n for _, item := range response.Items {\n switch item.Id.Kind {\n case \"youtube#video\":\n c:=YouTube{Id:item.Id.VideoId,Title:item.Snippet.Title}\n sArr=append(sArr,c)\n //jsonString, _ := json.Marshal(datas)\n //fmt.Println(jsonString)\n //videos[item.Id.VideoId] = item.Snippet.Title\n case \"youtube#channel\":\n channels[item.Id.ChannelId] = item.Snippet.Title\n case \"youtube#playlist\":\n playlists[item.Id.PlaylistId] = item.Snippet.Title\n }\n }\n //*a<-videos\n datas:=AllYoutube{All:sArr}\n jsonString, _ := json.Marshal(datas)\n\n\n *a <- jsonString\n //fmt.Println(videos)\n printIDs(\"Videos\", videos)\n\n}", "func (b *Batch) AddSkipResponse(request interface{}) {\n\tb.add(request, true)\n}", "func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListSnapshotsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Snapshots = append(r.Snapshots, results.Snapshots...)\n\tr.TotalCount += uint32(len(results.Snapshots))\n\treturn uint32(len(results.Snapshots)), nil\n}", "func copyFullPayload(ctx context.Context, responseWriter http.ResponseWriter, r *http.Request, destWriter io.Writer, limit int64, action string) error {\n\t// Get a channel that tells us if the client disconnects\n\tclientClosed := r.Context().Done()\n\tbody := r.Body\n\tif limit > 0 {\n\t\tbody = http.MaxBytesReader(responseWriter, body, limit)\n\t}\n\n\t// Read in the data, if any.\n\tcopied, err := io.Copy(destWriter, body)\n\tif clientClosed != nil && (err != nil || (r.ContentLength > 0 && copied < r.ContentLength)) {\n\t\t// Didn't receive as much content as expected. Did the client\n\t\t// disconnect during the request? If so, avoid returning a 400\n\t\t// error to keep the logs cleaner.\n\t\tselect {\n\t\tcase <-clientClosed:\n\t\t\t// Set the response code to \"499 Client Closed Request\"\n\t\t\t// Even though the connection has already been closed,\n\t\t\t// this causes the logger to pick up a 499 error\n\t\t\t// instead of showing 0 for the HTTP status.\n\t\t\tresponseWriter.WriteHeader(499)\n\n\t\t\tdcontext.GetLoggerWithFields(ctx, map[interface{}]interface{}{\n\t\t\t\t\"error\": err,\n\t\t\t\t\"copied\": copied,\n\t\t\t\t\"contentLength\": r.ContentLength,\n\t\t\t}, \"error\", \"copied\", \"contentLength\").Error(\"client disconnected during \" + action)\n\t\t\treturn errors.New(\"client disconnected\")\n\t\tdefault:\n\t\t}\n\t}\n\n\tif err != nil {\n\t\tdcontext.GetLogger(ctx).Errorf(\"unknown error reading request payload: %v\", err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (m *MockResultDBClient) ListArtifacts(ctx context.Context, in *ListArtifactsRequest, opts ...grpc.CallOption) (*ListArtifactsResponse, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{ctx, in}\n\tfor _, a := range opts {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ListArtifacts\", varargs...)\n\tret0, _ := ret[0].(*ListArtifactsResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (r *responseInfoRecorder) partialResponse() *http.Response {\n\treturn &http.Response{\n\t\tStatusCode: r.StatusCode(),\n\t\tContentLength: r.ContentLength,\n\t\tHeader: r.Header(),\n\t}\n}", "func (r *Responder) PartialContent() { r.write(http.StatusPartialContent) }", "func (client UsageDetailsClient) ListByEnrollmentAccountComplete(ctx context.Context, enrollmentAccountID string, expand string, filter string, skiptoken string, top *int32, apply string) (result UsageDetailsListResultIterator, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/UsageDetailsClient.ListByEnrollmentAccount\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response().Response.Response != nil {\n\t\t\t\tsc = result.page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.page, err = client.ListByEnrollmentAccount(ctx, enrollmentAccountID, expand, filter, skiptoken, top, apply)\n\treturn\n}", "func TestRemainingBytes(t *testing.T) {\n\tmockTr := new(mockTTransport)\n\treads := make(chan []byte, 2)\n\treads <- frame[0:4]\n\treads <- frame[4:]\n\tclose(reads)\n\tmockTr.reads = reads\n\ttr := NewTFramedTransport(mockTr)\n\tmockTr.On(\"Read\", make([]byte, 4096)).Return(4, nil).Once()\n\tmockTr.On(\"Read\", append(frame[0:4], make([]byte, 4092)...)).Return(len(frame), nil).Once()\n\n\tassert.Equal(t, uint64(0), tr.RemainingBytes())\n\n\tbuff := make([]byte, len(frame)-10)\n\t_, err := tr.Read(buff)\n\tassert.Nil(t, err)\n\n\tassert.Equal(t, uint64(6), tr.RemainingBytes())\n}", "func (o *ArtifactListerPartialContent) WithNext(next string) *ArtifactListerPartialContent {\n\to.Next = next\n\treturn o\n}", "func (r *ListDNSZoneVersionsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneVersionsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Versions = append(r.Versions, results.Versions...)\n\tr.TotalCount += uint32(len(results.Versions))\n\treturn uint32(len(results.Versions)), nil\n}", "func (*ListEnabledNSRecordsResponse) Descriptor() ([]byte, []int) {\n\treturn file_service_ns_record_proto_rawDescGZIP(), []int{6}\n}", "func (client UsageDetailsClient) ListByDepartmentComplete(ctx context.Context, departmentID string, expand string, filter string, skiptoken string, top *int32, apply string) (result UsageDetailsListResultIterator, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/UsageDetailsClient.ListByDepartment\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response().Response.Response != nil {\n\t\t\t\tsc = result.page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.page, err = client.ListByDepartment(ctx, departmentID, expand, filter, skiptoken, top, apply)\n\treturn\n}", "func (ctrl Attachment) List(ctx context.Context, r *request.AttachmentList) (interface{}, error) {\n\tif !auth.GetIdentityFromContext(ctx).Valid() {\n\t\treturn nil, errors.New(\"Unauthorized\")\n\t}\n\n\tf := types.AttachmentFilter{\n\t\tNamespaceID: r.NamespaceID,\n\t\tKind: r.Kind,\n\t\tModuleID: r.ModuleID,\n\t\tRecordID: r.RecordID,\n\t\tFieldName: r.FieldName,\n\t\t// Filter: r.Filter,\n\t\tPerPage: r.PerPage,\n\t\tPage: r.Page,\n\t\t// Sort: r.Sort,\n\t}\n\n\tset, filter, err := ctrl.attachment.With(ctx).Find(f)\n\treturn ctrl.makeFilterPayload(ctx, set, filter, err)\n}", "func (client UsageDetailsClient) listByDepartmentNextResults(ctx context.Context, lastResults UsageDetailsListResult) (result UsageDetailsListResult, err error) {\n\treq, err := lastResults.usageDetailsListResultPreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listByDepartmentNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListByDepartmentSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listByDepartmentNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListByDepartmentResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"listByDepartmentNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (client UsageDetailsClient) ListByEnrollmentAccountPreparer(ctx context.Context, enrollmentAccountID string, expand string, filter string, skiptoken string, top *int32, apply string) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"enrollmentAccountId\": autorest.Encode(\"path\", enrollmentAccountID),\n\t}\n\n\tconst APIVersion = \"2018-06-30\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\tif len(expand) > 0 {\n\t\tqueryParameters[\"$expand\"] = autorest.Encode(\"query\", expand)\n\t}\n\tif len(filter) > 0 {\n\t\tqueryParameters[\"$filter\"] = autorest.Encode(\"query\", filter)\n\t}\n\tif len(skiptoken) > 0 {\n\t\tqueryParameters[\"$skiptoken\"] = autorest.Encode(\"query\", skiptoken)\n\t}\n\tif top != nil {\n\t\tqueryParameters[\"$top\"] = autorest.Encode(\"query\", *top)\n\t}\n\tif len(apply) > 0 {\n\t\tqueryParameters[\"$apply\"] = autorest.Encode(\"query\", apply)\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsGet(),\n\t\tautorest.WithBaseURL(client.BaseURI),\n\t\tautorest.WithPathParameters(\"/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/usageDetails\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (w *DeploymentWrite) pending(q *msg.Request, mr *msg.Result) {\n\tvar (\n\t\tinstanceID string\n\t\terr error\n\t\tlist *sql.Rows\n\t)\n\n\tif list, err = w.stmtList.Query(\n\t\tq.Monitoring.ID,\n\t); err != nil {\n\t\tmr.ServerError(err, q.Section)\n\t\treturn\n\t}\n\tdefer list.Close()\n\n\tfor list.Next() {\n\t\tif err = list.Scan(\n\t\t\t&instanceID,\n\t\t); err != nil {\n\t\t\tmr.ServerError(err, q.Section)\n\t\t\treturn\n\t\t}\n\n\t\tmr.Deployment = append(mr.Deployment, proto.Deployment{\n\t\t\tID: instanceID,\n\t\t})\n\n\t\t// XXX BUG requires a manual transaction\n\t\tw.stmtClearFlag.Exec(instanceID)\n\t}\n\tif err = list.Err(); err != nil {\n\t\tmr.ServerError(err, q.Section)\n\t\treturn\n\t}\n\tmr.OK()\n}" ]
[ "0.7257407", "0.565533", "0.5209284", "0.5129928", "0.49627718", "0.4876884", "0.4797178", "0.46875754", "0.4657041", "0.46173438", "0.44904017", "0.44647884", "0.44330287", "0.44215667", "0.44097626", "0.43981874", "0.43955588", "0.4385607", "0.43707445", "0.43707445", "0.43676633", "0.43586352", "0.43385112", "0.43245038", "0.43196353", "0.43167907", "0.43085298", "0.42964557", "0.42706698", "0.4267792", "0.42382884", "0.42180806", "0.42053387", "0.41952735", "0.41926068", "0.41894194", "0.41744727", "0.41465276", "0.41426867", "0.41209313", "0.4116838", "0.4092869", "0.40720937", "0.4041689", "0.40353024", "0.40313646", "0.4030121", "0.40161437", "0.40161437", "0.40114838", "0.40101126", "0.400299", "0.40019798", "0.39999512", "0.39964265", "0.39939696", "0.39897704", "0.39853072", "0.39846855", "0.39829147", "0.39826697", "0.3976266", "0.39716634", "0.39715496", "0.3964993", "0.39649394", "0.39604056", "0.3950449", "0.3945235", "0.3945235", "0.39450067", "0.3943484", "0.39431617", "0.3937865", "0.393288", "0.39308596", "0.39307848", "0.3927043", "0.3918434", "0.3917752", "0.3914949", "0.39077827", "0.39001894", "0.3897444", "0.38935468", "0.3887681", "0.38874114", "0.38811055", "0.3878522", "0.38775903", "0.38758194", "0.38704097", "0.38683513", "0.3866331", "0.38642257", "0.38577077", "0.3857565", "0.38566172", "0.3853048", "0.38486937" ]
0.7293859
0
SetRemainingRecords sets the remainingRecords to the artifact lister partial content response
func (o *ArtifactListerPartialContent) SetRemainingRecords(remainingRecords uint64) { o.RemainingRecords = remainingRecords }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerPartialContent) WithRemainingRecords(remainingRecords uint64) *ArtifactListerPartialContent {\n\to.RemainingRecords = remainingRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerOK) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerPartialContent) WithTotalRecords(totalRecords uint64) *ArtifactListerPartialContent {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (s *ContainerInstance) SetRemainingResources(v []*Resource) *ContainerInstance {\n\ts.RemainingResources = v\n\treturn s\n}", "func (rs *RuleSpec) fillRemaining() {\n\tlength := len(rs.RuleParameters)\n\tfor i, rp := range rs.RuleParameters {\n\t\trp.Remaining = length - i -1\n\t}\n}", "func (cl *Client) failBufferedRecords(err error) {\n\tp := &cl.producer\n\n\tfor _, partitions := range p.topics.load() {\n\t\tfor _, partition := range partitions.load().partitions {\n\t\t\trecBuf := partition.records\n\t\t\trecBuf.mu.Lock()\n\t\t\trecBuf.failAllRecords(err)\n\t\t\trecBuf.mu.Unlock()\n\t\t}\n\t}\n\n\tp.topicsMu.Lock()\n\tdefer p.topicsMu.Unlock()\n\tp.unknownTopicsMu.Lock()\n\tdefer p.unknownTopicsMu.Unlock()\n\n\ttoStore := p.topics.clone()\n\tdefer p.topics.storeData(toStore)\n\n\tvar toFail [][]promisedRec\n\tfor topic, unknown := range p.unknownTopics {\n\t\tdelete(toStore, topic)\n\t\tdelete(p.unknownTopics, topic)\n\t\tclose(unknown.wait)\n\t\ttoFail = append(toFail, unknown.buffered)\n\t}\n\n\tgo func() {\n\t\tfor _, fail := range toFail {\n\t\t\tfor _, pr := range fail {\n\t\t\t\tcl.finishRecordPromise(pr, err)\n\t\t\t}\n\t\t}\n\t}()\n}", "func (o *ArtifactListerOK) WithTotalRecords(totalRecords uint64) *ArtifactListerOK {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (s *statusCollector) fillRemaining(err error) {\n\t// Amount of times certain recipient was specified is indicated by the channel\n\t// buffer size, so once we fill it, we can be confident that we sent\n\t// at least as much statuses as needed. Extra statuses will be ignored anyway.\nchLoop:\n\tfor _, ch := range s.statusMap {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase ch <- err:\n\t\t\tdefault:\n\t\t\t\tcontinue chLoop\n\t\t\t}\n\t\t}\n\t}\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsReadResponseDuration(time.Duration) {}", "func (o *ArtifactListerPartialContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Next\n\n\tnext := o.Next\n\tif next != \"\" {\n\t\trw.Header().Set(\"Next\", next)\n\t}\n\n\t// response header Previous\n\n\tprevious := o.Previous\n\tif previous != \"\" {\n\t\trw.Header().Set(\"Previous\", previous)\n\t}\n\n\t// response header RemainingRecords\n\n\tremainingRecords := swag.FormatUint64(o.RemainingRecords)\n\tif remainingRecords != \"\" {\n\t\trw.Header().Set(\"RemainingRecords\", remainingRecords)\n\t}\n\n\t// response header TotalRecords\n\n\ttotalRecords := swag.FormatUint64(o.TotalRecords)\n\tif totalRecords != \"\" {\n\t\trw.Header().Set(\"TotalRecords\", totalRecords)\n\t}\n\n\trw.WriteHeader(206)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*weles.ArtifactInfo, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\tp.mutex.Lock()\n\tdefer p.mutex.Unlock()\n\n\tclient := &http.Client{}\n\n\tvar updatedRecords []libdns.Record\n\n\tvar resourceRecordSets []LeasewebRecordSet\n\n\tfor _, record := range records {\n\n\t\trecordSet := LeasewebRecordSet{\n\t\t\tName: record.Name,\n\t\t\tType: record.Type,\n\t\t\tContent: []string{record.Value},\n\t\t\tTTL: int(record.TTL.Seconds()),\n\t\t}\n\n\t\tresourceRecordSets = append(resourceRecordSets, recordSet)\n\n\t\tupdatedRecords = append(updatedRecords, record)\n\t}\n\n\tbody := &LeasewebRecordSets{\n\t\tResourceRecordSets: resourceRecordSets,\n\t}\n\n\tbodyBuffer := new(bytes.Buffer)\n\tjson.NewEncoder(bodyBuffer).Encode(body)\n\n\treq, err := http.NewRequest(http.MethodPut, fmt.Sprintf(\"https://api.leaseweb.com/hosting/v2/domains/%s/resourceRecordSets\", zone), bodyBuffer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(LeasewebApiKeyHeader, p.APIKey)\n\n\tres, err := client.Do(req)\n\tdefer res.Body.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\treturn nil, fmt.Errorf(\"Received StatusCode %d from Leaseweb API\", res.StatusCode)\n\t}\n\n\treturn updatedRecords, nil\n}", "func (c *Conn) setReadRemaining(n int64) error {\n\tif n < 0 {\n\t\treturn ErrReadLimit\n\t}\n\n\tc.readRemaining = n\n\treturn nil\n}", "func (resource *billingInfoList) setResponse(res *ResponseMetadata) {\n\tresource.recurlyResponse = res\n}", "func (_obj *DataService) GetActivityRecords(index int32, batch int32, activity_id string, nextIndex *int32, recordList *[]ActivityRecord, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(activity_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*recordList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *recordList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\ttarsCtx := context.Background()\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getActivityRecords\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*recordList) = make([]ActivityRecord, length)\n\t\tfor i20, e20 := int32(0), length; i20 < e20; i20++ {\n\n\t\t\terr = (*recordList)[i20].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (lp *LoadPoint) setRemainingDuration(chargeRemainingDuration time.Duration) {\n\tlp.Lock()\n\tdefer lp.Unlock()\n\n\tif lp.chargeRemainingDuration != chargeRemainingDuration {\n\t\tlp.chargeRemainingDuration = chargeRemainingDuration\n\t\tlp.publish(\"chargeRemainingDuration\", chargeRemainingDuration)\n\t}\n}", "func RateLimitRemaining(r *http.Response) int {\n\treturn intResponseHeaderOrNegOne(r, \"X-RateLimit-Remaining\")\n}", "func (b *LeakyLimiter) Remaining() uint {\n\treturn b.remaining\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (sou *SubjectsOfferedUpdate) SetRemain(i int) *SubjectsOfferedUpdate {\n\tsou.mutation.ResetRemain()\n\tsou.mutation.SetRemain(i)\n\treturn sou\n}", "func (resource *accountList) setResponse(res *ResponseMetadata) {\n\tresource.recurlyResponse = res\n}", "func (mrlr MonitorResourceListResponse) monitorResourceListResponsePreparer(ctx context.Context) (*http.Request, error) {\n\tif !mrlr.hasNextLink() {\n\t\treturn nil, nil\n\t}\n\treturn autorest.Prepare((&http.Request{}).WithContext(ctx),\n\t\tautorest.AsJSON(),\n\t\tautorest.AsGet(),\n\t\tautorest.WithBaseURL(to.String(mrlr.NextLink)))\n}", "func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\tp.mutex.Lock()\n\tdefer p.mutex.Unlock()\n\n\tclient := &http.Client{}\n\n\tvar addedRecords []libdns.Record\n\n\tfor _, record := range records {\n\t\tbody := &LeasewebRecordSet{\n\t\t\tName: record.Name,\n\t\t\tType: record.Type,\n\t\t\tContent: []string{record.Value},\n\t\t\tTTL: int(record.TTL.Seconds()),\n\t\t}\n\n\t\tbodyBuffer := new(bytes.Buffer)\n\t\tjson.NewEncoder(bodyBuffer).Encode(body)\n\n\t\treq, err := http.NewRequest(http.MethodPost, fmt.Sprintf(\"https://api.leaseweb.com/hosting/v2/domains/%s/resourceRecordSets\", zone), bodyBuffer)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treq.Header.Add(LeasewebApiKeyHeader, p.APIKey)\n\n\t\tres, err := client.Do(req)\n\t\tdefer res.Body.Close()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\t\treturn nil, fmt.Errorf(\"Received StatusCode %d from Leaseweb API\", res.StatusCode)\n\t\t}\n\n\t\taddedRecords = append(addedRecords, record)\n\t}\n\n\treturn addedRecords, nil\n}", "func (l *DatabasesExportPollerResponse) Resume(ctx context.Context, client *DatabasesClient, token string) error {\n\tpt, err := armruntime.NewPollerFromResumeToken(\"DatabasesClient.Export\", token, client.pl, client.exportHandleError)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpoller := &DatabasesExportPoller{\n\t\tpt: pt,\n\t}\n\tresp, err := poller.Poll(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tl.Poller = poller\n\tl.RawResponse = resp\n\treturn nil\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsCalled(int) {}", "func (r *ListDNSZoneVersionRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneVersionRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (dsc *DefaultConsumerStatsCollector) UpdateGetRecordsReadResponseDuration(duration time.Duration) {\n\tdsc.GetRecordsReadResponseDuration.Update(duration.Nanoseconds())\n}", "func (souo *SubjectsOfferedUpdateOne) SetRemain(i int) *SubjectsOfferedUpdateOne {\n\tsouo.mutation.ResetRemain()\n\tsouo.mutation.SetRemain(i)\n\treturn souo\n}", "func responderArtifact206(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerPartialContent) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\n\tresponder = artifacts.NewArtifactListerPartialContent()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tresponder.SetRemainingRecords(listInfo.RemainingRecords)\n\n\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\tartifactListerURL.After = &tmp\n\n\tif defaultPageLimit != paginator.Limit {\n\t\ttmp := paginator.Limit\n\t\tartifactListerURL.Limit = &tmp\n\t}\n\tresponder.SetNext(artifactListerURL.String())\n\n\tif paginator.ID != 0 { //... and not the first\n\t\t//paginator.ID is from query parameter not artifactmanager\n\t\tvar artifactListerURL artifacts.ArtifactListerURL\n\t\ttmp = artifactInfoReturned[0].ID\n\t\tartifactListerURL.Before = &tmp\n\t\tif defaultPageLimit != paginator.Limit {\n\t\t\ttmp := paginator.Limit\n\t\t\tartifactListerURL.Limit = &tmp\n\t\t}\n\t\tresponder.SetPrevious(artifactListerURL.String())\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (m *BarGroupMutation) ResetRecords() {\n\tm.records = nil\n\tm.clearedrecords = false\n\tm.removedrecords = nil\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (recBuf *recBuf) failAllRecords(err error) {\n\trecBuf.mu.Lock()\n\tdefer recBuf.mu.Unlock()\n\trecBuf.lockedFailAllRecords(err)\n}", "func (o *GetCSVOK) SetPayload(payload models.GetFileResp) {\n\to.Payload = payload\n}", "func (r *Records) SetRecords() error {\n\turl := fmt.Sprintf(\"%s/v1/domains/%s/records/%s/%s\", r.Config.GetAPI(), r.Domain, r.Records[0].Type, r.Records[0].Name)\n\tclient := &http.Client{}\n\n\tdata, err := json.Marshal(r.Records)\n\treq, _ := http.NewRequest(\"PUT\", url, bytes.NewBuffer(data))\n\treq.Header.Set(r.Config.GetAuth())\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.StatusCode != 200 {\n\t\treturn errors.New(string(res.StatusCode))\n\t}\n\n\treturn nil\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsUnmarshalDuration(time.Duration) {}", "func (*ListNSRecordsAfterVersionResponse) Descriptor() ([]byte, []int) {\n\treturn file_service_ns_record_proto_rawDescGZIP(), []int{10}\n}", "func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\treturn p.updateRecords(ctx, zone, records)\n}", "func (e *Enforcer) UpdateRecords() (int, int, error) {\n\t// Client Auth\n\tcertificate, err := tls.LoadX509KeyPair(e.Vars.Certificate, e.Vars.Key)\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\thost, _, err := net.SplitHostPort(e.Vars.Endpoint)\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\tcreds := credentials.NewTLS(&tls.Config{\n\t\tServerName: host,\n\t\tCertificates: []tls.Certificate{certificate},\n\t})\n\n\t// gRPC connection\n\tconn, err := grpc.Dial(e.Vars.Endpoint, grpc.WithTransportCredentials(creds))\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\tdefer conn.Close()\n\n\tctx := context.Background()\n\n\t// Get Zone\n\tc := dns.NewDynamicDnsServiceClient(conn)\n\n\t// Get and convert all remote records to local style records\n\tonlineRecords := make([]*Record, 0)\n\tvar mutex = &sync.Mutex{}\n\tvar wg sync.WaitGroup\n\tfor _, zone := range e.Vars.Zones {\n\t\twg.Add(1)\n\t\tgo func(zone string) {\n\t\t\tres, err := c.GetZone(ctx, &dns.GetZoneRequest{\n\t\t\t\tZone: zone,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(err)\n\t\t\t}\n\n\t\t\tif res.Record != nil {\n\t\t\t\tfor _, record := range res.Record {\n\t\t\t\t\tif !e.ignoredType(record.Type) {\n\t\t\t\t\t\tmutex.Lock()\n\t\t\t\t\t\tonlineRecords = append(onlineRecords, &Record{\n\t\t\t\t\t\t\tName: record.Domain,\n\t\t\t\t\t\t\tTTL: int(record.Ttl),\n\t\t\t\t\t\t\tType: record.Type,\n\t\t\t\t\t\t\tData: []string{record.Data},\n\t\t\t\t\t\t})\n\t\t\t\t\t\tmutex.Unlock()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(zone)\n\t}\n\n\twg.Wait()\n\n\t// Get locally constructed records\n\tlocalRecords, err := e.GetAllRecords()\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\t// Find which records to remove\n\tremove := make([]*dns.Record, 0)\n\tfor _, r := range onlineRecords {\n\t\tif !contains(localRecords, r) {\n\t\t\t// Delete\n\t\t\tfor _, d := range r.Data {\n\t\t\t\tremove = append(remove, &dns.Record{\n\t\t\t\t\tDomain: r.Name,\n\t\t\t\t\tType: r.Type,\n\t\t\t\t\tData: d,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove records that are present on server but no locally\n\tremoved := 0\n\tif !e.Vars.DryRun {\n\t\tlog.Infof(\"Deleting %d records\", len(remove))\n\t\tfor _, r := range remove {\n\t\t\tif _, err := c.Remove(ctx, &dns.RemoveRequest{Record: []*dns.Record{r}}); err != nil {\n\t\t\t\tlog.Errorf(\"Remove of %s failed with %v\", r.Domain, err)\n\t\t\t} else {\n\t\t\t\tlog.Infof(\"Removed %s\", r.Domain)\n\t\t\t\tremoved += 1\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor _, r := range remove {\n\t\t\tfmt.Printf(\"-%s:%s:%d:%s\\n\", r.Domain, r.Type, r.Ttl, r.Data)\n\t\t}\n\t}\n\n\t// Find which records to insert\n\tinsert := make([]*dns.Record, 0)\n\tfor _, r := range localRecords {\n\t\tif !contains(onlineRecords, r) {\n\t\t\t// Add\n\t\t\tfor _, d := range r.Data {\n\t\t\t\tinsert = append(insert, &dns.Record{\n\t\t\t\t\tDomain: r.Name,\n\t\t\t\t\tTtl: uint32(r.TTL),\n\t\t\t\t\tClass: \"IN\",\n\t\t\t\t\tType: r.Type,\n\t\t\t\t\tData: d,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t// Insert records that are missing on the server\n\tadded := 0\n\tif !e.Vars.DryRun {\n\t\tlog.Infof(\"Inserting %d records\", len(insert))\n\t\tfor _, r := range insert {\n\t\t\tif _, err := c.Insert(ctx, &dns.InsertRequest{Record: []*dns.Record{r}}); err != nil {\n\t\t\t\tlog.Errorf(\"Insert of %s failed with %v\", r.Domain, err)\n\t\t\t} else {\n\t\t\t\tadded += 1\n\t\t\t\tlog.Infof(\"Added %s\", r.Domain)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor _, r := range insert {\n\t\t\tfmt.Printf(\"+%s:%s:%d:%s\\n\", r.Domain, r.Type, r.Ttl, r.Data)\n\t\t}\n\t}\n\n\treturn added, removed, nil\n}", "func (m *MockPartitions) FailListAfter(n int) *MockPartitions {\n\tm.failListAfter = n\n\treturn m\n}", "func (m *TradeTimeRangeMutation) ResetRecords() {\n\tm.records = nil\n\tm.clearedrecords = false\n\tm.removedrecords = nil\n}", "func (p *TBufferedReadTransport) RemainingBytes() uint64 {\n\treturn uint64(p.readBuf.Len())\n}", "func TestListRecordings(t *testing.T) {\n\tif !haveArchive {\n\t\treturn\n\t}\n\n\tif testing.Verbose() && DEBUG {\n\t\tlogging.SetLevel(logging.DEBUG, \"archive\")\n\t}\n\n\trecordings, err := archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tinitial := len(recordings)\n\tt.Logf(\"Initial count is %d\", initial)\n\n\t// Add a recording\n\tsubscriptionID, err := archive.StartRecording(testCases[0].sampleChannel, testCases[0].sampleStream, true, true)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tt.Logf(\"SubscriptionID is %d\", subscriptionID)\n\n\t// Add a publication on that\n\tpublication, err := archive.AddPublication(testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif testing.Verbose() && DEBUG {\n\t\tt.Logf(\"Publication is %#v\", publication)\n\t}\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif len(recordings) == 0 {\n\t\tt.Log(\"No Recordings!\")\n\t\tt.FailNow()\n\t}\n\n\t// Grab the recordingID\n\trecordingID := recordings[len(recordings)-1].RecordingId\n\tt.Logf(\"Working count is %d, recordingID is %d\", len(recordings), recordingID)\n\n\t// Cleanup\n\tres, err := archive.StopRecordingByIdentity(recordingID)\n\tif err != nil {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed: %s\", recordingID, err.Error())\n\t} else if !res {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed\", recordingID)\n\t}\n\tif err := archive.PurgeRecording(recordingID); err != nil {\n\t\tt.Logf(\"PurgeRecording(%d) failed: %s\", recordingID, err.Error())\n\t}\n\tpublication.Close()\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tfinal := len(recordings)\n\tt.Logf(\"Final count is %d\", final)\n\n\tif initial != final {\n\t\tt.Logf(\"Number of recordings changed from %d to %d\", initial, final)\n\t\tt.Fail()\n\t}\n}", "func (o *VolumeModifyIterAsyncRequest) MaxRecords() int {\n\tvar r int\n\tif o.MaxRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.MaxRecordsPtr\n\treturn r\n}", "func WithIncludeFinal(includeFinal bool) ListDealRecordsOption {\n\treturn func(c *rpc.ListDealRecordsConfig) {\n\t\tc.IncludeFinal = includeFinal\n\t}\n}", "func (v *ConstructionPayloadsResponse) Reset() {\n\tv.Payloads = v.Payloads[:0]\n\tv.UnsignedTransaction = \"\"\n}", "func verifyRemainingObjects(t *testing.T, clientSet clientset.Interface, namespace string, rsNum, podNum int) (bool, error) {\n\trsClient := clientSet.Extensions().ReplicaSets(namespace)\n\tpodClient := clientSet.Core().Pods(namespace)\n\tpods, err := podClient.List(metav1.ListOptions{})\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"Failed to list pods: %v\", err)\n\t}\n\tvar ret = true\n\tif len(pods.Items) != podNum {\n\t\tret = false\n\t\tt.Logf(\"expect %d pods, got %d pods\", podNum, len(pods.Items))\n\t}\n\trss, err := rsClient.List(metav1.ListOptions{})\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"Failed to list replica sets: %v\", err)\n\t}\n\tif len(rss.Items) != rsNum {\n\t\tret = false\n\t\tt.Logf(\"expect %d RSs, got %d RSs\", rsNum, len(rss.Items))\n\t}\n\treturn ret, nil\n}", "func (x *fastReflection_ValidatorOutstandingRewardsRecord) SetUnknown(fields protoreflect.RawFields) {\n\tx.unknownFields = fields\n}", "func (d *DBClient) AllRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\trecords, err := d.Cache.GetAllRequests()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordedRequests\n\t\tresponse.Data = records\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (resource *subscriptionAddOnList) setResponse(res *ResponseMetadata) {\n\tresource.recurlyResponse = res\n}", "func updateInventoryMasterRecords(stub shim.ChaincodeStubInterface, custInvoice string, vendInvoice string) error {\r\n\tvar recordList []string\r\n\trecBytes, _ := stub.GetState(ALL_INVOICES)\r\n\r\n\terr := json.Unmarshal(recBytes, &recordList)\r\n\tif err != nil {\r\n\t\treturn errors.New(\"Failed to unmarshal updateInventoryMasterRecords \")\r\n\t}\r\n\trecordList = append(recordList, custInvoice)\r\n\trecordList = append(recordList, vendInvoice)\r\n\r\n\tbytesToStore, _ := json.Marshal(recordList)\r\n\tlogger.Info(\"After addition\" + string(bytesToStore))\r\n\tstub.PutState(ALL_INVOICES, bytesToStore)\r\n\treturn nil\r\n}", "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (d *Dataset) BadRecords() []string {\n\treturn d.badRecords\n}", "func (f *File) RemainingDownloadableCount() int {\n\treturn f.DownloadLimit - int(f.DownloadCount)\n}", "func (recBuf *recBuf) lockedFailAllRecords(err error) {\n\trecBuf.lockedStopLinger()\n\tfor _, batch := range recBuf.batches {\n\t\t// We need to guard our clearing of records against a\n\t\t// concurrent write. This is the only spot that the records\n\t\t// slice can be modified outside of the main recBuf\n\t\t// batch-buffering logic. Since we lock the recBuf, we do not\n\t\t// need to worry about record buffering. However, we need to\n\t\t// worry about a buffered write that will eventually read this\n\t\t// batch. So, we lock while we clear.\n\t\tbatch.mu.Lock()\n\t\tfor i, pnr := range batch.records {\n\t\t\trecBuf.cl.finishRecordPromise(pnr.promisedRec, err)\n\t\t\tbatch.records[i] = noPNR\n\t\t}\n\t\tbatch.records = nil\n\t\tbatch.mu.Unlock()\n\t\temptyRecordsPool.Put(&batch.records)\n\t}\n\trecBuf.resetBatchDrainIdx()\n\trecBuf.batches = nil\n}", "func (v *SearchTransactionsResponse) Reset() {\n\tv.NextOffset.Value = 0\n\tv.NextOffset.Set = false\n\tv.TotalCount = 0\n\tv.Transactions = v.Transactions[:0]\n}", "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (c *Client) FilteredRecords(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewFilteredRecordsRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}", "func (c *Client) ResolvedRecords(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewResolvedRecordsRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}", "func (m *MockDpsServiceClient) ListFailedRecord(ctx context.Context, in *v1.ListFailedRequest, opts ...grpc.CallOption) (*v1.ListFailedResponse, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{ctx, in}\n\tfor _, a := range opts {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ListFailedRecord\", varargs...)\n\tret0, _ := ret[0].(*v1.ListFailedResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (o *BalanceResponse) SetRetained(v []BalanceCommonField) {\n\to.Retained = v\n}", "func (mr *MockDpsServiceServerMockRecorder) ListFailedRecord(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ListFailedRecord\", reflect.TypeOf((*MockDpsServiceServer)(nil).ListFailedRecord), arg0, arg1)\n}", "func (c *cur) waitRecords(ctx context.Context) {\n\tctx2, cancel := context.WithCancel(ctx)\n\tfor _, it := range c.its {\n\t\tgo func(it *journal.Iterator) {\n\t\t\tit.WaitNewData(ctx2)\n\t\t\tcancel()\n\t\t}(it)\n\t}\n\t<-ctx2.Done()\n}", "func (m *MockDpsServiceServer) ListFailedRecord(arg0 context.Context, arg1 *v1.ListFailedRequest) (*v1.ListFailedResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListFailedRecord\", arg0, arg1)\n\tret0, _ := ret[0].(*v1.ListFailedResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (o *GetAccountsListOK) SetPayload(payload []*models.AccountsRow) {\n\to.Payload = payload\n}", "func (x *fastReflection_ValidatorHistoricalRewardsRecord) SetUnknown(fields protoreflect.RawFields) {\n\tx.unknownFields = fields\n}", "func (cl *Client) AbortBufferedRecords(ctx context.Context) error {\n\tatomic.StoreUint32(&cl.producer.aborting, 1)\n\tdefer atomic.StoreUint32(&cl.producer.aborting, 0)\n\t// At this point, all drain loops that start will immediately stop,\n\t// thus they will not begin any AddPartitionsToTxn request. We must\n\t// now wait for any req currently built to be done being issued.\n\n\tfor _, partitions := range cl.loadTopics() { // a good a time as any to fail all records\n\t\tfor _, partition := range partitions.load().partitions {\n\t\t\tpartition.records.failAllRecords(ErrAborting)\n\t\t}\n\t}\n\n\tcl.unknownTopicsMu.Lock() // we also have to clear anything waiting in unknown topics\n\tfor topic, unknown := range cl.unknownTopics {\n\t\tdelete(cl.unknownTopics, topic)\n\t\tclose(unknown.wait)\n\t\tfor _, pr := range unknown.buffered {\n\t\t\tcl.finishRecordPromise(pr, ErrAborting)\n\t\t}\n\t}\n\tcl.unknownTopicsMu.Unlock()\n\n\t// Now, we wait for any active drain to stop. We must wait for all\n\t// drains to stop otherwise we could end up with some exceptionally\n\t// weird scenario where we end a txn and begin a new one before a\n\t// prior AddPartitionsToTxn request that was built is issued.\n\t//\n\t// By waiting for our drains count to hit 0, we know that at that\n\t// point, no new AddPartitionsToTxn request will be sent.\n\tquit := false\n\tdone := make(chan struct{})\n\tgo func() {\n\t\tcl.producer.notifyMu.Lock()\n\t\tdefer cl.producer.notifyMu.Unlock()\n\t\tdefer close(done)\n\n\t\tfor !quit && atomic.LoadInt32(&cl.producer.drains) > 0 {\n\t\t\tcl.producer.notifyCond.Wait()\n\t\t}\n\t}()\n\n\tselect {\n\tcase <-done:\n\t\t// All records were failed above, and all drains are stopped.\n\t\t// We are safe to return.\n\t\treturn nil\n\tcase <-ctx.Done():\n\t\tcl.producer.notifyMu.Lock()\n\t\tquit = true\n\t\tcl.producer.notifyMu.Unlock()\n\t\tcl.producer.notifyCond.Broadcast()\n\t\treturn ctx.Err()\n\t}\n}", "func TestRemainingBytes(t *testing.T) {\n\tmockTr := new(mockTTransport)\n\treads := make(chan []byte, 2)\n\treads <- frame[0:4]\n\treads <- frame[4:]\n\tclose(reads)\n\tmockTr.reads = reads\n\ttr := NewTFramedTransport(mockTr)\n\tmockTr.On(\"Read\", make([]byte, 4096)).Return(4, nil).Once()\n\tmockTr.On(\"Read\", append(frame[0:4], make([]byte, 4092)...)).Return(len(frame), nil).Once()\n\n\tassert.Equal(t, uint64(0), tr.RemainingBytes())\n\n\tbuff := make([]byte, len(frame)-10)\n\t_, err := tr.Read(buff)\n\tassert.Nil(t, err)\n\n\tassert.Equal(t, uint64(6), tr.RemainingBytes())\n}", "func (mr *MockDpsServiceClientMockRecorder) ListFailedRecord(ctx, in interface{}, opts ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{ctx, in}, opts...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ListFailedRecord\", reflect.TypeOf((*MockDpsServiceClient)(nil).ListFailedRecord), varargs...)\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsDuration(time.Duration) {}", "func (x *fastReflection_ValidatorCurrentRewardsRecord) SetUnknown(fields protoreflect.RawFields) {\n\tx.unknownFields = fields\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (conn *Connection) GetLimitedRecords(q interface{}, n int, doc interface{}, fields ...string) error {\n\tif len(fields) == 0 {\n\t\treturn conn.collection.Find(q).Limit(n).All(doc)\n\t}\n\n\treturn conn.collection.Find(q).Sort(fields...).Limit(n).All(doc)\n}", "func outputRecordsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (c *applicationUsecaseImpl) ListRecords(ctx context.Context, appName string) (*apisv1.ListWorkflowRecordsResponse, error) {\n\tvar record = model.WorkflowRecord{\n\t\tAppPrimaryKey: appName,\n\t\tStatus: model.RevisionStatusRunning,\n\t}\n\trecords, err := c.ds.List(ctx, &record, &datastore.ListOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(records) == 0 {\n\t\trecord.Status = model.RevisionStatusComplete\n\t\trecords, err = c.ds.List(ctx, &record, &datastore.ListOptions{\n\t\t\tPage: 1,\n\t\t\tPageSize: 1,\n\t\t\tSortBy: []datastore.SortOption{{Key: \"model.createTime\", Order: datastore.SortOrderDescending}},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tresp := &apisv1.ListWorkflowRecordsResponse{\n\t\tRecords: []apisv1.WorkflowRecord{},\n\t}\n\tfor _, raw := range records {\n\t\trecord, ok := raw.(*model.WorkflowRecord)\n\t\tif ok {\n\t\t\tresp.Records = append(resp.Records, *convertFromRecordModel(record))\n\t\t}\n\t}\n\tresp.Total = int64(len(records))\n\n\treturn resp, nil\n}", "func (pw *pendingWrite) markDone(resp *storagepb.AppendRowsResponse, err error) {\n\t// First, propagate necessary state from the pendingWrite to the final result.\n\tif resp != nil {\n\t\tpw.result.response = resp\n\t}\n\tpw.result.err = err\n\tpw.result.totalAttempts = pw.attemptCount\n\n\t// Close the result's ready channel.\n\tclose(pw.result.ready)\n\t// Cleanup references remaining on the write explicitly.\n\tpw.req = nil\n\tpw.descVersion = nil\n\tpw.writer = nil\n\tpw.reqCtx = nil\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *IscsiInitiatorGetIterRequest) MaxRecords() int {\n\tvar r int\n\tif o.MaxRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.MaxRecordsPtr\n\treturn r\n}", "func (r *ReleaseAccessBearersResponse) SetLength() {\n\tr.Header.Length = uint16(r.MarshalLen() - 4)\n}", "func (d *DBClient) ImportRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\n\tvar requests recordedRequests\n\n\tdefer req.Body.Close()\n\tbody, err := ioutil.ReadAll(req.Body)\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tvar response messageResponse\n\n\tif err != nil {\n\t\t// failed to read response body\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Error(\"Could not read response body!\")\n\t\tresponse.Message = \"Bad request. Nothing to import!\"\n\t\thttp.Error(w, \"Failed to read request body.\", 400)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &requests)\n\n\tif err != nil {\n\t\tw.WriteHeader(422) // can't process this entity\n\t\treturn\n\t}\n\n\terr = d.ImportPayloads(requests.Data)\n\n\tif err != nil {\n\t\tresponse.Message = err.Error()\n\t\tw.WriteHeader(400)\n\t} else {\n\t\tresponse.Message = fmt.Sprintf(\"%d payloads import complete.\", len(requests.Data))\n\t}\n\n\tb, err := json.Marshal(response)\n\tw.Write(b)\n\n}", "func (client GroupClient) ListTablePartitionsPreparer(accountName string, databaseName string, schemaName string, tableName string, filter string, top *int32, skip *int32, expand string, selectParameter string, orderby string, count *bool) (*http.Request, error) {\n\turlParameters := map[string]interface{}{\n\t\t\"accountName\": accountName,\n\t\t\"adlaCatalogDnsSuffix\": client.AdlaCatalogDNSSuffix,\n\t}\n\n\tpathParameters := map[string]interface{}{\n\t\t\"databaseName\": autorest.Encode(\"path\", databaseName),\n\t\t\"schemaName\": autorest.Encode(\"path\", schemaName),\n\t\t\"tableName\": autorest.Encode(\"path\", tableName),\n\t}\n\n\tconst APIVersion = \"2015-10-01-preview\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\tif len(filter) > 0 {\n\t\tqueryParameters[\"$filter\"] = autorest.Encode(\"query\", filter)\n\t}\n\tif top != nil {\n\t\tqueryParameters[\"$top\"] = autorest.Encode(\"query\", *top)\n\t}\n\tif skip != nil {\n\t\tqueryParameters[\"$skip\"] = autorest.Encode(\"query\", *skip)\n\t}\n\tif len(expand) > 0 {\n\t\tqueryParameters[\"$expand\"] = autorest.Encode(\"query\", expand)\n\t}\n\tif len(selectParameter) > 0 {\n\t\tqueryParameters[\"$select\"] = autorest.Encode(\"query\", selectParameter)\n\t}\n\tif len(orderby) > 0 {\n\t\tqueryParameters[\"$orderby\"] = autorest.Encode(\"query\", orderby)\n\t}\n\tif count != nil {\n\t\tqueryParameters[\"$count\"] = autorest.Encode(\"query\", *count)\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsGet(),\n\t\tautorest.WithCustomBaseURL(\"https://{accountName}.{adlaCatalogDnsSuffix}\", urlParameters),\n\t\tautorest.WithPathParameters(\"/catalog/usql/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/partitions\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare(&http.Request{})\n}", "func (records Records) Cleaned() Records {\n\trecordsCount := len(records)\n\tif recordsCount == 0 {\n\t\treturn records\n\t}\n\n\tif recordsCount == 1 {\n\t\tr := records[0]\n\t\tif r.Duration == 0 {\n\t\t\tr.Duration = DefaultMeetDuration\n\t\t}\n\n\t\treturn records\n\t}\n\n\tsort.Sort(OrderByDate(records))\n\n\treturn fixDuration(recordsCount, records)\n}", "func RemainingArgs(s kingpin.Settings) (target *[]string) {\n\ttarget = new([]string)\n\ts.SetValue((*RemainingArgsList)(target))\n\treturn\n}", "func (o *FileInfoCollectionGetParams) SetMaxRecords(maxRecords *int64) {\n\to.MaxRecords = maxRecords\n}", "func (client DatasetClient) ListComplete(ctx context.Context) (result DatasetListResponseIterator, err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/DatasetClient.List\")\n defer func() {\n sc := -1\n if result.Response().Response.Response != nil {\n sc = result.page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n result.page, err = client.List(ctx)\n return\n }", "func (o *IscsiInterfaceGetIterRequest) MaxRecords() int {\n\tvar r int\n\tif o.MaxRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.MaxRecordsPtr\n\treturn r\n}", "func updateMasterRecords(stub shim.ChaincodeStubInterface, ufaNumber string) error {\r\n\tvar recordList []string\r\n\trecBytes, _ := stub.GetState(ALL_ELEMENENTS)\r\n\r\n\terr := json.Unmarshal(recBytes, &recordList)\r\n\tif err != nil {\r\n\t\treturn errors.New(\"Failed to unmarshal updateMasterReords \")\r\n\t}\r\n\trecordList = append(recordList, ufaNumber)\r\n\tbytesToStore, _ := json.Marshal(recordList)\r\n\tlogger.Info(\"After addition\" + string(bytesToStore))\r\n\tstub.PutState(ALL_ELEMENENTS, bytesToStore)\r\n\treturn nil\r\n}", "func (o *PortsetCollectionGetParams) SetMaxRecords(maxRecords *int64) {\n\to.MaxRecords = maxRecords\n}", "func (c *copReqSenderPool) recycleIdxRecords(idxRecs []*indexRecord) {\n\tif len(idxRecs) == 0 {\n\t\treturn\n\t}\n\tc.idxBufPool.Put(idxRecs[:0])\n}", "func (o *ViewProjectBudget) SetRepeatsRemaining(v int32) {\n\to.RepeatsRemaining = &v\n}", "func (o *VolumeModifyIterAsyncResponseResultFailureList) setValues(newValue []VolumeModifyIterAsyncInfoType) *VolumeModifyIterAsyncResponseResultFailureList {\n\tnewSlice := make([]VolumeModifyIterAsyncInfoType, len(newValue))\n\tcopy(newSlice, newValue)\n\to.VolumeModifyIterAsyncInfoPtr = newSlice\n\treturn o\n}", "func (_obj *DataService) GetActivityRecordsWithContext(tarsCtx context.Context, index int32, batch int32, activity_id string, nextIndex *int32, recordList *[]ActivityRecord, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(activity_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*recordList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *recordList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getActivityRecords\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*recordList) = make([]ActivityRecord, length)\n\t\tfor i21, e21 := int32(0), length; i21 < e21; i21++ {\n\n\t\t\terr = (*recordList)[i21].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (o *GetPreEnrollmentsForFacilityOK) SetPayload(payload []*models.Enrollment) {\n\to.Payload = payload\n}", "func (souo *SubjectsOfferedUpdateOne) AddRemain(i int) *SubjectsOfferedUpdateOne {\n\tsouo.mutation.AddRemain(i)\n\treturn souo\n}", "func updateMasterRecords(stub shim.ChaincodeStubInterface, ufaNumber string) error {\n\tvar recordList []string\n\trecBytes, _ := stub.GetState(ALL_ELEMENENTS)\n\n\terr := json.Unmarshal(recBytes, &recordList)\n\tif err != nil {\n\t\treturn errors.New(\"Failed to unmarshal updateMasterReords \")\n\t}\n\trecordList = append(recordList, ufaNumber)\n\tbytesToStore, _ := json.Marshal(recordList)\n\tlogger.Info(\"After addition\" + string(bytesToStore))\n\tstub.PutState(ALL_ELEMENENTS, bytesToStore)\n\treturn nil\n}", "func (r *ListDatabaseBackupsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDatabaseBackupsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.DatabaseBackups = append(r.DatabaseBackups, results.DatabaseBackups...)\n\tr.TotalCount += uint32(len(results.DatabaseBackups))\n\treturn uint32(len(results.DatabaseBackups)), nil\n}", "func (mrlr MonitoredResourceListResponse) monitoredResourceListResponsePreparer(ctx context.Context) (*http.Request, error) {\n\tif !mrlr.hasNextLink() {\n\t\treturn nil, nil\n\t}\n\treturn autorest.Prepare((&http.Request{}).WithContext(ctx),\n\t\tautorest.AsJSON(),\n\t\tautorest.AsGet(),\n\t\tautorest.WithBaseURL(to.String(mrlr.NextLink)))\n}", "func (s *Session) setFailed(failures []string) {\n\ts.Failures = append(s.Failures, failures...)\n\ts.Status = \"failed\"\n}", "func (sou *SubjectsOfferedUpdate) AddRemain(i int) *SubjectsOfferedUpdate {\n\tsou.mutation.AddRemain(i)\n\treturn sou\n}", "func (d *Dataset) BadRecordsCount() int {\n\tif len(d.badRecords) == 0 {\n\t\td.RecordCount() //hack to get records loaded so errors can be populated in dataset\n\t}\n\n\treturn len(d.badRecords)\n}" ]
[ "0.69616556", "0.5386693", "0.5374586", "0.52538633", "0.49944463", "0.4884808", "0.4698167", "0.46968845", "0.46378824", "0.45794222", "0.45628688", "0.4557788", "0.45545992", "0.44833428", "0.44659272", "0.44270992", "0.4404188", "0.43419722", "0.43134865", "0.43134865", "0.43080506", "0.4300385", "0.42881703", "0.4284156", "0.4282685", "0.42585817", "0.42339087", "0.4233074", "0.4227725", "0.42258954", "0.42165443", "0.42132676", "0.42064622", "0.42016742", "0.41944885", "0.418099", "0.41715425", "0.4169465", "0.4164064", "0.41539982", "0.41532898", "0.4149307", "0.41478744", "0.4138347", "0.41345263", "0.41316962", "0.4129107", "0.41266903", "0.41194206", "0.4115126", "0.4114705", "0.41131562", "0.41088173", "0.4108472", "0.41006455", "0.40893918", "0.40856478", "0.40768787", "0.40750092", "0.40732732", "0.40719953", "0.40714392", "0.40690783", "0.40628508", "0.40624154", "0.4051029", "0.40496638", "0.40493143", "0.40464827", "0.40446416", "0.40390742", "0.40382478", "0.40288877", "0.40277812", "0.40185195", "0.4018211", "0.40109974", "0.40037903", "0.40016067", "0.4000394", "0.39813748", "0.39812186", "0.3977928", "0.3974794", "0.39741653", "0.39708441", "0.3969771", "0.3967866", "0.39669028", "0.39627066", "0.39577258", "0.39558312", "0.3954772", "0.39511818", "0.3947392", "0.39461708", "0.3943821", "0.39423212", "0.39418632", "0.39374474" ]
0.7889897
0
WithTotalRecords adds the totalRecords to the artifact lister partial content response
func (o *ArtifactListerPartialContent) WithTotalRecords(totalRecords uint64) *ArtifactListerPartialContent { o.TotalRecords = totalRecords return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) WithTotalRecords(totalRecords uint64) *ArtifactListerOK {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerOK) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerPartialContent) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerPartialContent) WithRemainingRecords(remainingRecords uint64) *ArtifactListerPartialContent {\n\to.RemainingRecords = remainingRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetRemainingRecords(remainingRecords uint64) {\n\to.RemainingRecords = remainingRecords\n}", "func (g *GlobalResponse) Sum() {\n\tsum := 0\n\n\tfor _, v := range g.Records {\n\t\tsum += v.Fields.NumBikesAvailable\n\t}\n\n\tg.Total = sum\n}", "func (rest *RestController) All(w http.ResponseWriter, r *http.Request) (Response, error) {\n\tresources := reflect.New(reflect.SliceOf(reflect.TypeOf(rest.Table).Elem()))\n\tcount, err := rest.Table.List(resources.Interface(), models.NewDBQuery(r.URL.Query(), nil))\n\tif err != nil {\n\t\treturn nil, &httpError{err, \"\", 500}\n\t}\n\tw.Header().Set(\"Total\", strconv.FormatInt(count, 10))\n\treturn &JSONResponse{resources.Interface(), 200}, nil\n}", "func outputRecordsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (rb *ShardsRecordBuilder) FlushTotal(flushtotal string) *ShardsRecordBuilder {\n\trb.v.FlushTotal = &flushtotal\n\treturn rb\n}", "func (r *SubscriptionsListServerResponse) Total(value int) *SubscriptionsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (r *MachinePoolsListServerResponse) Total(value int) *MachinePoolsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsCalled(int) {}", "func (d *DBClient) RecordsCount(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\tcount, err := d.Cache.RecordsCount()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordsCount\n\t\tresponse.Count = count\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (resp *DomainRecordsPagedResponse) appendData(r *DomainRecordsPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsCalled(count int) {\n\tdsc.GetRecordsCalled.Inc(int64(count))\n}", "func (d *DBClient) AllRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\trecords, err := d.Cache.GetAllRequests()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordedRequests\n\t\tresponse.Data = records\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (t File_summary_by_instance) TotalRowContent() string {\n\treturn t.totals.row_content(t.totals)\n}", "func (fc *FileControl) TotalRecordCountField() string {\n\treturn fc.numericField(fc.TotalRecordCount, 8)\n}", "func (o ServerEndpointSyncActivityStatusResponseOutput) TotalItemCount() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointSyncActivityStatusResponse) float64 { return v.TotalItemCount }).(pulumi.Float64Output)\n}", "func (k Keeper) RecordsAll(c context.Context, req *types.RecordsAllRequest) (*types.RecordsAllResponse, error) {\n\tdefer telemetry.MeasureSince(time.Now(), types.ModuleName, \"query\", \"RecordsAll\")\n\tretval := types.RecordsAllResponse{Request: req}\n\n\tpageRequest := getPageRequest(req)\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tkvStore := ctx.KVStore(k.storeKey)\n\tprefixStore := prefix.NewStore(kvStore, types.RecordKeyPrefix)\n\n\tpageRes, err := query.Paginate(prefixStore, pageRequest, func(key, value []byte) error {\n\t\tvar record types.Record\n\t\tvErr := record.Unmarshal(value)\n\t\tif vErr == nil {\n\t\t\tretval.Records = append(retval.Records, types.WrapRecord(&record))\n\t\t\treturn nil\n\t\t}\n\t\t// Something's wrong. Let's do what we can to give indications of it.\n\t\tvar addr types.MetadataAddress\n\t\tkErr := addr.Unmarshal(key)\n\t\tif kErr == nil {\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record\", \"address\", addr, \"error\", vErr)\n\t\t\tretval.Records = append(retval.Records, types.WrapRecordNotFound(addr))\n\t\t} else {\n\t\t\tk64 := b64.StdEncoding.EncodeToString(key)\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record key and value\",\n\t\t\t\t\"key error\", kErr, \"value error\", vErr, \"key (base64)\", k64)\n\t\t\tretval.Records = append(retval.Records, &types.RecordWrapper{})\n\t\t}\n\t\treturn nil // Still want to move on to the next.\n\t})\n\tif err != nil {\n\t\treturn &retval, status.Error(codes.Unavailable, err.Error())\n\t}\n\tretval.Pagination = pageRes\n\treturn &retval, nil\n}", "func (r *MachinePoolsListResponse) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func (o *ArtifactListerPartialContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Next\n\n\tnext := o.Next\n\tif next != \"\" {\n\t\trw.Header().Set(\"Next\", next)\n\t}\n\n\t// response header Previous\n\n\tprevious := o.Previous\n\tif previous != \"\" {\n\t\trw.Header().Set(\"Previous\", previous)\n\t}\n\n\t// response header RemainingRecords\n\n\tremainingRecords := swag.FormatUint64(o.RemainingRecords)\n\tif remainingRecords != \"\" {\n\t\trw.Header().Set(\"RemainingRecords\", remainingRecords)\n\t}\n\n\t// response header TotalRecords\n\n\ttotalRecords := swag.FormatUint64(o.TotalRecords)\n\tif totalRecords != \"\" {\n\t\trw.Header().Set(\"TotalRecords\", totalRecords)\n\t}\n\n\trw.WriteHeader(206)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*weles.ArtifactInfo, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (m *TotalListHandler) ServeHTTP(\n\trw http.ResponseWriter, req *http.Request) {\n\tvar user string\n\tvar all_records TotalRecordList\n\tvar err error\n\n\tif user = m.auth.GetAuthenticatedUser(req); user == \"\" {\n\t\tm.auth.RequestAuthorization(rw, req)\n\t\treturn\n\t}\n\n\tif len(m.admingroup) > 0 && !m.auth.IsAuthenticatedScope(\n\t\treq, m.admingroup) {\n\t\tvar agreement *membersys.MembershipAgreement\n\n\t\tagreement, err = m.database.GetMemberDetailByUsername(\n\t\t\treq.Context(), user)\n\t\tif err != nil {\n\t\t\tlog.Print(\"Can't get membership agreement for \", user, \": \", err)\n\t\t\treturn\n\t\t}\n\n\t\terr = m.uniqueMemberTemplate.ExecuteTemplate(rw, \"memberdetail.html\",\n\t\t\tagreement.GetMemberData())\n\t\tif err != nil {\n\t\t\tlog.Print(\"Can't run membership detail template: \", err)\n\t\t}\n\n\t\treturn\n\t}\n\n\tall_records.Applicants, err = m.database.EnumerateMembershipRequests(\n\t\treq.Context(), req.FormValue(\"applicant_criterion\"),\n\t\treq.FormValue(\"applicant_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list applicants from \",\n\t\t\treq.FormValue(\"applicant_start\"), \": \", err)\n\t}\n\n\tall_records.Members, err = m.database.EnumerateMembers(\n\t\treq.Context(), req.FormValue(\"member_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list members from \",\n\t\t\treq.FormValue(\"member_start\"), \": \", err)\n\t}\n\n\tall_records.Queue, err = m.database.EnumerateQueuedMembers(\n\t\treq.Context(), req.FormValue(\"queued_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list queued members from \",\n\t\t\treq.FormValue(\"queued_start\"), \": \", err)\n\t}\n\n\tall_records.DeQueue, err = m.database.EnumerateDeQueuedMembers(\n\t\treq.Context(), req.FormValue(\"queued_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list dequeued members from \",\n\t\t\treq.FormValue(\"queued_start\"), \": \", err)\n\t}\n\n\tall_records.Trash, err = m.database.EnumerateTrashedMembers(\n\t\treq.Context(), req.FormValue(\"trashed_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list trashed members from \",\n\t\t\treq.FormValue(\"trashed_start\"), \": \", err)\n\t}\n\n\tall_records.ApprovalCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, applicantApprovalURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating approval CSRF token: \", err)\n\t}\n\tall_records.RejectionCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, applicantRejectionURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating rejection CSRF token: \", err)\n\t}\n\tall_records.UploadCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, applicantAgreementUploadURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating agreement upload CSRF token: \", err)\n\t}\n\tall_records.CancelCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, queueCancelURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating queue cancellation CSRF token: \", err)\n\t}\n\tall_records.GoodbyeCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, memberGoodbyeURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating member goodbye CSRF token: \", err)\n\t}\n\n\tall_records.PageSize = m.pagesize\n\n\terr = m.template.ExecuteTemplate(rw, \"memberlist.html\", all_records)\n\tif err != nil {\n\t\tlog.Print(\"Error executing member list template: \", err)\n\t}\n}", "func TotalCount(resp *http.Response) int {\n\tif resp == nil {\n\t\treturn 0\n\t}\n\n\ttotalCountHeader := resp.Header.Get(totalCountHeaderKey)\n\ttotalCount, err := strconv.ParseInt(totalCountHeader, 10, 64)\n\tif err != nil {\n\t\treturn 0\n\t}\n\n\treturn int(totalCount)\n}", "func WithIncludeFinal(includeFinal bool) ListDealRecordsOption {\n\treturn func(c *rpc.ListDealRecordsConfig) {\n\t\tc.IncludeFinal = includeFinal\n\t}\n}", "func WithTotalItems(totalItems int) Opt {\n\treturn func(opts *Options) {\n\t\topts.TotalItems = totalItems\n\t}\n}", "func (_obj *DataService) GetActivityRecords(index int32, batch int32, activity_id string, nextIndex *int32, recordList *[]ActivityRecord, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(activity_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*recordList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *recordList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\ttarsCtx := context.Background()\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getActivityRecords\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*recordList) = make([]ActivityRecord, length)\n\t\tfor i20, e20 := int32(0), length; i20 < e20; i20++ {\n\n\t\t\terr = (*recordList)[i20].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (m *MonitoringAlertRecordsRequestBuilder) Count()(*MonitoringAlertRecordsCountRequestBuilder) {\n return NewMonitoringAlertRecordsCountRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func (w *Wrapper) WithTotalCount() *Wrapper {\n\tw.SetQueryOption(\"SQL_CALC_FOUND_ROWS\")\n\treturn w\n}", "func (o ServerEndpointSyncActivityStatusResponseOutput) TotalBytes() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointSyncActivityStatusResponse) float64 { return v.TotalBytes }).(pulumi.Float64Output)\n}", "func (ac *AppContext) totalMessages(w http.ResponseWriter, r *http.Request) {\n\tcnt, err := ac.r.TotalMessages()\n\tif err != nil {\n\t\tlogrus.WithError(err).Error(\"Failed getting total messages\")\n\t\tWriteError(w, ErrInternalServer)\n\t\treturn\n\t}\n\tjson.NewEncoder(w).Encode(messageCount{cnt})\n}", "func (resp *LongviewClientsPagedResponse) appendData(r *LongviewClientsPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func outputRecordSpecsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordSpecificationsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordSpecificationsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (r ApiGetBulkExportedItemListRequest) Count(count bool) ApiGetBulkExportedItemListRequest {\n\tr.count = &count\n\treturn r\n}", "func IncrementSuccessfulList(counts int) {\n\tincSuccessfulRequestByHandler(\"list\", counts)\n}", "func (bguo *BarGroupUpdateOne) AddRecords(b ...*BarRecord) *BarGroupUpdateOne {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bguo.AddRecordIDs(ids...)\n}", "func (r *ListDNSZoneVersionRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneVersionRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func addIncludeRecordsFlag(cmd *cobra.Command) {\n\tcmd.Flags().BoolVar(&includeRecords, \"include-records\", false, \"include records in the output\")\n}", "func getTotals(snapshots []Snapshot) TotalResponse {\n reports := len(snapshots)\n days := make(map[string]int)\n people := make(map[string]int)\n locations := make(map[string]int)\n activities:= make(map[string]int)\n coffees := 0\n\n for _, snapshot := range snapshots {\n // Count people\n date := snapshot.Date[:10]\n days[date]++\n\n for _, response := range snapshot.Responses {\n question := response.QuestionPrompt\n // Count people\n if question == \"Who are you with?\" {\n for _, token := range response.Tokens {\n people[token.Text]++\n }\n } else if question == \"Where are you?\" {\n // count locations\n locations[response.LocationResponse.Text]++\n } else if question == \"How many coffees did you have today?\" {\n // count coffees\n amount, err := strconv.Atoi(response.NumericResponse)\n if err == nil {\n coffees += amount\n }\n } else if question == \"What are you doing?\" {\n for _, token := range response.Tokens {\n activities[token.Text]++\n }\n }\n }\n }\n\n return TotalResponse{\n TotalDays: len(days),\n TotalReports: reports,\n TotalPeople: len(people),\n TotalLocations: len(locations),\n AvgPerDay: float32(reports)/float32(len(days)),\n TotalCoffees: coffees,\n CoffeesPerDay: float32(coffees)/float32(len(days)),\n PeopleList: people,\n LocationList: locations,\n ActivityList: activities,\n }\n}", "func (r ApiGetBulkExportListRequest) Count(count bool) ApiGetBulkExportListRequest {\n\tr.count = &count\n\treturn r\n}", "func (rb *ShardsRecordBuilder) WarmerTotal(warmertotal string) *ShardsRecordBuilder {\n\trb.v.WarmerTotal = &warmertotal\n\treturn rb\n}", "func ExampleSavingsPlanClient_NewListAllPager() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armbillingbenefits.NewClientFactory(cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tpager := clientFactory.NewSavingsPlanClient().NewListAllPager(&armbillingbenefits.SavingsPlanClientListAllOptions{Filter: to.Ptr(\"(properties%2farchived+eq+false)\"),\n\t\tOrderby: to.Ptr(\"properties/displayName asc\"),\n\t\tRefreshSummary: nil,\n\t\tSkiptoken: to.Ptr[float32](50),\n\t\tSelectedState: nil,\n\t\tTake: to.Ptr[float32](1),\n\t})\n\tfor pager.More() {\n\t\tpage, err := pager.NextPage(ctx)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed to advance page: %v\", err)\n\t\t}\n\t\tfor _, v := range page.Value {\n\t\t\t// You could use page here. We use blank identifier for just demo purposes.\n\t\t\t_ = v\n\t\t}\n\t\t// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t\t// page.SavingsPlanModelListResult = armbillingbenefits.SavingsPlanModelListResult{\n\t\t// \tAdditionalProperties: []*armbillingbenefits.SavingsPlanSummary{\n\t\t// \t\t{\n\t\t// \t\t\tName: to.Ptr(\"summary\"),\n\t\t// \t\t\tValue: &armbillingbenefits.SavingsPlanSummaryCount{\n\t\t// \t\t\t\tCancelledCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tExpiredCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tExpiringCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tFailedCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tNoBenefitCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tPendingCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tProcessingCount: to.Ptr[float32](0),\n\t\t// \t\t\t\tSucceededCount: to.Ptr[float32](1),\n\t\t// \t\t\t\tWarningCount: to.Ptr[float32](0),\n\t\t// \t\t\t},\n\t\t// \t}},\n\t\t// \tValue: []*armbillingbenefits.SavingsPlanModel{\n\t\t// \t\t{\n\t\t// \t\t\tName: to.Ptr(\"20000000-0000-0000-0000-000000000000/30000000-0000-0000-0000-000000000000\"),\n\t\t// \t\t\tType: to.Ptr(\"Microsoft.BillingBenefits/savingsPlanOrders/savingsPlans\"),\n\t\t// \t\t\tID: to.Ptr(\"/providers/microsoft.billingbenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000\"),\n\t\t// \t\t\tProperties: &armbillingbenefits.SavingsPlanModelProperties{\n\t\t// \t\t\t\tAppliedScopeProperties: &armbillingbenefits.AppliedScopeProperties{\n\t\t// \t\t\t\t\tDisplayName: to.Ptr(\"Azure subscription 1\"),\n\t\t// \t\t\t\t\tSubscriptionID: to.Ptr(\"/subscriptions/20000000-0000-0000-0000-000000000005\"),\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tAppliedScopeType: to.Ptr(armbillingbenefits.AppliedScopeTypeSingle),\n\t\t// \t\t\t\tBillingAccountID: to.Ptr(\"/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31\"),\n\t\t// \t\t\t\tBillingProfileID: to.Ptr(\"/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000000:20000000-0000-3000-0000-000000000000_2019-05-31/billingProfiles/KPSV-DWNE-BG7-TGB\"),\n\t\t// \t\t\t\tBillingScopeID: to.Ptr(\"/providers/Microsoft.Billing/billingAccounts/20000000-1000-0000-0000-000000000009\"),\n\t\t// \t\t\t\tCommitment: &armbillingbenefits.Commitment{\n\t\t// \t\t\t\t\tAmount: to.Ptr[float64](0.001),\n\t\t// \t\t\t\t\tCurrencyCode: to.Ptr(\"USD\"),\n\t\t// \t\t\t\t\tGrain: to.Ptr(armbillingbenefits.CommitmentGrainHourly),\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tDisplayName: to.Ptr(\"Compute_SavingsPlan_10-19-2022_11-03\"),\n\t\t// \t\t\t\tDisplayProvisioningState: to.Ptr(\"Succeeded\"),\n\t\t// \t\t\t\tEffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2022-10-19T18:05:37.1034288Z\"); return t}()),\n\t\t// \t\t\t\tExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2023-10-19T18:05:36.5252231Z\"); return t}()),\n\t\t// \t\t\t\tProvisioningState: to.Ptr(armbillingbenefits.ProvisioningStateSucceeded),\n\t\t// \t\t\t\tPurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2022-10-19T18:03:56.4032132Z\"); return t}()),\n\t\t// \t\t\t\tRenew: to.Ptr(false),\n\t\t// \t\t\t\tTerm: to.Ptr(armbillingbenefits.TermP1Y),\n\t\t// \t\t\t\tUserFriendlyAppliedScopeType: to.Ptr(\"Single\"),\n\t\t// \t\t\t\tUtilization: &armbillingbenefits.Utilization{\n\t\t// \t\t\t\t\tAggregates: []*armbillingbenefits.UtilizationAggregates{\n\t\t// \t\t\t\t\t\t{\n\t\t// \t\t\t\t\t\t\tGrain: to.Ptr[float32](1),\n\t\t// \t\t\t\t\t\t\tGrainUnit: to.Ptr(\"days\"),\n\t\t// \t\t\t\t\t\t\tValue: to.Ptr[float32](100),\n\t\t// \t\t\t\t\t\t\tValueUnit: to.Ptr(\"percentage\"),\n\t\t// \t\t\t\t\t\t},\n\t\t// \t\t\t\t\t\t{\n\t\t// \t\t\t\t\t\t\tGrain: to.Ptr[float32](7),\n\t\t// \t\t\t\t\t\t\tGrainUnit: to.Ptr(\"days\"),\n\t\t// \t\t\t\t\t\t\tValue: to.Ptr[float32](78),\n\t\t// \t\t\t\t\t\t\tValueUnit: to.Ptr(\"percentage\"),\n\t\t// \t\t\t\t\t\t},\n\t\t// \t\t\t\t\t\t{\n\t\t// \t\t\t\t\t\t\tGrain: to.Ptr[float32](30),\n\t\t// \t\t\t\t\t\t\tGrainUnit: to.Ptr(\"days\"),\n\t\t// \t\t\t\t\t\t\tValue: to.Ptr[float32](78.12),\n\t\t// \t\t\t\t\t\t\tValueUnit: to.Ptr(\"percentage\"),\n\t\t// \t\t\t\t\t}},\n\t\t// \t\t\t\t\tTrend: to.Ptr(\"\"),\n\t\t// \t\t\t\t},\n\t\t// \t\t\t},\n\t\t// \t\t\tSKU: &armbillingbenefits.SKU{\n\t\t// \t\t\t\tName: to.Ptr(\"Compute_Savings_Plan\"),\n\t\t// \t\t\t},\n\t\t// \t}},\n\t\t// }\n\t}\n}", "func (r ApiGetBulkSubRequestObjListRequest) Count(count bool) ApiGetBulkSubRequestObjListRequest {\n\tr.count = &count\n\treturn r\n}", "func (r ApiGetBulkResultListRequest) Count(count bool) ApiGetBulkResultListRequest {\n\tr.count = &count\n\treturn r\n}", "func displayAllRecords(records []Record) {\n\tfmt.Printf(\"\\nDisplaying all records...\\n\\n\")\n\n\tfor i := 0; i < len(records); i++ {\n\t\tfmt.Printf(\"Record ID: %d: %+v\\n\", i, records[i])\n\t\ttime.Sleep(5 * time.Millisecond) // 5ms between records\n\t}\n}", "func (m *ItemItemsItemWorkbookTablesWorkbookTableItemRequestBuilder) TotalRowRange()(*ItemItemsItemWorkbookTablesItemTotalRowRangeRequestBuilder) {\n return NewItemItemsItemWorkbookTablesItemTotalRowRangeRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func ReportTotalHandler(writer http.ResponseWriter, request *http.Request) {\n session, err := mgo.Dial(\"10.11.12.13:27017\")\n check(err)\n defer session.Close()\n\n snapshots := make([]Snapshot, 1)\n\n c := session.DB(\"reports\").C(\"snapshots\")\n c.Find(bson.M{}).All(&snapshots)\n\n resp := getTotals(snapshots)\n\n writeJSONResp(writer, resp, 200)\n}", "func (rb *ShardsRecordBuilder) GetTotal(gettotal string) *ShardsRecordBuilder {\n\trb.v.GetTotal = &gettotal\n\treturn rb\n}", "func (rb *ShardsRecordBuilder) RefreshExternalTotal(refreshexternaltotal string) *ShardsRecordBuilder {\n\trb.v.RefreshExternalTotal = &refreshexternaltotal\n\treturn rb\n}", "func (o *GetAllPublicIPUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (t File_summary_by_instance) RowContent(max_rows int) []string {\n\trows := make([]string, 0, max_rows)\n\n\tfor i := range t.results {\n\t\tif i < max_rows {\n\t\t\trows = append(rows, t.results[i].row_content(t.totals))\n\t\t}\n\t}\n\n\treturn rows\n}", "func (bgu *BarGroupUpdate) AddRecords(b ...*BarRecord) *BarGroupUpdate {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bgu.AddRecordIDs(ids...)\n}", "func (k Keeper) RecordSpecificationsAll(c context.Context, req *types.RecordSpecificationsAllRequest) (*types.RecordSpecificationsAllResponse, error) {\n\tdefer telemetry.MeasureSince(time.Now(), types.ModuleName, \"query\", \"RecordSpecificationsAll\")\n\tretval := types.RecordSpecificationsAllResponse{Request: req}\n\n\tpageRequest := getPageRequest(req)\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tkvStore := ctx.KVStore(k.storeKey)\n\tprefixStore := prefix.NewStore(kvStore, types.RecordSpecificationKeyPrefix)\n\n\tpageRes, err := query.Paginate(prefixStore, pageRequest, func(key, value []byte) error {\n\t\tvar recordSpec types.RecordSpecification\n\t\tvErr := recordSpec.Unmarshal(value)\n\t\tif vErr == nil {\n\t\t\tretval.RecordSpecifications = append(retval.RecordSpecifications, types.WrapRecordSpec(&recordSpec))\n\t\t\treturn nil\n\t\t}\n\t\t// Something's wrong. Let's do what we can to give indications of it.\n\t\tvar addr types.MetadataAddress\n\t\tkErr := addr.Unmarshal(key)\n\t\tif kErr == nil {\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record spec\", \"address\", addr, \"error\", vErr)\n\t\t\tretval.RecordSpecifications = append(retval.RecordSpecifications, types.WrapRecordSpecNotFound(addr))\n\t\t} else {\n\t\t\tk64 := b64.StdEncoding.EncodeToString(key)\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record spec key and value\",\n\t\t\t\t\"key error\", kErr, \"value error\", vErr, \"key (base64)\", k64)\n\t\t\tretval.RecordSpecifications = append(retval.RecordSpecifications, &types.RecordSpecificationWrapper{})\n\t\t}\n\t\treturn nil // Still want to move on to the next.\n\t})\n\tif err != nil {\n\t\treturn &retval, status.Error(codes.Unavailable, err.Error())\n\t}\n\tretval.Pagination = pageRes\n\treturn &retval, nil\n}", "func (r *SubscriptionsListServerRequest) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func (r ApiGetHyperflexFeatureLimitExternalListRequest) Count(count bool) ApiGetHyperflexFeatureLimitExternalListRequest {\n\tr.count = &count\n\treturn r\n}", "func ListAssetSummaries(settings *playfab.Settings, postData *ListAssetSummariesRequestModel, entityToken string) (*ListAssetSummariesResponseModel, error) {\n if entityToken == \"\" {\n return nil, playfab.NewCustomError(\"entityToken should not be an empty string\", playfab.ErrorGeneric)\n }\n b, errMarshal := json.Marshal(postData)\n if errMarshal != nil {\n return nil, playfab.NewCustomError(errMarshal.Error(), playfab.ErrorMarshal)\n }\n\n sourceMap, err := playfab.Request(settings, b, \"/MultiplayerServer/ListAssetSummaries\", \"X-EntityToken\", entityToken)\n if err != nil {\n return nil, err\n }\n \n result := &ListAssetSummariesResponseModel{}\n\n config := mapstructure.DecoderConfig{\n DecodeHook: playfab.StringToDateTimeHook,\n Result: result,\n }\n \n decoder, errDecoding := mapstructure.NewDecoder(&config)\n if errDecoding != nil {\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\n }\n \n errDecoding = decoder.Decode(sourceMap)\n if errDecoding != nil {\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\n }\n\n return result, nil\n}", "func (r ApiGetHyperflexConfigResultEntryListRequest) Count(count bool) ApiGetHyperflexConfigResultEntryListRequest {\n\tr.count = &count\n\treturn r\n}", "func (c *PlanClient) AllWithFilters(filters Filters) (*PlanListResponse, error) {\n\tresponse := PlanListResponse{}\n\tvalues := url.Values{}\n\taddFiltersToValues([]string{\"count\", \"offset\"}, filters, &values)\n\terr := c.client.get(\"/plans\", values, &response)\n\treturn &response, err\n}", "func (page *Page) SetTotal(rowCount, pageSize uint64) {\n\tpage.Total = int64(math.Ceil(float64(rowCount) / float64(pageSize)))\n\tpage.TotalRows = int64(rowCount)\n}", "func TotalRetention(amount float64, values []RetValue) float64 {\n\ttotal := 0.0\n\tfor _, v := range values {\n\t\ttotal += PartialRetention(amount, v)\n\t}\n\treturn total\n}", "func (tt *TransactionTransformer) transformCollection(request *http.Request, data interface{}, totalData int, limit string) *TransactionResponse {\n\ttransactionResponse := &TransactionResponse{}\n\ttransactionResponse.TotalCount = totalData\n\ttransactionResponse.Data = data\n\n\t// Convert limit to int if not empty\n\tif limit != \"\" {\n\t\tlimitInt, _ := strconv.Atoi(limit)\n\n\t\tif limitInt != -1 && limitInt != 0 {\n\t\t\t// If limit not euqal to `-1` and `0' set transaction links. Transaction links contain link to current page,\n\t\t\t// first page, next page and last page.\n\t\t\ttransactionResponse.Links = PaginationReponse.BuildPaginationLinks(request, totalData)\n\t\t}\n\t}\n\n\treturn transactionResponse\n}", "func (ulw Wrapper) TotalRowContent() string {\n\treturn ulw.content(ulw.ul.Totals, ulw.ul.Totals)\n}", "func TestListRecordings(t *testing.T) {\n\tif !haveArchive {\n\t\treturn\n\t}\n\n\tif testing.Verbose() && DEBUG {\n\t\tlogging.SetLevel(logging.DEBUG, \"archive\")\n\t}\n\n\trecordings, err := archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tinitial := len(recordings)\n\tt.Logf(\"Initial count is %d\", initial)\n\n\t// Add a recording\n\tsubscriptionID, err := archive.StartRecording(testCases[0].sampleChannel, testCases[0].sampleStream, true, true)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tt.Logf(\"SubscriptionID is %d\", subscriptionID)\n\n\t// Add a publication on that\n\tpublication, err := archive.AddPublication(testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif testing.Verbose() && DEBUG {\n\t\tt.Logf(\"Publication is %#v\", publication)\n\t}\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif len(recordings) == 0 {\n\t\tt.Log(\"No Recordings!\")\n\t\tt.FailNow()\n\t}\n\n\t// Grab the recordingID\n\trecordingID := recordings[len(recordings)-1].RecordingId\n\tt.Logf(\"Working count is %d, recordingID is %d\", len(recordings), recordingID)\n\n\t// Cleanup\n\tres, err := archive.StopRecordingByIdentity(recordingID)\n\tif err != nil {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed: %s\", recordingID, err.Error())\n\t} else if !res {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed\", recordingID)\n\t}\n\tif err := archive.PurgeRecording(recordingID); err != nil {\n\t\tt.Logf(\"PurgeRecording(%d) failed: %s\", recordingID, err.Error())\n\t}\n\tpublication.Close()\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tfinal := len(recordings)\n\tt.Logf(\"Final count is %d\", final)\n\n\tif initial != final {\n\t\tt.Logf(\"Number of recordings changed from %d to %d\", initial, final)\n\t\tt.Fail()\n\t}\n}", "func (b *block) addAggregateResults(\n\tctx context.Context,\n\tresults AggregateResults,\n\tbatch []AggregateResultsEntry,\n\tsource []byte,\n) ([]AggregateResultsEntry, int, int, error) {\n\t_, sp := ctx.StartTraceSpan(tracepoint.NSIdxBlockAggregateQueryAddDocuments)\n\tdefer sp.Finish()\n\t// try to add the docs to the resource.\n\tsize, docsCount := results.AddFields(batch)\n\n\taggDocs := len(batch)\n\tfor i := range batch {\n\t\taggDocs += len(batch[i].Terms)\n\t}\n\n\t// update recently queried docs to monitor memory.\n\tif results.EnforceLimits() {\n\t\tif err := b.aggDocsLimit.Inc(aggDocs, source); err != nil {\n\t\t\treturn batch, 0, 0, err\n\t\t}\n\t}\n\n\t// reset batch.\n\tvar emptyField AggregateResultsEntry\n\tfor i := range batch {\n\t\tbatch[i] = emptyField\n\t}\n\tbatch = batch[:0]\n\n\t// return results.\n\treturn batch, size, docsCount, nil\n}", "func (o *GetSellerServicesUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (o *IscsiInterfaceGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (rb *ShardsRecordBuilder) SearchFetchTotal(searchfetchtotal string) *ShardsRecordBuilder {\n\trb.v.SearchFetchTotal = &searchfetchtotal\n\treturn rb\n}", "func (f *FileList) TotalByteSize() string {\n\treturn ByteSize(f.totalSize)\n}", "func (s *Service) Records(c context.Context, types []int64, mid, stime, etime int64, order, sort string, pn, ps int32) (res []*model.Record, total int32, err error) {\n\tvar midAts []int64\n\tif res, total, err = s.search.RecordPaginate(c, types, mid, stime, etime, order, sort, pn, ps); err != nil {\n\t\tlog.Error(\"s.search.RecordPaginate(%d,%d,%d,%d,%s,%s) error(%v)\", mid, sort, pn, ps, stime, etime, err)\n\t\treturn\n\t}\n\tif res == nil {\n\t\tres = _emptyRecords\n\t\treturn\n\t}\n\tfor _, r := range res {\n\t\tr.Message = template.HTMLEscapeString(r.Message)\n\t\tif len(r.Ats) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tvar ats []int64\n\t\tif ats, err = xstr.SplitInts(r.Ats); err != nil {\n\t\t\tlog.Error(\"xstr.SplitInts(%s) error(%v)\", r.Ats, err)\n\t\t\terr = nil\n\t\t}\n\t\tmidAts = append(midAts, ats...)\n\t}\n\tif len(midAts) == 0 {\n\t\treturn\n\t}\n\taccMap, _ := s.getAccInfo(c, midAts)\n\tfor _, r := range res {\n\t\tr.FillAts(accMap)\n\t}\n\treturn\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsTimeout(int) {}", "func (r ApiGetBulkRequestListRequest) Count(count bool) ApiGetBulkRequestListRequest {\n\tr.count = &count\n\treturn r\n}", "func (r ApiGetHyperflexFeatureLimitInternalListRequest) Count(count bool) ApiGetHyperflexFeatureLimitInternalListRequest {\n\tr.count = &count\n\treturn r\n}", "func ListEndpointGroupResults(r *http.Request, cfg config.Config) (int, http.Header, []byte, error) {\n\n\t//STANDARD DECLARATIONS START\n\tcode := http.StatusOK\n\th := http.Header{}\n\toutput := []byte(\"\")\n\terr := error(nil)\n\tcontentType := \"application/xml\"\n\tcharset := \"utf-8\"\n\t//STANDARD DECLARATIONS END\n\n\tcontentType, err = respond.ParseAcceptHeader(r)\n\th.Set(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\tif err != nil {\n\t\tcode = http.StatusNotAcceptable\n\t\toutput, _ = respond.MarshalContent(respond.NotAcceptableContentType, contentType, \"\", \" \")\n\t\treturn code, h, output, err\n\t}\n\n\t// Parse the request into the input\n\turlValues := r.URL.Query()\n\tvars := mux.Vars(r)\n\n\ttenantDbConfig, err := authentication.AuthenticateTenant(r.Header, cfg)\n\tif err != nil {\n\t\tif err.Error() == \"Unauthorized\" {\n\t\t\tcode = http.StatusUnauthorized\n\t\t\tout := respond.UnauthorizedMessage\n\t\t\toutput = out.MarshalTo(contentType)\n\t\t\treturn code, h, output, err\n\t\t}\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\tsession, err := mongo.OpenSession(tenantDbConfig)\n\tdefer mongo.CloseSession(session)\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\treport := reports.MongoInterface{}\n\terr = mongo.FindOne(session, tenantDbConfig.Db, \"reports\", bson.M{\"info.name\": vars[\"report_name\"]}, &report)\n\n\tif err != nil {\n\t\tcode = http.StatusBadRequest\n\t\tmessage := \"The report with the name \" + vars[\"report_name\"] + \" does not exist\"\n\t\toutput, err := createErrorMessage(message, contentType) //Render the response into XML or JSON\n\t\th.Set(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\t\treturn code, h, output, err\n\t}\n\n\tinput := endpointGroupResultQuery{\n\t\tbasicQuery{\n\t\t\tName: vars[\"lgroup_name\"],\n\t\t\tGranularity: urlValues.Get(\"granularity\"),\n\t\t\tFormat: contentType,\n\t\t\tStartTime: urlValues.Get(\"start_time\"),\n\t\t\tEndTime: urlValues.Get(\"end_time\"),\n\t\t\tReport: report,\n\t\t\tVars: vars,\n\t\t}, \"\",\n\t}\n\n\ttenantDB := session.DB(tenantDbConfig.Db)\n\terrs := input.Validate(tenantDB)\n\tif len(errs) > 0 {\n\t\tout := respond.BadRequestSimple\n\t\tout.Errors = errs\n\t\toutput = out.MarshalTo(contentType)\n\t\tcode = 400\n\t\treturn code, h, output, err\n\t}\n\n\tif vars[\"lgroup_type\"] != report.GetEndpointGroupType() {\n\t\tcode = http.StatusBadRequest\n\t\tmessage := \"The report \" + vars[\"report_name\"] + \" does not define endpoint group type: \" + vars[\"lgroup_type\"] + \". Try using \" + report.GetEndpointGroupType() + \" instead.\"\n\t\toutput, err := createErrorMessage(message, contentType) //Render the response into XML or JSON\n\t\th.Set(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\t\treturn code, h, output, err\n\t}\n\n\tresults := []EndpointGroupInterface{}\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\t// Construct the query to mongodb based on the input\n\tfilter := bson.M{\n\t\t\"date\": bson.M{\"$gte\": input.StartTimeInt, \"$lte\": input.EndTimeInt},\n\t\t\"report\": report.ID,\n\t}\n\n\tif input.Name != \"\" {\n\t\tfilter[\"name\"] = input.Name\n\t}\n\n\t// Select the granularity of the search daily/monthly\n\tif input.Granularity == \"daily\" {\n\t\tcustomForm[0] = \"20060102\"\n\t\tcustomForm[1] = \"2006-01-02\"\n\t\tquery := DailyEndpointGroup(filter)\n\t\terr = mongo.Pipe(session, tenantDbConfig.Db, \"endpoint_group_ar\", query, &results)\n\t} else if input.Granularity == \"monthly\" {\n\t\tcustomForm[0] = \"200601\"\n\t\tcustomForm[1] = \"2006-01\"\n\t\tquery := MonthlyEndpointGroup(filter)\n\t\terr = mongo.Pipe(session, tenantDbConfig.Db, \"endpoint_group_ar\", query, &results)\n\t}\n\n\t// mongo.Find(session, tenantDbConfig.Db, \"endpoint_group_ar\", bson.M{}, \"_id\", &results)\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\toutput, err = createEndpointGroupResultView(results, report, input.Format)\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\treturn code, h, output, err\n}", "func (r apiGetCustomerActivityReportsWithoutTotalCountRequest) Execute() (InlineResponse20025, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue InlineResponse20025\n\t)\n\n\tlocalBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, \"ManagementApiService.GetCustomerActivityReportsWithoutTotalCount\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/v1/applications/{applicationId}/customer_activity_reports/no_total\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"applicationId\"+\"}\", _neturl.QueryEscape(parameterToString(r.applicationId, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif r.rangeStart == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"rangeStart is required and must be specified\")\n\t}\n\n\tif r.rangeEnd == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"rangeEnd is required and must be specified\")\n\t}\n\n\tif r.pageSize != nil {\n\t\tlocalVarQueryParams.Add(\"pageSize\", parameterToString(*r.pageSize, \"\"))\n\t}\n\tif r.skip != nil {\n\t\tlocalVarQueryParams.Add(\"skip\", parameterToString(*r.skip, \"\"))\n\t}\n\tif r.sort != nil {\n\t\tlocalVarQueryParams.Add(\"sort\", parameterToString(*r.sort, \"\"))\n\t}\n\tlocalVarQueryParams.Add(\"rangeStart\", parameterToString(*r.rangeStart, \"\"))\n\tlocalVarQueryParams.Add(\"rangeEnd\", parameterToString(*r.rangeEnd, \"\"))\n\tif r.name != nil {\n\t\tlocalVarQueryParams.Add(\"name\", parameterToString(*r.name, \"\"))\n\t}\n\tif r.integrationId != nil {\n\t\tlocalVarQueryParams.Add(\"integrationId\", parameterToString(*r.integrationId, \"\"))\n\t}\n\tif r.campaignName != nil {\n\t\tlocalVarQueryParams.Add(\"campaignName\", parameterToString(*r.campaignName, \"\"))\n\t}\n\tif r.advocateName != nil {\n\t\tlocalVarQueryParams.Add(\"advocateName\", parameterToString(*r.advocateName, \"\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\treq, err := r.apiService.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := r.apiService.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\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 == 200 {\n\t\t\tvar v InlineResponse20025\n\t\t\terr = r.apiService.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\tnewErr.model = v\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = r.apiService.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 (result *FedoraResult) AllRecordsSucceeded() bool {\n\tfor _, record := range result.MetadataRecords {\n\t\tif false == record.Succeeded() {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (d byTotal) Len() int { return len(d) }", "func (sample *Sample) AddPercentageToTotal() {\n\tsample.shuffleAlgorithm235()\n\tsample.keep = uint64((float64(sample.PercentageKeep) / 100.0) * float64(sample.WellSeen))\n\tvar i uint64 = 0\n\tfor i = 0; i < sample.keep; i++ {\n\t\tsample.Sample = append(sample.Sample, sample.Well[i])\n\t}\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsTimeout(count int) {\n\tdsc.GetRecordsTimeout.Inc(int64(count))\n}", "func ListSuperGroupResults(r *http.Request, cfg config.Config) (int, http.Header, []byte, error) {\n\n\t//STANDARD DECLARATIONS START\n\tcode := http.StatusOK\n\th := http.Header{}\n\toutput := []byte(\"\")\n\terr := error(nil)\n\tcontentType := \"application/xml\"\n\tcharset := \"utf-8\"\n\t//STANDARD DECLARATIONS END\n\n\tcontentType, err = respond.ParseAcceptHeader(r)\n\th.Set(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\tif err != nil {\n\t\tcode = http.StatusNotAcceptable\n\t\toutput, _ = respond.MarshalContent(respond.NotAcceptableContentType, contentType, \"\", \" \")\n\t\treturn code, h, output, err\n\t}\n\n\t// Parse the request into the input\n\turlValues := r.URL.Query()\n\tvars := mux.Vars(r)\n\n\ttenantDbConfig, err := authentication.AuthenticateTenant(r.Header, cfg)\n\n\tif err != nil {\n\t\tif err.Error() == \"Unauthorized\" {\n\t\t\tcode = http.StatusUnauthorized\n\t\t\tout := respond.UnauthorizedMessage\n\t\t\toutput = out.MarshalTo(contentType)\n\t\t\treturn code, h, output, err\n\t\t}\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\tsession, err := mongo.OpenSession(tenantDbConfig)\n\tdefer mongo.CloseSession(session)\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\treport := reports.MongoInterface{}\n\terr = mongo.FindOne(session, tenantDbConfig.Db, \"reports\", bson.M{\"info.name\": vars[\"report_name\"]}, &report)\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\tinput := endpointGroupResultQuery{\n\t\tbasicQuery{\n\t\t\tName: vars[\"group_name\"],\n\t\t\tGranularity: urlValues.Get(\"granularity\"),\n\t\t\tFormat: contentType,\n\t\t\tStartTime: urlValues.Get(\"start_time\"),\n\t\t\tEndTime: urlValues.Get(\"end_time\"),\n\t\t\tReport: report,\n\t\t\tVars: vars,\n\t\t}, \"\",\n\t}\n\n\ttenantDB := session.DB(tenantDbConfig.Db)\n\terrs := input.Validate(tenantDB)\n\tif len(errs) > 0 {\n\t\tout := respond.BadRequestSimple\n\t\tout.Errors = errs\n\t\toutput = out.MarshalTo(contentType)\n\t\tcode = 400\n\t\treturn code, h, output, err\n\t}\n\n\tresults := []SuperGroupInterface{}\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\t// Construct the query to mongodb based on the input\n\tfilter := bson.M{\n\t\t\"date\": bson.M{\"$gte\": input.StartTimeInt, \"$lte\": input.EndTimeInt},\n\t\t\"report\": report.ID,\n\t}\n\n\tif input.Name != \"\" {\n\t\tfilter[\"supergroup\"] = input.Name\n\t}\n\n\t// Select the granularity of the search daily/monthly\n\tif input.Granularity == \"daily\" {\n\t\tcustomForm[0] = \"20060102\"\n\t\tcustomForm[1] = \"2006-01-02\"\n\t\tquery := DailySuperGroup(filter)\n\t\terr = mongo.Pipe(session, tenantDbConfig.Db, \"endpoint_group_ar\", query, &results)\n\t} else if input.Granularity == \"monthly\" {\n\t\tcustomForm[0] = \"200601\"\n\t\tcustomForm[1] = \"2006-01\"\n\t\tquery := MonthlySuperGroup(filter)\n\t\terr = mongo.Pipe(session, tenantDbConfig.Db, \"endpoint_group_ar\", query, &results)\n\t}\n\t// mongo.Find(session, tenantDbConfig.Db, \"endpoint_group_ar\", bson.M{}, \"_id\", &results)\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\toutput, err = createSuperGroupView(results, report, input.Format)\n\n\tif err != nil {\n\t\tcode = http.StatusInternalServerError\n\t\treturn code, h, output, err\n\t}\n\n\treturn code, h, output, err\n}", "func (o ServerEndpointSyncActivityStatusResponsePtrOutput) TotalItemCount() pulumi.Float64PtrOutput {\n\treturn o.ApplyT(func(v *ServerEndpointSyncActivityStatusResponse) *float64 {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.TotalItemCount\n\t}).(pulumi.Float64PtrOutput)\n}", "func (o *IscsiInitiatorGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (m *Iterator) Total(ctx context.Context) (int, error) {\n\tif m.totalGot {\n\t\treturn m.count, nil\n\t}\n\n\treturn m.FetchTotal(ctx)\n}", "func (b *SampleFJSONBuilder) AddAll() *SampleFJSONBuilder {\n\tb._properties[\"A\"] = b.A\n\tb._properties[\"B\"] = b.B\n\treturn b\n}", "func (d *DBClient) ImportRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\n\tvar requests recordedRequests\n\n\tdefer req.Body.Close()\n\tbody, err := ioutil.ReadAll(req.Body)\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tvar response messageResponse\n\n\tif err != nil {\n\t\t// failed to read response body\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Error(\"Could not read response body!\")\n\t\tresponse.Message = \"Bad request. Nothing to import!\"\n\t\thttp.Error(w, \"Failed to read request body.\", 400)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &requests)\n\n\tif err != nil {\n\t\tw.WriteHeader(422) // can't process this entity\n\t\treturn\n\t}\n\n\terr = d.ImportPayloads(requests.Data)\n\n\tif err != nil {\n\t\tresponse.Message = err.Error()\n\t\tw.WriteHeader(400)\n\t} else {\n\t\tresponse.Message = fmt.Sprintf(\"%d payloads import complete.\", len(requests.Data))\n\t}\n\n\tb, err := json.Marshal(response)\n\tw.Write(b)\n\n}", "func (m *Iterator) FetchTotal(ctx context.Context) (int, error) {\n\tr, err := m.query.Query(ctx, Request{\n\t\tLimit: 1,\n\t\tOffsetPeer: &tg.InputPeerEmpty{},\n\t})\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"fetch total\")\n\t}\n\n\tswitch msgs := r.(type) {\n\tcase *tg.MessagesMessages: // messages.messages#8c718e87\n\t\tm.count = len(msgs.Messages)\n\tcase *tg.MessagesMessagesSlice: // messages.messagesSlice#3a54685e\n\t\tm.count = msgs.Count\n\tcase *tg.MessagesChannelMessages: // messages.channelMessages#64479808\n\t\tm.count = msgs.Count\n\tdefault: // messages.messagesNotModified#74535f21\n\t\treturn 0, errors.Errorf(\"unexpected type %T\", r)\n\t}\n\n\tm.totalGot = true\n\treturn m.count, nil\n}", "func (resp *IPAddressesPagedResponse) appendData(r *IPAddressesPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func (client DatasetClient) listNextResults(ctx context.Context, lastResults DatasetListResponse) (result DatasetListResponse, err error) {\n req, err := lastResults.datasetListResponsePreparer(ctx)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", nil , \"Failure preparing next results request\")\n }\n if req == nil {\n return\n }\n resp, err := client.ListSender(req)\n if err != nil {\n result.Response = autorest.Response{Response: resp}\n return result, autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure sending next results request\")\n }\n result, err = client.ListResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"creator.DatasetClient\", \"listNextResults\", resp, \"Failure responding to next results request\")\n }\n return\n }", "func (u *UserResultsPage) setTotalPages(p int) {\n\tu.TotalPages = p\n}", "func (o *GetAssetsListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header X-Total-Count\n\n\txTotalCount := swag.FormatInt64(o.XTotalCount)\n\tif xTotalCount != \"\" {\n\t\trw.Header().Set(\"X-Total-Count\", xTotalCount)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.TokenAssetRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (a *API) catalogList(rw http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\n\ttyp := httprouter.ContextParam(r, \"type\").(string)\n\n\tsearch := a.catalogSearch(typ, \"\", r)\n\tif search == nil {\n\t\trw.WriteHeader(http.StatusNotFound)\n\t\treturn\n\t}\n\n\t// Fill result list\n\tfilter := httprouter.QueryParam(r, \"filter\")\n\n\ts := set.New()\n\tfor _, item := range search {\n\t\tname := reflect.Indirect(reflect.ValueOf(item)).FieldByName(\"Name\").String()\n\t\tif filter == \"\" {\n\t\t\ts.Add(name)\n\t\t} else if match, err := pattern.Match(filter, name); err != nil {\n\t\t\thttputil.WriteJSON(rw, newMessage(errInvalidFilter), http.StatusBadRequest)\n\t\t\treturn\n\t\t} else if match {\n\t\t\ts.Add(name)\n\t\t}\n\t}\n\n\ttotal := s.Len()\n\n\t// Apply items list offset and limit\n\tresult := set.StringSlice(s)\n\tsort.Strings(result)\n\n\toffset, err := parseIntParam(r, \"offset\")\n\tif err != nil || offset < 0 {\n\t\thttputil.WriteJSON(rw, newMessage(errInvalidParameter), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif offset < total {\n\t\tlimit, err := parseIntParam(r, \"limit\")\n\t\tif err != nil || limit < 0 {\n\t\t\thttputil.WriteJSON(rw, newMessage(errInvalidParameter), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tif limit != 0 && total > offset+limit {\n\t\t\tresult = result[offset : offset+limit]\n\t\t} else if offset > 0 {\n\t\t\tresult = result[offset:total]\n\t\t}\n\t} else {\n\t\tresult = []string{}\n\t}\n\n\trw.Header().Set(\"X-Total-Records\", fmt.Sprintf(\"%d\", total))\n\thttputil.WriteJSON(rw, result, http.StatusOK)\n}", "func (m *MultiInstances) Total() int {\n\ttotal := 0\n\tfor _, instances := range m.m {\n\t\ttotal += len(instances)\n\t}\n\treturn total\n}", "func (p *Pagination) Total() uint {\n\treturn p.total\n}", "func responderArtifact206(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerPartialContent) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\n\tresponder = artifacts.NewArtifactListerPartialContent()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tresponder.SetRemainingRecords(listInfo.RemainingRecords)\n\n\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\tartifactListerURL.After = &tmp\n\n\tif defaultPageLimit != paginator.Limit {\n\t\ttmp := paginator.Limit\n\t\tartifactListerURL.Limit = &tmp\n\t}\n\tresponder.SetNext(artifactListerURL.String())\n\n\tif paginator.ID != 0 { //... and not the first\n\t\t//paginator.ID is from query parameter not artifactmanager\n\t\tvar artifactListerURL artifacts.ArtifactListerURL\n\t\ttmp = artifactInfoReturned[0].ID\n\t\tartifactListerURL.Before = &tmp\n\t\tif defaultPageLimit != paginator.Limit {\n\t\t\ttmp := paginator.Limit\n\t\t\tartifactListerURL.Limit = &tmp\n\t\t}\n\t\tresponder.SetPrevious(artifactListerURL.String())\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (client DataControllersClient) listInGroupNextResults(ctx context.Context, lastResults PageOfDataControllerResource) (result PageOfDataControllerResource, err error) {\n\treq, err := lastResults.pageOfDataControllerResourcePreparer(ctx)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"listInGroupNextResults\", nil, \"Failure preparing next results request\")\n\t}\n\tif req == nil {\n\t\treturn\n\t}\n\tresp, err := client.ListInGroupSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"listInGroupNextResults\", resp, \"Failure sending next results request\")\n\t}\n\tresult, err = client.ListInGroupResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"listInGroupNextResults\", resp, \"Failure responding to next results request\")\n\t}\n\treturn\n}", "func (dc *DatadogCollector) UpdateTotalDuration(timeSinceStart time.Duration) {\n\tms := float64(timeSinceStart.Nanoseconds() / 1000000)\n\t_ = dc.client.TimeInMilliseconds(dmTotalDuration, ms, dc.tags, 1.0)\n}", "func (mp MassPayment) Total() float64 {\n\ttotal := 0.0\n\tfor _, item := range mp.Items {\n\t\ttotal += item.Amount\n\t}\n\n\treturn total\n}", "func (b *ClusterNodesBuilder) Total(value int) *ClusterNodesBuilder {\n\tb.total = &value\n\treturn b\n}", "func listHelper(lr listRetriever, opts *ListOptions) error {\n\tvar (\n\t\tfound, firstReportedTotal, lastReportedTotal int\n\t)\n\tfor {\n\t\tels, reportedtotal, err := lr(opts)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfound += els\n\t\tif firstReportedTotal == 0 {\n\t\t\tfirstReportedTotal = reportedtotal\n\t\t}\n\t\tlastReportedTotal = reportedtotal\n\n\t\tif reportedtotal <= opts.Offset+opts.Limit {\n\t\t\tbreak\n\t\t}\n\t\topts.Offset += opts.Limit\n\t}\n\n\t// Safety check\n\tif !opts.DisableCountValidation && (firstReportedTotal != found || lastReportedTotal != found) {\n\t\treturn fmt.Errorf(\"got %d elements total, first response indicated %d, last response indicated %d\", found, firstReportedTotal, lastReportedTotal)\n\t}\n\n\treturn nil\n}" ]
[ "0.68602043", "0.68162364", "0.68050385", "0.576847", "0.5462304", "0.52687824", "0.5133332", "0.50719863", "0.5024894", "0.49290606", "0.49057037", "0.48331985", "0.48321137", "0.4808243", "0.47965768", "0.47944167", "0.4767452", "0.47474995", "0.47454843", "0.47244698", "0.4677201", "0.4669452", "0.46640614", "0.4661166", "0.46347585", "0.45890656", "0.4553005", "0.45447424", "0.4539576", "0.45059013", "0.44980222", "0.44943246", "0.4484762", "0.4484762", "0.44833812", "0.44765767", "0.4466636", "0.44653085", "0.44613054", "0.44497094", "0.44403198", "0.4439271", "0.44375527", "0.44350645", "0.44331986", "0.4430425", "0.4419742", "0.44170156", "0.44149548", "0.44103348", "0.44071782", "0.4399637", "0.4391532", "0.43887255", "0.435879", "0.4330359", "0.4329121", "0.43226922", "0.4322661", "0.43217963", "0.43210313", "0.4312172", "0.4311918", "0.43084574", "0.43011987", "0.4287836", "0.42832324", "0.42780897", "0.4269033", "0.42637762", "0.42592403", "0.42528883", "0.42477328", "0.42333436", "0.42287377", "0.42231643", "0.42129946", "0.42103308", "0.4208748", "0.4208284", "0.42028534", "0.41940668", "0.41938734", "0.4190807", "0.4181757", "0.41812566", "0.41748416", "0.41701967", "0.41621265", "0.41534942", "0.41468638", "0.4139751", "0.41355094", "0.41352868", "0.4133896", "0.4130499", "0.41297686", "0.4129125", "0.41286615", "0.41212496" ]
0.71389055
0
SetTotalRecords sets the totalRecords to the artifact lister partial content response
func (o *ArtifactListerPartialContent) SetTotalRecords(totalRecords uint64) { o.TotalRecords = totalRecords }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) SetTotalRecords(totalRecords uint64) {\n\to.TotalRecords = totalRecords\n}", "func (o *ArtifactListerPartialContent) WithTotalRecords(totalRecords uint64) *ArtifactListerPartialContent {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerOK) WithTotalRecords(totalRecords uint64) *ArtifactListerOK {\n\to.TotalRecords = totalRecords\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetRemainingRecords(remainingRecords uint64) {\n\to.RemainingRecords = remainingRecords\n}", "func (o *ArtifactListerPartialContent) WithRemainingRecords(remainingRecords uint64) *ArtifactListerPartialContent {\n\to.RemainingRecords = remainingRecords\n\treturn o\n}", "func (page *Page) SetTotal(rowCount, pageSize uint64) {\n\tpage.Total = int64(math.Ceil(float64(rowCount) / float64(pageSize)))\n\tpage.TotalRows = int64(rowCount)\n}", "func (u *UserResultsPage) setTotalPages(p int) {\n\tu.TotalPages = p\n}", "func (r *MachinePoolsListServerResponse) Total(value int) *MachinePoolsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (rb *ShardsRecordBuilder) FlushTotal(flushtotal string) *ShardsRecordBuilder {\n\trb.v.FlushTotal = &flushtotal\n\treturn rb\n}", "func (u *UserResultsPage) setTotalMatches(m int) {\n\tu.TotalMatches = m\n}", "func (r *SubscriptionsListServerResponse) Total(value int) *SubscriptionsListServerResponse {\n\tr.total = &value\n\treturn r\n}", "func (suite *TestPagingSuite) TestSetTotalCount(c *C) {\n\ttestCases := []*struct {\n\t\ttotalCount int32\n\t\texpected bool\n\t}{\n\t\t{21, true},\n\t\t{20, false},\n\t\t{19, false},\n\t\t{0, false},\n\t}\n\n\tfor i, testCase := range testCases {\n\t\tcomment := ocheck.TestCaseComment(i)\n\t\tocheck.LogTestCase(c, testCase)\n\n\t\ttestedPaging := NewUndefinedPaging()\n\t\ttestedPaging.Position = 2\n\t\ttestedPaging.Size = 10\n\n\t\ttestedPaging.SetTotalCount(testCase.totalCount)\n\n\t\tc.Assert(testedPaging.PageMore, Equals, testCase.expected, comment)\n\t}\n}", "func (g *GlobalResponse) Sum() {\n\tsum := 0\n\n\tfor _, v := range g.Records {\n\t\tsum += v.Fields.NumBikesAvailable\n\t}\n\n\tg.Total = sum\n}", "func (o *IscsiInterfaceGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (o *IscsiInitiatorGetIterResponseResult) NumRecords() int {\n\tvar r int\n\tif o.NumRecordsPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.NumRecordsPtr\n\treturn r\n}", "func (d *DBClient) RecordsCount(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\tcount, err := d.Cache.RecordsCount()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordsCount\n\t\tresponse.Count = count\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func outputRecordsAll(cmd *cobra.Command) error {\n\tclientCtx, err := client.GetClientQueryContext(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpageReq, e := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags()))\n\tif e != nil {\n\t\treturn e\n\t}\n\tqueryClient := types.NewQueryClient(clientCtx)\n\tres, err := queryClient.RecordsAll(\n\t\tcontext.Background(),\n\t\t&types.RecordsAllRequest{Pagination: pageReq},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !includeRequest {\n\t\tres.Request = nil\n\t}\n\n\treturn clientCtx.PrintProto(res)\n}", "func (rest *RestController) All(w http.ResponseWriter, r *http.Request) (Response, error) {\n\tresources := reflect.New(reflect.SliceOf(reflect.TypeOf(rest.Table).Elem()))\n\tcount, err := rest.Table.List(resources.Interface(), models.NewDBQuery(r.URL.Query(), nil))\n\tif err != nil {\n\t\treturn nil, &httpError{err, \"\", 500}\n\t}\n\tw.Header().Set(\"Total\", strconv.FormatInt(count, 10))\n\treturn &JSONResponse{resources.Interface(), 200}, nil\n}", "func (fc *FileControl) TotalRecordCountField() string {\n\treturn fc.numericField(fc.TotalRecordCount, 8)\n}", "func (ms *Sales) setRecords() (err error) {\n\n\tsales, err := ms.DB.GetMonthlySales(ms.dates)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thst := (float64(ms.cfg.HST)/100 + 1)\n\tstationMap, err := ms.DB.GetStationMap()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, s := range sales {\n\n\t\temployee, err := ms.DB.GetEmployee(s.Attendant.ID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// set HST\n\t\tfuelSalesNoHST := s.Summary.FuelDollar / hst\n\t\tfuelSalesHST := s.Summary.FuelDollar - fuelSalesNoHST\n\n\t\trecord := &model.MonthlySales{\n\t\t\tBankAmex: model.SetFloat(s.CreditCard.Amex),\n\t\t\tBankDiscover: model.SetFloat(s.CreditCard.Discover),\n\t\t\tBankGales: model.SetFloat(s.CreditCard.Gales),\n\t\t\tBankMC: model.SetFloat(s.CreditCard.MC),\n\t\t\tBankVisa: model.SetFloat(s.CreditCard.Visa),\n\t\t\tBobsGiftCertificates: model.SetFloat(s.OtherNonFuelBobs.BobsGiftCerts),\n\t\t\tBobsNonFuelAdjustments: model.SetFloat(s.Summary.BobsFuelAdj),\n\t\t\tBobsSales: model.SetFloat(s.OtherNonFuel.Bobs),\n\t\t\tCashBills: model.SetFloat(s.Cash.Bills),\n\t\t\tCashDebit: model.SetFloat(s.Cash.Debit),\n\t\t\tCashDieselDiscount: model.SetFloat(s.Cash.DieselDiscount),\n\t\t\tCashDriveOffNSF: model.SetFloat(s.Cash.DriveOffNSF),\n\t\t\tCashGiftCertRedeem: model.SetFloat(s.Cash.GiftCertRedeem),\n\t\t\tCashLotteryPayout: model.SetFloat(s.Cash.LotteryPayout),\n\t\t\tCashOSAdjusted: model.SetFloat(s.Cash.OSAdjusted),\n\t\t\tCashOther: model.SetFloat(s.Cash.Other),\n\t\t\tCashPayout: model.SetFloat(s.Cash.Payout),\n\t\t\tCashWriteOff: model.SetFloat(s.Cash.WriteOff),\n\t\t\tEmployee: employee,\n\t\t\tFuelSales: fuelSalesNoHST,\n\t\t\tFuelSalesHST: fuelSalesHST,\n\t\t\tFuelSalesOther: model.SetFloat(s.Summary.OtherFuelDollar),\n\t\t\tFuelSalesTotal: model.SetFloat(s.Summary.FuelDollar),\n\t\t\tGiftCertificates: model.SetFloat(s.OtherNonFuel.GiftCerts),\n\t\t\tNonFuelTotal: model.SetFloat(s.Summary.TotalNonFuel),\n\t\t\tRecordNumber: s.RecordNum,\n\t\t\tShiftOvershort: model.SetFloat(s.Overshort.Amount),\n\t\t\tStationID: s.StationID,\n\t\t\tStationName: stationMap[s.StationID].Name,\n\t\t}\n\t\tms.Sales = append(ms.Sales, record)\n\t}\n\n\treturn err\n}", "func (nsc *NilConsumerStatsCollector) AddGetRecordsCalled(int) {}", "func (d *DBClient) AllRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\trecords, err := d.Cache.GetAllRequests()\n\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tvar response recordedRequests\n\t\tresponse.Data = records\n\t\tb, err := json.Marshal(response)\n\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t} else {\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"Error\": err.Error(),\n\t\t}).Error(\"Failed to get data from cache!\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(500) // can't process this entity\n\t\treturn\n\t}\n}", "func (r *MachinePoolsListResponse) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func (r *Records) SetRecords() error {\n\turl := fmt.Sprintf(\"%s/v1/domains/%s/records/%s/%s\", r.Config.GetAPI(), r.Domain, r.Records[0].Type, r.Records[0].Name)\n\tclient := &http.Client{}\n\n\tdata, err := json.Marshal(r.Records)\n\treq, _ := http.NewRequest(\"PUT\", url, bytes.NewBuffer(data))\n\treq.Header.Set(r.Config.GetAuth())\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.StatusCode != 200 {\n\t\treturn errors.New(string(res.StatusCode))\n\t}\n\n\treturn nil\n}", "func (b BarReaderProxy) SetTotal(total int64) {\n\tb.Bar.SetTotal(total, false)\n}", "func (o ServerEndpointSyncActivityStatusResponseOutput) TotalItemCount() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointSyncActivityStatusResponse) float64 { return v.TotalItemCount }).(pulumi.Float64Output)\n}", "func (m *Model) SetTotalPages(items int) int {\n\tif items < 1 {\n\t\treturn m.TotalPages\n\t}\n\tn := items / m.PerPage\n\tif items%m.PerPage > 0 {\n\t\tn++\n\t}\n\tm.TotalPages = n\n\treturn n\n}", "func (m *CloudPcBulkActionSummary) SetSuccessfulCount(value *int32)() {\n err := m.GetBackingStore().Set(\"successfulCount\", value)\n if err != nil {\n panic(err)\n }\n}", "func TotalCount(resp *http.Response) int {\n\tif resp == nil {\n\t\treturn 0\n\t}\n\n\ttotalCountHeader := resp.Header.Get(totalCountHeaderKey)\n\ttotalCount, err := strconv.ParseInt(totalCountHeader, 10, 64)\n\tif err != nil {\n\t\treturn 0\n\t}\n\n\treturn int(totalCount)\n}", "func (i *Invoice) SetTotal() {\n\t// recorre la cantidad de datos que tenga items\n\t// item1 alamacena el valor de un item\n\t// luego se extrae su precio con el getter value() de invoiceitem\n\tfor _, item1 := range i.items {\n\t\ti.total += item1.Value()\n\t}\n}", "func (n *resPool) SetTotalAllocatedResources(allocation *scalar.Resources) {\n\tn.Lock()\n\tdefer n.Unlock()\n\tn.allocation.Value[scalar.TotalAllocation] = allocation\n}", "func (p *Pagination) SetTotal(total uint) {\n\tp.total = total\n}", "func (dsc *DefaultConsumerStatsCollector) AddGetRecordsCalled(count int) {\n\tdsc.GetRecordsCalled.Inc(int64(count))\n}", "func (i *InsertRecordsInput) SetRecords(records []*Record) {\n\ti.Data = make([]map[int]*InsertRecordsInputData, len(records))\n\tfor n, r := range records {\n\t\tdata := make(map[int]*InsertRecordsInputData)\n\t\tfor fid, val := range r.Fields {\n\t\t\tdata[fid] = &InsertRecordsInputData{Value: val}\n\t\t}\n\t\ti.Data[n] = data\n\t}\n}", "func (resp *DomainRecordsPagedResponse) appendData(r *DomainRecordsPagedResponse) {\n\tresp.Data = append(resp.Data, r.Data...)\n}", "func ReportTotalHandler(writer http.ResponseWriter, request *http.Request) {\n session, err := mgo.Dial(\"10.11.12.13:27017\")\n check(err)\n defer session.Close()\n\n snapshots := make([]Snapshot, 1)\n\n c := session.DB(\"reports\").C(\"snapshots\")\n c.Find(bson.M{}).All(&snapshots)\n\n resp := getTotals(snapshots)\n\n writeJSONResp(writer, resp, 200)\n}", "func (o *IscsiInterfaceGetIterResponseResult) SetNumRecords(newValue int) *IscsiInterfaceGetIterResponseResult {\n\to.NumRecordsPtr = &newValue\n\treturn o\n}", "func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\tp.mutex.Lock()\n\tdefer p.mutex.Unlock()\n\n\tclient := &http.Client{}\n\n\tvar updatedRecords []libdns.Record\n\n\tvar resourceRecordSets []LeasewebRecordSet\n\n\tfor _, record := range records {\n\n\t\trecordSet := LeasewebRecordSet{\n\t\t\tName: record.Name,\n\t\t\tType: record.Type,\n\t\t\tContent: []string{record.Value},\n\t\t\tTTL: int(record.TTL.Seconds()),\n\t\t}\n\n\t\tresourceRecordSets = append(resourceRecordSets, recordSet)\n\n\t\tupdatedRecords = append(updatedRecords, record)\n\t}\n\n\tbody := &LeasewebRecordSets{\n\t\tResourceRecordSets: resourceRecordSets,\n\t}\n\n\tbodyBuffer := new(bytes.Buffer)\n\tjson.NewEncoder(bodyBuffer).Encode(body)\n\n\treq, err := http.NewRequest(http.MethodPut, fmt.Sprintf(\"https://api.leaseweb.com/hosting/v2/domains/%s/resourceRecordSets\", zone), bodyBuffer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(LeasewebApiKeyHeader, p.APIKey)\n\n\tres, err := client.Do(req)\n\tdefer res.Body.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\treturn nil, fmt.Errorf(\"Received StatusCode %d from Leaseweb API\", res.StatusCode)\n\t}\n\n\treturn updatedRecords, nil\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (m *CloudPcBulkActionSummary) SetFailedCount(value *int32)() {\n err := m.GetBackingStore().Set(\"failedCount\", value)\n if err != nil {\n panic(err)\n }\n}", "func (k Keeper) RecordsAll(c context.Context, req *types.RecordsAllRequest) (*types.RecordsAllResponse, error) {\n\tdefer telemetry.MeasureSince(time.Now(), types.ModuleName, \"query\", \"RecordsAll\")\n\tretval := types.RecordsAllResponse{Request: req}\n\n\tpageRequest := getPageRequest(req)\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tkvStore := ctx.KVStore(k.storeKey)\n\tprefixStore := prefix.NewStore(kvStore, types.RecordKeyPrefix)\n\n\tpageRes, err := query.Paginate(prefixStore, pageRequest, func(key, value []byte) error {\n\t\tvar record types.Record\n\t\tvErr := record.Unmarshal(value)\n\t\tif vErr == nil {\n\t\t\tretval.Records = append(retval.Records, types.WrapRecord(&record))\n\t\t\treturn nil\n\t\t}\n\t\t// Something's wrong. Let's do what we can to give indications of it.\n\t\tvar addr types.MetadataAddress\n\t\tkErr := addr.Unmarshal(key)\n\t\tif kErr == nil {\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record\", \"address\", addr, \"error\", vErr)\n\t\t\tretval.Records = append(retval.Records, types.WrapRecordNotFound(addr))\n\t\t} else {\n\t\t\tk64 := b64.StdEncoding.EncodeToString(key)\n\t\t\tk.Logger(ctx).Error(\"failed to unmarshal record key and value\",\n\t\t\t\t\"key error\", kErr, \"value error\", vErr, \"key (base64)\", k64)\n\t\t\tretval.Records = append(retval.Records, &types.RecordWrapper{})\n\t\t}\n\t\treturn nil // Still want to move on to the next.\n\t})\n\tif err != nil {\n\t\treturn &retval, status.Error(codes.Unavailable, err.Error())\n\t}\n\tretval.Pagination = pageRes\n\treturn &retval, nil\n}", "func (s *Service) Records(c context.Context, types []int64, mid, stime, etime int64, order, sort string, pn, ps int32) (res []*model.Record, total int32, err error) {\n\tvar midAts []int64\n\tif res, total, err = s.search.RecordPaginate(c, types, mid, stime, etime, order, sort, pn, ps); err != nil {\n\t\tlog.Error(\"s.search.RecordPaginate(%d,%d,%d,%d,%s,%s) error(%v)\", mid, sort, pn, ps, stime, etime, err)\n\t\treturn\n\t}\n\tif res == nil {\n\t\tres = _emptyRecords\n\t\treturn\n\t}\n\tfor _, r := range res {\n\t\tr.Message = template.HTMLEscapeString(r.Message)\n\t\tif len(r.Ats) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tvar ats []int64\n\t\tif ats, err = xstr.SplitInts(r.Ats); err != nil {\n\t\t\tlog.Error(\"xstr.SplitInts(%s) error(%v)\", r.Ats, err)\n\t\t\terr = nil\n\t\t}\n\t\tmidAts = append(midAts, ats...)\n\t}\n\tif len(midAts) == 0 {\n\t\treturn\n\t}\n\taccMap, _ := s.getAccInfo(c, midAts)\n\tfor _, r := range res {\n\t\tr.FillAts(accMap)\n\t}\n\treturn\n}", "func SetTotalURLs(total int) (err error) {\n\tclient := getClient()\n\terr = client.Set(\"TotalUrls\", total, 0).Err()\n\treturn\n}", "func IncrementSuccessfulList(counts int) {\n\tincSuccessfulRequestByHandler(\"list\", counts)\n}", "func (tt *TransactionTransformer) transformCollection(request *http.Request, data interface{}, totalData int, limit string) *TransactionResponse {\n\ttransactionResponse := &TransactionResponse{}\n\ttransactionResponse.TotalCount = totalData\n\ttransactionResponse.Data = data\n\n\t// Convert limit to int if not empty\n\tif limit != \"\" {\n\t\tlimitInt, _ := strconv.Atoi(limit)\n\n\t\tif limitInt != -1 && limitInt != 0 {\n\t\t\t// If limit not euqal to `-1` and `0' set transaction links. Transaction links contain link to current page,\n\t\t\t// first page, next page and last page.\n\t\t\ttransactionResponse.Links = PaginationReponse.BuildPaginationLinks(request, totalData)\n\t\t}\n\t}\n\n\treturn transactionResponse\n}", "func (r ApiGetBulkSubRequestObjListRequest) Count(count bool) ApiGetBulkSubRequestObjListRequest {\n\tr.count = &count\n\treturn r\n}", "func (_obj *DataService) GetActivityRecords(index int32, batch int32, activity_id string, nextIndex *int32, recordList *[]ActivityRecord, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(activity_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*recordList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *recordList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\ttarsCtx := context.Background()\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getActivityRecords\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*recordList) = make([]ActivityRecord, length)\n\t\tfor i20, e20 := int32(0), length; i20 < e20; i20++ {\n\n\t\t\terr = (*recordList)[i20].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (o *GetAllPublicIPUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (o *IscsiInitiatorGetIterResponseResult) SetNumRecords(newValue int) *IscsiInitiatorGetIterResponseResult {\n\to.NumRecordsPtr = &newValue\n\treturn o\n}", "func (rb *ShardsRecordBuilder) RefreshExternalTotal(refreshexternaltotal string) *ShardsRecordBuilder {\n\trb.v.RefreshExternalTotal = &refreshexternaltotal\n\treturn rb\n}", "func (r *ListDNSZoneVersionRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) {\n\tresults, ok := res.(*ListDNSZoneVersionRecordsResponse)\n\tif !ok {\n\t\treturn 0, errors.New(\"%T type cannot be appended to type %T\", res, r)\n\t}\n\n\tr.Records = append(r.Records, results.Records...)\n\tr.TotalCount += uint32(len(results.Records))\n\treturn uint32(len(results.Records)), nil\n}", "func (result *FedoraResult) AllRecordsSucceeded() bool {\n\tfor _, record := range result.MetadataRecords {\n\t\tif false == record.Succeeded() {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func displayAllRecords(records []Record) {\n\tfmt.Printf(\"\\nDisplaying all records...\\n\\n\")\n\n\tfor i := 0; i < len(records); i++ {\n\t\tfmt.Printf(\"Record ID: %d: %+v\\n\", i, records[i])\n\t\ttime.Sleep(5 * time.Millisecond) // 5ms between records\n\t}\n}", "func (bguo *BarGroupUpdateOne) AddRecords(b ...*BarRecord) *BarGroupUpdateOne {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bguo.AddRecordIDs(ids...)\n}", "func (pb *Bar) SetTotal(value int64) *Bar {\n\tatomic.StoreInt64(&pb.total, value)\n\tif pb.current >= pb.total && pb.total != -1 {\n\t\tpb.Finish()\n\t}\n\treturn pb\n}", "func (o *GetSellerServicesUsingGETParams) SetTotal(total *int32) {\n\to.Total = total\n}", "func (r ApiGetBulkResultListRequest) Count(count bool) ApiGetBulkResultListRequest {\n\tr.count = &count\n\treturn r\n}", "func (o ServerEndpointSyncActivityStatusResponseOutput) TotalBytes() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointSyncActivityStatusResponse) float64 { return v.TotalBytes }).(pulumi.Float64Output)\n}", "func TotalRetention(amount float64, values []RetValue) float64 {\n\ttotal := 0.0\n\tfor _, v := range values {\n\t\ttotal += PartialRetention(amount, v)\n\t}\n\treturn total\n}", "func (records *Records) NumRecords() int {\n\treturn len(records.Passwords)\n}", "func (resource *billingInfoList) setResponse(res *ResponseMetadata) {\n\tresource.recurlyResponse = res\n}", "func updateMasterRecords(stub shim.ChaincodeStubInterface, ufaNumber string) error {\n\tvar recordList []string\n\trecBytes, _ := stub.GetState(ALL_ELEMENENTS)\n\n\terr := json.Unmarshal(recBytes, &recordList)\n\tif err != nil {\n\t\treturn errors.New(\"Failed to unmarshal updateMasterReords \")\n\t}\n\trecordList = append(recordList, ufaNumber)\n\tbytesToStore, _ := json.Marshal(recordList)\n\tlogger.Info(\"After addition\" + string(bytesToStore))\n\tstub.PutState(ALL_ELEMENENTS, bytesToStore)\n\treturn nil\n}", "func (r ApiGetBulkExportListRequest) Count(count bool) ApiGetBulkExportListRequest {\n\tr.count = &count\n\treturn r\n}", "func (o ServerEndpointSyncActivityStatusResponsePtrOutput) TotalItemCount() pulumi.Float64PtrOutput {\n\treturn o.ApplyT(func(v *ServerEndpointSyncActivityStatusResponse) *float64 {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.TotalItemCount\n\t}).(pulumi.Float64PtrOutput)\n}", "func updateMasterRecords(stub shim.ChaincodeStubInterface, ufaNumber string) error {\r\n\tvar recordList []string\r\n\trecBytes, _ := stub.GetState(ALL_ELEMENENTS)\r\n\r\n\terr := json.Unmarshal(recBytes, &recordList)\r\n\tif err != nil {\r\n\t\treturn errors.New(\"Failed to unmarshal updateMasterReords \")\r\n\t}\r\n\trecordList = append(recordList, ufaNumber)\r\n\tbytesToStore, _ := json.Marshal(recordList)\r\n\tlogger.Info(\"After addition\" + string(bytesToStore))\r\n\tstub.PutState(ALL_ELEMENENTS, bytesToStore)\r\n\treturn nil\r\n}", "func (r *SubscriptionsListServerRequest) Total() int {\n\tif r != nil && r.total != nil {\n\t\treturn *r.total\n\t}\n\treturn 0\n}", "func (r ApiGetBulkExportedItemListRequest) Count(count bool) ApiGetBulkExportedItemListRequest {\n\tr.count = &count\n\treturn r\n}", "func (m *Iterator) FetchTotal(ctx context.Context) (int, error) {\n\tr, err := m.query.Query(ctx, Request{\n\t\tLimit: 1,\n\t\tOffsetPeer: &tg.InputPeerEmpty{},\n\t})\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"fetch total\")\n\t}\n\n\tswitch msgs := r.(type) {\n\tcase *tg.MessagesMessages: // messages.messages#8c718e87\n\t\tm.count = len(msgs.Messages)\n\tcase *tg.MessagesMessagesSlice: // messages.messagesSlice#3a54685e\n\t\tm.count = msgs.Count\n\tcase *tg.MessagesChannelMessages: // messages.channelMessages#64479808\n\t\tm.count = msgs.Count\n\tdefault: // messages.messagesNotModified#74535f21\n\t\treturn 0, errors.Errorf(\"unexpected type %T\", r)\n\t}\n\n\tm.totalGot = true\n\treturn m.count, nil\n}", "func (fa *FindAndCountAll) Result(records interface{}, count int) {\n\tfa.Arguments[1] = mock.AnythingOfType(fmt.Sprintf(\"*%T\", records))\n\n\tfa.Run(func(args mock.Arguments) {\n\t\treflect.ValueOf(args[1]).Elem().Set(reflect.ValueOf(records))\n\t}).Return(count, nil)\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsReadResponseDuration(time.Duration) {}", "func (p *Pagination) SetTotalPage(total int32) *Pagination {\n\ttotalPages := int32(1)\n\n\tif p.PageSize == limitPage {\n\t\tp.PageSize = total\n\t} else {\n\t\td := float64(total) / float64(p.PageSize)\n\t\ttotalPages = int32(math.Ceil(d))\n\t}\n\n\tp.TotalPage = totalPages\n\tp.TotalResult = total\n\treturn p\n}", "func (s BmUnitResource) PaginatedFindAll(r api2go.Request) (uint, api2go.Responder, error) {\n\tvar (\n\t\tresult []BmModel.Unit\n\t\tnumber, size, offset, limit string\n\t)\n\n\tnumberQuery, ok := r.QueryParams[\"page[number]\"]\n\tif ok {\n\t\tnumber = numberQuery[0]\n\t}\n\tsizeQuery, ok := r.QueryParams[\"page[size]\"]\n\tif ok {\n\t\tsize = sizeQuery[0]\n\t}\n\toffsetQuery, ok := r.QueryParams[\"page[offset]\"]\n\tif ok {\n\t\toffset = offsetQuery[0]\n\t}\n\tlimitQuery, ok := r.QueryParams[\"page[limit]\"]\n\tif ok {\n\t\tlimit = limitQuery[0]\n\t}\n\n\tif size != \"\" {\n\t\tsizeI, err := strconv.ParseInt(size, 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, &Response{}, err\n\t\t}\n\n\t\tnumberI, err := strconv.ParseInt(number, 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, &Response{}, err\n\t\t}\n\n\t\tstart := sizeI * (numberI - 1)\n\t\tfor _, iter := range s.BmUnitStorage.GetAll(r, int(start), int(sizeI)) {\n\t\t\tresult = append(result, *iter)\n\t\t}\n\n\t} else {\n\t\tlimitI, err := strconv.ParseUint(limit, 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, &Response{}, err\n\t\t}\n\n\t\toffsetI, err := strconv.ParseUint(offset, 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, &Response{}, err\n\t\t}\n\n\t\tfor _, iter := range s.BmUnitStorage.GetAll(r, int(offsetI), int(limitI)) {\n\t\t\tresult = append(result, *iter)\n\t\t}\n\t}\n\n\tin := BmModel.Unit{}\n\tcount := s.BmUnitStorage.Count(in)\n\n\treturn uint(count), &Response{Res: result}, nil\n}", "func updateInvoiceMasterRecords(stub shim.ChaincodeStubInterface, invoiceList []string) error {\n\tvar recordList []string\n\trecBytes, _ := stub.GetState(ALL_INVOICES)\n\n\terr := json.Unmarshal(recBytes, &recordList)\n\tif err != nil {\n\t\treturn errors.New(\"Failed to unmarshal updateInvoiceMasterRecords \")\n\t}\n\trecordList = append(recordList, invoiceList...)\n\tbytesToStore, _ := json.Marshal(recordList)\n\tlogger.Info(\"After addition\" + string(bytesToStore))\n\tstub.PutState(ALL_INVOICES, bytesToStore)\n\treturn nil\n}", "func (m *MonitoringAlertRecordsRequestBuilder) Count()(*MonitoringAlertRecordsCountRequestBuilder) {\n return NewMonitoringAlertRecordsCountRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func getTotals(snapshots []Snapshot) TotalResponse {\n reports := len(snapshots)\n days := make(map[string]int)\n people := make(map[string]int)\n locations := make(map[string]int)\n activities:= make(map[string]int)\n coffees := 0\n\n for _, snapshot := range snapshots {\n // Count people\n date := snapshot.Date[:10]\n days[date]++\n\n for _, response := range snapshot.Responses {\n question := response.QuestionPrompt\n // Count people\n if question == \"Who are you with?\" {\n for _, token := range response.Tokens {\n people[token.Text]++\n }\n } else if question == \"Where are you?\" {\n // count locations\n locations[response.LocationResponse.Text]++\n } else if question == \"How many coffees did you have today?\" {\n // count coffees\n amount, err := strconv.Atoi(response.NumericResponse)\n if err == nil {\n coffees += amount\n }\n } else if question == \"What are you doing?\" {\n for _, token := range response.Tokens {\n activities[token.Text]++\n }\n }\n }\n }\n\n return TotalResponse{\n TotalDays: len(days),\n TotalReports: reports,\n TotalPeople: len(people),\n TotalLocations: len(locations),\n AvgPerDay: float32(reports)/float32(len(days)),\n TotalCoffees: coffees,\n CoffeesPerDay: float32(coffees)/float32(len(days)),\n PeopleList: people,\n LocationList: locations,\n ActivityList: activities,\n }\n}", "func (o *PrivilegeUsersResponse) SetTotal(v int32) {\n\to.Total = &v\n}", "func (o GetSrvRecordResultOutput) Records() GetSrvRecordRecordArrayOutput {\n\treturn o.ApplyT(func(v GetSrvRecordResult) []GetSrvRecordRecord { return v.Records }).(GetSrvRecordRecordArrayOutput)\n}", "func (rb *ShardsRecordBuilder) WarmerTotal(warmertotal string) *ShardsRecordBuilder {\n\trb.v.WarmerTotal = &warmertotal\n\treturn rb\n}", "func (ac *AppContext) totalMessages(w http.ResponseWriter, r *http.Request) {\n\tcnt, err := ac.r.TotalMessages()\n\tif err != nil {\n\t\tlogrus.WithError(err).Error(\"Failed getting total messages\")\n\t\tWriteError(w, ErrInternalServer)\n\t\treturn\n\t}\n\tjson.NewEncoder(w).Encode(messageCount{cnt})\n}", "func (m *MockMetaDataMgmtService) TotalContentCount(resourceId, contentType, providerName, catalogType, entityStatus, pageNumber, pageSize string) (int, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"TotalContentCount\", resourceId, contentType, providerName, catalogType, entityStatus, pageNumber, pageSize)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (bgu *BarGroupUpdate) AddRecords(b ...*BarRecord) *BarGroupUpdate {\n\tids := make([]int, len(b))\n\tfor i := range b {\n\t\tids[i] = b[i].ID\n\t}\n\treturn bgu.AddRecordIDs(ids...)\n}", "func TestListRecordings(t *testing.T) {\n\tif !haveArchive {\n\t\treturn\n\t}\n\n\tif testing.Verbose() && DEBUG {\n\t\tlogging.SetLevel(logging.DEBUG, \"archive\")\n\t}\n\n\trecordings, err := archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tinitial := len(recordings)\n\tt.Logf(\"Initial count is %d\", initial)\n\n\t// Add a recording\n\tsubscriptionID, err := archive.StartRecording(testCases[0].sampleChannel, testCases[0].sampleStream, true, true)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tt.Logf(\"SubscriptionID is %d\", subscriptionID)\n\n\t// Add a publication on that\n\tpublication, err := archive.AddPublication(testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif testing.Verbose() && DEBUG {\n\t\tt.Logf(\"Publication is %#v\", publication)\n\t}\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tif len(recordings) == 0 {\n\t\tt.Log(\"No Recordings!\")\n\t\tt.FailNow()\n\t}\n\n\t// Grab the recordingID\n\trecordingID := recordings[len(recordings)-1].RecordingId\n\tt.Logf(\"Working count is %d, recordingID is %d\", len(recordings), recordingID)\n\n\t// Cleanup\n\tres, err := archive.StopRecordingByIdentity(recordingID)\n\tif err != nil {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed: %s\", recordingID, err.Error())\n\t} else if !res {\n\t\tt.Logf(\"StopRecordingByIdentity(%d) failed\", recordingID)\n\t}\n\tif err := archive.PurgeRecording(recordingID); err != nil {\n\t\tt.Logf(\"PurgeRecording(%d) failed: %s\", recordingID, err.Error())\n\t}\n\tpublication.Close()\n\n\trecordings, err = archive.ListRecordingsForUri(0, 100, testCases[0].sampleChannel, testCases[0].sampleStream)\n\tif err != nil {\n\t\tt.Log(err)\n\t\tt.FailNow()\n\t}\n\tfinal := len(recordings)\n\tt.Logf(\"Final count is %d\", final)\n\n\tif initial != final {\n\t\tt.Logf(\"Number of recordings changed from %d to %d\", initial, final)\n\t\tt.Fail()\n\t}\n}", "func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {\n\tp.mutex.Lock()\n\tdefer p.mutex.Unlock()\n\n\tclient := &http.Client{}\n\n\tvar addedRecords []libdns.Record\n\n\tfor _, record := range records {\n\t\tbody := &LeasewebRecordSet{\n\t\t\tName: record.Name,\n\t\t\tType: record.Type,\n\t\t\tContent: []string{record.Value},\n\t\t\tTTL: int(record.TTL.Seconds()),\n\t\t}\n\n\t\tbodyBuffer := new(bytes.Buffer)\n\t\tjson.NewEncoder(bodyBuffer).Encode(body)\n\n\t\treq, err := http.NewRequest(http.MethodPost, fmt.Sprintf(\"https://api.leaseweb.com/hosting/v2/domains/%s/resourceRecordSets\", zone), bodyBuffer)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treq.Header.Add(LeasewebApiKeyHeader, p.APIKey)\n\n\t\tres, err := client.Do(req)\n\t\tdefer res.Body.Close()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\t\treturn nil, fmt.Errorf(\"Received StatusCode %d from Leaseweb API\", res.StatusCode)\n\t\t}\n\n\t\taddedRecords = append(addedRecords, record)\n\t}\n\n\treturn addedRecords, nil\n}", "func (r ApiGetBulkRequestListRequest) Count(count bool) ApiGetBulkRequestListRequest {\n\tr.count = &count\n\treturn r\n}", "func (m *JobManager) Total() (int64, error) {\n\treturn m.table.Count()\n}", "func (rb *ShardsRecordBuilder) SearchFetchTotal(searchfetchtotal string) *ShardsRecordBuilder {\n\trb.v.SearchFetchTotal = &searchfetchtotal\n\treturn rb\n}", "func (nsc *NilConsumerStatsCollector) UpdateGetRecordsUnmarshalDuration(time.Duration) {}", "func (m *MailTips) SetTotalMemberCount(value *int32)() {\n err := m.GetBackingStore().Set(\"totalMemberCount\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *TotalListHandler) ServeHTTP(\n\trw http.ResponseWriter, req *http.Request) {\n\tvar user string\n\tvar all_records TotalRecordList\n\tvar err error\n\n\tif user = m.auth.GetAuthenticatedUser(req); user == \"\" {\n\t\tm.auth.RequestAuthorization(rw, req)\n\t\treturn\n\t}\n\n\tif len(m.admingroup) > 0 && !m.auth.IsAuthenticatedScope(\n\t\treq, m.admingroup) {\n\t\tvar agreement *membersys.MembershipAgreement\n\n\t\tagreement, err = m.database.GetMemberDetailByUsername(\n\t\t\treq.Context(), user)\n\t\tif err != nil {\n\t\t\tlog.Print(\"Can't get membership agreement for \", user, \": \", err)\n\t\t\treturn\n\t\t}\n\n\t\terr = m.uniqueMemberTemplate.ExecuteTemplate(rw, \"memberdetail.html\",\n\t\t\tagreement.GetMemberData())\n\t\tif err != nil {\n\t\t\tlog.Print(\"Can't run membership detail template: \", err)\n\t\t}\n\n\t\treturn\n\t}\n\n\tall_records.Applicants, err = m.database.EnumerateMembershipRequests(\n\t\treq.Context(), req.FormValue(\"applicant_criterion\"),\n\t\treq.FormValue(\"applicant_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list applicants from \",\n\t\t\treq.FormValue(\"applicant_start\"), \": \", err)\n\t}\n\n\tall_records.Members, err = m.database.EnumerateMembers(\n\t\treq.Context(), req.FormValue(\"member_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list members from \",\n\t\t\treq.FormValue(\"member_start\"), \": \", err)\n\t}\n\n\tall_records.Queue, err = m.database.EnumerateQueuedMembers(\n\t\treq.Context(), req.FormValue(\"queued_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list queued members from \",\n\t\t\treq.FormValue(\"queued_start\"), \": \", err)\n\t}\n\n\tall_records.DeQueue, err = m.database.EnumerateDeQueuedMembers(\n\t\treq.Context(), req.FormValue(\"queued_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list dequeued members from \",\n\t\t\treq.FormValue(\"queued_start\"), \": \", err)\n\t}\n\n\tall_records.Trash, err = m.database.EnumerateTrashedMembers(\n\t\treq.Context(), req.FormValue(\"trashed_start\"), m.pagesize)\n\tif err != nil {\n\t\tlog.Print(\"Unable to list trashed members from \",\n\t\t\treq.FormValue(\"trashed_start\"), \": \", err)\n\t}\n\n\tall_records.ApprovalCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, applicantApprovalURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating approval CSRF token: \", err)\n\t}\n\tall_records.RejectionCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, applicantRejectionURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating rejection CSRF token: \", err)\n\t}\n\tall_records.UploadCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, applicantAgreementUploadURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating agreement upload CSRF token: \", err)\n\t}\n\tall_records.CancelCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, queueCancelURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating queue cancellation CSRF token: \", err)\n\t}\n\tall_records.GoodbyeCsrfToken, err = m.auth.GenCSRFToken(\n\t\treq, memberGoodbyeURL, 10*time.Minute)\n\tif err != nil {\n\t\tlog.Print(\"Error generating member goodbye CSRF token: \", err)\n\t}\n\n\tall_records.PageSize = m.pagesize\n\n\terr = m.template.ExecuteTemplate(rw, \"memberlist.html\", all_records)\n\tif err != nil {\n\t\tlog.Print(\"Error executing member list template: \", err)\n\t}\n}", "func updateInventoryMasterRecords(stub shim.ChaincodeStubInterface, custInvoice string, vendInvoice string) error {\r\n\tvar recordList []string\r\n\trecBytes, _ := stub.GetState(ALL_INVOICES)\r\n\r\n\terr := json.Unmarshal(recBytes, &recordList)\r\n\tif err != nil {\r\n\t\treturn errors.New(\"Failed to unmarshal updateInventoryMasterRecords \")\r\n\t}\r\n\trecordList = append(recordList, custInvoice)\r\n\trecordList = append(recordList, vendInvoice)\r\n\r\n\tbytesToStore, _ := json.Marshal(recordList)\r\n\tlogger.Info(\"After addition\" + string(bytesToStore))\r\n\tstub.PutState(ALL_INVOICES, bytesToStore)\r\n\treturn nil\r\n}", "func (d *DBClient) ImportRecordsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\n\tvar requests recordedRequests\n\n\tdefer req.Body.Close()\n\tbody, err := ioutil.ReadAll(req.Body)\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tvar response messageResponse\n\n\tif err != nil {\n\t\t// failed to read response body\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Error(\"Could not read response body!\")\n\t\tresponse.Message = \"Bad request. Nothing to import!\"\n\t\thttp.Error(w, \"Failed to read request body.\", 400)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &requests)\n\n\tif err != nil {\n\t\tw.WriteHeader(422) // can't process this entity\n\t\treturn\n\t}\n\n\terr = d.ImportPayloads(requests.Data)\n\n\tif err != nil {\n\t\tresponse.Message = err.Error()\n\t\tw.WriteHeader(400)\n\t} else {\n\t\tresponse.Message = fmt.Sprintf(\"%d payloads import complete.\", len(requests.Data))\n\t}\n\n\tb, err := json.Marshal(response)\n\tw.Write(b)\n\n}", "func (dsc *DefaultConsumerStatsCollector) UpdateGetRecordsReadResponseDuration(duration time.Duration) {\n\tdsc.GetRecordsReadResponseDuration.Update(duration.Nanoseconds())\n}", "func (c WorkItemTypeResource) PaginatedFindAll(r api2go.Request) (uint, api2go.Responder, error) {\n\n\t// build filter expression\n\tfilter, err := c.getFilterFromRequest(r)\n\tif err != nil {\n\t\treturn 0, &api2go.Response{}, err\n\t}\n\n\t// parse out offset and limit\n\tqueryOffset, queryLimit, err := utils.ParsePaging(r)\n\tif err!=nil {\n\t\treturn 0, &api2go.Response{}, err\n\t}\n\n\t// get the paged data from storage\n\tresult, err := c.WorkItemTypeStorage.GetAllPaged(filter, queryOffset, queryLimit)\n\tif err!=nil {\n\t\treturn 0, &api2go.Response{}, err\n\t}\n\n\t// get total count for paging\n\tallCount, err := c.WorkItemTypeStorage.GetAllCount(filter)\n\tif err!=nil {\n\t\treturn 0, &api2go.Response{}, err\n\t}\n\n\t// return everything\n\treturn uint(allCount), &api2go.Response{Res: result}, nil\n}", "func (t File_summary_by_instance) TotalRowContent() string {\n\treturn t.totals.row_content(t.totals)\n}", "func (m *MultiInstances) Total() int {\n\ttotal := 0\n\tfor _, instances := range m.m {\n\t\ttotal += len(instances)\n\t}\n\treturn total\n}", "func (m *BarGroupMutation) ResetRecords() {\n\tm.records = nil\n\tm.clearedrecords = false\n\tm.removedrecords = nil\n}", "func updateRecords(conf *Configuration, slicev reflect.Value, c *mgo.Collection) error {\n\tids := fetchIds(conf, slicev)\n\t// update all matching documents to processing\n\t_, err := c.UpdateAll(\n\t\tbson.M{\"_id\": bson.M{\"$in\": ids}},\n\t\tbson.M{\"$set\": bson.M{conf.StateFld: conf.ProcessedState, conf.ProcessedTimeFld: time.Now().Unix()}},\n\t)\n\treturn err\n}", "func (milestones MilestoneList) LoadTotalTrackedTimes() error {\n\treturn milestones.loadTotalTrackedTimes(db.DefaultContext)\n}", "func (o ServerEndpointRecallStatusResponseOutput) TotalRecallErrorsCount() pulumi.Float64Output {\n\treturn o.ApplyT(func(v ServerEndpointRecallStatusResponse) float64 { return v.TotalRecallErrorsCount }).(pulumi.Float64Output)\n}" ]
[ "0.7586981", "0.68356216", "0.65602857", "0.5993812", "0.53407735", "0.5330599", "0.5120447", "0.5045564", "0.5006892", "0.4913021", "0.49010208", "0.48902938", "0.48774007", "0.4825394", "0.48173904", "0.4800855", "0.4796975", "0.47928557", "0.47822073", "0.47713763", "0.47586083", "0.47478747", "0.47395816", "0.47344384", "0.47244865", "0.47187287", "0.46907118", "0.4686247", "0.46481898", "0.46452138", "0.46261698", "0.46147743", "0.4598674", "0.4573093", "0.45448187", "0.45294645", "0.4514391", "0.4511468", "0.4505422", "0.4505422", "0.4493873", "0.44909063", "0.44702944", "0.44534254", "0.4452867", "0.44456276", "0.44425628", "0.44401258", "0.44204953", "0.44087023", "0.4400018", "0.43930697", "0.4388504", "0.4378992", "0.43469605", "0.43465737", "0.43434545", "0.43392012", "0.4333387", "0.433035", "0.43268424", "0.4323776", "0.43231854", "0.43206203", "0.43094087", "0.43043715", "0.43018994", "0.43001047", "0.42976564", "0.42788395", "0.4272434", "0.42690971", "0.426037", "0.4255567", "0.42517924", "0.42512614", "0.42433825", "0.42364395", "0.42338312", "0.42256653", "0.4220732", "0.4217135", "0.42143682", "0.42125317", "0.42089045", "0.41994905", "0.41907772", "0.418178", "0.41781852", "0.41766596", "0.41702804", "0.41691598", "0.4165178", "0.41606444", "0.41570172", "0.41565937", "0.41522688", "0.41513848", "0.41489783", "0.41462597" ]
0.74971026
1
WithPayload adds the payload to the artifact lister partial content response
func (o *ArtifactListerPartialContent) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerPartialContent { o.Payload = payload return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerOK) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerOK {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerInternalServerError) WithPayload(payload *weles.ErrResponse) *ArtifactListerInternalServerError {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetAssetsListOK) SetPayload(payload []*models.TokenAssetRow) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) WithPayload(payload *weles.ErrResponse) *ArtifactListerBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *ListStorageV1alpha1VolumeAttachmentOK) SetPayload(payload *models.IoK8sAPIStorageV1alpha1VolumeAttachmentList) {\n\to.Payload = payload\n}", "func (o *ListAppsV1NamespacedDeploymentOK) SetPayload(payload *models.IoK8sAPIAppsV1DeploymentList) {\n\to.Payload = payload\n}", "func (o *PatchApiextensionsV1beta1CustomResourceDefinitionStatusOK) SetPayload(payload *models.IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinition) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetImagesListOK) SetPayload(payload []*models.Image) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesOK) SetPayload(payload models.PackageManifest) {\n\to.Payload = payload\n}", "func (o *AddItemAccepted) SetPayload(payload *models.AddResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListOK) SetPayload(payload *models.ObjectsListResponse) {\n\to.Payload = payload\n}", "func (o *DeleteApiextensionsV1CollectionCustomResourceDefinitionOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1Status) {\n\to.Payload = payload\n}", "func (o *GetCoreAPIVersionsOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1APIVersions) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesCreated) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsOK) SetPayload(payload []*models.Item) {\n\to.Payload = payload\n}", "func (o *GetIdentityEndpointsOK) SetPayload(payload []*models.IdentityEndpoints) {\n\to.Payload = payload\n}", "func (o *GetAccountsListOK) SetPayload(payload []*models.AccountsRow) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) WithPayload(payload *weles.ErrResponse) *ArtifactListerNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *ActivityListSuggestOK) SetPayload(payload *models.InlineResponse2004) {\n\to.Payload = payload\n}", "func (o *SpareListOK) SetPayload(payload *models.InlineResponse20013) {\n\to.Payload = payload\n}", "func (o *PartialUpdateAppForbidden) SetPayload(payload *models.Unauthorized) {\n\to.Payload = payload\n}", "func (o *ObjectsListForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddItemOK) SetPayload(payload *models.CartSuccessResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetfeedsOK) SetPayload(payload []string) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostOK) SetPayload(payload *models.ID) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *PostOperationsGetNetworkElementListOK) SetPayload(payload *models.TapiNetworkElementGetNetworkElementListOutput) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetAllGroupsOK) SetPayload(payload *models.PageGroupList) {\n\to.Payload = payload\n}", "func (o *GetCapabilityOK) SetPayload(payload []*models.Capability) {\n\to.Payload = payload\n}", "func (o *GetImagesListDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetPreEnrollmentsForFacilityOK) SetPayload(payload []*models.Enrollment) {\n\to.Payload = payload\n}", "func (o *GetApisOK) SetPayload(payload *models.APIMeta) {\n\to.Payload = payload\n}", "func (o *PatchFoldersIDOK) SetPayload(payload *models.CreateFolderResp) {\n\to.Payload = payload\n}", "func (o *ReplaceApiextensionsV1beta1CustomResourceDefinitionOK) SetPayload(payload *models.IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinition) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesOK) SetPayload(payload []*models.VSphereManagementObject) {\n\to.Payload = payload\n}", "func (o *DeleteAllRevisionsOK) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetAllStorageOK) SetPayload(payload *models.PageStorageList) {\n\to.Payload = payload\n}", "func (o *ActivityListJoinedOK) SetPayload(payload *models.InlineResponse2004) {\n\to.Payload = payload\n}", "func (o *ListBatchV1NamespacedJobOK) SetPayload(payload *models.IoK8sAPIBatchV1JobList) {\n\to.Payload = payload\n}", "func (o *ReplaceApiextensionsV1beta1CustomResourceDefinitionCreated) SetPayload(payload *models.IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinition) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoOK) SetPayload(payload *models.RepositoryInfo) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetFleetsFleetIDMembersInternalServerError) SetPayload(payload *models.GetFleetsFleetIDMembersInternalServerErrorBody) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetFleetsFleetIDMembersOK) SetPayload(payload models.GetFleetsFleetIDMembersOKBody) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ListVsphereResourceOK) SetPayload(payload *ListVsphereResourceOKBody) {\n\to.Payload = payload\n}", "func (o *GetFleetsFleetIDMembersForbidden) SetPayload(payload *models.GetFleetsFleetIDMembersForbiddenBody) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationOK) SetPayload(payload *models.DeletedResponse) {\n\to.Payload = payload\n}", "func (o *GetSchedulingV1APIResourcesOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1APIResourceList) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *GetGitignoreTemplatesOK) SetPayload(payload models.Gitignore) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationNotFound) SetPayload(payload *models.MissingResponse) {\n\to.Payload = payload\n}", "func (o *ActivityListFavOK) SetPayload(payload *models.InlineResponse2004) {\n\to.Payload = payload\n}", "func (o *CreateDiscoveryV1beta1NamespacedEndpointSliceCreated) SetPayload(payload *models.IoK8sAPIDiscoveryV1beta1EndpointSlice) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreateDiscoveryV1beta1NamespacedEndpointSliceOK) SetPayload(payload *models.IoK8sAPIDiscoveryV1beta1EndpointSlice) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDUnauthorized) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetTweetsOK) SetPayload(payload *models.TweetDetailsListResponse) {\n\to.Payload = payload\n}", "func (o *AddKeypairConflict) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *PetUploadImageOK) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *PartialUpdateAppUnauthorized) SetPayload(payload *models.Unauthorized) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchOK) SetPayload(payload *models.ActionGetResponse) {\n\to.Payload = payload\n}", "func (o *GetAllReposOK) SetPayload(payload *models.ResourceArrayData) {\n\to.Payload = payload\n}", "func (o *UpdateCatalogInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsOK) SetPayload(payload []*models.AviServiceEngineGroup) {\n\to.Payload = payload\n}", "func (o *GetMarketsGroupsOK) SetPayload(payload []int32) {\n\to.Payload = payload\n}", "func (o *GetSectionOK) SetPayload(payload *models.SectionResponse) {\n\to.Payload = payload\n}", "func (o *ListOfDevicesOK) SetPayload(payload models.Devices) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDInternalServerError) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetCapabilityForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDOK) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *ObjectsListBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDNotFound) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetVersionsOK) SetPayload(payload *GetVersionsOKBody) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1InternalServerError) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *PartialUpdateAppOK) SetPayload(payload *models.App) {\n\to.Payload = payload\n}", "func (o *GetChatroomsIDForbidden) SetPayload(payload *apimodel.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigForbidden) SetPayload(payload *models.InfraError) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}" ]
[ "0.67320496", "0.6584429", "0.6506249", "0.64527833", "0.6376058", "0.6320063", "0.61683536", "0.6130742", "0.60633284", "0.59844196", "0.59294057", "0.5903623", "0.5874044", "0.57567525", "0.5752173", "0.57191354", "0.57170546", "0.571159", "0.57087535", "0.5708628", "0.57005733", "0.5687264", "0.56841207", "0.56784594", "0.5659141", "0.5656168", "0.565377", "0.56461114", "0.56379116", "0.56244314", "0.56208146", "0.5614559", "0.56142515", "0.5611622", "0.5594845", "0.5578401", "0.55739355", "0.55704653", "0.55644685", "0.55618924", "0.55538964", "0.55431455", "0.5537936", "0.5536886", "0.5535856", "0.5534435", "0.5533515", "0.551346", "0.551241", "0.5508273", "0.55050695", "0.5503586", "0.5498224", "0.5496036", "0.5495911", "0.5491661", "0.5487213", "0.54861593", "0.5482783", "0.54723847", "0.54676497", "0.5466295", "0.5464924", "0.5456785", "0.5453111", "0.5451823", "0.5451191", "0.5450129", "0.54469305", "0.54441977", "0.54439825", "0.5431456", "0.543083", "0.5430648", "0.54270405", "0.5426393", "0.5426198", "0.54227996", "0.542049", "0.5420177", "0.5414266", "0.5395921", "0.53954804", "0.5394038", "0.53909725", "0.5388913", "0.5385049", "0.5382401", "0.5379628", "0.537634", "0.5375614", "0.5375163", "0.5373746", "0.5372333", "0.53698754", "0.5366298", "0.5362651", "0.5361478", "0.5361148", "0.53593683" ]
0.71963346
0
SetPayload sets the payload to the artifact lister partial content response
func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) { o.Payload = payload }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetAssetsListOK) SetPayload(payload []*models.TokenAssetRow) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *AddReleasesUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ListAppsV1NamespacedDeploymentOK) SetPayload(payload *models.IoK8sAPIAppsV1DeploymentList) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsOK) SetPayload(payload []*models.Item) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetPreEnrollmentsForFacilityOK) SetPayload(payload []*models.Enrollment) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesOK) SetPayload(payload []*models.VSphereManagementObject) {\n\to.Payload = payload\n}", "func (o *GetAccountsListOK) SetPayload(payload []*models.AccountsRow) {\n\to.Payload = payload\n}", "func (o *PostOperationsGetNetworkElementListOK) SetPayload(payload *models.TapiNetworkElementGetNetworkElementListOutput) {\n\to.Payload = payload\n}", "func (o *ListStorageV1alpha1VolumeAttachmentOK) SetPayload(payload *models.IoK8sAPIStorageV1alpha1VolumeAttachmentList) {\n\to.Payload = payload\n}", "func (o *SpareListOK) SetPayload(payload *models.InlineResponse20013) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateCatalogInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetfeedsOK) SetPayload(payload []string) {\n\to.Payload = payload\n}", "func (o *AddReleasesCreated) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetIBAServerUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetIdentityEndpointsOK) SetPayload(payload []*models.IdentityEndpoints) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostOK) SetPayload(payload *models.ID) {\n\to.Payload = payload\n}", "func (o *AddKeypairConflict) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchOK) SetPayload(payload *models.ActionGetResponse) {\n\to.Payload = payload\n}", "func (o *AddItemOK) SetPayload(payload *models.CartSuccessResponse) {\n\to.Payload = payload\n}", "func (o *UpdateMovieUnauthorized) SetPayload(payload *models.Result) {\n\to.Payload = payload\n}", "func (o *ObjectsListForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetImagesListOK) SetPayload(payload []*models.Image) {\n\to.Payload = payload\n}", "func (o *UpdateClusterInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetAllStorageOK) SetPayload(payload *models.PageStorageList) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetVisiblePruebasFromQuestionTestOK) SetPayload(payload []*models.Prueba) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDUnauthorized) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *AddKeypairInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddRegionAZInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetCorrectedAnswersFromPublishedTestsOK) SetPayload(payload []*models.Answer) {\n\to.Payload = payload\n}", "func (o *GetTweetsOK) SetPayload(payload *models.TweetDetailsListResponse) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetCoreAPIVersionsOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1APIVersions) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PartialUpdateAppForbidden) SetPayload(payload *models.Unauthorized) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetApisOK) SetPayload(payload *models.APIMeta) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListOK) SetPayload(payload *models.ObjectsListResponse) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDInternalServerError) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetS3BackupOK) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDInternalServerError) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksUnauthorized) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *PostUserIDF2aUnauthorized) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1InternalServerError) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *GetTaskSyncInternalServerError) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1Unauthorized) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *GetGitignoreTemplatesOK) SetPayload(payload models.Gitignore) {\n\to.Payload = payload\n}", "func (o *ActivityListSuggestOK) SetPayload(payload *models.InlineResponse2004) {\n\to.Payload = payload\n}", "func (o *PatchApiextensionsV1beta1CustomResourceDefinitionStatusOK) SetPayload(payload *models.IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinition) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresOK) SetPayload(payload []*models.VSphereDatastore) {\n\to.Payload = payload\n}", "func (o *GetMarketsGroupsOK) SetPayload(payload []int32) {\n\to.Payload = payload\n}", "func (o *PetUploadImageOK) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *RemoveTeamToPublishedTestForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetApisUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigForbidden) SetPayload(payload *models.InfraError) {\n\to.Payload = payload\n}", "func (o *GetAllGroupsOK) SetPayload(payload *models.PageGroupList) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetSectionOK) SetPayload(payload *models.SectionResponse) {\n\to.Payload = payload\n}", "func (o *DeleteAllRevisionsOK) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationUnauthorized) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *GetTaskTaskIDOK) SetPayload(payload *models.ResponseTask) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsNotFound) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *ListBatchV1NamespacedJobOK) SetPayload(payload *models.IoK8sAPIBatchV1JobList) {\n\to.Payload = payload\n}", "func (o *GetChartsInfoOK) SetPayload(payload []*models.ChartsData) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *GetActivationsUnauthorized) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *GetProviderRegionByIDInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetActivationsInternalServerError) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTeamsOK) SetPayload(payload []*models.Team) {\n\to.Payload = payload\n}", "func (o *GetQuestionAnswersFromAnswerOK) SetPayload(payload []*models.QuestionAnswer) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDOK) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetSchedulingV1APIResourcesOK) SetPayload(payload *models.IoK8sApimachineryPkgApisMetaV1APIResourceList) {\n\to.Payload = payload\n}", "func (o *GetAllStorageUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}" ]
[ "0.7755639", "0.77370477", "0.7547121", "0.74540854", "0.7391761", "0.71630627", "0.71489614", "0.7132938", "0.71324253", "0.7063658", "0.7039256", "0.70076543", "0.69959146", "0.6990534", "0.69864225", "0.69838345", "0.6963603", "0.6956441", "0.6955837", "0.6955526", "0.69302726", "0.6921313", "0.6884859", "0.68817884", "0.6880987", "0.6874842", "0.6873074", "0.687163", "0.6871043", "0.6870635", "0.68694973", "0.68687123", "0.6868444", "0.6867127", "0.6865128", "0.6849103", "0.68461573", "0.68425584", "0.68423164", "0.6840539", "0.6834293", "0.6834063", "0.6829601", "0.6828314", "0.68193173", "0.6818091", "0.68163085", "0.6816184", "0.6814872", "0.6813902", "0.6809741", "0.68091565", "0.6808268", "0.6805055", "0.679865", "0.67982155", "0.6793661", "0.6789718", "0.6785763", "0.67855376", "0.6780248", "0.67781955", "0.6774841", "0.67736363", "0.67690176", "0.6767182", "0.676575", "0.6763698", "0.67624444", "0.67601126", "0.67599994", "0.6758511", "0.6758022", "0.67566425", "0.67559296", "0.6745309", "0.6744156", "0.674022", "0.6737111", "0.67369986", "0.67361593", "0.6731461", "0.67309076", "0.672681", "0.67262995", "0.67246085", "0.672274", "0.6720997", "0.67183214", "0.6718165", "0.67174226", "0.67171437", "0.671694", "0.67160004", "0.67158043", "0.6715456", "0.67114854", "0.67112464", "0.6711158", "0.67106766" ]
0.7865953
0
WriteResponse to the client
func (o *ArtifactListerPartialContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { // response header Next next := o.Next if next != "" { rw.Header().Set("Next", next) } // response header Previous previous := o.Previous if previous != "" { rw.Header().Set("Previous", previous) } // response header RemainingRecords remainingRecords := swag.FormatUint64(o.RemainingRecords) if remainingRecords != "" { rw.Header().Set("RemainingRecords", remainingRecords) } // response header TotalRecords totalRecords := swag.FormatUint64(o.TotalRecords) if totalRecords != "" { rw.Header().Set("TotalRecords", totalRecords) } rw.WriteHeader(206) payload := o.Payload if payload == nil { payload = make([]*weles.ArtifactInfo, 0, 50) } if err := producer.Produce(rw, payload); err != nil { panic(err) // let the recovery middleware deal with this } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Response) Write(w io.Writer) error", "func (c *Operation) writeResponse(rw http.ResponseWriter, status int, data []byte) { // nolint: unparam\n\trw.WriteHeader(status)\n\n\tif _, err := rw.Write(data); err != nil {\n\t\tlogger.Errorf(\"Unable to send error message, %s\", err)\n\t}\n}", "func WriteResponse(w http.ResponseWriter, mensaje string, code int) {\n\tmessage := myTypes.Respuesta{\n\t\tMessage: mensaje,\n\t}\n\tresponse, _ := json.Marshal(message)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(response)\n}", "func WriteResponse(w http.ResponseWriter, object interface{}, rerr *irma.RemoteError) {\n\tstatus, bts := JsonResponse(object, rerr)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\t_, err := w.Write(bts)\n\tif err != nil {\n\t\tLogWarning(errors.WrapPrefix(err, \"failed to write response\", 0))\n\t}\n}", "func (o *PingOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, v interface{}, statusCode int) {\n\tresBody, err := json.Marshal(v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\t_, _ = w.Write(resBody)\n}", "func WriteResponse(w http.ResponseWriter, code int, object interface{}) {\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func (o *GetPingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(body []byte, w *http.ResponseWriter) {\n\t(*w).Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t_, err := (*w).Write(body)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\t(*w).WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func WriteResponse(w http.ResponseWriter, code int, resp interface{}) error {\n\tj, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\n\t_, err = w.Write(j)\n\treturn err\n}", "func writeResponse(w *http.ResponseWriter, res responseData, status int) {\n\tresJSON, err := json.Marshal(res)\n\tif err != nil {\n\t\thttp.Error(*w, \"Failed to parse struct `responseData` into JSON object\", http.StatusInternalServerError)\n\t}\n\n\t(*w).Header().Set(\"Content-Type\", \"application/json\")\n\t(*w).WriteHeader(status)\n\t(*w).Write(resJSON)\n}", "func WriteResponse(w http.ResponseWriter, d string) {\n\tw.WriteHeader(200)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.Write([]byte(d))\n\treturn\n}", "func (o *CreateFacilityUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(w http.ResponseWriter, response Response) {\n\tjson, err := json.Marshal(&response)\n\n\tif err != nil {\n\t\tfmt.Fprint(w, \"There was an error processing the request.\")\n\t}\n\n\tcommon.Log(fmt.Sprintf(\"Returning response %s\", json))\n\tfmt.Fprintf(w, \"%s\", json)\n}", "func (o *CreateProgramOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DepositNewFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMedicineOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *CreateTaskCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Location\n\n\tlocation := o.Location.String()\n\tif location != \"\" {\n\t\trw.Header().Set(\"Location\", location)\n\t}\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(r *http.Request, w http.ResponseWriter, code int, resp interface{}) {\n\n\t// Deal with CORS\n\tif origin := r.Header.Get(\"Origin\"); origin != \"\" {\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", origin)\n\t\tw.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE, GET, HEAD, OPTIONS, POST, PUT\")\n\t\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\t\t// Allow any headers\n\t\tif wantedHeaders := r.Header.Get(\"Access-Control-Request-Headers\"); wantedHeaders != \"\" {\n\t\t\tw.Header().Set(\"Access-Control-Allow-Headers\", wantedHeaders)\n\t\t}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\n\tb, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintln(w, `{\"error\":\"failed to marshal json\"}`)\n\t\treturn\n\t}\n\n\tw.WriteHeader(code)\n\tfmt.Fprintln(w, string(b))\n}", "func (o *VerifyAccountCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(w http.ResponseWriter, h int, p interface{}) {\n\t// I set the content type...\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t// ... I write the specified status code...\n\tw.WriteHeader(h)\n\t// ... and I write the response\n\tb, _ := json.Marshal(p)\n\tw.Write(b)\n}", "func (o *UpdateCatalogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (c *SwitchVersion) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postSwitchVersion(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *PutRecordingsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *BofaChkUpdateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *VerifyHealthCredentialOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, code int, err error, data interface{}, t0 time.Time) {\n\tw.WriteHeader(code)\n\tresp := &Response{Data: data, Dur: fmt.Sprint(time.Since(t0)), OK: false}\n\tif code < 300 {\n\t\tresp.OK = true\n\t}\n\tif err != nil {\n\t\tresp.Err = err.Error()\n\t}\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Infof(\"failed to json encode response: %v\", err)\n\t\tif _, err = w.Write([]byte(spew.Sdump(resp))); err != nil {\n\t\t\tlog.Infof(\"failed to write dump of response: %v\", err)\n\t\t}\n\t}\n}", "func (o *NewDiscoveryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(data []byte, size int64, ctype string, w http.ResponseWriter) {\n\tw.Header().Set(\"Content-Type\", ctype)\n\tw.Header().Set(\"Content-Length\", fmt.Sprintf(\"%d\", size))\n\tw.Header().Set(\"Cache-Control\", \"no-transform,public,max-age=86400,s-maxage=2592000\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, code int, object interface{}) {\n\tfmt.Println(\"writing response:\", code, object)\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, authZRes *authorization.Response) {\n\n\tdata, err := json.Marshal(authZRes)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to marshel authz response %q\", err.Error())\n\t} else {\n\t\tw.Write(data)\n\t}\n\n\tif authZRes == nil || authZRes.Err != \"\" {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t}\n}", "func (o *GetCharactersCharacterIDOpportunitiesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetCharactersCharacterIDOpportunitiesOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *WeaviateThingsGetNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *UpdateLinkInPostOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetChatroomsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetEchoNameOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetUIContentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *ListVsphereResourceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func ResponseWrite(w http.ResponseWriter, responseCode int, responseData interface{}) {\n\t// Write Response\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(responseCode)\n\n\t// Write JSON to Response\n\tjson.NewEncoder(w).Encode(responseData)\n}", "func writeHTTPResponseInWriter(httpRes http.ResponseWriter, httpReq *http.Request, nobelPrizeWinnersResponse []byte, err error) {\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(httpRes, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tlog.Printf(\"Request %s Succesfully Completed\", httpReq.RequestURI)\n\thttpRes.Header().Set(\"Content-Type\", \"application/json\")\n\thttpRes.Write(nobelPrizeWinnersResponse)\n}", "func (o *PostKeysKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlog.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func writeResponse(data interface{}, w http.ResponseWriter) error {\n\tvar (\n\t\tenc []byte\n\t\terr error\n\t)\n\tenc, err = json.Marshal(data)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to marshal, err = %s\", err)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tn, err := w.Write(enc)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to write, err = %s\", err)\n\t}\n\tif n != len(enc) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Short write sent = %d, wrote = %d\", len(enc), n)\n\t}\n\treturn nil\n}", "func (o *CreateUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func WriteResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PutQuestionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (r *response) Write(b []byte) (n int, err error) {\n\tif !r.headersSend {\n\t\tif r.status == 0 {\n\t\t\tr.status = http.StatusOK\n\t\t}\n\t\tr.WriteHeader(r.status)\n\t}\n\tn, err = r.ResponseWriter.Write(b)\n\tr.size += int64(n)\n\treturn\n}", "func (o *PostOperationsDeleteP2PPathCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *HealthGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsPatchNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (o *VerifyEmailTokenOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DeleteServiceIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\t// as of now, just log errors for writing response\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PostOperationsGetNodeEdgePointDetailsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *UserEditOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviatePeersAnnounceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *CertifyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(writer http.ResponseWriter, response *http.Response) (int64, error) {\n\tdefer response.Body.Close()\n\twriteResponseHeaders(writer, response, false)\n\treturn io.Copy(writer, response.Body)\n}", "func (o *PutMeetupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *FingerPathsPostCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *PostPlaybookOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateHostIgnitionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *GetCharactersCharacterIDLocationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostManagementKubernetesIoV1NodesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *PutPerformancesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *StopAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(202)\n}", "func (o *GetFleetsFleetIDMembersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Content-Language\n\n\tcontentLanguage := o.ContentLanguage\n\tif contentLanguage != \"\" {\n\t\trw.Header().Set(\"Content-Language\", contentLanguage)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetFleetsFleetIDMembersOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *GetMeetupsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostEventCreated) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(201)\n}", "func (o *GetTaskTaskIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateTCPCheckAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Reload-ID\n\n\treloadID := o.ReloadID\n\tif reloadID != \"\" {\n\t\trw.Header().Set(\"Reload-ID\", reloadID)\n\t}\n\n\trw.WriteHeader(202)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *PostOperationsGetNetworkElementListCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ServiceInstanceLastOperationGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header RetryAfter\n\n\tretryAfter := o.RetryAfter\n\tif retryAfter != \"\" {\n\t\trw.Header().Set(\"RetryAfter\", retryAfter)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPiecesIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetTaskDetailsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *UpdateClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetDetailOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\trw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetServicesHaproxyRuntimeAclsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (r *responseInfoRecorder) Write(b []byte) (int, error) {\n\tr.ContentLength += int64(len(b))\n\tif r.statusCode == 0 {\n\t\tr.statusCode = http.StatusOK\n\t}\n\treturn r.ResponseWriter.Write(b)\n}", "func (o *LogoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UploadFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, data interface{}) error {\n\tenv := map[string]interface{}{\n\t\t\"meta\": map[string]interface{}{\n\t\t\t\"code\": http.StatusOK,\n\t\t},\n\t\t\"data\": data,\n\t}\n\treturn jsonResponse(w, env)\n}", "func (o *WeaviateThingTemplatesCreateNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (r *Responder) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\tfor k, v := range r.headers {\n\t\tfor _, val := range v {\n\t\t\trw.Header().Add(k, val)\n\t\t}\n\t}\n\n\trw.WriteHeader(r.code)\n\n\tif r.response != nil {\n\t\tif err := producer.Produce(rw, r.response); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "func (o *GetGateSourceByGateNameAndMntOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateSpoeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tpayload := o.Payload\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *Output) writeResponse(response string) error {\r\n\t// write the response\r\n\tif _, err := o.writer.WriteString(response + \"\\n\"); err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (o *GetTransportByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *TransferOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateUserCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ViewOneOrderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetVisiblePruebasFromQuestionTestInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(500)\n}", "func (o *GetWhaleTranfersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.OperationsRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *SearchTournamentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*models.Tournament, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateTCPCheckCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (s *Server) writeInfoResponse(\n\tw http.ResponseWriter,\n\tr *http.Request,\n\tmessage []byte,\n\tstatus int,\n\theaders map[string]string,\n) {\n\tfor k, v := range headers {\n\t\tw.Header().Add(k, v)\n\t}\n\n\tw.WriteHeader(status)\n\tw.Write(message)\n}" ]
[ "0.81303823", "0.7882039", "0.77722245", "0.7771901", "0.7753117", "0.7740585", "0.76670325", "0.7638451", "0.76095873", "0.75798", "0.7579178", "0.7567389", "0.7560546", "0.75579476", "0.75447774", "0.7542929", "0.75416607", "0.753386", "0.7531158", "0.75192654", "0.75191355", "0.7513389", "0.7512029", "0.75050455", "0.7503395", "0.74984574", "0.74875605", "0.74839836", "0.74772394", "0.7467842", "0.746699", "0.7465759", "0.7464175", "0.746404", "0.746404", "0.7461224", "0.7460309", "0.74595356", "0.74463046", "0.7443478", "0.7435917", "0.7426582", "0.7425581", "0.74186546", "0.7413175", "0.7407469", "0.74063516", "0.74048966", "0.7398737", "0.7389631", "0.738607", "0.73806983", "0.7360552", "0.7360491", "0.7355327", "0.7354953", "0.73532444", "0.7347445", "0.734586", "0.732798", "0.732577", "0.73178244", "0.7316643", "0.7316071", "0.7315527", "0.7312546", "0.73114824", "0.7310336", "0.7309039", "0.73007035", "0.7297214", "0.7291373", "0.7291277", "0.72884554", "0.72845477", "0.72835207", "0.7281928", "0.7281033", "0.72751075", "0.7274423", "0.7273193", "0.72730565", "0.72695094", "0.7269139", "0.72690886", "0.7265927", "0.72615093", "0.72529227", "0.7251764", "0.72490144", "0.72479355", "0.72469014", "0.72407585", "0.72390425", "0.72367245", "0.7234706", "0.722777", "0.722197", "0.7215153", "0.72140837", "0.7213089" ]
0.0
-1
NewArtifactListerBadRequest creates ArtifactListerBadRequest with default headers values
func NewArtifactListerBadRequest() *ArtifactListerBadRequest { return &ArtifactListerBadRequest{} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerBadRequest) WithPayload(payload *weles.ErrResponse) *ArtifactListerBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func NewListBadRequest(body *ListBadRequestResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewAllDashboardsBadRequest() *AllDashboardsBadRequest {\n return &AllDashboardsBadRequest{\n }\n}", "func NewBadRequest(err error, msg ...string) *Errs {\n\tif err == nil {\n\t\terr = ErrBadRequest\n\t}\n\n\treturn &Errs{\n\t\tcodeHTTP: http.StatusBadRequest,\n\t\terr: err,\n\t\tkind: trace(2),\n\t\tmessage: msg,\n\t}\n}", "func (ctx *CreateItemContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func BadRequest(format string, args ...interface{}) error {\n\treturn New(http.StatusBadRequest, format, args...)\n}", "func (ctx *CreateHostContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func SetNewBadRequestByFormat(ef *ErrorFormat) *ErrorMessage {\n\treturn &ErrorMessage{\n\t\tCode: http.StatusBadRequest,\n\t\tErrorList: []*ErrorFormat{\n\t\t\tef,\n\t\t},\n\t}\n}", "func (ctx *CreateSecretsContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func (ctx *ListFeedContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *ListMessageContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func BadRequest(err error) error {\n\treturn New(http.StatusBadRequest, err)\n}", "func BadRequest(w http.ResponseWriter, r *http.Request, h *render.Renderer) {\n\taccept := strings.Split(r.Header.Get(\"Accept\"), \",\")\n\taccept = append(accept, strings.Split(r.Header.Get(\"Content-Type\"), \",\")...)\n\n\tswitch {\n\tcase prefixInList(accept, ContentTypeHTML):\n\t\th.RenderHTMLStatus(w, http.StatusBadRequest, \"400\", nil)\n\tcase prefixInList(accept, ContentTypeJSON):\n\t\th.RenderJSON(w, http.StatusBadRequest, apiErrorBadRequest)\n\tdefault:\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t}\n}", "func (ctx *CreateOutputContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (c ApiWrapper) BadRequest(msg string, objs ...interface{}) revel.Result {\n\treturn c.renderErrorString(400, fmt.Sprintf(msg, objs))\n}", "func ErrBadRequestf(format string, arguments ...interface{}) *Status {\n\treturn &Status{Code: http.StatusBadRequest, Text: fmt.Sprintf(format, arguments...)}\n}", "func (ctx *ListOfferContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (o *ArtifactListerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(400)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func BadRequest(message ...interface{}) Err {\n\treturn Boomify(http.StatusBadRequest, message...)\n}", "func (ctx *GetDogsByHostIDHostContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func (id InvalidContainerIDError) BadRequest() {}", "func (ctx *CreateFeedContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *ListAnalysisContext) BadRequest(r *AntError) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.error+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *ShowSecretsContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func (ctx *DeleteHostContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func NewAddItemBadRequest() *AddItemBadRequest {\n\n\treturn &AddItemBadRequest{}\n}", "func (ctx *CreateFilterContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func CreateBadRequest(errorMessage string) BadRequest {\n\treturn BadRequest{Error: errorMessage}\n}", "func (ctx *DeleteOutputContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *ListListenContext) BadRequest(r *AntError) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.error+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func NewListBadRequestResponseBody(res *goa.ServiceError) *ListBadRequestResponseBody {\n\tbody := &ListBadRequestResponseBody{\n\t\tName: res.Name,\n\t\tID: res.ID,\n\t\tMessage: res.Message,\n\t\tTemporary: res.Temporary,\n\t\tTimeout: res.Timeout,\n\t\tFault: res.Fault,\n\t}\n\treturn body\n}", "func NewObjectsListBadRequest() *ObjectsListBadRequest {\n\n\treturn &ObjectsListBadRequest{}\n}", "func (r Response) BadRequest(code string, payload Payload, header ...ResponseHeader) {\n\tr.Response(code, http.BadRequest, payload, header...)\n}", "func BadRequest(w http.ResponseWriter, err error) {\n\t(Response{Error: err.Error()}).json(w, http.StatusBadRequest)\n}", "func (ctx *GetByIDHostContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func (ctx *CreateOfferContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func NewGetTagBadRequest() *GetTagBadRequest {\n\n\treturn &GetTagBadRequest{}\n}", "func NewGetTagBadRequest() *GetTagBadRequest {\n\n\treturn &GetTagBadRequest{}\n}", "func (ctx *CreateMessageContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func NewThingsListBadRequest() *ThingsListBadRequest {\n\treturn &ThingsListBadRequest{}\n}", "func BadRequest(w ResponseWriter, r *Request) {\n\tw.SetHeader(CodeBadRequest, \"bad request\")\n}", "func NewBadRequest(field string, message string, args ...interface{}) *AppError {\n\treturn NewError(InvalidArgument, field, message, args...)\n}", "func BadRequest(msg string) Error {\n\te := err{msg: msg, code: badRequestCode, group: generic, kind: badRequest}\n\treturn &e\n}", "func (ctx *CreateDogContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func NewListSelLogServiceEntriesBadRequest() *ListSelLogServiceEntriesBadRequest {\n\treturn &ListSelLogServiceEntriesBadRequest{}\n}", "func (ctx *DeleteFilterContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func CreateBadRequestResponse(w http.ResponseWriter, err error) {\n\tw.WriteHeader(http.StatusBadRequest)\n\tbytes, _ := json.Marshal(err.Error())\n\tw.Write(bytes)\n}", "func (ctx *GetOutputContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *PutEventContext) BadRequest(r *AntError) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.error+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func NewGetAssetsListBadRequest() *GetAssetsListBadRequest {\n\n\treturn &GetAssetsListBadRequest{}\n}", "func (ctx *GetFilterContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *GetFeedContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func BadRequest(message string, errors []Error) {\n\tresponse := Response{\n\t\tStatus: http.StatusBadRequest,\n\t\tMessage: message,\n\t\tData: nil,\n\t\tErrors: errors,\n\t}\n\tpanic(response)\n}", "func BadRequestErr(err error, format string, args ...interface{}) error {\n\treturn NewError(http.StatusBadRequest, err, format, args...)\n}", "func (ctx *StartFeedContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func BadRequest(err error) Response {\n\treturn &errorResponse{\n\t\tcode: http.StatusBadRequest,\n\t\tmsg: err.Error(),\n\t}\n}", "func (ctx *DeleteFeedContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *DeleteDogContext) BadRequest() error {\n\tctx.ResponseData.WriteHeader(400)\n\treturn nil\n}", "func NewDownloadMediaBadRequest(body *DownloadMediaBadRequestResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func (r *Response) BadRequest(v interface{}) {\n\tr.writeResponse(http.StatusBadRequest, v)\n}", "func (a *APIResponse) BadRequest(err error) {\n\ta.Status = HttpStatus{Code: http.StatusBadRequest, Message: http.StatusText(http.StatusBadRequest)}\n\ta.Data = APIError{Error: err.Error()}\n}", "func BadRequest(w http.ResponseWriter, err error) {\n\tError(w, http.StatusBadRequest, err)\n}", "func (client MultipleResponsesClient) Get202None204NoneDefaultNone400InvalidPreparer() (*http.Request, error) {\n preparer := autorest.CreatePreparer(\n autorest.AsGet(),\n autorest.WithBaseURL(client.BaseURI),\n autorest.WithPath(\"/http/payloads/202/none/204/none/default/none/response/400/invalid\"))\n return preparer.Prepare(&http.Request{})\n}", "func (ctx *UpdateFeedContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func invalid_request(w http.ResponseWriter, statCode int, message string){\n w.Header().Set(\"Content-Type\", \"application/json\")\n switch statCode {\n case 400: w.WriteHeader(http.StatusBadRequest)\n case 403: w.WriteHeader(http.StatusForbidden)\n case 404: w.WriteHeader(http.StatusNotFound)\n default: w.WriteHeader(http.StatusNotFound)\n }\n err := Error {\n StatusCode: statCode,\n ErrorMessage: message}\n json.NewEncoder(w).Encode(err)\n}", "func (ctx *CreateVerificationContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *UpdateOutputContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func NewGetEntriesBadRequest() *GetEntriesBadRequest {\n\treturn &GetEntriesBadRequest{}\n}", "func (ctx *PubPshbContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func BadRequest(message string, w http.ResponseWriter) {\n\tbody := createBodyWithMessage(message)\n\twriteResponse(400, body, w)\n}", "func (ctx *AcceptOfferContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (client MultipleResponsesClient) Get202None204NoneDefaultNone202InvalidPreparer() (*http.Request, error) {\n preparer := autorest.CreatePreparer(\n autorest.AsGet(),\n autorest.WithBaseURL(client.BaseURI),\n autorest.WithPath(\"/http/payloads/202/none/204/none/default/none/response/202/invalid\"))\n return preparer.Prepare(&http.Request{})\n}", "func (ctx *SubPshbContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func NewAddEntriesBadRequest() *AddEntriesBadRequest {\n\treturn &AddEntriesBadRequest{}\n}", "func (ctx *GetOpmlContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func NewRestException (\n status int, code, message, developerMessage string, extraInfo *url.URL,\n) RestException {\n if 400 > status || 499 < status || \"\" == message {\n return nil\n }\n\n return &_RestException {\n status: status,\n code: code,\n message: message,\n developerMessage: developerMessage,\n extraInfo: extraInfo,\n }\n}", "func (e ErrUnsupportedAllocation) BadRequest() {}", "func BadRequest(r *http.ResponseWriter) error {\n\tresponse := *r\n\tresponse.WriteHeader(400)\n\treturn nil\n}", "func (r *Responder) BadRequest() { r.write(http.StatusBadRequest) }", "func badRequest(resp *ApiResponse, msg string) error {\n resp.StatusCode = http.StatusBadRequest\n resp.Message = []byte(msg)\n resp.ErrorMessage = msg\n\n return nil\n}", "func (ctx *SignupAuthenticationContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *RegisterAuthenticationContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *UpdateFilterContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (client MultipleResponsesClient) GetDefaultNone400InvalidResponder(resp *http.Response) (result autorest.Response, err error) { \n err = autorest.Respond(\n resp,\n client.ByInspecting(),\n azure.WithErrorUnlessStatusCode(http.StatusOK),\n autorest.ByClosing())\n result.Response = resp\n return\n}", "func (o *ObjectsListBadRequest) WithPayload(payload *models.ErrorResponse) *ObjectsListBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (ctx *LoginAuthenticationContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *ListUserContext) BadRequest(r error) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *UploadOpmlContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (a *APIDefaults) ArtifactLister(params artifacts.ArtifactListerParams) middleware.Responder {\n\tpaginator := weles.ArtifactPagination{}\n\tif a.PageLimit != 0 {\n\t\tif (params.After != nil) && (params.Before != nil) {\n\t\t\treturn artifacts.NewArtifactListerBadRequest().WithPayload(&weles.ErrResponse{\n\t\t\t\tMessage: weles.ErrBeforeAfterNotAllowed.Error()})\n\t\t}\n\t\tpaginator = setArtifactPaginator(params, a.PageLimit)\n\t}\n\tfilter := setArtifactFilter(params.ArtifactFilterAndSort.Filter)\n\tsorter := setArtifactSorter(params.ArtifactFilterAndSort.Sorter)\n\n\tartifactInfoReceived, listInfo, err := a.Managers.AM.ListArtifact(filter, sorter, paginator)\n\n\tswitch err {\n\tdefault:\n\t\treturn artifacts.NewArtifactListerInternalServerError().WithPayload(\n\t\t\t&weles.ErrResponse{Message: err.Error()})\n\tcase weles.ErrArtifactNotFound:\n\t\treturn artifacts.NewArtifactListerNotFound().WithPayload(\n\t\t\t&weles.ErrResponse{Message: weles.ErrArtifactNotFound.Error()})\n\tcase nil:\n\t}\n\n\tartifactInfoReturned := artifactInfoReceivedToReturn(artifactInfoReceived)\n\n\tif (listInfo.RemainingRecords == 0) || (a.PageLimit == 0) { //last page...\n\t\treturn responderArtifact200(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n\t} //not last page...\n\treturn responderArtifact206(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n}", "func (ctx *UpdateListenContext) BadRequest(r *AntError) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.error+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (ctx *StopFeedContext) BadRequest(r error) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/vnd.goa.error\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func badRequest(msg string) error {\n\treturn status.Error(codes.InvalidArgument, msg)\n}", "func (ctx *AddListenContext) BadRequest(r *AntError) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.error+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func BadRequest(w http.ResponseWriter, message ...interface{}) {\n\tboom(w, 400, message...)\n}", "func (ctx *HookAnalysisContext) BadRequest(r *AntError) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.error+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 400, r)\n}", "func (response BasicJSONResponse) BadRequest(writer http.ResponseWriter) {\n\tBadRequest(writer, response)\n}", "func NewListServerGroupBadRequest() *ListServerGroupBadRequest {\n\treturn &ListServerGroupBadRequest{}\n}", "func NewUserGroupListBadRequest() *UserGroupListBadRequest {\n\treturn &UserGroupListBadRequest{}\n}", "func BadRequest(data Serializer, logging ...interface{}) Response {\n\tif data == nil {\n\t\tdata = String(\"400 Bad Request\")\n\t}\n\treturn Response{\n\t\tStatus: http.StatusBadRequest,\n\t\tData: data,\n\t\tLogging: logging,\n\t}\n}", "func (o *ArtifactListerInternalServerError) WithPayload(payload *weles.ErrResponse) *ArtifactListerInternalServerError {\n\to.Payload = payload\n\treturn o\n}" ]
[ "0.6623783", "0.59504145", "0.5825326", "0.5791996", "0.57016426", "0.56496376", "0.5584372", "0.5577911", "0.55503136", "0.553018", "0.5512467", "0.54805005", "0.54748464", "0.54560053", "0.54332155", "0.54139864", "0.5413202", "0.5401377", "0.5400714", "0.5381099", "0.5369809", "0.53697103", "0.535514", "0.53295404", "0.5328074", "0.53260237", "0.53116834", "0.5302807", "0.5294728", "0.52885395", "0.5284561", "0.52743274", "0.52487427", "0.5237605", "0.5235147", "0.52184683", "0.5204122", "0.5204122", "0.51939625", "0.5171443", "0.51710135", "0.5164502", "0.516081", "0.515899", "0.51552206", "0.51534504", "0.5150963", "0.514187", "0.513254", "0.5125778", "0.5122589", "0.5114809", "0.511121", "0.5108892", "0.5104789", "0.51015484", "0.5096333", "0.50756294", "0.506649", "0.5054813", "0.5051875", "0.5049106", "0.50440836", "0.50437886", "0.5043014", "0.50403947", "0.50403625", "0.5025621", "0.50243574", "0.5015599", "0.50143886", "0.500737", "0.50070274", "0.5005567", "0.4996301", "0.49929285", "0.49899974", "0.4985688", "0.4985283", "0.49805433", "0.4980175", "0.49778515", "0.49763483", "0.49729595", "0.49729133", "0.4968797", "0.49663028", "0.4965836", "0.49482998", "0.49478948", "0.49472055", "0.49393487", "0.49330565", "0.4929971", "0.49296823", "0.49289614", "0.4928494", "0.492363", "0.49139762", "0.49093172" ]
0.77091694
0
WithPayload adds the payload to the artifact lister bad request response
func (o *ArtifactListerBadRequest) WithPayload(payload *weles.ErrResponse) *ArtifactListerBadRequest { o.Payload = payload return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerInternalServerError) WithPayload(payload *weles.ErrResponse) *ArtifactListerInternalServerError {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ObjectsListBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetLinkInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *ObjectsListForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDBadRequest) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *ArtifactListerOK) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerOK {\n\to.Payload = payload\n\treturn o\n}", "func (o *AddOrgMembersV1BadRequest) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetMoveCounselingEvaluationReportsListBadRequest) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDForbidden) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *GetTagBadRequest) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *AddReleasesBadRequest) WithPayload(payload *models.APIResponse) *AddReleasesBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetCapabilityForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PartialUpdateAppForbidden) SetPayload(payload *models.Unauthorized) {\n\to.Payload = payload\n}", "func (o *UpdateClusterBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ServiceAddServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *V2GetIgnoredValidationsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAllGroupsNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceAddBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationNotFound) SetPayload(payload *models.MissingResponse) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetChatroomsIDForbidden) SetPayload(payload *apimodel.Error) {\n\to.Payload = payload\n}", "func (o *InviteUserToGroupBadRequest) SetPayload(payload *modelapi.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageUnprocessableEntity) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreateHPCResourceForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *CreateMailersSectionBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetInteractionsBadRequest) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetTagBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVisiblePruebasFromQuestionTestBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDBadRequest) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GraphqlPostUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordBadRequest) SetPayload(payload *models.BadRequest) {\n\to.Payload = payload\n}", "func (o *GetMeetupRemoteBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostInteractionBadRequest) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsPatchForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *BadRequest) WithPayload(payload *models.Error) *BadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *WeaviateActionsPatchUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetLinkInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddKeypairConflict) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *PostRegisterDetailsBadRequest) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *GetAssetsListOK) SetPayload(payload []*models.TokenAssetRow) {\n\to.Payload = payload\n}", "func (o *CreateMailerEntryBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ListStorageV1alpha1VolumeAttachmentOK) SetPayload(payload *models.IoK8sAPIStorageV1alpha1VolumeAttachmentList) {\n\to.Payload = payload\n}", "func (o *CreatePackageConflict) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListBadRequest) WithPayload(payload *models.ErrorResponse) *ObjectsListBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *UpdateRecordBadRequest) WithPayload(payload *models.BadRequest) *UpdateRecordBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetTagForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetIBAServerBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsBadRequest) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *CreateUserBadGateway) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *PutProjectProjectNameStageStageNameServiceServiceNameResourceBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GraphqlPostForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetResetPasswordRequestEmailForbidden) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetQuestionFromTeamForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTeamsForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddConsumptionForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeleteProjectUserBadGateway) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateActionForbidden) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *AddKeypairMethodNotAllowed) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *RemoveTeamToPublishedTestForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateLinkInPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostItemNameReservationBadRequest) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDInternalServerError) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *RemoveTeamToPublishedTestBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordNotFound) SetPayload(payload *models.NotFoundError) {\n\to.Payload = payload\n}", "func (o *AddConsumptionNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetTeamsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ThingsDeleteForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}" ]
[ "0.70712554", "0.66748416", "0.66125786", "0.6426536", "0.6421959", "0.62453586", "0.62187576", "0.6214958", "0.62071145", "0.61881536", "0.61808497", "0.6167171", "0.61444926", "0.61349064", "0.6130238", "0.6124997", "0.6106821", "0.6104793", "0.60994357", "0.60610396", "0.6055746", "0.6041377", "0.60408896", "0.6006516", "0.59925276", "0.5984148", "0.5976361", "0.59715384", "0.59619653", "0.5954686", "0.5954212", "0.5948303", "0.5937858", "0.5936111", "0.5928773", "0.5924048", "0.59234065", "0.59219", "0.59194", "0.5916028", "0.591237", "0.59105784", "0.5905903", "0.5901686", "0.5901664", "0.59002966", "0.5898665", "0.589427", "0.58926564", "0.58909345", "0.5889882", "0.5887723", "0.58835834", "0.58669865", "0.5861543", "0.58614945", "0.58563447", "0.58529943", "0.58499926", "0.5848844", "0.5842375", "0.5842335", "0.5839783", "0.5833503", "0.58318067", "0.5828867", "0.5821644", "0.58213943", "0.58204484", "0.581965", "0.5818196", "0.58179724", "0.5811711", "0.5809692", "0.5807852", "0.58013475", "0.5798143", "0.57963943", "0.5795367", "0.57935166", "0.5792412", "0.57908314", "0.57905954", "0.57882065", "0.5787505", "0.57860726", "0.57833576", "0.5782991", "0.5782165", "0.57790804", "0.57789147", "0.57786244", "0.57779646", "0.5775695", "0.57744336", "0.5765781", "0.57649916", "0.57643324", "0.5762808", "0.5762113" ]
0.7316845
0
SetPayload sets the payload to the artifact lister bad request response
func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) { o.Payload = payload }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *CreatePackageUnprocessableEntity) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetInteractionsBadRequest) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVisiblePruebasFromQuestionTestBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetTaskTaskIDBadRequest) SetPayload(payload *models.ResponseError) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetIBAServerUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GraphqlPostUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostInteractionBadRequest) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetIBAServerBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetCorrectedAnswersFromPublishedTestsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsBadRequest) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *CreateBackendSwitchingRuleBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetQuestionFromTeamForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksUnauthorized) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *GetLinkInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetQuestionAnswersFromAnswerBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetMoveCounselingEvaluationReportsListBadRequest) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDBadRequest) SetPayload(payload *models.InvalidParameterInput) {\n\to.Payload = payload\n}", "func (o *AddKeypairConflict) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetQuestionFromTeamBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddReleasesUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVisiblePruebasFromQuestionTestForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetIBAServerNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *GetTeamsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDInternalServerError) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1BadRequest) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsNotFound) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetCorrectedAnswersFromPublishedTestsForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ServiceAddBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetResetPasswordRequestEmailBadRequest) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *RemoveTeamToPublishedTestBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsPatchUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddKeypairInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDBadRequest) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *CreatePackageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetActivationsInternalServerError) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *GetTagBadRequest) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetApisUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigForbidden) SetPayload(payload *models.InfraError) {\n\to.Payload = payload\n}", "func (o *GetModelUnauthorized) SetPayload(payload *restmodels.Error) {\n\to.Payload = payload\n}", "func (o *CreateMailerEntryBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetQuestionAnswersFromAnswerForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetMeetupRemoteBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageConflict) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetQuestionsFromTagForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *RemoveTeamToPublishedTestForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTeamsForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPaymentBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetActivationsUnauthorized) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDBadRequest) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetPrefilterFailure) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *GetQuestionsFromTagBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ReplaceHTTPErrorRuleBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceAddServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTagsFromQuestionBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetPreconditionFailed) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTagsFromQuestionForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreateBackendSwitchingRuleConflict) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetApisInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordBadRequest) SetPayload(payload *models.BadRequest) {\n\to.Payload = payload\n}" ]
[ "0.8006691", "0.779523", "0.76306844", "0.7535646", "0.7526764", "0.74793965", "0.74657947", "0.74545217", "0.74450266", "0.7421751", "0.73978674", "0.73853314", "0.7370035", "0.73608977", "0.73517865", "0.7346822", "0.7346421", "0.7337875", "0.7331927", "0.7323504", "0.73230994", "0.73047876", "0.7302276", "0.7295689", "0.7293587", "0.72926635", "0.72917366", "0.72866565", "0.72815096", "0.7273537", "0.7267174", "0.72597635", "0.7259414", "0.72586954", "0.7258569", "0.7253194", "0.72479284", "0.72467786", "0.7246004", "0.7245733", "0.723958", "0.7237685", "0.7236938", "0.7234594", "0.72298425", "0.72292274", "0.72253346", "0.72224265", "0.72223353", "0.7221004", "0.7220784", "0.7219586", "0.72131675", "0.72117186", "0.7208559", "0.7205738", "0.7201326", "0.7199174", "0.71942127", "0.7193238", "0.71927994", "0.71886194", "0.7185306", "0.7175399", "0.7174874", "0.7171814", "0.7169614", "0.7169568", "0.71681875", "0.7168137", "0.71644974", "0.7159771", "0.7159456", "0.71581507", "0.7156129", "0.7154288", "0.71537083", "0.7153078", "0.71519667", "0.7147911", "0.7147709", "0.71469635", "0.71406734", "0.71404326", "0.7139378", "0.71365124", "0.71357465", "0.713352", "0.71328", "0.7132218", "0.7131677", "0.7131303", "0.71312034", "0.71302116", "0.7130018", "0.7129972", "0.7127365", "0.7127119", "0.71246177", "0.7122642" ]
0.8232403
0
WriteResponse to the client
func (o *ArtifactListerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { rw.WriteHeader(400) if o.Payload != nil { payload := o.Payload if err := producer.Produce(rw, payload); err != nil { panic(err) // let the recovery middleware deal with this } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Response) Write(w io.Writer) error", "func (c *Operation) writeResponse(rw http.ResponseWriter, status int, data []byte) { // nolint: unparam\n\trw.WriteHeader(status)\n\n\tif _, err := rw.Write(data); err != nil {\n\t\tlogger.Errorf(\"Unable to send error message, %s\", err)\n\t}\n}", "func WriteResponse(w http.ResponseWriter, mensaje string, code int) {\n\tmessage := myTypes.Respuesta{\n\t\tMessage: mensaje,\n\t}\n\tresponse, _ := json.Marshal(message)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(response)\n}", "func WriteResponse(w http.ResponseWriter, object interface{}, rerr *irma.RemoteError) {\n\tstatus, bts := JsonResponse(object, rerr)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\t_, err := w.Write(bts)\n\tif err != nil {\n\t\tLogWarning(errors.WrapPrefix(err, \"failed to write response\", 0))\n\t}\n}", "func (o *PingOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, v interface{}, statusCode int) {\n\tresBody, err := json.Marshal(v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\t_, _ = w.Write(resBody)\n}", "func WriteResponse(w http.ResponseWriter, code int, object interface{}) {\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func (o *GetPingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(body []byte, w *http.ResponseWriter) {\n\t(*w).Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t_, err := (*w).Write(body)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\t(*w).WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func WriteResponse(w http.ResponseWriter, code int, resp interface{}) error {\n\tj, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\n\t_, err = w.Write(j)\n\treturn err\n}", "func writeResponse(w *http.ResponseWriter, res responseData, status int) {\n\tresJSON, err := json.Marshal(res)\n\tif err != nil {\n\t\thttp.Error(*w, \"Failed to parse struct `responseData` into JSON object\", http.StatusInternalServerError)\n\t}\n\n\t(*w).Header().Set(\"Content-Type\", \"application/json\")\n\t(*w).WriteHeader(status)\n\t(*w).Write(resJSON)\n}", "func WriteResponse(w http.ResponseWriter, d string) {\n\tw.WriteHeader(200)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.Write([]byte(d))\n\treturn\n}", "func (o *CreateFacilityUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(w http.ResponseWriter, response Response) {\n\tjson, err := json.Marshal(&response)\n\n\tif err != nil {\n\t\tfmt.Fprint(w, \"There was an error processing the request.\")\n\t}\n\n\tcommon.Log(fmt.Sprintf(\"Returning response %s\", json))\n\tfmt.Fprintf(w, \"%s\", json)\n}", "func (o *CreateProgramOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DepositNewFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMedicineOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *CreateTaskCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Location\n\n\tlocation := o.Location.String()\n\tif location != \"\" {\n\t\trw.Header().Set(\"Location\", location)\n\t}\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(r *http.Request, w http.ResponseWriter, code int, resp interface{}) {\n\n\t// Deal with CORS\n\tif origin := r.Header.Get(\"Origin\"); origin != \"\" {\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", origin)\n\t\tw.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE, GET, HEAD, OPTIONS, POST, PUT\")\n\t\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\t\t// Allow any headers\n\t\tif wantedHeaders := r.Header.Get(\"Access-Control-Request-Headers\"); wantedHeaders != \"\" {\n\t\t\tw.Header().Set(\"Access-Control-Allow-Headers\", wantedHeaders)\n\t\t}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\n\tb, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintln(w, `{\"error\":\"failed to marshal json\"}`)\n\t\treturn\n\t}\n\n\tw.WriteHeader(code)\n\tfmt.Fprintln(w, string(b))\n}", "func (o *VerifyAccountCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(w http.ResponseWriter, h int, p interface{}) {\n\t// I set the content type...\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t// ... I write the specified status code...\n\tw.WriteHeader(h)\n\t// ... and I write the response\n\tb, _ := json.Marshal(p)\n\tw.Write(b)\n}", "func (o *UpdateCatalogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (c *SwitchVersion) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postSwitchVersion(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *PutRecordingsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *BofaChkUpdateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *VerifyHealthCredentialOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, code int, err error, data interface{}, t0 time.Time) {\n\tw.WriteHeader(code)\n\tresp := &Response{Data: data, Dur: fmt.Sprint(time.Since(t0)), OK: false}\n\tif code < 300 {\n\t\tresp.OK = true\n\t}\n\tif err != nil {\n\t\tresp.Err = err.Error()\n\t}\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Infof(\"failed to json encode response: %v\", err)\n\t\tif _, err = w.Write([]byte(spew.Sdump(resp))); err != nil {\n\t\t\tlog.Infof(\"failed to write dump of response: %v\", err)\n\t\t}\n\t}\n}", "func (o *NewDiscoveryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(data []byte, size int64, ctype string, w http.ResponseWriter) {\n\tw.Header().Set(\"Content-Type\", ctype)\n\tw.Header().Set(\"Content-Length\", fmt.Sprintf(\"%d\", size))\n\tw.Header().Set(\"Cache-Control\", \"no-transform,public,max-age=86400,s-maxage=2592000\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, code int, object interface{}) {\n\tfmt.Println(\"writing response:\", code, object)\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, authZRes *authorization.Response) {\n\n\tdata, err := json.Marshal(authZRes)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to marshel authz response %q\", err.Error())\n\t} else {\n\t\tw.Write(data)\n\t}\n\n\tif authZRes == nil || authZRes.Err != \"\" {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t}\n}", "func (o *GetCharactersCharacterIDOpportunitiesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetCharactersCharacterIDOpportunitiesOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *WeaviateThingsGetNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *UpdateLinkInPostOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetChatroomsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetEchoNameOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetUIContentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *ListVsphereResourceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func ResponseWrite(w http.ResponseWriter, responseCode int, responseData interface{}) {\n\t// Write Response\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(responseCode)\n\n\t// Write JSON to Response\n\tjson.NewEncoder(w).Encode(responseData)\n}", "func writeHTTPResponseInWriter(httpRes http.ResponseWriter, httpReq *http.Request, nobelPrizeWinnersResponse []byte, err error) {\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(httpRes, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tlog.Printf(\"Request %s Succesfully Completed\", httpReq.RequestURI)\n\thttpRes.Header().Set(\"Content-Type\", \"application/json\")\n\thttpRes.Write(nobelPrizeWinnersResponse)\n}", "func (o *PostKeysKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlog.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func writeResponse(data interface{}, w http.ResponseWriter) error {\n\tvar (\n\t\tenc []byte\n\t\terr error\n\t)\n\tenc, err = json.Marshal(data)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to marshal, err = %s\", err)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tn, err := w.Write(enc)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to write, err = %s\", err)\n\t}\n\tif n != len(enc) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Short write sent = %d, wrote = %d\", len(enc), n)\n\t}\n\treturn nil\n}", "func (o *CreateUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func WriteResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PutQuestionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (r *response) Write(b []byte) (n int, err error) {\n\tif !r.headersSend {\n\t\tif r.status == 0 {\n\t\t\tr.status = http.StatusOK\n\t\t}\n\t\tr.WriteHeader(r.status)\n\t}\n\tn, err = r.ResponseWriter.Write(b)\n\tr.size += int64(n)\n\treturn\n}", "func (o *PostOperationsDeleteP2PPathCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *HealthGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsPatchNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (o *VerifyEmailTokenOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DeleteServiceIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\t// as of now, just log errors for writing response\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PostOperationsGetNodeEdgePointDetailsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *UserEditOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviatePeersAnnounceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *CertifyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(writer http.ResponseWriter, response *http.Response) (int64, error) {\n\tdefer response.Body.Close()\n\twriteResponseHeaders(writer, response, false)\n\treturn io.Copy(writer, response.Body)\n}", "func (o *PutMeetupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *FingerPathsPostCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *PostPlaybookOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateHostIgnitionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *GetCharactersCharacterIDLocationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostManagementKubernetesIoV1NodesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *PutPerformancesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *StopAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(202)\n}", "func (o *GetFleetsFleetIDMembersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Content-Language\n\n\tcontentLanguage := o.ContentLanguage\n\tif contentLanguage != \"\" {\n\t\trw.Header().Set(\"Content-Language\", contentLanguage)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetFleetsFleetIDMembersOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *GetMeetupsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostEventCreated) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(201)\n}", "func (o *GetTaskTaskIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateTCPCheckAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Reload-ID\n\n\treloadID := o.ReloadID\n\tif reloadID != \"\" {\n\t\trw.Header().Set(\"Reload-ID\", reloadID)\n\t}\n\n\trw.WriteHeader(202)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *PostOperationsGetNetworkElementListCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ServiceInstanceLastOperationGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header RetryAfter\n\n\tretryAfter := o.RetryAfter\n\tif retryAfter != \"\" {\n\t\trw.Header().Set(\"RetryAfter\", retryAfter)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPiecesIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetTaskDetailsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *UpdateClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetDetailOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\trw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetServicesHaproxyRuntimeAclsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (r *responseInfoRecorder) Write(b []byte) (int, error) {\n\tr.ContentLength += int64(len(b))\n\tif r.statusCode == 0 {\n\t\tr.statusCode = http.StatusOK\n\t}\n\treturn r.ResponseWriter.Write(b)\n}", "func (o *LogoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UploadFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, data interface{}) error {\n\tenv := map[string]interface{}{\n\t\t\"meta\": map[string]interface{}{\n\t\t\t\"code\": http.StatusOK,\n\t\t},\n\t\t\"data\": data,\n\t}\n\treturn jsonResponse(w, env)\n}", "func (o *WeaviateThingTemplatesCreateNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (r *Responder) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\tfor k, v := range r.headers {\n\t\tfor _, val := range v {\n\t\t\trw.Header().Add(k, val)\n\t\t}\n\t}\n\n\trw.WriteHeader(r.code)\n\n\tif r.response != nil {\n\t\tif err := producer.Produce(rw, r.response); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "func (o *GetGateSourceByGateNameAndMntOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateSpoeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tpayload := o.Payload\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *Output) writeResponse(response string) error {\r\n\t// write the response\r\n\tif _, err := o.writer.WriteString(response + \"\\n\"); err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (o *GetTransportByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *TransferOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateUserCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ViewOneOrderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetVisiblePruebasFromQuestionTestInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(500)\n}", "func (o *GetWhaleTranfersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.OperationsRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *SearchTournamentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*models.Tournament, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateTCPCheckCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (s *Server) writeInfoResponse(\n\tw http.ResponseWriter,\n\tr *http.Request,\n\tmessage []byte,\n\tstatus int,\n\theaders map[string]string,\n) {\n\tfor k, v := range headers {\n\t\tw.Header().Add(k, v)\n\t}\n\n\tw.WriteHeader(status)\n\tw.Write(message)\n}" ]
[ "0.81303823", "0.7882039", "0.77722245", "0.7771901", "0.7753117", "0.7740585", "0.76670325", "0.7638451", "0.76095873", "0.75798", "0.7579178", "0.7567389", "0.7560546", "0.75579476", "0.75447774", "0.7542929", "0.75416607", "0.753386", "0.7531158", "0.75192654", "0.75191355", "0.7513389", "0.7512029", "0.75050455", "0.7503395", "0.74984574", "0.74875605", "0.74839836", "0.74772394", "0.7467842", "0.746699", "0.7465759", "0.7464175", "0.746404", "0.746404", "0.7461224", "0.7460309", "0.74595356", "0.74463046", "0.7443478", "0.7435917", "0.7426582", "0.7425581", "0.74186546", "0.7413175", "0.7407469", "0.74063516", "0.74048966", "0.7398737", "0.7389631", "0.738607", "0.73806983", "0.7360552", "0.7360491", "0.7355327", "0.7354953", "0.73532444", "0.7347445", "0.734586", "0.732798", "0.732577", "0.73178244", "0.7316643", "0.7316071", "0.7315527", "0.7312546", "0.73114824", "0.7310336", "0.7309039", "0.73007035", "0.7297214", "0.7291373", "0.7291277", "0.72884554", "0.72845477", "0.72835207", "0.7281928", "0.7281033", "0.72751075", "0.7274423", "0.7273193", "0.72730565", "0.72695094", "0.7269139", "0.72690886", "0.7265927", "0.72615093", "0.72529227", "0.7251764", "0.72490144", "0.72479355", "0.72469014", "0.72407585", "0.72390425", "0.72367245", "0.7234706", "0.722777", "0.722197", "0.7215153", "0.72140837", "0.7213089" ]
0.0
-1
NewArtifactListerNotFound creates ArtifactListerNotFound with default headers values
func NewArtifactListerNotFound() *ArtifactListerNotFound { return &ArtifactListerNotFound{} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerNotFound) WithPayload(payload *weles.ErrResponse) *ArtifactListerNotFound {\n\to.Payload = payload\n\treturn o\n}", "func NewNotFound(err error, msg ...string) *Errs {\n\tif err == nil {\n\t\terr = ErrNotFound\n\t}\n\treturn &Errs{\n\t\tcodeHTTP: http.StatusNotFound,\n\t\terr: err,\n\t\tkind: trace(2),\n\t\tmessage: msg,\n\t}\n}", "func NewNotFound(s string, v ...interface{}) error {\n\treturn asNotFound(fmt.Errorf(s, v...))\n}", "func NewNotFound() error {\n\treturn requestError{\n\t\tClientError: ClientError{\n\t\t\tErrors: []clientErrorSubError{{Message: \"status code 404\"}},\n\t\t},\n\t}\n}", "func NewNotFoundError(message string)*RestErr{\n\treturn &RestErr{\n\t\tMessage: message,\n\t\tStatus: http.StatusNotFound,\n\t\tError: \"Not Found\",\n\t}\n}", "func NewArtifactListerBadRequest() *ArtifactListerBadRequest {\n\n\treturn &ArtifactListerBadRequest{}\n}", "func NotFound(w ResponseWriter, r *Request) {\n\tw.SetHeader(CodeNotFound, \"not found\")\n}", "func NewArtifactListerOK() *ArtifactListerOK {\n\n\treturn &ArtifactListerOK{}\n}", "func NewNotFound(a Attributes) error {\n\tname, resource, err := extractResourceName(a)\n\tif err != nil {\n\t\treturn apierrors.NewInternalError(err)\n\t}\n\treturn apierrors.NewNotFound(resource, name)\n}", "func (a *APIDefaults) ArtifactLister(params artifacts.ArtifactListerParams) middleware.Responder {\n\tpaginator := weles.ArtifactPagination{}\n\tif a.PageLimit != 0 {\n\t\tif (params.After != nil) && (params.Before != nil) {\n\t\t\treturn artifacts.NewArtifactListerBadRequest().WithPayload(&weles.ErrResponse{\n\t\t\t\tMessage: weles.ErrBeforeAfterNotAllowed.Error()})\n\t\t}\n\t\tpaginator = setArtifactPaginator(params, a.PageLimit)\n\t}\n\tfilter := setArtifactFilter(params.ArtifactFilterAndSort.Filter)\n\tsorter := setArtifactSorter(params.ArtifactFilterAndSort.Sorter)\n\n\tartifactInfoReceived, listInfo, err := a.Managers.AM.ListArtifact(filter, sorter, paginator)\n\n\tswitch err {\n\tdefault:\n\t\treturn artifacts.NewArtifactListerInternalServerError().WithPayload(\n\t\t\t&weles.ErrResponse{Message: err.Error()})\n\tcase weles.ErrArtifactNotFound:\n\t\treturn artifacts.NewArtifactListerNotFound().WithPayload(\n\t\t\t&weles.ErrResponse{Message: weles.ErrArtifactNotFound.Error()})\n\tcase nil:\n\t}\n\n\tartifactInfoReturned := artifactInfoReceivedToReturn(artifactInfoReceived)\n\n\tif (listInfo.RemainingRecords == 0) || (a.PageLimit == 0) { //last page...\n\t\treturn responderArtifact200(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n\t} //not last page...\n\treturn responderArtifact206(listInfo, paginator, artifactInfoReturned, a.PageLimit)\n}", "func NotFound(w ResponseWriter, r *Request) { Error(w, \"404 page not found\", StatusNotFound) }", "func notFound(resource string) middleware.Responder {\n\tmessage := fmt.Sprintf(\"404 %s not found\", resource)\n\treturn operations.NewGetChartDefault(http.StatusNotFound).WithPayload(\n\t\t&models.Error{Code: helpers.Int64ToPtr(http.StatusNotFound), Message: &message},\n\t)\n}", "func (o *ArtifactListerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(404)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func NewNotFound(parameters ...wparams.ParamStorer) Error {\n\treturn newGenericError(nil, DefaultNotFound, wparams.NewParamStorer(parameters...))\n}", "func noFound(msg string) error {\n\treturn status.Error(codes.NotFound, msg)\n}", "func NewShowNotFound(body *ShowNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewShowNotFound(body *ShowNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewAllDashboardsNotFound() *AllDashboardsNotFound {\n return &AllDashboardsNotFound{\n }\n}", "func responderArtifact200(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerOK) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\tresponder = artifacts.NewArtifactListerOK()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tif paginator.ID != 0 { //not the first page\n\t\t// keep in mind that ArtifactPath in paginator is taken from query parameter,\n\t\t// not ArtifactManager\n\t\tif paginator.Forward {\n\t\t\ttmp := artifactInfoReturned[0].ID\n\t\t\tartifactListerURL.Before = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp\n\t\t\t}\n\t\t\tresponder.SetPrevious(artifactListerURL.String())\n\t\t} else {\n\t\t\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\t\t\tartifactListerURL.After = &tmp\n\t\t\tif defaultPageLimit != paginator.Limit {\n\t\t\t\ttmp2 := paginator.Limit\n\t\t\t\tartifactListerURL.Limit = &tmp2\n\t\t\t}\n\t\t\tresponder.SetNext(artifactListerURL.String())\n\t\t}\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (nse ErrNoSuchEndpoint) NotFound() {}", "func notFound(resp *ApiResponse, msg string) error {\n resp.StatusCode = http.StatusNotFound\n resp.Message = []byte(msg)\n resp.ErrorMessage = http.StatusText(http.StatusNotFound)\n\n return nil\n}", "func NewGetEntriesNotFound() *GetEntriesNotFound {\n\treturn &GetEntriesNotFound{}\n}", "func NewNotFound(msg string) error {\n\treturn &ELBError{\n\t\tmsg: msg,\n\t\tCode: http.StatusNotFound,\n\t}\n}", "func NotFound(w http.ResponseWriter, r *http.Request, h *render.Renderer) {\n\taccept := strings.Split(r.Header.Get(\"Accept\"), \",\")\n\taccept = append(accept, strings.Split(r.Header.Get(\"Content-Type\"), \",\")...)\n\n\tswitch {\n\tcase prefixInList(accept, ContentTypeHTML):\n\t\tm := TemplateMapFromContext(r.Context())\n\t\tm.Title(http.StatusText(http.StatusNotFound))\n\t\th.RenderHTMLStatus(w, http.StatusNotFound, \"404\", m)\n\tcase prefixInList(accept, ContentTypeJSON):\n\t\th.RenderJSON(w, http.StatusNotFound, http.StatusText(http.StatusNotFound))\n\tdefault:\n\t\thttp.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)\n\t}\n}", "func ERROR_ASSET_NOT_FOUND(w http.ResponseWriter, payload string) {\n\tbuildForeignError(w, http.StatusNotFound, \"ERROR_ASSET_NOT_FOUND\", payload)\n}", "func (c ApiWrapper) NotFound(msg string, objs ...interface{}) revel.Result {\n\treturn c.renderErrorString(404, fmt.Sprintf(msg, objs))\n}", "func NotFound(format string, args ...interface{}) error {\n\targs = append(args, withDefaultMessage(NotFoundDefaultMsg))\n\treturn Errorf(http.StatusNotFound, format, args...)\n}", "func (a *API) getNotFound(ctx context.Context, res *common.HttpResponseWriter) error {\n\tres.WriteHeader(http.StatusNotFound)\n\treturn nil\n}", "func notFoundLogger(logger log.Logger) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tlogger.Log(\"err\", http.StatusText(http.StatusNotFound), \"url\", r.URL)\n\t\tw.WriteHeader(http.StatusNotFound)\n\t})\n}", "func notfound(out http.ResponseWriter, format string, args ...interface{}) {\n\tsend(http.StatusNotFound, out, format, args...)\n}", "func NotFound(err error) error {\n\treturn New(http.StatusNotFound, err)\n}", "func NotFound(fn http.HandlerFunc) {\n\tinfoMutex.Lock()\n\tvestigo.CustomNotFoundHandlerFunc(fn)\n\tinfoMutex.Unlock()\n}", "func dependencyNotFoundInArtifactory(err error, noRegistry bool) bool {\n\tif !noRegistry && strings.EqualFold(err.Error(), \"404 Not Found\") {\n\t\treturn true\n\t}\n\treturn false\n}", "func ErrNotFoundf(format string, arguments ...interface{}) *Status {\n\treturn &Status{Code: http.StatusNotFound, Text: fmt.Sprintf(format, arguments...)}\n}", "func NotFound(msg string) Error {\n\te := err{msg: msg, code: notFoundCode, group: generic, kind: notFound}\n\treturn &e\n}", "func NewGetArchiveOrderNotFound(body *GetArchiveOrderNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NotFound(w http.ResponseWriter, r *http.Request) { Error(w, \"404 page not found\", http.StatusNotFound) }", "func NotFoundHandler() ServiceHttpHandler { return ServiceHttpHandler{Handler: NotFound} }", "func NewImportArchiveNotFound() *ImportArchiveNotFound {\n\treturn &ImportArchiveNotFound{}\n}", "func NewAddEntriesNotFound() *AddEntriesNotFound {\n\treturn &AddEntriesNotFound{}\n}", "func (r *Macross) NotFound(handlers ...Handler) {\n\tr.notFound = handlers\n\tr.notFoundHandlers = combineHandlers(r.handlers, r.notFound)\n}", "func notFound(w http.ResponseWriter, req *http.Request) {\n\t// w.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\tapiError := apirouter.ErrorFromRequest(req, fmt.Sprintf(\"404 occurred: %s\", req.RequestURI), \"Whoops - this request is not recognized\", http.StatusNotFound, http.StatusNotFound, \"\")\n\tapirouter.ReturnResponse(w, req, apiError.Code, apiError)\n}", "func NotFoundf(format string, args ...interface{}) error {\n\treturn &notFoundError{fmt.Errorf(format, args...)}\n}", "func NotFound(w http.ResponseWriter, r *http.Request) {\n\tresponse := response.CreateResponse()\n\tresponse.SendDataWithStatusCode(w, \"not found\", http.StatusOK)\n}", "func NewNotFound(name, group, resource string) error {\n\treturn errors.NewNotFound(schema.GroupResource{Group: group, Resource: resource}, name)\n}", "func NotFound(data Serializer, logging ...interface{}) Response {\n\tif data == nil {\n\t\tdata = String(\"404 Not Found\")\n\t}\n\treturn Response{Status: http.StatusNotFound, Data: data, Logging: logging}\n}", "func NotFound(message string, errors []Error) {\n\tresponse := Response{\n\t\tStatus: http.StatusNotFound,\n\t\tMessage: message,\n\t\tData: nil,\n\t\tErrors: errors,\n\t}\n\tpanic(response)\n}", "func NotFound(w http.ResponseWriter, _ error) {\n\t(Response{Error: \"resource not found\"}).json(w, http.StatusNotFound)\n}", "func (r Response) NotFound(code string, payload Payload, header ...ResponseHeader) {\n\tr.Response(code, http.NotFound, payload, header...)\n}", "func NewListComponentVersionsNotFound() *ListComponentVersionsNotFound {\n\treturn &ListComponentVersionsNotFound{}\n}", "func NewDownloadMediaNotFound(body *DownloadMediaNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NotFound(c *routing.Context, msg string, service string) error {\n\tResponse(c, `{\"error\": true, \"msg\": \"`+msg+`\"}`, 404, service, \"application/json\")\n\treturn nil\n}", "func NotFoundHandler() Handler { return HandlerFunc(NotFound) }", "func NotFoundHandler() Handler { return HandlerFunc(NotFound) }", "func NewListByPathNotFound(body *ListByPathNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewListByPathNotFound(body *ListByPathNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewNotFoundErr(err error) Error {\n\treturn StatusError{\n\t\tCode: http.StatusNotFound,\n\t\tErr: err,\n\t}\n}", "func WrapWithNotFound(cause error, parameters ...wparams.ParamStorer) Error {\n\treturn newGenericError(cause, DefaultNotFound, wparams.NewParamStorer(parameters...))\n}", "func NotFound(message string, args ...interface{}) *Failure {\n\treturn NewWithStatus(fmt.Sprintf(message, args...), http.StatusNotFound)\n}", "func (response BasicJSONResponse) NotFound(writer http.ResponseWriter) {\n\tNotFound(writer, response)\n}", "func NewListByReferenceNotFound(body *ListByReferenceNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func (m *mockAPI) notFound() *expectation {\n\treturn &expectation{code: http.StatusNotFound, body: nil}\n}", "func NewByNamespaceNotFound() *ByNamespaceNotFound {\n\treturn &ByNamespaceNotFound{}\n}", "func (o *GetProjectSummaryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(404)\n}", "func NotFound(rw http.ResponseWriter) {\n\tHttpError(rw, \"not found\", 404)\n}", "func NewGetTagNotFound() *GetTagNotFound {\n\treturn &GetTagNotFound{}\n}", "func NewDeleteArtifactNotFound() *DeleteArtifactNotFound {\n\treturn &DeleteArtifactNotFound{}\n}", "func AsNotFound(err error) error {\n\tif err == nil {\n\t\treturn nil\n\t}\n\treturn &notFoundError{err}\n}", "func NotFound(w http.ResponseWriter, message ...interface{}) {\n\tboom(w, 404, message...)\n}", "func (uee *UnknownEndpointError) NotFound() {}", "func NotFound(w http.ResponseWriter) {\n\trenderError(w, http.StatusNotFound, nil)\n}", "func NotFound(message ...interface{}) Err {\n\treturn Boomify(http.StatusNotFound, message...)\n}", "func NewGetNotFound(body *GetNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewGetNotFound(body *GetNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NotFound(msg string) ErrorResponse {\n\tif msg == \"\" {\n\t\tmsg = \"The requested resource was not found.\"\n\t}\n\treturn ErrorResponse{\n\t\tStatus: http.StatusNotFound,\n\t\tMessage: msg,\n\t}\n}", "func (Http) getNotFound(name string) *Http {\n\treturn &Http{\n\t\tCode: http.StatusNotFound,\n\t\tStatus: http.StatusText(http.StatusNotFound),\n\t\tMessage: fmt.Sprintf(\"%s not found\", toUpperFirstChar(name)),\n\t}\n}", "func ErrNotFound(err error) APIError {\n\treturn APIError{http.StatusNotFound, err}\n}", "func (r *Responder) NotFound() { r.write(http.StatusNotFound) }", "func NotFound(w http.ResponseWriter, r *http.Request) {\n\tw.WriteHeader(http.StatusNotFound)\n\tjson.NewEncoder(w).Encode(&ServiceError{\n\t\tMessage: \"Endpoint not found\",\n\t\tSolution: \"See / for possible directives\",\n\t\tErrorCode: http.StatusNotFound,\n\t})\n}", "func (ctx *GetAllHostContext) NotFound() error {\n\tctx.ResponseData.WriteHeader(404)\n\treturn nil\n}", "func NotFound(w http.ResponseWriter, err error) {\n\tError(w, http.StatusNotFound, err)\n}", "func notFound(w http.ResponseWriter, req *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"text/html\")\n\thttp.NotFound(w, req)\n}", "func responderArtifact206(listInfo weles.ListInfo, paginator weles.ArtifactPagination,\n\tartifactInfoReturned []*weles.ArtifactInfo, defaultPageLimit int32,\n) (responder *artifacts.ArtifactListerPartialContent) {\n\tvar artifactListerURL artifacts.ArtifactListerURL\n\n\tresponder = artifacts.NewArtifactListerPartialContent()\n\tresponder.SetTotalRecords(listInfo.TotalRecords)\n\tresponder.SetRemainingRecords(listInfo.RemainingRecords)\n\n\ttmp := artifactInfoReturned[len(artifactInfoReturned)-1].ID\n\tartifactListerURL.After = &tmp\n\n\tif defaultPageLimit != paginator.Limit {\n\t\ttmp := paginator.Limit\n\t\tartifactListerURL.Limit = &tmp\n\t}\n\tresponder.SetNext(artifactListerURL.String())\n\n\tif paginator.ID != 0 { //... and not the first\n\t\t//paginator.ID is from query parameter not artifactmanager\n\t\tvar artifactListerURL artifacts.ArtifactListerURL\n\t\ttmp = artifactInfoReturned[0].ID\n\t\tartifactListerURL.Before = &tmp\n\t\tif defaultPageLimit != paginator.Limit {\n\t\t\ttmp := paginator.Limit\n\t\t\tartifactListerURL.Limit = &tmp\n\t\t}\n\t\tresponder.SetPrevious(artifactListerURL.String())\n\t}\n\tresponder.SetPayload(artifactInfoReturned)\n\treturn\n}", "func (o *GetAssetsListNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(404)\n}", "func NotFound(w http.ResponseWriter) {\n\thttp.Error(w, \"404 not found!!!\", http.StatusNotFound)\n}", "func NotFound(msg string, args ...interface{}) error {\n\tif len(args) > 0 {\n\t\treturn status.Errorf(codes.NotFound, msg, args...)\n\t}\n\treturn status.Error(codes.NotFound, msg)\n}", "func NewListVsphereResourceNotFound() *ListVsphereResourceNotFound {\n\n\treturn &ListVsphereResourceNotFound{}\n}", "func (hr *httpRouter) NotFound(h http.Handler) {\n\thr.notFound = h\n}", "func (ctx *ShowSecretsContext) NotFound() error {\n\tctx.ResponseData.WriteHeader(404)\n\treturn nil\n}", "func NotFound(ctx context.Context, w http.ResponseWriter, message string) {\n\tfhirError(ctx, w, http.StatusNotFound, fhir.IssueSeverityWarning, fhir.IssueTypeNotFound, message)\n}", "func NewGetPresignedForClusterFilesNotFound() *GetPresignedForClusterFilesNotFound {\n\n\treturn &GetPresignedForClusterFilesNotFound{}\n}", "func NewGetNodeNotFound() *GetNodeNotFound {\n\treturn &GetNodeNotFound{}\n}", "func NewErrNotFound(e error) error {\n\tif e == nil {\n\t\te = errors.New(\"WARNING: nil error provided to `NewErrNotFound()`\")\n\t}\n\n\treturn errors.Wrap(ErrNotFound, e.Error())\n}", "func NewGetAssetsListNotFound() *GetAssetsListNotFound {\n\n\treturn &GetAssetsListNotFound{}\n}", "func NewObjectsListNotFound() *ObjectsListNotFound {\n\n\treturn &ObjectsListNotFound{}\n}", "func NewDeleteNotFound(body *DeleteNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewDeleteNotFound(body *DeleteNotFoundResponseBody) *goa.ServiceError {\n\tv := &goa.ServiceError{\n\t\tName: *body.Name,\n\t\tID: *body.ID,\n\t\tMessage: *body.Message,\n\t\tTemporary: *body.Temporary,\n\t\tTimeout: *body.Timeout,\n\t\tFault: *body.Fault,\n\t}\n\n\treturn v\n}", "func NewAddItemNotFound() *AddItemNotFound {\n\n\treturn &AddItemNotFound{}\n}", "func NewGetAllStorageNotFound() *GetAllStorageNotFound {\n\n\treturn &GetAllStorageNotFound{}\n}", "func NotFoundErr(w http.ResponseWriter, desc string) {\n\tsetError(w, desc, http.StatusNotFound)\n}" ]
[ "0.59044456", "0.57735026", "0.5671174", "0.5652109", "0.551046", "0.5478157", "0.54348093", "0.5429371", "0.54193217", "0.5406982", "0.5349323", "0.5341761", "0.5314563", "0.53118944", "0.5307573", "0.5300036", "0.5300036", "0.5294548", "0.52603376", "0.5257353", "0.52521986", "0.52499026", "0.5239719", "0.523886", "0.52300847", "0.5225403", "0.5213651", "0.5189838", "0.5188253", "0.51728517", "0.5138296", "0.51355815", "0.5123147", "0.51115453", "0.5092526", "0.5088274", "0.5073125", "0.5072821", "0.50615823", "0.5049779", "0.50460327", "0.5036647", "0.50255597", "0.50255054", "0.50227934", "0.5014432", "0.5000827", "0.49890316", "0.4983697", "0.49774894", "0.49765158", "0.4975852", "0.49715003", "0.49715003", "0.4966921", "0.4966921", "0.4964829", "0.49576855", "0.49531358", "0.49510923", "0.49508056", "0.49496922", "0.49461812", "0.49457362", "0.49276945", "0.49176294", "0.49070933", "0.48980337", "0.4886541", "0.48820078", "0.48707077", "0.48639676", "0.48635748", "0.48635748", "0.48574474", "0.48554763", "0.48464635", "0.48453254", "0.48441714", "0.48300216", "0.48294902", "0.48141164", "0.48084405", "0.48066282", "0.48009554", "0.47995973", "0.47927335", "0.47812995", "0.47767097", "0.47761023", "0.47734377", "0.4772867", "0.47700757", "0.47694868", "0.47592005", "0.4754676", "0.4754676", "0.4741995", "0.47359985", "0.47305903" ]
0.6899325
0
WithPayload adds the payload to the artifact lister not found response
func (o *ArtifactListerNotFound) WithPayload(payload *weles.ErrResponse) *ArtifactListerNotFound { o.Payload = payload return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerInternalServerError) WithPayload(payload *weles.ErrResponse) *ArtifactListerInternalServerError {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerBadRequest) WithPayload(payload *weles.ErrResponse) *ArtifactListerBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerOK) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerOK {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationNotFound) SetPayload(payload *models.MissingResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *CreatePackageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordNotFound) SetPayload(payload *models.NotFoundError) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordNotFound) WithPayload(payload *models.NotFoundError) *UpdateRecordNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *GetProjectProjectNameServiceServiceNameResourceNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetLinkInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetSectionNotFound) SetPayload(payload *models.NotFound) {\n\to.Payload = payload\n}", "func (o *GetModelNotFound) SetPayload(payload *restmodels.Error) {\n\to.Payload = payload\n}", "func (o *GetResetPasswordRequestEmailNotFound) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesNotFound) WithPayload(payload *models.Error) *ShowPackageReleasesNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetNamespacedNotebooksNotFound) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *AddOrgMembersV1NotFound) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *ArtifactListerPartialContent) WithPayload(payload []*weles.ArtifactInfo) *ArtifactListerPartialContent {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetDocumentNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostRegisterDetailsNotFound) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetInteractionsNotFound) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetBackupLocationsNotFound) SetPayload(payload *modelapi.Error) {\n\to.Payload = payload\n}", "func (o *GetRefreshTokenNotFound) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *AddNamespaceToGroupNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAllGroupsNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAllStorageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetIndexSearchNotFound) SetPayload(payload *GetIndexSearchNotFoundBody) {\n\to.Payload = payload\n}", "func (o *V2ListOperatorPropertiesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetServicesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetFleetsFleetIDMembersNotFound) SetPayload(payload *models.GetFleetsFleetIDMembersNotFoundBody) {\n\to.Payload = payload\n}", "func (o *GetUserNotFound) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetPaymentNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetClusterNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetServiceInstanceByNameNotFound) SetPayload(payload *v1.Error) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(404)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *DeletePostbyIDNotFound) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetMoveCounselingEvaluationReportsListNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetEventsEventIDNotFound) SetPayload(payload *GetEventsEventIDNotFoundBody) {\n\to.Payload = payload\n}", "func (o *CreatePackageNotFound) WithPayload(payload *models.Error) *CreatePackageNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetDistrictForSchoolNotFound) SetPayload(payload *models.NotFound) {\n\to.Payload = payload\n}", "func (o *PostInteractionNotFound) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetIBAServerNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddConsumptionNotFound) WithPayload(payload *models.ErrorResponse) *AddConsumptionNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *UpdateHostIgnitionNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteGroupByIDNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetBackendsBackendIDTestNotFound) SetPayload(payload *GetBackendsBackendIDTestNotFoundBody) {\n\to.Payload = payload\n}", "func (o *GetImagesListDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateMovieNotFound) SetPayload(payload *models.Result) {\n\to.Payload = payload\n}", "func (o *DeleteUserNotFound) SetPayload(payload *models.MissingResponse) {\n\to.Payload = payload\n}", "func (o *GetV1PullmetricsNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ReadProjectNotFound) SetPayload(payload *models.Project) {\n\to.Payload = payload\n}", "func (o *PostRegisterDetailsNotFound) WithPayload(payload *models.GeneralResponse) *PostRegisterDetailsNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ClientPermissionCreateNotFound) SetPayload(payload *ClientPermissionCreateNotFoundBody) {\n\to.Payload = payload\n}", "func (o *V2GetIgnoredValidationsNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetBackendNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksOK) SetPayload(payload *models.GetNotebooksResponse) {\r\n\to.Payload = payload\r\n}", "func (o *PostBackendsBackendIDGroupsNotFound) SetPayload(payload *PostBackendsBackendIDGroupsNotFoundBody) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *SemverGenerateNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetUserNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) WithPayload(payload *models.ErrorResponse) *PostFriendsUpdatesListNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetBackupRuntimeEnvironmentsNotFound) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *AddVappNotFound) SetPayload(payload *AddVappNotFoundBody) {\n\to.Payload = payload\n}", "func (o *ReplicateNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *CreateEvaluationReportNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *DeleteOrgNotFound) SetPayload(payload *DeleteOrgNotFoundBody) {\n\to.Payload = payload\n}", "func (o *GetAllStorageNotFound) WithPayload(payload *models.Error) *GetAllStorageNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetRepositoryInfoOK) SetPayload(payload *models.RepositoryInfo) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDNotFound) WithPayload(payload *models.Response) *DeletePostbyIDNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetClusterServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetSearchDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionNotFound) WithPayload(payload *models.Error) *UpdateHostIgnitionNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetTaskSyncNotFound) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *RegisterInfraEnvNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) WithPayload(payload *models.ErrorModel) *UpdateOfferingByIDNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *AddConsumptionNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ServiceAddServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetResetPasswordRequestEmailNotFound) WithPayload(payload *models.GeneralResponse) *GetResetPasswordRequestEmailNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *UpdateMovieNotFound) WithPayload(payload *models.Result) *UpdateMovieNotFound {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetServicesHaproxyRuntimeAclsIDNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksUnauthorized) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *GetGistsOK) SetPayload(payload models.Gists) {\n\to.Payload = payload\n}", "func (o *RecalculatePaymentRequestNotFound) SetPayload(payload *supportmessages.ClientError) {\n\to.Payload = payload\n}", "func (o *DeleteStorageByIDNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}" ]
[ "0.71166545", "0.6728402", "0.66189927", "0.64214116", "0.6334641", "0.62707865", "0.61188954", "0.6086991", "0.6048841", "0.60328", "0.6022252", "0.59993637", "0.59868425", "0.59859324", "0.59848446", "0.5979178", "0.59789467", "0.597695", "0.5948902", "0.5940029", "0.5900096", "0.58845234", "0.58420575", "0.58393824", "0.58210003", "0.58191365", "0.5819097", "0.5812214", "0.58122116", "0.58070576", "0.5758172", "0.5758096", "0.5749883", "0.57489264", "0.57487893", "0.5736412", "0.5728585", "0.57274145", "0.5726082", "0.5723036", "0.5714156", "0.5655576", "0.56522536", "0.56515294", "0.5636284", "0.56082034", "0.5597965", "0.5596754", "0.5585918", "0.5585254", "0.5581429", "0.5580496", "0.55773705", "0.55758476", "0.55740166", "0.5569156", "0.5557993", "0.55425805", "0.5515197", "0.55123305", "0.55114615", "0.5499123", "0.54966664", "0.5492723", "0.54865676", "0.5485094", "0.5468266", "0.5467411", "0.5467295", "0.5466248", "0.54542243", "0.5448034", "0.54340523", "0.543268", "0.54295796", "0.5422327", "0.5421007", "0.54166263", "0.5411824", "0.54083836", "0.54025596", "0.539581", "0.53881574", "0.5376925", "0.5367137", "0.53659165", "0.53591955", "0.53587914", "0.5353235", "0.5352976", "0.53525865", "0.53508765", "0.53462607", "0.5344271", "0.5338206", "0.533095", "0.53239334", "0.53097695", "0.5304424", "0.52966744" ]
0.7106535
1
SetPayload sets the payload to the artifact lister not found response
func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) { o.Payload = payload }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *CreatePackageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordNotFound) SetPayload(payload *models.NotFoundError) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationNotFound) SetPayload(payload *models.MissingResponse) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksNotFound) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *GetClusterInstallConfigNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetResetPasswordRequestEmailNotFound) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetInteractionsNotFound) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetProjectProjectNameServiceServiceNameResourceNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsNotFound) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *GetLinkInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostRegisterDetailsNotFound) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *GetIBAServerNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1NotFound) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *AddNamespaceToGroupNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetMoveCounselingEvaluationReportsListNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetModelNotFound) SetPayload(payload *restmodels.Error) {\n\to.Payload = payload\n}", "func (o *GetBackupLocationsNotFound) SetPayload(payload *modelapi.Error) {\n\to.Payload = payload\n}", "func (o *GetAllStorageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRefreshTokenNotFound) SetPayload(payload *models.GeneralResponse) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetSectionNotFound) SetPayload(payload *models.NotFound) {\n\to.Payload = payload\n}", "func (o *GetPaymentNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationNotFound) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *UpdateMovieNotFound) SetPayload(payload *models.Result) {\n\to.Payload = payload\n}", "func (o *PostInteractionNotFound) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeletePostbyIDNotFound) SetPayload(payload *models.Response) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksUnauthorized) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *ArtifactListerPartialContent) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *GetBackendNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetServicesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAllGroupsNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *SemverGenerateNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetTaskSyncNotFound) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *V2ListOperatorPropertiesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetDocumentNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetServicesHaproxyRuntimeAclsIDNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *RegisterInfraEnvNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetV1PullmetricsNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetUserNotFound) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetServiceInstanceByNameNotFound) SetPayload(payload *v1.Error) {\n\to.Payload = payload\n}", "func (o *GetImagesListDefault) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddConsumptionNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeregisterInfraEnvNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreateEvaluationReportNotFound) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigMethodNotAllowed) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteGroupByIDNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *RequestBackupUploadNotFound) SetPayload(payload *modelapi.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ReplaceHTTPErrorRuleNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetQuestionFromTeamForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *V2PostStepReplyNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *RetrieveCopyNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddKeypairInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ReplicateNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetDistrictForSchoolNotFound) SetPayload(payload *models.NotFound) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigForbidden) SetPayload(payload *models.InfraError) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddReleasesUnauthorized) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetBackendsBackendIDTestNotFound) SetPayload(payload *GetBackendsBackendIDTestNotFoundBody) {\n\to.Payload = payload\n}", "func (o *GetProviderRegionByIDInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoOK) SetPayload(payload *models.RepositoryInfo) {\n\to.Payload = payload\n}", "func (o *UpdateClusterInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *ServiceAddServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesConflict) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetFleetsFleetIDMembersNotFound) SetPayload(payload *models.GetFleetsFleetIDMembersNotFoundBody) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetIdentityIDUnreachable) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *AddKeypairConflict) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeleteStorageByIDNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetCorrectedAnswersFromPublishedTestsForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}" ]
[ "0.7733741", "0.74927545", "0.73879963", "0.73810774", "0.729546", "0.72907823", "0.72536606", "0.7219174", "0.71641356", "0.7158319", "0.71465546", "0.7140486", "0.71336025", "0.7127423", "0.7115021", "0.70977026", "0.7092067", "0.7070966", "0.706679", "0.7057871", "0.7033657", "0.7010871", "0.6987578", "0.69828194", "0.6977859", "0.69754434", "0.6971481", "0.6970885", "0.6970243", "0.69679326", "0.695277", "0.69508314", "0.69499844", "0.69455373", "0.69410545", "0.6940671", "0.69387704", "0.6936052", "0.6916818", "0.6913344", "0.68943626", "0.68889654", "0.6877116", "0.6870123", "0.68675846", "0.68632394", "0.68514276", "0.685135", "0.6836275", "0.68283314", "0.68205", "0.68178165", "0.680323", "0.67980176", "0.67929053", "0.6789968", "0.6781432", "0.678103", "0.6779405", "0.6773432", "0.67688644", "0.6764456", "0.67594033", "0.6758641", "0.67485374", "0.67382777", "0.6731975", "0.6731297", "0.6728667", "0.6717765", "0.6711485", "0.6703705", "0.6702122", "0.66965795", "0.6695969", "0.6691136", "0.6689214", "0.668723", "0.6686938", "0.6685921", "0.66857666", "0.66823363", "0.66794056", "0.6677385", "0.66766465", "0.66765815", "0.66752064", "0.667412", "0.6674026", "0.6672182", "0.6671005", "0.66704667", "0.66702086", "0.6661237", "0.66533554", "0.6650479", "0.66501397", "0.6647498", "0.66470546", "0.66361123" ]
0.8157627
0
WriteResponse to the client
func (o *ArtifactListerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { rw.WriteHeader(404) if o.Payload != nil { payload := o.Payload if err := producer.Produce(rw, payload); err != nil { panic(err) // let the recovery middleware deal with this } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Response) Write(w io.Writer) error", "func (c *Operation) writeResponse(rw http.ResponseWriter, status int, data []byte) { // nolint: unparam\n\trw.WriteHeader(status)\n\n\tif _, err := rw.Write(data); err != nil {\n\t\tlogger.Errorf(\"Unable to send error message, %s\", err)\n\t}\n}", "func WriteResponse(w http.ResponseWriter, mensaje string, code int) {\n\tmessage := myTypes.Respuesta{\n\t\tMessage: mensaje,\n\t}\n\tresponse, _ := json.Marshal(message)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(response)\n}", "func WriteResponse(w http.ResponseWriter, object interface{}, rerr *irma.RemoteError) {\n\tstatus, bts := JsonResponse(object, rerr)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\t_, err := w.Write(bts)\n\tif err != nil {\n\t\tLogWarning(errors.WrapPrefix(err, \"failed to write response\", 0))\n\t}\n}", "func (o *PingOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, v interface{}, statusCode int) {\n\tresBody, err := json.Marshal(v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\t_, _ = w.Write(resBody)\n}", "func WriteResponse(w http.ResponseWriter, code int, object interface{}) {\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func (o *GetPingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(body []byte, w *http.ResponseWriter) {\n\t(*w).Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t_, err := (*w).Write(body)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\t(*w).WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func WriteResponse(w http.ResponseWriter, code int, resp interface{}) error {\n\tj, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\n\t_, err = w.Write(j)\n\treturn err\n}", "func writeResponse(w *http.ResponseWriter, res responseData, status int) {\n\tresJSON, err := json.Marshal(res)\n\tif err != nil {\n\t\thttp.Error(*w, \"Failed to parse struct `responseData` into JSON object\", http.StatusInternalServerError)\n\t}\n\n\t(*w).Header().Set(\"Content-Type\", \"application/json\")\n\t(*w).WriteHeader(status)\n\t(*w).Write(resJSON)\n}", "func WriteResponse(w http.ResponseWriter, d string) {\n\tw.WriteHeader(200)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.Write([]byte(d))\n\treturn\n}", "func (o *CreateFacilityUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(w http.ResponseWriter, response Response) {\n\tjson, err := json.Marshal(&response)\n\n\tif err != nil {\n\t\tfmt.Fprint(w, \"There was an error processing the request.\")\n\t}\n\n\tcommon.Log(fmt.Sprintf(\"Returning response %s\", json))\n\tfmt.Fprintf(w, \"%s\", json)\n}", "func (o *CreateProgramOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DepositNewFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMedicineOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *CreateTaskCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Location\n\n\tlocation := o.Location.String()\n\tif location != \"\" {\n\t\trw.Header().Set(\"Location\", location)\n\t}\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(r *http.Request, w http.ResponseWriter, code int, resp interface{}) {\n\n\t// Deal with CORS\n\tif origin := r.Header.Get(\"Origin\"); origin != \"\" {\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", origin)\n\t\tw.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE, GET, HEAD, OPTIONS, POST, PUT\")\n\t\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\t\t// Allow any headers\n\t\tif wantedHeaders := r.Header.Get(\"Access-Control-Request-Headers\"); wantedHeaders != \"\" {\n\t\t\tw.Header().Set(\"Access-Control-Allow-Headers\", wantedHeaders)\n\t\t}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\n\tb, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintln(w, `{\"error\":\"failed to marshal json\"}`)\n\t\treturn\n\t}\n\n\tw.WriteHeader(code)\n\tfmt.Fprintln(w, string(b))\n}", "func (o *VerifyAccountCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(w http.ResponseWriter, h int, p interface{}) {\n\t// I set the content type...\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t// ... I write the specified status code...\n\tw.WriteHeader(h)\n\t// ... and I write the response\n\tb, _ := json.Marshal(p)\n\tw.Write(b)\n}", "func (o *UpdateCatalogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (c *SwitchVersion) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postSwitchVersion(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *PutRecordingsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *BofaChkUpdateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *VerifyHealthCredentialOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, code int, err error, data interface{}, t0 time.Time) {\n\tw.WriteHeader(code)\n\tresp := &Response{Data: data, Dur: fmt.Sprint(time.Since(t0)), OK: false}\n\tif code < 300 {\n\t\tresp.OK = true\n\t}\n\tif err != nil {\n\t\tresp.Err = err.Error()\n\t}\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Infof(\"failed to json encode response: %v\", err)\n\t\tif _, err = w.Write([]byte(spew.Sdump(resp))); err != nil {\n\t\t\tlog.Infof(\"failed to write dump of response: %v\", err)\n\t\t}\n\t}\n}", "func (o *NewDiscoveryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(data []byte, size int64, ctype string, w http.ResponseWriter) {\n\tw.Header().Set(\"Content-Type\", ctype)\n\tw.Header().Set(\"Content-Length\", fmt.Sprintf(\"%d\", size))\n\tw.Header().Set(\"Cache-Control\", \"no-transform,public,max-age=86400,s-maxage=2592000\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, code int, object interface{}) {\n\tfmt.Println(\"writing response:\", code, object)\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, authZRes *authorization.Response) {\n\n\tdata, err := json.Marshal(authZRes)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to marshel authz response %q\", err.Error())\n\t} else {\n\t\tw.Write(data)\n\t}\n\n\tif authZRes == nil || authZRes.Err != \"\" {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t}\n}", "func (o *GetCharactersCharacterIDOpportunitiesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetCharactersCharacterIDOpportunitiesOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *WeaviateThingsGetNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *UpdateLinkInPostOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetChatroomsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetEchoNameOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetUIContentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *ListVsphereResourceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func ResponseWrite(w http.ResponseWriter, responseCode int, responseData interface{}) {\n\t// Write Response\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(responseCode)\n\n\t// Write JSON to Response\n\tjson.NewEncoder(w).Encode(responseData)\n}", "func writeHTTPResponseInWriter(httpRes http.ResponseWriter, httpReq *http.Request, nobelPrizeWinnersResponse []byte, err error) {\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(httpRes, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tlog.Printf(\"Request %s Succesfully Completed\", httpReq.RequestURI)\n\thttpRes.Header().Set(\"Content-Type\", \"application/json\")\n\thttpRes.Write(nobelPrizeWinnersResponse)\n}", "func (o *PostKeysKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlog.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func writeResponse(data interface{}, w http.ResponseWriter) error {\n\tvar (\n\t\tenc []byte\n\t\terr error\n\t)\n\tenc, err = json.Marshal(data)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to marshal, err = %s\", err)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tn, err := w.Write(enc)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to write, err = %s\", err)\n\t}\n\tif n != len(enc) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Short write sent = %d, wrote = %d\", len(enc), n)\n\t}\n\treturn nil\n}", "func (o *CreateUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func WriteResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PutQuestionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (r *response) Write(b []byte) (n int, err error) {\n\tif !r.headersSend {\n\t\tif r.status == 0 {\n\t\t\tr.status = http.StatusOK\n\t\t}\n\t\tr.WriteHeader(r.status)\n\t}\n\tn, err = r.ResponseWriter.Write(b)\n\tr.size += int64(n)\n\treturn\n}", "func (o *PostOperationsDeleteP2PPathCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *HealthGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsPatchNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (o *VerifyEmailTokenOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DeleteServiceIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\t// as of now, just log errors for writing response\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PostOperationsGetNodeEdgePointDetailsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *UserEditOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviatePeersAnnounceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *CertifyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(writer http.ResponseWriter, response *http.Response) (int64, error) {\n\tdefer response.Body.Close()\n\twriteResponseHeaders(writer, response, false)\n\treturn io.Copy(writer, response.Body)\n}", "func (o *PutMeetupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *FingerPathsPostCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *PostPlaybookOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateHostIgnitionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *GetCharactersCharacterIDLocationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostManagementKubernetesIoV1NodesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *PutPerformancesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *StopAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(202)\n}", "func (o *GetFleetsFleetIDMembersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Content-Language\n\n\tcontentLanguage := o.ContentLanguage\n\tif contentLanguage != \"\" {\n\t\trw.Header().Set(\"Content-Language\", contentLanguage)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetFleetsFleetIDMembersOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *GetMeetupsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostEventCreated) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(201)\n}", "func (o *GetTaskTaskIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateTCPCheckAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Reload-ID\n\n\treloadID := o.ReloadID\n\tif reloadID != \"\" {\n\t\trw.Header().Set(\"Reload-ID\", reloadID)\n\t}\n\n\trw.WriteHeader(202)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *PostOperationsGetNetworkElementListCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ServiceInstanceLastOperationGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header RetryAfter\n\n\tretryAfter := o.RetryAfter\n\tif retryAfter != \"\" {\n\t\trw.Header().Set(\"RetryAfter\", retryAfter)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPiecesIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetTaskDetailsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *UpdateClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetDetailOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\trw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetServicesHaproxyRuntimeAclsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (r *responseInfoRecorder) Write(b []byte) (int, error) {\n\tr.ContentLength += int64(len(b))\n\tif r.statusCode == 0 {\n\t\tr.statusCode = http.StatusOK\n\t}\n\treturn r.ResponseWriter.Write(b)\n}", "func (o *LogoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UploadFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, data interface{}) error {\n\tenv := map[string]interface{}{\n\t\t\"meta\": map[string]interface{}{\n\t\t\t\"code\": http.StatusOK,\n\t\t},\n\t\t\"data\": data,\n\t}\n\treturn jsonResponse(w, env)\n}", "func (o *WeaviateThingTemplatesCreateNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (r *Responder) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\tfor k, v := range r.headers {\n\t\tfor _, val := range v {\n\t\t\trw.Header().Add(k, val)\n\t\t}\n\t}\n\n\trw.WriteHeader(r.code)\n\n\tif r.response != nil {\n\t\tif err := producer.Produce(rw, r.response); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "func (o *GetGateSourceByGateNameAndMntOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateSpoeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tpayload := o.Payload\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *Output) writeResponse(response string) error {\r\n\t// write the response\r\n\tif _, err := o.writer.WriteString(response + \"\\n\"); err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (o *GetTransportByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *TransferOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateUserCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ViewOneOrderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetVisiblePruebasFromQuestionTestInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(500)\n}", "func (o *GetWhaleTranfersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.OperationsRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *SearchTournamentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*models.Tournament, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateTCPCheckCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (s *Server) writeInfoResponse(\n\tw http.ResponseWriter,\n\tr *http.Request,\n\tmessage []byte,\n\tstatus int,\n\theaders map[string]string,\n) {\n\tfor k, v := range headers {\n\t\tw.Header().Add(k, v)\n\t}\n\n\tw.WriteHeader(status)\n\tw.Write(message)\n}" ]
[ "0.81303823", "0.7882039", "0.77722245", "0.7771901", "0.7753117", "0.7740585", "0.76670325", "0.7638451", "0.76095873", "0.75798", "0.7579178", "0.7567389", "0.7560546", "0.75579476", "0.75447774", "0.7542929", "0.75416607", "0.753386", "0.7531158", "0.75192654", "0.75191355", "0.7513389", "0.7512029", "0.75050455", "0.7503395", "0.74984574", "0.74875605", "0.74839836", "0.74772394", "0.7467842", "0.746699", "0.7465759", "0.7464175", "0.746404", "0.746404", "0.7461224", "0.7460309", "0.74595356", "0.74463046", "0.7443478", "0.7435917", "0.7426582", "0.7425581", "0.74186546", "0.7413175", "0.7407469", "0.74063516", "0.74048966", "0.7398737", "0.7389631", "0.738607", "0.73806983", "0.7360552", "0.7360491", "0.7355327", "0.7354953", "0.73532444", "0.7347445", "0.734586", "0.732798", "0.732577", "0.73178244", "0.7316643", "0.7316071", "0.7315527", "0.7312546", "0.73114824", "0.7310336", "0.7309039", "0.73007035", "0.7297214", "0.7291373", "0.7291277", "0.72884554", "0.72845477", "0.72835207", "0.7281928", "0.7281033", "0.72751075", "0.7274423", "0.7273193", "0.72730565", "0.72695094", "0.7269139", "0.72690886", "0.7265927", "0.72615093", "0.72529227", "0.7251764", "0.72490144", "0.72479355", "0.72469014", "0.72407585", "0.72390425", "0.72367245", "0.7234706", "0.722777", "0.722197", "0.7215153", "0.72140837", "0.7213089" ]
0.0
-1
WithPayload adds the payload to the artifact lister internal server error response
func (o *ArtifactListerInternalServerError) WithPayload(payload *weles.ErrResponse) *ArtifactListerInternalServerError { o.Payload = payload return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerBadRequest) WithPayload(payload *weles.ErrResponse) *ArtifactListerBadRequest {\n\to.Payload = payload\n\treturn o\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTagInternalServerError) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *GraphqlPostInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetApisInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceAddServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAppsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetV1RdssInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetIBAServerNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *CreateHPCResourceInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDInternalServerError) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetLinkInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDInternalServerError) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1InternalServerError) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *AddReleasesBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetActivationsInternalServerError) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *SemverGenerateInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPaymentRequestEDIInternalServerError) SetPayload(payload *supportmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetProjectProjectNameServiceServiceNameResourceNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordNotFound) SetPayload(payload *models.NotFoundError) {\n\to.Payload = payload\n}", "func (o *RegisterInfraEnvInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddKeypairInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetIBAServerBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *PostBackendsOauth2InternalServerError) SetPayload(payload *PostBackendsOauth2InternalServerErrorBody) {\n\to.Payload = payload\n}", "func (o *AddConsumptionInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDInternalServerError) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ReadProjectInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAllGroupsNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetIdentityIDInvalidStorageFormat) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *AddNamespaceToGroupNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetPreconditionFailed) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTagBadRequest) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) WithPayload(payload *models.APIResponse) *AddReleasesInternalServerError {\n\to.Payload = payload\n\treturn o\n}", "func (o *GetClusterInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeregisterInfraEnvInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddItemInternalServerError) SetPayload(payload string) {\n\to.Payload = payload\n}", "func (o *ObjectsListUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GraphqlPostUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetMoveCounselingEvaluationReportsListInternalServerError) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *ShowPackageReleasesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAllStorageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationForbidden) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetV1PullmetricsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetLinkInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceAddBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostForbidden) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddItemDefault) SetPayload(payload models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddConsumptionNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeleteServiceIDFailure) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *GetStateAddressServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigForbidden) SetPayload(payload *models.InfraError) {\n\to.Payload = payload\n}", "func (o *GetInteractionsInternalServerError) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *CreateMailersSectionBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetStateAddressInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionForbidden) SetPayload(payload *models.InfraError) {\n\to.Payload = payload\n}", "func (o *GetTaskTaskIDBadRequest) SetPayload(payload *models.ResponseError) {\n\to.Payload = payload\n}", "func (o *GetModelNotFound) SetPayload(payload *restmodels.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsPatchInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}" ]
[ "0.7157846", "0.6921978", "0.6862238", "0.6658315", "0.62427086", "0.61828434", "0.61777896", "0.6167557", "0.61196446", "0.609198", "0.60899943", "0.60818005", "0.6081588", "0.6076011", "0.60722697", "0.6067129", "0.60604006", "0.6055573", "0.60487366", "0.60356337", "0.6033873", "0.6032934", "0.603137", "0.6020795", "0.60065573", "0.5996992", "0.59880316", "0.59817934", "0.5980514", "0.5977736", "0.5977018", "0.59739995", "0.59709513", "0.5969849", "0.5967997", "0.59633946", "0.5946796", "0.5946308", "0.5937931", "0.59357303", "0.59324324", "0.59277153", "0.59272885", "0.5926817", "0.59236574", "0.59231216", "0.5922394", "0.59222066", "0.591757", "0.59123904", "0.5910551", "0.5906478", "0.5904788", "0.59002215", "0.58980477", "0.58946145", "0.58915156", "0.5882438", "0.58770555", "0.58738565", "0.5867521", "0.58655936", "0.58654803", "0.58635217", "0.58574677", "0.58532447", "0.58511233", "0.5851084", "0.5845575", "0.5845244", "0.5844013", "0.58384794", "0.5838192", "0.5837664", "0.583676", "0.5836054", "0.58343285", "0.583307", "0.5832605", "0.58298075", "0.5820593", "0.58200645", "0.5819326", "0.5818355", "0.5813666", "0.580657", "0.5802423", "0.58009684", "0.58007973", "0.5799898", "0.57982403", "0.57973844", "0.5796913", "0.5794829", "0.5784664", "0.57785434", "0.57780576", "0.5774627", "0.5773349", "0.5773331" ]
0.72021204
0
SetPayload sets the payload to the artifact lister internal server error response
func (o *ArtifactListerInternalServerError) SetPayload(payload *weles.ErrResponse) { o.Payload = payload }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *ArtifactListerBadRequest) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *ArtifactListerNotFound) SetPayload(payload *weles.ErrResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetV1RdssInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetmoviesinfoInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *FetchTodoItemsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetApisInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTagInternalServerError) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *GetIBAServerNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GraphqlPostInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereDatastoresUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetPreconditionFailed) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *RegisterInfraEnvInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetVSphereComputeResourcesUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetInteractionsInternalServerError) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *SemverGenerateInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddNewMaterialsForPostBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ArtifactListerOK) SetPayload(payload []*weles.ArtifactInfo) {\n\to.Payload = payload\n}", "func (o *ServiceAddServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreateHPCResourceInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetPaymentRequestEDIInternalServerError) SetPayload(payload *supportmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetIBAServerBadRequest) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDInternalServerError) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetActivationsInternalServerError) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *RegisterInfraEnvNotImplemented) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsUnauthorized) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeregisterInfraEnvInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetIBAServerUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateHostIgnitionNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostInteractionInternalServerError) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *GetClusterInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetIdentityIDInvalidStorageFormat) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *RetrieveCopyInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreateUploadSessionPreconditionFailed) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageUnprocessableEntity) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListNotFound) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetNamespacedNotebooksUnauthorized) SetPayload(payload *models.Error) {\r\n\to.Payload = payload\r\n}", "func (o *GraphqlPostUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *UpdateClusterInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *AddKeypairInternalServerError) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *DeregisterInfraEnvNotImplemented) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDNotFound) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAppsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *AddConsumptionInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *ReadProjectInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *ObjectsListUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddOrgMembersV1InternalServerError) SetPayload(payload *model.StandardError) {\n\to.Payload = payload\n}", "func (o *RequestBackupUploadInternalServerError) SetPayload(payload *modelapi.Error) {\n\to.Payload = payload\n}", "func (o *GetMoveCounselingEvaluationReportsListInternalServerError) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeregisterInfraEnvNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreatePackageNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateActionInternalServerError) SetPayload(payload *models.ErrorMessage) {\n\to.Payload = payload\n}", "func (o *ServiceInstanceLastOperationGetBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTaskTaskIDBadRequest) SetPayload(payload *models.ResponseError) {\n\to.Payload = payload\n}", "func (o *PostFriendsUpdatesListUnauthorized) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *GetBackendNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateRecordNotFound) SetPayload(payload *models.NotFoundError) {\n\to.Payload = payload\n}", "func (o *GetTweetsInternalServerError) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *CreateBackendSwitchingRuleBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteServiceIDFailure) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *DeleteOrganizationInternalServerError) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *AddReleasesBadRequest) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetV1PullmetricsInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetPresignedForClusterFilesNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *TestEndpointInternalServerError) SetPayload(payload interface{}) {\n\to.Payload = payload\n}", "func (o *GetStateAddressInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *RecalculatePaymentRequestInternalServerError) SetPayload(payload *supportmessages.Error) {\n\to.Payload = payload\n}", "func (o *GetRepositoryInfoNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *V2PostStepReplyInternalServerError) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *UpdateClusterNotFound) SetPayload(payload *models.APIResponse) {\n\to.Payload = payload\n}", "func (o *GetStateAddressServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *CreateBackendSwitchingRuleConflict) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetTeamsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetReportViolationsByReportIDInternalServerError) SetPayload(payload *ghcmessages.Error) {\n\to.Payload = payload\n}", "func (o *UpdateOfferingByIDForbidden) SetPayload(payload *models.ErrorModel) {\n\to.Payload = payload\n}", "func (o *GetPrefilterFailure) SetPayload(payload models.Error) {\n\to.Payload = payload\n}", "func (o *WeaviateActionsPatchUnprocessableEntity) SetPayload(payload *models.ErrorResponse) {\n\to.Payload = payload\n}", "func (o *DeregisterInfraEnvConflict) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *RegisterInfraEnvNotFound) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetAviServiceEngineGroupsBadRequest) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetInteractionsBadRequest) SetPayload(payload *models.APIError) {\n\to.Payload = payload\n}", "func (o *V2PostStepReplyServiceUnavailable) SetPayload(payload *models.Error) {\n\to.Payload = payload\n}", "func (o *GetClusterInstallConfigForbidden) SetPayload(payload *models.InfraError) {\n\to.Payload = payload\n}", "func (o *GetBackupRuntimeEnvironmentsNotFound) SetPayload(payload string) {\n\to.Payload = payload\n}" ]
[ "0.7831036", "0.75439966", "0.736797", "0.730542", "0.7304041", "0.72276163", "0.7226452", "0.722291", "0.72117543", "0.72073513", "0.7200168", "0.7198472", "0.7189686", "0.7186961", "0.7180009", "0.71769434", "0.7167124", "0.71656305", "0.71651083", "0.7156538", "0.7151973", "0.7147612", "0.7129652", "0.71251464", "0.7119529", "0.7118962", "0.7111146", "0.7100074", "0.7099536", "0.70947564", "0.7092195", "0.70855826", "0.7081349", "0.7080401", "0.70785654", "0.70682824", "0.7061798", "0.70592177", "0.7058629", "0.7053274", "0.705313", "0.7052142", "0.70517504", "0.7043882", "0.704127", "0.7030991", "0.7030868", "0.70300794", "0.7024323", "0.70220065", "0.70219153", "0.70205826", "0.7020445", "0.70158917", "0.701502", "0.70148665", "0.700845", "0.7008375", "0.7008011", "0.700709", "0.7003887", "0.7001144", "0.7000909", "0.7000191", "0.6999925", "0.69968367", "0.6986414", "0.698467", "0.69840425", "0.6973099", "0.6970416", "0.6961846", "0.6960295", "0.6959527", "0.6958273", "0.69571805", "0.6956241", "0.6956", "0.6955906", "0.69549054", "0.69546944", "0.6953733", "0.6953626", "0.6948186", "0.6947433", "0.6943364", "0.6940258", "0.6933754", "0.6931688", "0.6931685", "0.69280756", "0.69277626", "0.69249535", "0.6924478", "0.69190526", "0.69189465", "0.6915685", "0.6915054", "0.6914799", "0.6913366" ]
0.81285137
0
WriteResponse to the client
func (o *ArtifactListerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { rw.WriteHeader(500) if o.Payload != nil { payload := o.Payload if err := producer.Produce(rw, payload); err != nil { panic(err) // let the recovery middleware deal with this } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Response) Write(w io.Writer) error", "func (c *Operation) writeResponse(rw http.ResponseWriter, status int, data []byte) { // nolint: unparam\n\trw.WriteHeader(status)\n\n\tif _, err := rw.Write(data); err != nil {\n\t\tlogger.Errorf(\"Unable to send error message, %s\", err)\n\t}\n}", "func WriteResponse(w http.ResponseWriter, mensaje string, code int) {\n\tmessage := myTypes.Respuesta{\n\t\tMessage: mensaje,\n\t}\n\tresponse, _ := json.Marshal(message)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(response)\n}", "func WriteResponse(w http.ResponseWriter, object interface{}, rerr *irma.RemoteError) {\n\tstatus, bts := JsonResponse(object, rerr)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\t_, err := w.Write(bts)\n\tif err != nil {\n\t\tLogWarning(errors.WrapPrefix(err, \"failed to write response\", 0))\n\t}\n}", "func (o *PingOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, v interface{}, statusCode int) {\n\tresBody, err := json.Marshal(v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(statusCode)\n\t_, _ = w.Write(resBody)\n}", "func WriteResponse(w http.ResponseWriter, code int, object interface{}) {\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func (o *GetPingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(body []byte, w *http.ResponseWriter) {\n\t(*w).Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t_, err := (*w).Write(body)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\t(*w).WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func WriteResponse(w http.ResponseWriter, code int, resp interface{}) error {\n\tj, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\n\t_, err = w.Write(j)\n\treturn err\n}", "func writeResponse(w *http.ResponseWriter, res responseData, status int) {\n\tresJSON, err := json.Marshal(res)\n\tif err != nil {\n\t\thttp.Error(*w, \"Failed to parse struct `responseData` into JSON object\", http.StatusInternalServerError)\n\t}\n\n\t(*w).Header().Set(\"Content-Type\", \"application/json\")\n\t(*w).WriteHeader(status)\n\t(*w).Write(resJSON)\n}", "func WriteResponse(w http.ResponseWriter, d string) {\n\tw.WriteHeader(200)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.Write([]byte(d))\n\treturn\n}", "func (o *CreateFacilityUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(w http.ResponseWriter, response Response) {\n\tjson, err := json.Marshal(&response)\n\n\tif err != nil {\n\t\tfmt.Fprint(w, \"There was an error processing the request.\")\n\t}\n\n\tcommon.Log(fmt.Sprintf(\"Returning response %s\", json))\n\tfmt.Fprintf(w, \"%s\", json)\n}", "func (o *CreateProgramOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DepositNewFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMedicineOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *CreateTaskCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Location\n\n\tlocation := o.Location.String()\n\tif location != \"\" {\n\t\trw.Header().Set(\"Location\", location)\n\t}\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(r *http.Request, w http.ResponseWriter, code int, resp interface{}) {\n\n\t// Deal with CORS\n\tif origin := r.Header.Get(\"Origin\"); origin != \"\" {\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", origin)\n\t\tw.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE, GET, HEAD, OPTIONS, POST, PUT\")\n\t\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\t\t// Allow any headers\n\t\tif wantedHeaders := r.Header.Get(\"Access-Control-Request-Headers\"); wantedHeaders != \"\" {\n\t\t\tw.Header().Set(\"Access-Control-Allow-Headers\", wantedHeaders)\n\t\t}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\n\tb, err := json.Marshal(resp)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintln(w, `{\"error\":\"failed to marshal json\"}`)\n\t\treturn\n\t}\n\n\tw.WriteHeader(code)\n\tfmt.Fprintln(w, string(b))\n}", "func (o *VerifyAccountCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func writeResponse(w http.ResponseWriter, h int, p interface{}) {\n\t// I set the content type...\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t// ... I write the specified status code...\n\tw.WriteHeader(h)\n\t// ... and I write the response\n\tb, _ := json.Marshal(p)\n\tw.Write(b)\n}", "func (o *UpdateCatalogOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (c *SwitchVersion) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postSwitchVersion(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *PutRecordingsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *BofaChkUpdateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *VerifyHealthCredentialOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, code int, err error, data interface{}, t0 time.Time) {\n\tw.WriteHeader(code)\n\tresp := &Response{Data: data, Dur: fmt.Sprint(time.Since(t0)), OK: false}\n\tif code < 300 {\n\t\tresp.OK = true\n\t}\n\tif err != nil {\n\t\tresp.Err = err.Error()\n\t}\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Infof(\"failed to json encode response: %v\", err)\n\t\tif _, err = w.Write([]byte(spew.Sdump(resp))); err != nil {\n\t\t\tlog.Infof(\"failed to write dump of response: %v\", err)\n\t\t}\n\t}\n}", "func (o *NewDiscoveryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func writeResponse(data []byte, size int64, ctype string, w http.ResponseWriter) {\n\tw.Header().Set(\"Content-Type\", ctype)\n\tw.Header().Set(\"Content-Length\", fmt.Sprintf(\"%d\", size))\n\tw.Header().Set(\"Cache-Control\", \"no-transform,public,max-age=86400,s-maxage=2592000\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, code int, object interface{}) {\n\tfmt.Println(\"writing response:\", code, object)\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func writeResponse(w http.ResponseWriter, authZRes *authorization.Response) {\n\n\tdata, err := json.Marshal(authZRes)\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to marshel authz response %q\", err.Error())\n\t} else {\n\t\tw.Write(data)\n\t}\n\n\tif authZRes == nil || authZRes.Err != \"\" {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t}\n}", "func (o *GetCharactersCharacterIDOpportunitiesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetCharactersCharacterIDOpportunitiesOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *WeaviateThingsGetNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (c *UpdateSwitch) WriteResponse(rw http.ResponseWriter, rp runtime.Producer) {\n\tswitch c.Request.Method {\n\tcase http.MethodPost:\n\t\tc.postUpdateSwitch(rw, rp)\n\tdefault:\n\t\tc.notSupported(rw, rp)\n\t}\n}", "func (o *UpdateLinkInPostOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetChatroomsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetEchoNameOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetUIContentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *ListVsphereResourceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func ResponseWrite(w http.ResponseWriter, responseCode int, responseData interface{}) {\n\t// Write Response\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(responseCode)\n\n\t// Write JSON to Response\n\tjson.NewEncoder(w).Encode(responseData)\n}", "func writeHTTPResponseInWriter(httpRes http.ResponseWriter, httpReq *http.Request, nobelPrizeWinnersResponse []byte, err error) {\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(httpRes, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tlog.Printf(\"Request %s Succesfully Completed\", httpReq.RequestURI)\n\thttpRes.Header().Set(\"Content-Type\", \"application/json\")\n\thttpRes.Write(nobelPrizeWinnersResponse)\n}", "func (o *PostKeysKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlog.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func writeResponse(data interface{}, w http.ResponseWriter) error {\n\tvar (\n\t\tenc []byte\n\t\terr error\n\t)\n\tenc, err = json.Marshal(data)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to marshal, err = %s\", err)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tn, err := w.Write(enc)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to write, err = %s\", err)\n\t}\n\tif n != len(enc) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Short write sent = %d, wrote = %d\", len(enc), n)\n\t}\n\treturn nil\n}", "func (o *CreateUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateMoveTaskOrderPostCounselingInformationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func WriteResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PutQuestionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (r *response) Write(b []byte) (n int, err error) {\n\tif !r.headersSend {\n\t\tif r.status == 0 {\n\t\t\tr.status = http.StatusOK\n\t\t}\n\t\tr.WriteHeader(r.status)\n\t}\n\tn, err = r.ResponseWriter.Write(b)\n\tr.size += int64(n)\n\treturn\n}", "func (o *PostOperationsDeleteP2PPathCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *HealthGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsPatchNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (o *VerifyEmailTokenOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *DeleteServiceIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviateThingsGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\t// as of now, just log errors for writing response\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "func (o *PostOperationsGetNodeEdgePointDetailsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *UserEditOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *WeaviatePeersAnnounceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "func (o *CertifyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func writeResponse(writer http.ResponseWriter, response *http.Response) (int64, error) {\n\tdefer response.Body.Close()\n\twriteResponseHeaders(writer, response, false)\n\treturn io.Copy(writer, response.Body)\n}", "func (o *PutMeetupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *FingerPathsPostCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *PostPlaybookOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UpdateHostIgnitionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *GetCharactersCharacterIDLocationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostManagementKubernetesIoV1NodesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *PutPerformancesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *StopAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(202)\n}", "func (o *GetFleetsFleetIDMembersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Content-Language\n\n\tcontentLanguage := o.ContentLanguage\n\tif contentLanguage != \"\" {\n\t\trw.Header().Set(\"Content-Language\", contentLanguage)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetFleetsFleetIDMembersOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *GetMeetupsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "func (o *PostEventCreated) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(201)\n}", "func (o *GetTaskTaskIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateTCPCheckAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Reload-ID\n\n\treloadID := o.ReloadID\n\tif reloadID != \"\" {\n\t\trw.Header().Set(\"Reload-ID\", reloadID)\n\t}\n\n\trw.WriteHeader(202)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *PostOperationsGetNetworkElementListCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ServiceInstanceLastOperationGetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header RetryAfter\n\n\tretryAfter := o.RetryAfter\n\tif retryAfter != \"\" {\n\t\trw.Header().Set(\"RetryAfter\", retryAfter)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetPiecesIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetTaskDetailsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *UpdateClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *GetDetailOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\trw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetServicesHaproxyRuntimeAclsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (r *responseInfoRecorder) Write(b []byte) (int, error) {\n\tr.ContentLength += int64(len(b))\n\tif r.statusCode == 0 {\n\t\tr.statusCode = http.StatusOK\n\t}\n\treturn r.ResponseWriter.Write(b)\n}", "func (o *LogoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func (o *UploadFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "func WriteResponse(w http.ResponseWriter, data interface{}) error {\n\tenv := map[string]interface{}{\n\t\t\"meta\": map[string]interface{}{\n\t\t\t\"code\": http.StatusOK,\n\t\t},\n\t\t\"data\": data,\n\t}\n\treturn jsonResponse(w, env)\n}", "func (o *WeaviateThingTemplatesCreateNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "func (r *Responder) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\tfor k, v := range r.headers {\n\t\tfor _, val := range v {\n\t\t\trw.Header().Add(k, val)\n\t\t}\n\t}\n\n\trw.WriteHeader(r.code)\n\n\tif r.response != nil {\n\t\tif err := producer.Produce(rw, r.response); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "func (o *GetGateSourceByGateNameAndMntOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *CreateSpoeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tpayload := o.Payload\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *Output) writeResponse(response string) error {\r\n\t// write the response\r\n\tif _, err := o.writer.WriteString(response + \"\\n\"); err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (o *GetTransportByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *TransferOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateUserCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "func (o *ViewOneOrderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (o *GetVisiblePruebasFromQuestionTestInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(500)\n}", "func (o *GetWhaleTranfersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.OperationsRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (o *SearchTournamentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*models.Tournament, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (o *CreateTCPCheckCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (s *Server) writeInfoResponse(\n\tw http.ResponseWriter,\n\tr *http.Request,\n\tmessage []byte,\n\tstatus int,\n\theaders map[string]string,\n) {\n\tfor k, v := range headers {\n\t\tw.Header().Add(k, v)\n\t}\n\n\tw.WriteHeader(status)\n\tw.Write(message)\n}" ]
[ "0.81303823", "0.7882039", "0.77722245", "0.7771901", "0.7753117", "0.7740585", "0.76670325", "0.7638451", "0.76095873", "0.75798", "0.7579178", "0.7567389", "0.7560546", "0.75579476", "0.75447774", "0.7542929", "0.75416607", "0.753386", "0.7531158", "0.75192654", "0.75191355", "0.7513389", "0.7512029", "0.75050455", "0.7503395", "0.74984574", "0.74875605", "0.74839836", "0.74772394", "0.7467842", "0.746699", "0.7465759", "0.7464175", "0.746404", "0.746404", "0.7461224", "0.7460309", "0.74595356", "0.74463046", "0.7443478", "0.7435917", "0.7426582", "0.7425581", "0.74186546", "0.7413175", "0.7407469", "0.74063516", "0.74048966", "0.7398737", "0.7389631", "0.738607", "0.73806983", "0.7360552", "0.7360491", "0.7355327", "0.7354953", "0.73532444", "0.7347445", "0.734586", "0.732798", "0.732577", "0.73178244", "0.7316643", "0.7316071", "0.7315527", "0.7312546", "0.73114824", "0.7310336", "0.7309039", "0.73007035", "0.7297214", "0.7291373", "0.7291277", "0.72884554", "0.72845477", "0.72835207", "0.7281928", "0.7281033", "0.72751075", "0.7274423", "0.7273193", "0.72730565", "0.72695094", "0.7269139", "0.72690886", "0.7265927", "0.72615093", "0.72529227", "0.7251764", "0.72490144", "0.72479355", "0.72469014", "0.72407585", "0.72390425", "0.72367245", "0.7234706", "0.722777", "0.722197", "0.7215153", "0.72140837", "0.7213089" ]
0.0
-1
Main is the main.
func Main(use string, options ...RootCommandOption) { appcmd.Main(context.Background(), newRootCommand(use, options...), version) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Main(args ...interface{}) {\n\n\t// ...\n}", "func main() {\n\tapplication.Application()\n}", "func main() {\n\tgimain.Main(func() {\n\t\tmainrun()\n\t})\n}", "func main() {\n\tgimain.Main(func() {\n\t\tmainrun()\n\t})\n}", "func main() {\n\tgimain.Main(func() {\n\t\tmainrun()\n\t})\n}", "func main() {\n\tgimain.Main(func() {\n\t\tmainrun()\n\t})\n}", "func main() {\n\tgimain.Main(func() {\n\t\tmainrun()\n\t})\n}", "func main_init()", "func main() {\n\tcore.Start()\n}", "func main() {\n\twf.Run(run)\n}", "func main() {\n\n\t\n}", "func Main() error {\n\tapp, err := New(context.Background())\n\tif err != nil {\n\t\treturn skerr.Wrap(err)\n\t}\n\n\treturn app.Run()\n}", "func main()", "func main()", "func main()", "func main() {\n\tif err := run(); err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}", "func main() {\r\n\r\n}", "func main() {\n\t\n}", "func main() {\n\t\n}", "func main() {\n\tcmd.Run()\n}", "func main() {\n\t//Clears screen for better readability\n\tCallClear()\n\t//Calls function to start program\n\tmenu()\n}", "func Main() {\n\tif err := Run(cmd.NewLogger(), cmd.StandardIOStreams(), os.Args[1:]); err != nil {\n\t\tos.Exit(1)\n\t}\n}", "func Main() {\n\tos.Exit(Run(os.Args, os.Stdin, os.Stdout, os.Stderr))\n}", "func main() {\n\tif err := run(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func main() {\n\tif err := run(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func main(){\n\t//Basic Hello World example\n\tfmt.Println(\"Hello World\")\n}", "func Main() {\n\tflag.Parse()\n\n\tif err := run(); err != nil {\n\t\tlog.Warningf(\"%v\", err)\n\t\tos.Exit(1)\n\t}\n}", "func main() {\n\tapp := getRootCmd()\n\n\t// ignore error so we don't exit non-zero and break gfmrun README example tests\n\t_ = app.Execute()\n}", "func main() {\n\t// starting server\n\tcuxs.StartServer(engine.Router())\n}", "func Main(m rv.RenderModel) {\n\tmain(m)\n}", "func main() {\n\tdebugln(\"main!\")\n}", "func main(){\n\n}", "func main() {\n\tapp := cli.NewCLI() // Get a new CLI\n\n\terr := app.Run(os.Args) // Run the CLI\n\tif err != nil { // Check for errors\n\t\tlog.Fatal(err) // Panic\n\t}\n}", "func main() {\n\tif err := realMain(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func main() {}", "func Main() {\n\tfullCmd := kingpin.MustParse(app.Parse(os.Args[1:])) // 解析用户命令行\n\n\t// \"version\" command\n\tif fullCmd == version.FullCommand() {\n\t\tfmt.Println(metadata.GetVersionInfo())\n\t\treturn\n\t}\n\n\tconf, err := localconfig.Load() // 记载orderer配置文件\n\tif err != nil {\n\t\tlogger.Error(\"failed to parse config: \", nil)\n\t\tos.Exit(1)\n\t}\n\tinitializeLogging()\n\n\tprettyPrintStruct(conf)\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\n}", "func main() {\n\tserver.New().Start()\n}", "func Main(name string) {\n\tappcmd.Main(context.Background(), NewRootCommand(name))\n}", "func main() {\n\n\tcli := CLI{}\n\tcli.Run()\n}", "func main(){\n\tfmt.Println(\"Hi there!\")\n}", "func main() {\n\terr := run()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func main() {\n\tapp.Run(app.Callbacks{})\n}", "func main() { \n\n}", "func main() {\n\tfmt.Println(\"Welcome to origourls!\")\n}", "func main() {\n\t// initial database\n\tdbHandler := singleton.NewDatabaseInitialize(\"root\", \"password\", \"repository\")\n\tdb, err := dbHandler.GetConnection()\n\n\tif err != nil {\n\t\tfmt.Println(\"error connect database : \" + err.Error())\n\t}\n\n\t// initial object user handler\n\tuserCtrl := handlers.NewUserController(db)\n\tuserCtrl.GetUserByID()\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}", "func main() {\n}" ]
[ "0.76547235", "0.76154083", "0.756919", "0.756919", "0.756919", "0.756919", "0.756919", "0.7539344", "0.7493354", "0.7487511", "0.7462853", "0.74361163", "0.74144876", "0.74144876", "0.74144876", "0.73895395", "0.731854", "0.73091245", "0.73091245", "0.72880375", "0.7265347", "0.72370565", "0.7134214", "0.7119417", "0.7119417", "0.7106974", "0.7104559", "0.7081958", "0.7080164", "0.7071223", "0.7060277", "0.7052407", "0.70464784", "0.7042475", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041827", "0.7041324", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.7029904", "0.701692", "0.6994015", "0.6992666", "0.69920397", "0.698264", "0.69784373", "0.6970745", "0.695132", "0.69437313", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981", "0.6936981" ]
0.0
-1
NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewExecutableSchema(resolvers ResolverRoot) graphql.ExecutableSchema {\n\treturn MakeExecutableSchema(shortMapper{r: resolvers})\n}", "func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t}\n}", "func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}", "func MakeExecutableSchema(resolvers Resolvers) graphql.ExecutableSchema {\n\treturn &executableSchema{resolvers: resolvers}\n}", "func New() *types.Schema {\n\ts := &types.Schema{\n\t\tEntryPointNames: make(map[string]string),\n\t\tTypes: make(map[string]types.NamedType),\n\t\tDirectives: make(map[string]*types.DirectiveDefinition),\n\t}\n\tm := newMeta()\n\tfor n, t := range m.Types {\n\t\ts.Types[n] = t\n\t}\n\tfor n, d := range m.Directives {\n\t\ts.Directives[n] = d\n\t}\n\treturn s\n}", "func NewRoot(db *db.DB) *Root {\n\n\t// Create reslver for holding our database.\n\t// More on resolver https://graphql.org/learn/execution/#root-fields-resolvers\n\tresolver := Resolver{db: db}\n\n\t// Create a new Root\n\troot := Root{\n\t\tQuery: graphql.NewObject(\n\t\t\tgraphql.ObjectConfig{\n\t\t\t\tName: \"Query\",\n\t\t\t\tFields: graphql.Fields{\n\t\t\t\t\t\"doctor\": doctorQuery(&resolver),\n\t\t\t\t\t\"doctors\": doctorsQuery(&resolver),\n\t\t\t\t\t\"illness\": illnessQuery(&resolver),\n\t\t\t\t\t\"illnesses\": illnessesQuery(&resolver),\n\t\t\t\t\t\"user\": userQuery(&resolver),\n\t\t\t\t\t\"users\": usersQuery(&resolver),\n\t\t\t\t\t\"userByEmail\": userByEmailQuery(&resolver),\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t}\n\n\treturn &root\n}", "func NewBaseSchema() (schema *Schema, err error) {\n\tb, err := baseSchemaBytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar node yaml.Node\n\terr = yaml.Unmarshal(b, &node)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn NewSchemaFromObject(&node), nil\n}", "func ExecSchema() error {\r\n\treturn migration.InitMigrate(&MigrationHistory{})\r\n}", "func NewSchema() *Schema {\n\tschema := &Schema{\n\t\tobjects: make(map[string]*Object),\n\t}\n\n\t// Default registrations.\n\tschema.Enum(SortOrder(0), map[string]SortOrder{\n\t\t\"asc\": SortOrder_Ascending,\n\t\t\"desc\": SortOrder_Descending,\n\t})\n\n\treturn schema\n}", "func NewSchema() *Schema {\n\tc := &Schema{\n\t\trequired: false,\n\t\trules: []IValidationRule{},\n\t}\n\tc.base = c\n\treturn c\n}", "func NewSchema(ctx *pulumi.Context,\n\tname string, args *SchemaArgs, opts ...pulumi.ResourceOption) (*Schema, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.Content == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Content'\")\n\t}\n\tif args.RegistryName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'RegistryName'\")\n\t}\n\tif args.Type == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Type'\")\n\t}\n\tvar resource Schema\n\terr := ctx.RegisterResource(\"aws:schemas/schema:Schema\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewSchema(init ...*Schema) *Schema {\n\tvar o *Schema\n\tif len(init) == 1 {\n\t\to = init[0]\n\t} else {\n\t\to = new(Schema)\n\t}\n\treturn o\n}", "func NewRuntime(schema *Schema) (*Runtime, error) {\n\tif err := validateSchema(schema); err != nil {\n\t\treturn nil, err\n\t}\n\n\truntime := &Runtime{\n\t\tScalars: make(map[string]*Scalar),\n\t\tObjects: make(map[string]*Object),\n\t\tIfaces: make(map[string]*Interface),\n\t\tUnions: make(map[string]*Union),\n\t\tEnums: make(map[string]*Enum),\n\t\tInputObjs: make(map[string]*InputObject),\n\t\tLists: make(map[string]*List),\n\t\tNonNulls: make(map[string]*NonNull),\n\t}\n\tif schema == nil {\n\t\treturn runtime, nil\n\t}\n\textractObjectTypes(runtime, schema.Qry)\n\textractObjectTypes(runtime, schema.Mut)\n\treturn runtime, nil\n}", "func NewSchema(m ...interface{}) *Schema {\n\tif len(m) > 0 {\n\t\tsche := &Schema{}\n\t\tstack := toMiddleware(m)\n\t\tfor _, s := range stack {\n\t\t\t*sche = append(*sche, s)\n\t\t}\n\t\treturn sche\n\t}\n\treturn nil\n}", "func NewResolverRoot(svcs Services, strms Streamers) graphql.ResolverRoot {\n\treturn resolverRoot{\n\t\tquery: newQueryResolver(svcs),\n\t\tmutation: newMutationResolver(svcs),\n\t\tsubscription: newSubscriptionResolver(strms),\n\n\t\tmusicResolvers: newMusicResolvers(svcs.Music),\n\t\tlocationResolvers: locationResolvers{},\n\t\tproductivityResolvers: productivityResolvers{},\n\n\t\tfullAbout: aboutgql.Resolver{},\n\t\ttransitDeparture: transgql.DepartureResolver{},\n\t}\n}", "func NewExecutable(cli string) Executable {\n\treturn &executable{\n\t\tcli: cli,\n\t}\n}", "func MakeTestingSchema(doc interface{}) *Schema {\n\tvar testingPool *schemaPool\n\tif doc != nil {\n\t\ttestingPool = &schemaPool{standaloneDocument: doc}\n\t}\n\treturn &Schema{pool: testingPool}\n}", "func (e *BaseExecutor) Schema() *expression.Schema {\n\tif e.schema == nil {\n\t\treturn expression.NewSchema()\n\t}\n\treturn e.schema\n}", "func NewSchema(db *sqlx.DB) *graphql.Schema {\n\tresolver := Resolver{\n\t\tdb: db,\n\t}\n\treturn graphql.MustParseSchema(schema, &resolver)\n}", "func NewRootResolver(log *zap.Logger, k8sCli client.Client, policyService policy.Service) *RootResolver {\n\tactionConverter := action.NewConverter()\n\tactionService := action.NewService(log, k8sCli)\n\tactionResolver := action.NewResolver(actionService, actionConverter)\n\n\tpolicyConverter := policy.NewConverter()\n\tpolicyResolver := policy.NewResolver(policyService, policyConverter)\n\n\treturn &RootResolver{\n\t\tcombinedResolver{\n\t\t\tactionResolver: actionResolver,\n\t\t\tpolicyResolver: policyResolver,\n\t\t},\n\t}\n}", "func NewSchemaObj(jsonType, typeName string) (so *SchemaObj) {\n\tso = &SchemaObj{\n\t\tType: jsonType,\n\t\tTypeName: typeName,\n\t}\n\tif typeName != \"\" {\n\t\tso.Ref = refDefinitionPrefix + typeName\n\t}\n\treturn\n}", "func NewResolver() exec.Resolver {\n\treturn &resolver{}\n}", "func NewRoot() *Root {\n\t// Create a new Root that describes our base query set up. In this\n\t// example we have a user query that takes one argument called ID\n\troot := Root{\n\t\tQuery: queryType,\n\t\tMutation: mutationType,\n\t}\n\n\treturn &root\n}", "func NewRoot(db *sql.Db) (*QRoot, *MRoot) {\n\tqueryResolver := QueryResolver{db: db}\n\tmutationResolver := MutationResolver{db: db}\n\n\tqueryRoot := QRoot{\n\t\tQuery: graphql.NewObject(\n\t\t\tgraphql.ObjectConfig{\n\t\t\t\tName: \"RootQuery\",\n\t\t\t\tFields: graphql.Fields{\n\t\t\t\t\t\"GetPages\": &graphql.Field{\n\t\t\t\t\t\tType: graphql.NewList(WikiPage),\n\t\t\t\t\t\tArgs: graphql.FieldConfigArgument{\n\t\t\t\t\t\t\t\"Title\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.String,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"Tags\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.String,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tResolve: queryResolver.GetPagesResolver,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t}\n\tmutRoot := MRoot{\n\t\tMutation: graphql.NewObject(\n\t\t\tgraphql.ObjectConfig{\n\t\t\t\tName: \"RootMutation\",\n\t\t\t\tFields: graphql.Fields{\n\t\t\t\t\t\"SavePage\": &graphql.Field{\n\t\t\t\t\t\tType: WikiPage,\n\t\t\t\t\t\tArgs: graphql.FieldConfigArgument{\n\t\t\t\t\t\t\t\"Title\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"Tags\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"Ingress\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"MainText\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"SideBarInfo\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"ProfileImagePath\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"BodyImagePath\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"Visible\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.Boolean),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"Author\": &graphql.ArgumentConfig{\n\t\t\t\t\t\t\t\tType: graphql.NewNonNull(graphql.String),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tResolve: mutationResolver.SavePageResolver,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t}\n\treturn &queryRoot, &mutRoot\n}", "func NewSchema()(*Schema) {\n m := &Schema{\n Entity: *iadcd81124412c61e647227ecfc4449d8bba17de0380ddda76f641a29edf2b242.NewEntity(),\n }\n return m\n}", "func (s *Schema) Build() (*graphql.Schema, error) {\n\tsb := &schemaBuilder{\n\t\ttypes: make(map[reflect.Type]graphql.Type),\n\t\ttypeNames: make(map[string]reflect.Type),\n\t\tobjects: make(map[reflect.Type]*Object),\n\t\tenumMappings: s.enumTypes,\n\t\ttypeCache: make(map[reflect.Type]cachedType, 0),\n\t}\n\n\ts.Object(\"Query\", query{})\n\ts.Object(\"Mutation\", mutation{})\n\n\tfor _, object := range s.objects {\n\t\ttyp := reflect.TypeOf(object.Type)\n\t\tif typ.Kind() != reflect.Struct {\n\t\t\treturn nil, fmt.Errorf(\"object.Type should be a struct, not %s\", typ.String())\n\t\t}\n\n\t\tif _, ok := sb.objects[typ]; ok {\n\t\t\treturn nil, fmt.Errorf(\"duplicate object for %s\", typ.String())\n\t\t}\n\n\t\tsb.objects[typ] = object\n\t}\n\n\tqueryTyp, err := sb.getType(reflect.TypeOf(&query{}))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmutationTyp, err := sb.getType(reflect.TypeOf(&mutation{}))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &graphql.Schema{\n\t\tQuery: queryTyp,\n\t\tMutation: mutationTyp,\n\t}, nil\n}", "func (e *AnalyzeExec) Schema() *expression.Schema {\n\treturn expression.NewSchema()\n}", "func (creator *resolverCreator) NewRootResolver(ctx context.Context) (types.RootResolverContract, error) {\n\treturn root.NewRootResolver(\n\t\tctx,\n\t\tcreator,\n\t\tcreator.logger)\n}", "func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }", "func TestResolveObjectCodegen(t *testing.T) {\n\tscm, err := schema.Parse(testResolveObject_Schema)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tscope := parseCodeToScope(t, testResolveObject_ResolverCode)\n\n\tmb := newModelBuilder(scm.Definitions)\n\tres, err := mb.buildResolver(typeResolverPair{\n\t\tASTType: scm.Definitions.RootQuery,\n\t\tResolverType: scope.Lookup(\"RootResolver\").Type(),\n\t})\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tdecls, err := res.GenerateGoASTDecls()\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tif len(decls) != 1 {\n\t\tt.Fatalf(\"expected 1 decl, got %d\", len(decls))\n\t}\n\n\ttestASTCodegenDecls(\n\t\tt,\n\t\tdecls,\n\t\tobjectExpectedOut,\n\t)\n}", "func New(root string, config *converter.Config) (runtime.Source, error) {\n\treturn newFsSource(root, config, kube_meta.Types.All())\n}", "func NewRoot(repo restic.Repository, cfg Config) *Root {\n\tdebug.Log(\"NewRoot(), config %v\", cfg)\n\n\troot := &Root{\n\t\trepo: repo,\n\t\tcfg: cfg,\n\t\tblobCache: bloblru.New(blobCacheSize),\n\t}\n\n\tif !cfg.OwnerIsRoot {\n\t\troot.uid = uint32(os.Getuid())\n\t\troot.gid = uint32(os.Getgid())\n\t}\n\n\t// set defaults, if PathTemplates is not set\n\tif len(cfg.PathTemplates) == 0 {\n\t\tcfg.PathTemplates = []string{\n\t\t\t\"ids/%i\",\n\t\t\t\"snapshots/%T\",\n\t\t\t\"hosts/%h/%T\",\n\t\t\t\"tags/%t/%T\",\n\t\t}\n\t}\n\n\troot.SnapshotsDir = NewSnapshotsDir(root, rootInode, rootInode, NewSnapshotsDirStructure(root, cfg.PathTemplates, cfg.TimeTemplate), \"\")\n\n\treturn root\n}", "func NewSchema(ts *prompb.TimeSeries) *Schema {\n\treturn &Schema{\n\t\tTableName: getTimeSeriesTableName(ts),\n\t\tLabelNames: getLabelNames(ts),\n\t}\n}", "func (d Definition) GetExecutableType() *ExecutableType {\n\tt := ExecutableTypeDefinition\n\treturn &t\n}", "func generateGoSchemaFile(schema map[string]interface{}, config Config) {\r\n var obj map[string]interface{}\r\n var schemas = make(map[string]interface{})\r\n var outString = \"package main\\n\\nvar schemas = `\\n\"\r\n\r\n var filename = config.Schemas.GoSchemaFilename\r\n var apiFunctions = config.Schemas.API\r\n var elementNames = config.Schemas.GoSchemaElements\r\n \r\n var functionKey = \"API\"\r\n var objectModelKey = \"objectModelSchemas\"\r\n \r\n schemas[functionKey] = interface{}(make(map[string]interface{}))\r\n schemas[objectModelKey] = interface{}(make(map[string]interface{}))\r\n\r\n fmt.Printf(\"Generate Go SCHEMA file %s for: \\n %s and: \\n %s\\n\", filename, apiFunctions, elementNames)\r\n\r\n // grab the event API functions for input\r\n for i := range apiFunctions {\r\n functionSchemaName := \"#/definitions/API/\" + apiFunctions[i]\r\n functionName := apiFunctions[i]\r\n obj = getObject(schema, functionSchemaName)\r\n if obj == nil {\r\n fmt.Printf(\"** WARN ** %s returned nil from getObject\\n\", functionSchemaName)\r\n return\r\n }\r\n schemas[functionKey].(map[string]interface{})[functionName] = obj \r\n } \r\n\r\n // grab the elements requested (these are useful separately even though\r\n // they obviously appear already as part of the event API functions)\r\n for i := range elementNames {\r\n elementName := elementNames[i]\r\n obj = getObject(schema, elementName)\r\n if obj == nil {\r\n fmt.Printf(\"** ERR ** %s returned nil from getObject\\n\", elementName)\r\n return\r\n }\r\n schemas[objectModelKey].(map[string]interface{})[elementName] = obj \r\n }\r\n \r\n // marshal for output to file \r\n schemaOut, err := json.MarshalIndent(&schemas, \"\", \" \")\r\n if err != nil {\r\n fmt.Printf(\"** ERR ** cannot marshal schema file output for writing\\n\")\r\n return\r\n }\r\n outString += string(schemaOut) + \"`\"\r\n ioutil.WriteFile(filename, []byte(outString), 0644)\r\n}", "func NewAPI(root string, pg *ast.CXProgram) *API {\n\tif root == \"\" {\n\t\troot = \"/\"\n\t}\n\treturn &API{root: root, pg: pg}\n}", "func BuildSchema(uri string, files []string) *jsonschema.Schema {\n\tcompiler := jsonschema.NewCompiler()\n\tfor _, file := range files {\n\t\tif err := compiler.AddResource(file, strings.NewReader(Data[file])); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\tschema, err := compiler.Compile(uri)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn schema\n}", "func NewResolver(baseConfig config.Config, client kubectl.Client, configOptions *loader.ConfigOptions, log log.Logger) ResolverInterface {\n\tvar id string\n\n\tvar kubeLoader kubeconfig.Loader\n\tif client == nil {\n\t\tkubeLoader = kubeconfig.NewLoader()\n\t} else {\n\t\tkubeLoader = client.KubeConfigLoader()\n\t}\n\n\tbasePath, err := filepath.Abs(\".\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tremote, err := git.GetRemote(basePath)\n\tif err == nil {\n\t\tid = remote\n\t} else {\n\t\tid = basePath\n\t}\n\n\treturn &resolver{\n\t\tRootID: id,\n\t\tDependencyGraph: newGraph(newNode(id, nil)),\n\n\t\tBaseConfig: baseConfig.Config(),\n\t\tBaseCache: baseConfig.Generated(),\n\t\tBaseVars: baseConfig.Variables(),\n\n\t\tConfigOptions: configOptions,\n\n\t\t// We only need that for saving\n\t\tkubeLoader: kubeLoader,\n\t\tclient: client,\n\t\tgeneratedSaver: generated.NewConfigLoaderFromDevSpacePath(\"\", baseConfig.Path()),\n\t\tlog: log,\n\t}\n}", "func NewSchema() *Schema {\n\treturn &Schema{\n\t\ttables: make(map[string]([]*sqlparser.ColumnDefinition)),\n\t}\n}", "func NewRoot() *Root {\n\tr := new(Root)\n\tr.objects.init(8)\n\tr.idCache = make(map[int]libFldDoc)\n\tr.missing = make(map[int]libFldDoc)\n\treturn r\n}", "func (*ResolvedObjectPrefix) SchemaMeta() {}", "func WithRootSchema(oapi spec.OpenAPI) Option {\n\treturn func(r *Options) error {\n\t\tr.root = oapi\n\t\treturn nil\n\t}\n}", "func NewResolver(root string, backgroundTaskManager *task.BackgroundTaskManager, cfg config.Config, resolveHandlers map[string]remote.Handler, metadataStore metadata.Store, overlayOpaqueType OverlayOpaqueType, additionalDecompressors func(context.Context, source.RegistryHosts, reference.Spec, ocispec.Descriptor) []metadata.Decompressor) (*Resolver, error) {\n\tresolveResultEntryTTL := time.Duration(cfg.ResolveResultEntryTTLSec) * time.Second\n\tif resolveResultEntryTTL == 0 {\n\t\tresolveResultEntryTTL = defaultResolveResultEntryTTLSec * time.Second\n\t}\n\tprefetchTimeout := time.Duration(cfg.PrefetchTimeoutSec) * time.Second\n\tif prefetchTimeout == 0 {\n\t\tprefetchTimeout = defaultPrefetchTimeoutSec * time.Second\n\t}\n\n\t// layerCache caches resolved layers for future use. This is useful in a use-case where\n\t// the filesystem resolves and caches all layers in an image (not only queried one) in parallel,\n\t// before they are actually queried.\n\tlayerCache := cacheutil.NewTTLCache(resolveResultEntryTTL)\n\tlayerCache.OnEvicted = func(key string, value interface{}) {\n\t\tif err := value.(*layer).close(); err != nil {\n\t\t\tlogrus.WithField(\"key\", key).WithError(err).Warnf(\"failed to clean up layer\")\n\t\t\treturn\n\t\t}\n\t\tlogrus.WithField(\"key\", key).Debugf(\"cleaned up layer\")\n\t}\n\n\t// blobCache caches resolved blobs for futural use. This is especially useful when a layer\n\t// isn't eStargz/stargz (the *layer object won't be created/cached in this case).\n\tblobCache := cacheutil.NewTTLCache(resolveResultEntryTTL)\n\tblobCache.OnEvicted = func(key string, value interface{}) {\n\t\tif err := value.(remote.Blob).Close(); err != nil {\n\t\t\tlogrus.WithField(\"key\", key).WithError(err).Warnf(\"failed to clean up blob\")\n\t\t\treturn\n\t\t}\n\t\tlogrus.WithField(\"key\", key).Debugf(\"cleaned up blob\")\n\t}\n\n\tif err := os.MkdirAll(root, 0700); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Resolver{\n\t\trootDir: root,\n\t\tresolver: remote.NewResolver(cfg.BlobConfig, resolveHandlers),\n\t\tlayerCache: layerCache,\n\t\tblobCache: blobCache,\n\t\tprefetchTimeout: prefetchTimeout,\n\t\tbackgroundTaskManager: backgroundTaskManager,\n\t\tconfig: cfg,\n\t\tresolveLock: new(namedmutex.NamedMutex),\n\t\tmetadataStore: metadataStore,\n\t\toverlayOpaqueType: overlayOpaqueType,\n\t\tadditionalDecompressors: additionalDecompressors,\n\t}, nil\n}", "func NewSolutionsRoot()(*SolutionsRoot) {\n m := &SolutionsRoot{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func NewSchemaDependenciesResolver(pr *PluginRegistry) *SchemaDependenciesResolver {\n\treturn &SchemaDependenciesResolver{\n\t\tpr: pr,\n\t}\n}", "func MakeSchema(jsonData interface{}) Schema {\n\t//panic(fmt.Sprintf(\"Excepted types was 'map[string]interface{}' and '[]interface{}' got: %T\", jsonData))\n\tvar root = hub(VarRoot, jsonData)\n\treturn root\n}", "func (cfg *Config) bind() (*Build, error) {\n\tnamedTypes := cfg.buildNamedTypes()\n\n\tprog, err := cfg.loadProgram(namedTypes, true)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"loading failed\")\n\t}\n\n\timports := buildImports(namedTypes, cfg.Exec.Dir())\n\tcfg.bindTypes(imports, namedTypes, cfg.Exec.Dir(), prog)\n\n\tobjects, err := cfg.buildObjects(namedTypes, prog, imports)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinputs, err := cfg.buildInputs(namedTypes, prog, imports)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb := &Build{\n\t\tPackageName: cfg.Exec.Package,\n\t\tObjects: objects,\n\t\tInterfaces: cfg.buildInterfaces(namedTypes, prog),\n\t\tInputs: inputs,\n\t\tImports: imports.finalize(),\n\t}\n\n\tif qr, ok := cfg.schema.EntryPoints[\"query\"]; ok {\n\t\tb.QueryRoot = b.Objects.ByName(qr.TypeName())\n\t}\n\n\tif mr, ok := cfg.schema.EntryPoints[\"mutation\"]; ok {\n\t\tb.MutationRoot = b.Objects.ByName(mr.TypeName())\n\t}\n\n\tif sr, ok := cfg.schema.EntryPoints[\"subscription\"]; ok {\n\t\tb.SubscriptionRoot = b.Objects.ByName(sr.TypeName())\n\t}\n\n\tif b.QueryRoot == nil {\n\t\treturn b, fmt.Errorf(\"query entry point missing\")\n\t}\n\n\t// Poke a few magic methods into query\n\tq := b.Objects.ByName(b.QueryRoot.GQLType)\n\tq.Fields = append(q.Fields, Field{\n\t\tType: &Type{namedTypes[\"__Schema\"], []string{modPtr}, \"\"},\n\t\tGQLName: \"__schema\",\n\t\tNoErr: true,\n\t\tGoMethodName: \"ec.introspectSchema\",\n\t\tObject: q,\n\t})\n\tq.Fields = append(q.Fields, Field{\n\t\tType: &Type{namedTypes[\"__Type\"], []string{modPtr}, \"\"},\n\t\tGQLName: \"__type\",\n\t\tNoErr: true,\n\t\tGoMethodName: \"ec.introspectType\",\n\t\tArgs: []FieldArgument{\n\t\t\t{GQLName: \"name\", Type: &Type{namedTypes[\"String\"], []string{}, \"\"}, Object: &Object{}},\n\t\t},\n\t\tObject: q,\n\t})\n\n\treturn b, nil\n}", "func NewFxAdminAPIYARPCProcedures() interface{} {\n\treturn func(params FxAdminAPIYARPCProceduresParams) FxAdminAPIYARPCProceduresResult {\n\t\treturn FxAdminAPIYARPCProceduresResult{\n\t\t\tProcedures: buildAdminAPIYARPCProcedures(buildAdminAPIYARPCProceduresParams{\n\t\t\t\tServer: params.Server,\n\t\t\t\tAnyResolver: params.AnyResolver,\n\t\t\t}),\n\t\t\tReflectionMeta: reflection.ServerMeta{\n\t\t\t\tServiceName: \"uber.cadence.admin.v1.AdminAPI\",\n\t\t\t\tFileDescriptors: yarpcFileDescriptorClosurec6fc96d64a8b67fd,\n\t\t\t},\n\t\t}\n\t}\n}", "func Schema() (*ytypes.Schema, error) {\n\tuzp, err := UnzipSchema()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unzip schema, %v\", err)\n\t}\n\n\treturn &ytypes.Schema{\n\t\tRoot: &Device{},\n\t\tSchemaTree: uzp,\n\t\tUnmarshal: Unmarshal,\n\t}, nil\n}", "func Schema() (*ytypes.Schema, error) {\n\tuzp, err := UnzipSchema()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unzip schema, %v\", err)\n\t}\n\n\treturn &ytypes.Schema{\n\t\tRoot: &Device{},\n\t\tSchemaTree: uzp,\n\t\tUnmarshal: Unmarshal,\n\t}, nil\n}", "func Schema() (*ytypes.Schema, error) {\n\tuzp, err := UnzipSchema()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unzip schema, %v\", err)\n\t}\n\n\treturn &ytypes.Schema{\n\t\tRoot: &Device{},\n\t\tSchemaTree: uzp,\n\t\tUnmarshal: Unmarshal,\n\t}, nil\n}", "func Schema() (*ytypes.Schema, error) {\n\tuzp, err := UnzipSchema()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unzip schema, %v\", err)\n\t}\n\n\treturn &ytypes.Schema{\n\t\tRoot: &Device{},\n\t\tSchemaTree: uzp,\n\t\tUnmarshal: Unmarshal,\n\t}, nil\n}", "func Schema() (*ytypes.Schema, error) {\n\tuzp, err := UnzipSchema()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unzip schema, %v\", err)\n\t}\n\n\treturn &ytypes.Schema{\n\t\tRoot: &Device{},\n\t\tSchemaTree: uzp,\n\t\tUnmarshal: Unmarshal,\n\t}, nil\n}", "func Schema() (*ytypes.Schema, error) {\n\tuzp, err := UnzipSchema()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot unzip schema, %v\", err)\n\t}\n\n\treturn &ytypes.Schema{\n\t\tRoot: &Device{},\n\t\tSchemaTree: uzp,\n\t\tUnmarshal: Unmarshal,\n\t}, nil\n}", "func New(opt ...Option) interfaces.Schema {\n\topts := newOptions(opt...)\n\treturn &schema{\n\t\tquery: opts.Query,\n\t\tmut: opts.Mutation,\n\t\tsub: opts.Subscription,\n\t}\n}", "func BuildSchema(db *sql.DB, sqlSchema schema.SQLSchemaStruct, graphqlSchema schema.GraphqlSchema) (*graphql.Schema, error) {\n\tobjectTypes := buildObjectTypes(db, sqlSchema, graphqlSchema)\n\tschema, err := graphql.NewSchema(graphql.SchemaConfig{\n\t\tQuery: buildQueryType(db, sqlSchema, graphqlSchema, objectTypes),\n\t\tMutation: buildMutationType(db, sqlSchema, graphqlSchema, objectTypes),\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &schema, nil\n}" ]
[ "0.7599504", "0.71238595", "0.7099825", "0.6739987", "0.5023748", "0.4870003", "0.47683108", "0.4757958", "0.470629", "0.465203", "0.4584383", "0.45783812", "0.45181683", "0.44727597", "0.44668096", "0.44606218", "0.44596046", "0.44547275", "0.4448324", "0.444426", "0.43619865", "0.43576935", "0.43566337", "0.43504193", "0.43360272", "0.42927194", "0.42860475", "0.42735246", "0.42723185", "0.42283362", "0.422549", "0.41586152", "0.41478962", "0.4142805", "0.41402632", "0.41219702", "0.4109542", "0.41079038", "0.4106649", "0.41032892", "0.4096842", "0.4034047", "0.40309185", "0.40254602", "0.4022521", "0.40143582", "0.4011649", "0.4010025", "0.39978668", "0.39978668", "0.39978668", "0.39978668", "0.39978668", "0.39978668", "0.39834222", "0.39729834" ]
0.71002424
33
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) _Application(ctx context.Context, sel ast.SelectionSet, obj *model.Application) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, applicationImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Application") case "id": out.Values[i] = ec._Application_id(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "description": out.Values[i] = ec._Application_description(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "appliedBy": out.Values[i] = ec._Application_appliedBy(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "appliedAt": out.Values[i] = ec._Application_appliedAt(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "verifiedBy": out.Values[i] = ec._Application_verifiedBy(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "verifiedAt": out.Values[i] = ec._Application_verifiedAt(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}", "func cioperation(asm *global.AssemblyWithComponents, ci *global.Operations, com *global.Component) error {\n\n\tpair_scm, perrscm := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-scm\")\n\tif perrscm != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrscm)\n\t}\n\n\tpair_enable, perrenable := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-enable\")\n\tif perrenable != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrenable)\n\t}\n\n\tif pair_scm.Value == GITLAB && pair_enable.Value == ENABLE {\n\t\tlog.Info(\"GitLab is working..\")\n\n\t\tpair_token, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-token\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-token value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_url, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-url\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-url value : %s\", perrtoken)\n\n\t\t}\n\t\tpair_apiversion, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-apiversion\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-apiversion value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_owner, perrowner := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-owner\")\n\t\tif perrowner != nil {\n\t\t\tlog.Error(\"Failed to get the ci-owner value : %s\", perrowner)\n\t\t}\n\n\t\tapi_host, apierr := config.GetString(\"api:host\")\n\t\tif apierr != nil {\n\t\t\treturn apierr\n\t\t}\n\n\t\tapi_version, apiverr := config.GetString(\"api:version\")\n\t\tif apiverr != nil {\n\t\t\treturn apiverr\n\t\t}\n\n\t\ttrigger_url := \"http://\" + api_host + \"/\" + api_version + \"/assembly/build/\" + asm.Id + \"/\" + com.Id\n\n\t\tclient := gogitlab.NewGitlab(pair_url.Value, pair_apiversion.Value, pair_token.Value)\n\n\t\terr := client.AddProjectHook(pair_owner.Value, trigger_url, false, false, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t} else {\n\t\tlog.Info(\"GitLab is skipped\")\n\t}\n\treturn nil\n\n}" ]
[ "0.58961266", "0.5789828", "0.5636053", "0.5535501", "0.55172944", "0.5413666", "0.5380411", "0.53663796", "0.5304195", "0.52977353", "0.5256102", "0.5206977", "0.51570046", "0.5108867", "0.5090636", "0.50079507", "0.5005115", "0.49890158", "0.49617404", "0.4953384", "0.49496338", "0.4943333", "0.4938032", "0.49377695", "0.49371013", "0.48892474", "0.4879942", "0.48412317", "0.4835042", "0.48108783", "0.4809765", "0.48069692", "0.47939944", "0.47783145", "0.47631812", "0.47408515", "0.47219324", "0.47214746", "0.4716085", "0.47150454", "0.47143012", "0.46807986", "0.4680691", "0.4679108", "0.46781546", "0.4672201", "0.4665336", "0.46624157", "0.4657677", "0.4656666", "0.4646265", "0.46374854", "0.4626893", "0.4623417", "0.46169728", "0.46097746", "0.46058506", "0.45994207", "0.45980203", "0.459653", "0.458499", "0.4583806", "0.45710316", "0.4562715", "0.4548842", "0.45392466", "0.45388052", "0.45359296", "0.45347303", "0.45305216", "0.45277935", "0.45229968", "0.4519931", "0.45197445", "0.45197284", "0.45160732", "0.4515749", "0.45092243", "0.45053992", "0.44994125", "0.44983986", "0.44983447", "0.44925055", "0.44910246", "0.44880784", "0.44855097", "0.448023", "0.44800323", "0.4479746", "0.44740906", "0.4472409", "0.44713724", "0.44711667", "0.44711", "0.44696054", "0.44676214", "0.4458835", "0.445852", "0.44480598", "0.44477978", "0.44473055" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, mutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Mutation", }) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "newUser": out.Values[i] = ec._Mutation_newUser(ctx, field) if out.Values[i] == graphql.Null { invalid = true } case "newAppliation": out.Values[i] = ec._Mutation_newAppliation(ctx, field) if out.Values[i] == graphql.Null { invalid = true } default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func cgounimpl() {\n\tthrow(\"cgo not implemented\")\n}" ]
[ "0.58951914", "0.5789157", "0.56343776", "0.55349874", "0.5516496", "0.54126674", "0.5380506", "0.53651625", "0.5303207", "0.5297547", "0.52558833", "0.52072686", "0.51567554", "0.51085794", "0.508947", "0.5007158", "0.50040805", "0.49892417", "0.4960484", "0.49534518", "0.49490517", "0.49424648", "0.49373418", "0.49367136", "0.49357283", "0.48906133", "0.4879801", "0.48414347", "0.4835298", "0.4810418", "0.4810253", "0.4806392", "0.47960514", "0.47785494", "0.47633868", "0.47411403", "0.47214967", "0.4721041", "0.47165513", "0.47153512", "0.47133312", "0.46809536", "0.46801886", "0.46794483", "0.46776083", "0.46707362", "0.46633914", "0.46626285", "0.4657592", "0.46561047", "0.46463773", "0.46384448", "0.4625341", "0.46210644", "0.46170443", "0.46095508", "0.46059948", "0.45982367", "0.45978078", "0.4596986", "0.45850873", "0.45840323", "0.4570754", "0.45618755", "0.4548203", "0.45382392", "0.4538029", "0.45360819", "0.45342618", "0.45304775", "0.45291564", "0.452381", "0.45203948", "0.45201117", "0.4518946", "0.45164886", "0.45164186", "0.45093197", "0.45046136", "0.4500351", "0.44988295", "0.4498462", "0.44921872", "0.4490083", "0.44874597", "0.44859907", "0.44797602", "0.44794062", "0.4478887", "0.44747335", "0.447302", "0.44706154", "0.4470536", "0.44703138", "0.4469773", "0.44673866", "0.44593135", "0.44589624", "0.44488844", "0.4447977", "0.44471195" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", }) var wg sync.WaitGroup out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "users": wg.Add(1) go func(i int, field graphql.CollectedField) { out.Values[i] = ec._Query_users(ctx, field) if out.Values[i] == graphql.Null { invalid = true } wg.Done() }(i, field) case "userById": wg.Add(1) go func(i int, field graphql.CollectedField) { out.Values[i] = ec._Query_userById(ctx, field) if out.Values[i] == graphql.Null { invalid = true } wg.Done() }(i, field) case "userByIds": wg.Add(1) go func(i int, field graphql.CollectedField) { out.Values[i] = ec._Query_userByIds(ctx, field) if out.Values[i] == graphql.Null { invalid = true } wg.Done() }(i, field) case "applications": wg.Add(1) go func(i int, field graphql.CollectedField) { out.Values[i] = ec._Query_applications(ctx, field) if out.Values[i] == graphql.Null { invalid = true } wg.Done() }(i, field) case "applicationByUserId": wg.Add(1) go func(i int, field graphql.CollectedField) { out.Values[i] = ec._Query_applicationByUserId(ctx, field) if out.Values[i] == graphql.Null { invalid = true } wg.Done() }(i, field) case "applicationByUserIds": wg.Add(1) go func(i int, field graphql.CollectedField) { out.Values[i] = ec._Query_applicationByUserIds(ctx, field) if out.Values[i] == graphql.Null { invalid = true } wg.Done() }(i, field) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = ec._Query___schema(ctx, field) default: panic("unknown field " + strconv.Quote(field.Name)) } } wg.Wait() if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func cioperation(asm *global.AssemblyWithComponents, ci *global.Operations, com *global.Component) error {\n\n\tpair_scm, perrscm := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-scm\")\n\tif perrscm != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrscm)\n\t}\n\n\tpair_enable, perrenable := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-enable\")\n\tif perrenable != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrenable)\n\t}\n\n\tif pair_scm.Value == GITLAB && pair_enable.Value == ENABLE {\n\t\tlog.Info(\"GitLab is working..\")\n\n\t\tpair_token, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-token\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-token value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_url, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-url\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-url value : %s\", perrtoken)\n\n\t\t}\n\t\tpair_apiversion, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-apiversion\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-apiversion value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_owner, perrowner := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-owner\")\n\t\tif perrowner != nil {\n\t\t\tlog.Error(\"Failed to get the ci-owner value : %s\", perrowner)\n\t\t}\n\n\t\tapi_host, apierr := config.GetString(\"api:host\")\n\t\tif apierr != nil {\n\t\t\treturn apierr\n\t\t}\n\n\t\tapi_version, apiverr := config.GetString(\"api:version\")\n\t\tif apiverr != nil {\n\t\t\treturn apiverr\n\t\t}\n\n\t\ttrigger_url := \"http://\" + api_host + \"/\" + api_version + \"/assembly/build/\" + asm.Id + \"/\" + com.Id\n\n\t\tclient := gogitlab.NewGitlab(pair_url.Value, pair_apiversion.Value, pair_token.Value)\n\n\t\terr := client.AddProjectHook(pair_owner.Value, trigger_url, false, false, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t} else {\n\t\tlog.Info(\"GitLab is skipped\")\n\t}\n\treturn nil\n\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}" ]
[ "0.58957493", "0.57890224", "0.5634927", "0.55365646", "0.5517367", "0.5414204", "0.5380421", "0.5367313", "0.530519", "0.5298157", "0.5256187", "0.520729", "0.5157703", "0.5108482", "0.5088959", "0.5006738", "0.50056857", "0.49891955", "0.49601772", "0.49536383", "0.49474543", "0.4941032", "0.4937261", "0.49371833", "0.4935779", "0.48898372", "0.4880983", "0.4841098", "0.48353028", "0.48108184", "0.480908", "0.48051006", "0.47925648", "0.4777952", "0.47638056", "0.47412705", "0.4722208", "0.47206172", "0.4715555", "0.47153008", "0.47123638", "0.46826577", "0.46793494", "0.46789354", "0.46778846", "0.46705785", "0.46640012", "0.46623862", "0.46580508", "0.46573684", "0.46467605", "0.4637481", "0.46272343", "0.4621879", "0.46180874", "0.46105066", "0.4606366", "0.4598552", "0.45976844", "0.45959467", "0.45852116", "0.45832124", "0.45723125", "0.45629054", "0.4549626", "0.4539504", "0.45388716", "0.45355004", "0.45347318", "0.453242", "0.4527843", "0.45229974", "0.45192558", "0.45187134", "0.45185712", "0.4515775", "0.45155033", "0.4508769", "0.4503325", "0.44994304", "0.44990364", "0.4498911", "0.44911814", "0.44902813", "0.44880268", "0.4485675", "0.44791022", "0.44788063", "0.44786975", "0.447282", "0.44724923", "0.4472069", "0.4471657", "0.44698405", "0.4469574", "0.44678274", "0.44582465", "0.4458026", "0.44483453", "0.44480035", "0.44473222" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "email": out.Values[i] = ec._User_email(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "contact": out.Values[i] = ec._User_contact(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "createAt": out.Values[i] = ec._User_createAt(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func cioperation(asm *global.AssemblyWithComponents, ci *global.Operations, com *global.Component) error {\n\n\tpair_scm, perrscm := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-scm\")\n\tif perrscm != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrscm)\n\t}\n\n\tpair_enable, perrenable := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-enable\")\n\tif perrenable != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrenable)\n\t}\n\n\tif pair_scm.Value == GITLAB && pair_enable.Value == ENABLE {\n\t\tlog.Info(\"GitLab is working..\")\n\n\t\tpair_token, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-token\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-token value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_url, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-url\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-url value : %s\", perrtoken)\n\n\t\t}\n\t\tpair_apiversion, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-apiversion\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-apiversion value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_owner, perrowner := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-owner\")\n\t\tif perrowner != nil {\n\t\t\tlog.Error(\"Failed to get the ci-owner value : %s\", perrowner)\n\t\t}\n\n\t\tapi_host, apierr := config.GetString(\"api:host\")\n\t\tif apierr != nil {\n\t\t\treturn apierr\n\t\t}\n\n\t\tapi_version, apiverr := config.GetString(\"api:version\")\n\t\tif apiverr != nil {\n\t\t\treturn apiverr\n\t\t}\n\n\t\ttrigger_url := \"http://\" + api_host + \"/\" + api_version + \"/assembly/build/\" + asm.Id + \"/\" + com.Id\n\n\t\tclient := gogitlab.NewGitlab(pair_url.Value, pair_apiversion.Value, pair_token.Value)\n\n\t\terr := client.AddProjectHook(pair_owner.Value, trigger_url, false, false, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t} else {\n\t\tlog.Info(\"GitLab is skipped\")\n\t}\n\treturn nil\n\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}" ]
[ "0.58957493", "0.57890224", "0.5634927", "0.55365646", "0.5517367", "0.5414204", "0.5380421", "0.5367313", "0.530519", "0.5298157", "0.5256187", "0.520729", "0.5157703", "0.5108482", "0.5088959", "0.5006738", "0.50056857", "0.49891955", "0.49601772", "0.49536383", "0.49474543", "0.4941032", "0.4937261", "0.49371833", "0.4935779", "0.48898372", "0.4880983", "0.4841098", "0.48353028", "0.48108184", "0.480908", "0.48051006", "0.47925648", "0.4777952", "0.47638056", "0.47412705", "0.4722208", "0.47206172", "0.4715555", "0.47153008", "0.47123638", "0.46826577", "0.46793494", "0.46789354", "0.46778846", "0.46705785", "0.46640012", "0.46623862", "0.46580508", "0.46573684", "0.46467605", "0.4637481", "0.46272343", "0.4621879", "0.46180874", "0.46105066", "0.4606366", "0.4598552", "0.45976844", "0.45959467", "0.45852116", "0.45832124", "0.45723125", "0.45629054", "0.4549626", "0.4539504", "0.45388716", "0.45355004", "0.45347318", "0.453242", "0.4527843", "0.45229974", "0.45192558", "0.45187134", "0.45185712", "0.4515775", "0.45155033", "0.4508769", "0.4503325", "0.44994304", "0.44990364", "0.4498911", "0.44911814", "0.44902813", "0.44880268", "0.4485675", "0.44791022", "0.44788063", "0.44786975", "0.447282", "0.44724923", "0.4472069", "0.4471657", "0.44698405", "0.4469574", "0.44678274", "0.44582465", "0.4458026", "0.44483453", "0.44480035", "0.44473222" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "locations": out.Values[i] = ec.___Directive_locations(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "args": out.Values[i] = ec.___Directive_args(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}", "func cioperation(asm *global.AssemblyWithComponents, ci *global.Operations, com *global.Component) error {\n\n\tpair_scm, perrscm := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-scm\")\n\tif perrscm != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrscm)\n\t}\n\n\tpair_enable, perrenable := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-enable\")\n\tif perrenable != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrenable)\n\t}\n\n\tif pair_scm.Value == GITLAB && pair_enable.Value == ENABLE {\n\t\tlog.Info(\"GitLab is working..\")\n\n\t\tpair_token, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-token\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-token value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_url, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-url\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-url value : %s\", perrtoken)\n\n\t\t}\n\t\tpair_apiversion, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-apiversion\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-apiversion value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_owner, perrowner := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-owner\")\n\t\tif perrowner != nil {\n\t\t\tlog.Error(\"Failed to get the ci-owner value : %s\", perrowner)\n\t\t}\n\n\t\tapi_host, apierr := config.GetString(\"api:host\")\n\t\tif apierr != nil {\n\t\t\treturn apierr\n\t\t}\n\n\t\tapi_version, apiverr := config.GetString(\"api:version\")\n\t\tif apiverr != nil {\n\t\t\treturn apiverr\n\t\t}\n\n\t\ttrigger_url := \"http://\" + api_host + \"/\" + api_version + \"/assembly/build/\" + asm.Id + \"/\" + com.Id\n\n\t\tclient := gogitlab.NewGitlab(pair_url.Value, pair_apiversion.Value, pair_token.Value)\n\n\t\terr := client.AddProjectHook(pair_owner.Value, trigger_url, false, false, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t} else {\n\t\tlog.Info(\"GitLab is skipped\")\n\t}\n\treturn nil\n\n}" ]
[ "0.58961266", "0.5789828", "0.5636053", "0.5535501", "0.55172944", "0.5413666", "0.5380411", "0.53663796", "0.5304195", "0.52977353", "0.5256102", "0.5206977", "0.51570046", "0.5108867", "0.5090636", "0.50079507", "0.5005115", "0.49890158", "0.49617404", "0.4953384", "0.49496338", "0.4943333", "0.4938032", "0.49377695", "0.49371013", "0.48892474", "0.4879942", "0.48412317", "0.4835042", "0.48108783", "0.4809765", "0.48069692", "0.47939944", "0.47783145", "0.47631812", "0.47408515", "0.47219324", "0.47214746", "0.4716085", "0.47150454", "0.47143012", "0.46807986", "0.4680691", "0.4679108", "0.46781546", "0.4672201", "0.4665336", "0.46624157", "0.4657677", "0.4656666", "0.4646265", "0.46374854", "0.4626893", "0.4623417", "0.46169728", "0.46097746", "0.46058506", "0.45994207", "0.45980203", "0.459653", "0.458499", "0.4583806", "0.45710316", "0.4562715", "0.4548842", "0.45392466", "0.45388052", "0.45359296", "0.45347303", "0.45305216", "0.45277935", "0.45229968", "0.4519931", "0.45197445", "0.45197284", "0.45160732", "0.4515749", "0.45092243", "0.45053992", "0.44994125", "0.44983986", "0.44983447", "0.44925055", "0.44910246", "0.44880784", "0.44855097", "0.448023", "0.44800323", "0.4479746", "0.44740906", "0.4472409", "0.44713724", "0.44711667", "0.44711", "0.44696054", "0.44676214", "0.4458835", "0.445852", "0.44480598", "0.44477978", "0.44473055" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": out.Values[i] = ec.___EnumValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "description": out.Values[i] = ec.___EnumValue_description(ctx, field, obj) case "isDeprecated": out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "deprecationReason": out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func cgounimpl() {\n\tthrow(\"cgo not implemented\")\n}" ]
[ "0.58951914", "0.5789157", "0.56343776", "0.55349874", "0.5516496", "0.54126674", "0.5380506", "0.53651625", "0.5303207", "0.5297547", "0.52558833", "0.52072686", "0.51567554", "0.51085794", "0.508947", "0.5007158", "0.50040805", "0.49892417", "0.4960484", "0.49534518", "0.49490517", "0.49424648", "0.49373418", "0.49367136", "0.49357283", "0.48906133", "0.4879801", "0.48414347", "0.4835298", "0.4810418", "0.4810253", "0.4806392", "0.47960514", "0.47785494", "0.47633868", "0.47411403", "0.47214967", "0.4721041", "0.47165513", "0.47153512", "0.47133312", "0.46809536", "0.46801886", "0.46794483", "0.46776083", "0.46707362", "0.46633914", "0.46626285", "0.4657592", "0.46561047", "0.46463773", "0.46384448", "0.4625341", "0.46210644", "0.46170443", "0.46095508", "0.46059948", "0.45982367", "0.45978078", "0.4596986", "0.45850873", "0.45840323", "0.4570754", "0.45618755", "0.4548203", "0.45382392", "0.4538029", "0.45360819", "0.45342618", "0.45304775", "0.45291564", "0.452381", "0.45203948", "0.45201117", "0.4518946", "0.45164886", "0.45164186", "0.45093197", "0.45046136", "0.4500351", "0.44988295", "0.4498462", "0.44921872", "0.4490083", "0.44874597", "0.44859907", "0.44797602", "0.44794062", "0.4478887", "0.44747335", "0.447302", "0.44706154", "0.4470536", "0.44703138", "0.4469773", "0.44673866", "0.44593135", "0.44589624", "0.44488844", "0.4447977", "0.44471195" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": out.Values[i] = ec.___Field_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "description": out.Values[i] = ec.___Field_description(ctx, field, obj) case "args": out.Values[i] = ec.___Field_args(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "type": out.Values[i] = ec.___Field_type(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "isDeprecated": out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "deprecationReason": out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func cioperation(asm *global.AssemblyWithComponents, ci *global.Operations, com *global.Component) error {\n\n\tpair_scm, perrscm := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-scm\")\n\tif perrscm != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrscm)\n\t}\n\n\tpair_enable, perrenable := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-enable\")\n\tif perrenable != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrenable)\n\t}\n\n\tif pair_scm.Value == GITLAB && pair_enable.Value == ENABLE {\n\t\tlog.Info(\"GitLab is working..\")\n\n\t\tpair_token, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-token\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-token value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_url, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-url\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-url value : %s\", perrtoken)\n\n\t\t}\n\t\tpair_apiversion, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-apiversion\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-apiversion value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_owner, perrowner := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-owner\")\n\t\tif perrowner != nil {\n\t\t\tlog.Error(\"Failed to get the ci-owner value : %s\", perrowner)\n\t\t}\n\n\t\tapi_host, apierr := config.GetString(\"api:host\")\n\t\tif apierr != nil {\n\t\t\treturn apierr\n\t\t}\n\n\t\tapi_version, apiverr := config.GetString(\"api:version\")\n\t\tif apiverr != nil {\n\t\t\treturn apiverr\n\t\t}\n\n\t\ttrigger_url := \"http://\" + api_host + \"/\" + api_version + \"/assembly/build/\" + asm.Id + \"/\" + com.Id\n\n\t\tclient := gogitlab.NewGitlab(pair_url.Value, pair_apiversion.Value, pair_token.Value)\n\n\t\terr := client.AddProjectHook(pair_owner.Value, trigger_url, false, false, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t} else {\n\t\tlog.Info(\"GitLab is skipped\")\n\t}\n\treturn nil\n\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}" ]
[ "0.58957493", "0.57890224", "0.5634927", "0.55365646", "0.5517367", "0.5414204", "0.5380421", "0.5367313", "0.530519", "0.5298157", "0.5256187", "0.520729", "0.5157703", "0.5108482", "0.5088959", "0.5006738", "0.50056857", "0.49891955", "0.49601772", "0.49536383", "0.49474543", "0.4941032", "0.4937261", "0.49371833", "0.4935779", "0.48898372", "0.4880983", "0.4841098", "0.48353028", "0.48108184", "0.480908", "0.48051006", "0.47925648", "0.4777952", "0.47638056", "0.47412705", "0.4722208", "0.47206172", "0.4715555", "0.47153008", "0.47123638", "0.46826577", "0.46793494", "0.46789354", "0.46778846", "0.46705785", "0.46640012", "0.46623862", "0.46580508", "0.46573684", "0.46467605", "0.4637481", "0.46272343", "0.4621879", "0.46180874", "0.46105066", "0.4606366", "0.4598552", "0.45976844", "0.45959467", "0.45852116", "0.45832124", "0.45723125", "0.45629054", "0.4549626", "0.4539504", "0.45388716", "0.45355004", "0.45347318", "0.453242", "0.4527843", "0.45229974", "0.45192558", "0.45187134", "0.45185712", "0.4515775", "0.45155033", "0.4508769", "0.4503325", "0.44994304", "0.44990364", "0.4498911", "0.44911814", "0.44902813", "0.44880268", "0.4485675", "0.44791022", "0.44788063", "0.44786975", "0.447282", "0.44724923", "0.4472069", "0.4471657", "0.44698405", "0.4469574", "0.44678274", "0.44582465", "0.4458026", "0.44483453", "0.44480035", "0.44473222" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": out.Values[i] = ec.___InputValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "description": out.Values[i] = ec.___InputValue_description(ctx, field, obj) case "type": out.Values[i] = ec.___InputValue_type(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "defaultValue": out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func cioperation(asm *global.AssemblyWithComponents, ci *global.Operations, com *global.Component) error {\n\n\tpair_scm, perrscm := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-scm\")\n\tif perrscm != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrscm)\n\t}\n\n\tpair_enable, perrenable := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-enable\")\n\tif perrenable != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrenable)\n\t}\n\n\tif pair_scm.Value == GITLAB && pair_enable.Value == ENABLE {\n\t\tlog.Info(\"GitLab is working..\")\n\n\t\tpair_token, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-token\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-token value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_url, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-url\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-url value : %s\", perrtoken)\n\n\t\t}\n\t\tpair_apiversion, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-apiversion\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-apiversion value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_owner, perrowner := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-owner\")\n\t\tif perrowner != nil {\n\t\t\tlog.Error(\"Failed to get the ci-owner value : %s\", perrowner)\n\t\t}\n\n\t\tapi_host, apierr := config.GetString(\"api:host\")\n\t\tif apierr != nil {\n\t\t\treturn apierr\n\t\t}\n\n\t\tapi_version, apiverr := config.GetString(\"api:version\")\n\t\tif apiverr != nil {\n\t\t\treturn apiverr\n\t\t}\n\n\t\ttrigger_url := \"http://\" + api_host + \"/\" + api_version + \"/assembly/build/\" + asm.Id + \"/\" + com.Id\n\n\t\tclient := gogitlab.NewGitlab(pair_url.Value, pair_apiversion.Value, pair_token.Value)\n\n\t\terr := client.AddProjectHook(pair_owner.Value, trigger_url, false, false, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t} else {\n\t\tlog.Info(\"GitLab is skipped\")\n\t}\n\treturn nil\n\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}" ]
[ "0.58957493", "0.57890224", "0.5634927", "0.55365646", "0.5517367", "0.5414204", "0.5380421", "0.5367313", "0.530519", "0.5298157", "0.5256187", "0.520729", "0.5157703", "0.5108482", "0.5088959", "0.5006738", "0.50056857", "0.49891955", "0.49601772", "0.49536383", "0.49474543", "0.4941032", "0.4937261", "0.49371833", "0.4935779", "0.48898372", "0.4880983", "0.4841098", "0.48353028", "0.48108184", "0.480908", "0.48051006", "0.47925648", "0.4777952", "0.47638056", "0.47412705", "0.4722208", "0.47206172", "0.4715555", "0.47153008", "0.47123638", "0.46826577", "0.46793494", "0.46789354", "0.46778846", "0.46705785", "0.46640012", "0.46623862", "0.46580508", "0.46573684", "0.46467605", "0.4637481", "0.46272343", "0.4621879", "0.46180874", "0.46105066", "0.4606366", "0.4598552", "0.45976844", "0.45959467", "0.45852116", "0.45832124", "0.45723125", "0.45629054", "0.4549626", "0.4539504", "0.45388716", "0.45355004", "0.45347318", "0.453242", "0.4527843", "0.45229974", "0.45192558", "0.45187134", "0.45185712", "0.4515775", "0.45155033", "0.4508769", "0.4503325", "0.44994304", "0.44990364", "0.4498911", "0.44911814", "0.44902813", "0.44880268", "0.4485675", "0.44791022", "0.44788063", "0.44786975", "0.447282", "0.44724923", "0.4472069", "0.4471657", "0.44698405", "0.4469574", "0.44678274", "0.44582465", "0.4458026", "0.44483453", "0.44480035", "0.44473222" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "types": out.Values[i] = ec.___Schema_types(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "queryType": out.Values[i] = ec.___Schema_queryType(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "mutationType": out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) case "subscriptionType": out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) case "directives": out.Values[i] = ec.___Schema_directives(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}", "func cioperation(asm *global.AssemblyWithComponents, ci *global.Operations, com *global.Component) error {\n\n\tpair_scm, perrscm := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-scm\")\n\tif perrscm != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrscm)\n\t}\n\n\tpair_enable, perrenable := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-enable\")\n\tif perrenable != nil {\n\t\tlog.Error(\"Failed to get the domain value : %s\", perrenable)\n\t}\n\n\tif pair_scm.Value == GITLAB && pair_enable.Value == ENABLE {\n\t\tlog.Info(\"GitLab is working..\")\n\n\t\tpair_token, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-token\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-token value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_url, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-url\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-url value : %s\", perrtoken)\n\n\t\t}\n\t\tpair_apiversion, perrtoken := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-apiversion\")\n\t\tif perrtoken != nil {\n\t\t\tlog.Error(\"Failed to get the ci-apiversion value : %s\", perrtoken)\n\n\t\t}\n\n\t\tpair_owner, perrowner := global.ParseKeyValuePair(ci.OperationRequirements, \"ci-owner\")\n\t\tif perrowner != nil {\n\t\t\tlog.Error(\"Failed to get the ci-owner value : %s\", perrowner)\n\t\t}\n\n\t\tapi_host, apierr := config.GetString(\"api:host\")\n\t\tif apierr != nil {\n\t\t\treturn apierr\n\t\t}\n\n\t\tapi_version, apiverr := config.GetString(\"api:version\")\n\t\tif apiverr != nil {\n\t\t\treturn apiverr\n\t\t}\n\n\t\ttrigger_url := \"http://\" + api_host + \"/\" + api_version + \"/assembly/build/\" + asm.Id + \"/\" + com.Id\n\n\t\tclient := gogitlab.NewGitlab(pair_url.Value, pair_apiversion.Value, pair_token.Value)\n\n\t\terr := client.AddProjectHook(pair_owner.Value, trigger_url, false, false, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t} else {\n\t\tlog.Info(\"GitLab is skipped\")\n\t}\n\treturn nil\n\n}" ]
[ "0.58961266", "0.5789828", "0.5636053", "0.5535501", "0.55172944", "0.5413666", "0.5380411", "0.53663796", "0.5304195", "0.52977353", "0.5256102", "0.5206977", "0.51570046", "0.5108867", "0.5090636", "0.50079507", "0.5005115", "0.49890158", "0.49617404", "0.4953384", "0.49496338", "0.4943333", "0.4938032", "0.49377695", "0.49371013", "0.48892474", "0.4879942", "0.48412317", "0.4835042", "0.48108783", "0.4809765", "0.48069692", "0.47939944", "0.47783145", "0.47631812", "0.47408515", "0.47219324", "0.47214746", "0.4716085", "0.47150454", "0.47143012", "0.46807986", "0.4680691", "0.4679108", "0.46781546", "0.4672201", "0.4665336", "0.46624157", "0.4657677", "0.4656666", "0.4646265", "0.46374854", "0.4626893", "0.4623417", "0.46169728", "0.46097746", "0.46058506", "0.45994207", "0.45980203", "0.459653", "0.458499", "0.4583806", "0.45710316", "0.4562715", "0.4548842", "0.45392466", "0.45388052", "0.45359296", "0.45347303", "0.45305216", "0.45277935", "0.45229968", "0.4519931", "0.45197445", "0.45197284", "0.45160732", "0.4515749", "0.45092243", "0.45053992", "0.44994125", "0.44983986", "0.44983447", "0.44925055", "0.44910246", "0.44880784", "0.44855097", "0.448023", "0.44800323", "0.4479746", "0.44740906", "0.4472409", "0.44713724", "0.44711667", "0.44711", "0.44696054", "0.44676214", "0.4458835", "0.445852", "0.44480598", "0.44477978", "0.44473055" ]
0.0
-1
nolint: gocyclo, errcheck, gas, goconst
func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false for i, field := range fields { out.Keys[i] = field.Alias switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": out.Values[i] = ec.___Type_kind(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "name": out.Values[i] = ec.___Type_name(ctx, field, obj) case "description": out.Values[i] = ec.___Type_description(ctx, field, obj) case "fields": out.Values[i] = ec.___Type_fields(ctx, field, obj) case "interfaces": out.Values[i] = ec.___Type_interfaces(ctx, field, obj) case "possibleTypes": out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) case "enumValues": out.Values[i] = ec.___Type_enumValues(ctx, field, obj) case "inputFields": out.Values[i] = ec.___Type_inputFields(ctx, field, obj) case "ofType": out.Values[i] = ec.___Type_ofType(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } if invalid { return graphql.Null } return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tusing x2 = 2\n\t\t\t\tx = 3\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\tusing y2 = 2\n\t\t\t\t\ty = 3\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t\tUnsupportedJSFeatures: compat.Using,\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: WARNING: This assignment will throw because \"y\" is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func (comp *compiler) patchConsts(consts map[string]uint64) {\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.IntFlags:\n\t\t\t// Unsupported flag values are dropped.\n\t\t\tn := decl.(*ast.IntFlags)\n\t\t\tvar values []*ast.Int\n\t\t\tfor _, v := range n.Values {\n\t\t\t\tif comp.patchIntConst(&v.Value, &v.Ident, consts, nil) {\n\t\t\t\t\tvalues = append(values, v)\n\t\t\t\t}\n\t\t\t}\n\t\t\tn.Values = values\n\t\tcase *ast.Resource, *ast.Struct, *ast.Call, *ast.TypeDef:\n\t\t\t// Walk whole tree and replace consts in Type's and Int's.\n\t\t\tmissing := \"\"\n\t\t\tcomp.foreachType(decl, func(_ *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tcomp.patchIntConst(&arg.Value, &arg.Ident, consts, &missing)\n\t\t\t\t\t\tif arg.HasColon {\n\t\t\t\t\t\t\tcomp.patchIntConst(&arg.Value2,\n\t\t\t\t\t\t\t\t&arg.Ident2, consts, &missing)\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\tif n, ok := decl.(*ast.Resource); ok {\n\t\t\t\tfor _, v := range n.Values {\n\t\t\t\t\tcomp.patchIntConst(&v.Value, &v.Ident, consts, &missing)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif n, ok := decl.(*ast.Struct); ok {\n\t\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\t\tsz := attr.Args[0]\n\t\t\t\t\t\tcomp.patchIntConst(&sz.Value, &sz.Ident, consts, &missing)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif missing == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Produce a warning about unsupported syscall/resource/struct.\n\t\t\t// TODO(dvyukov): we should transitively remove everything that\n\t\t\t// depends on unsupported things.\n\t\t\t// Potentially we still can get, say, a bad int range error\n\t\t\t// due to the 0 const value.\n\t\t\tpos, typ, name := decl.Info()\n\t\t\tif id := typ + \" \" + name; !comp.unsupported[id] {\n\t\t\t\tcomp.unsupported[id] = true\n\t\t\t\tcomp.warning(pos, \"unsupported %v: %v due to missing const %v\",\n\t\t\t\t\ttyp, name, missing)\n\t\t\t}\n\t\t\tif c, ok := decl.(*ast.Call); ok {\n\t\t\t\tc.NR = ^uint64(0) // mark as unused to not generate it\n\t\t\t}\n\t\t}\n\t}\n}", "func TestForbidConstAssignWhenBundling(t *testing.T) {\n\tdefault_suite.expectBundled(t, bundled{\n\t\tfiles: map[string]string{\n\t\t\t\"/entry.js\": `\n\t\t\t\tconst x = 1\n\t\t\t\tx = 2\n\t\t\t\tfunction foo() {\n\t\t\t\t\tconst y = 1\n\t\t\t\t\ty = 2\n\t\t\t\t}\n\t\t\t`,\n\t\t},\n\t\tentryPaths: []string{\"/entry.js\"},\n\t\toptions: config.Options{\n\t\t\tMode: config.ModeBundle,\n\t\t\tAbsOutputFile: \"/out.js\",\n\t\t},\n\t\texpectedScanLog: `entry.js: ERROR: Cannot assign to \"x\" because it is a constant\nentry.js: NOTE: The symbol \"x\" was declared a constant here:\nentry.js: ERROR: Cannot assign to \"y\" because it is a constant\nentry.js: NOTE: The symbol \"y\" was declared a constant here:\n`,\n\t})\n}", "func consts() {\n\tconst (\n\t\tfilename = \"abc.txt\"\n\t\ta, b = 3, 4\n\t)\n\tvar c int\n\tc = int(math.Sqrt(a*a + b*b))\n\tfmt.Println(filename, c)\n\n}", "func mainerr() (retErr error) {\n\tfs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)\n\tfs.Usage = func() {\n\t\tmainUsage(os.Stderr)\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tif len(fs.Args()) == 0 {\n\t\treturn fmt.Errorf(\"consttofile takes at least one argument\")\n\t}\n\n\tenvPkg := os.Getenv(\"GOPACKAGE\")\n\n\tconfig := &packages.Config{\n\t\tMode: packages.LoadSyntax,\n\t\tFset: token.NewFileSet(),\n\t\tTests: true,\n\t}\n\n\tpkgs, err := packages.Load(config, \".\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not load package from current dir: %v\", err)\n\t}\n\n\tforTest := regexp.MustCompile(` \\[[^\\]]+\\]$`)\n\n\ttestPkgs := make(map[string]*packages.Package)\n\tvar nonTestPkg *packages.Package\n\n\t// Becase of https://github.com/golang/go/issues/27910 we have to\n\t// apply some janky logic to find the \"right\" package\n\tfor _, p := range pkgs {\n\t\tswitch {\n\t\tcase strings.HasSuffix(p.PkgPath, \".test\"):\n\t\t\t// we don't ever want this package\n\t\t\tcontinue\n\t\tcase forTest.MatchString(p.ID):\n\t\t\ttestPkgs[p.Name] = p\n\t\tdefault:\n\t\t\tnonTestPkg = p\n\t\t}\n\t}\n\n\tids := func() []string {\n\t\tvar ids []string\n\t\tfor _, p := range pkgs {\n\t\t\tids = append(ids, p.ID)\n\t\t}\n\t\tsort.Strings(ids)\n\t\treturn ids\n\t}\n\n\tif nonTestPkg == nil {\n\t\treturn fmt.Errorf(\"always expect to have the actual package. Got %v\", ids())\n\t}\n\n\tvar pkg *packages.Package\n\n\tif strings.HasSuffix(envPkg, \"_test\") {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\treturn fmt.Errorf(\"called with package name %v, but go/packages did not give us such a package. Got %v\", envPkg, ids())\n\t\t}\n\t} else {\n\t\tif pkg = testPkgs[envPkg]; pkg == nil {\n\t\t\tpkg = nonTestPkg\n\t\t}\n\t}\n\n\tfor _, cn := range fs.Args() {\n\t\tco := pkg.Types.Scope().Lookup(cn)\n\t\tif co == nil {\n\t\t\treturn fmt.Errorf(\"failed to find const %v\\n\", cn)\n\t\t}\n\n\t\tc, ok := co.(*types.Const)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"found %v, but it was not a const, instead it was a %T\", cn, co)\n\t\t}\n\n\t\tif c.Val().Kind() != constant.String {\n\t\t\treturn fmt.Errorf(\"expected %v to be a string constant; got %v\", cn, c.Val().Kind())\n\t\t}\n\n\t\ti := strings.LastIndex(cn, \"_\")\n\t\tif i == -1 || i == len(cn)-1 {\n\t\t\treturn fmt.Errorf(\"constant %v does not specifcy an extension\", cn)\n\t\t}\n\n\t\tfn := \"gen_\" + cn[:i] + \"_consttofile\" + \".\" + cn[i+1:]\n\n\t\tif err := ioutil.WriteFile(fn, []byte(constant.StringVal(c.Val())), 0666); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to %v: %v\", fn, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Validate_const_rec(name string, cafType ICafType, val *TConstValue) {\n\tif (cafType.IsVoid()) {\n\t\tpanic(\"type error: cannot declare a void const: \" + name)\n\t}\n\n\tif cafType.IsBaseType() {\n\t\tswitch(cafType.(*TBaseType).GetBase()) {\n\t\tcase TYPE_STRING:\n\t\t\tif val.GetType() != CV_STRING {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as string\")\n\t\t\t}\n\t\tcase TYPE_BOOL:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as bool\")\n\t\t\t}\n\t\tcase TYPE_I8:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as byte\")\n\t\t\t}\n\t\tcase TYPE_I16:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i16\")\n\t\t\t}\n\t\tcase TYPE_I32:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i32\")\n\t\t\t}\n\n\t\tcase TYPE_I64:\n\t\t\tif (val.GetType() != CV_INTEGER) {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as i64\")\n\t\t\t}\n\t\tcase TYPE_DOUBLE:\n\t\t\tif val.GetType() != CV_INTEGER && val.GetType() != CV_DOUBLE {\n\t\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as double\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"compiler error: no const of base type \" + name)\n\t\t}\n\t} else if (cafType.IsEnum()) {\n\t\tif (val.GetType() != CV_IDENTIFIER) {\n\t\t\tpanic(\"type error: const \\\"\" + name + \"\\\" was declared as enum\")\n\t\t}\n\t\t/*\n// see if there's a dot in the identifier\nstd::string name_portion = value->get_identifier_name();\n\nconst vector<t_enum_value*>& enum_values = ((t_enum*)type)->get_constants();\nvector<t_enum_value*>::const_iterator c_iter;\nbool found = false;\n\nfor (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) {\nif ((*c_iter)->get_name() == name_portion) {\nfound = true;\nbreak;\n}\n}\nif (!found) {\n\tpanic(\"type error: const \" + name + \" was declared as type \" + cafType.GetName() + \" which is an enum, but \" + val.GetIdentifier() + \" is not a valid value for that enum\")\n}\n} else if (cafType.IsStruct() || cafType.IsXception()) {\nif (val.GetType() != CV_MAP) {\npanic(\"type error: const \\\"\" + name + \"\\\" was declared as struct/xception\")\n}\nconst vector<t_field*>& fields = ((t_struct*)type)->get_members();\nvector<t_field*>::const_iterator f_iter;\n\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nif (v_iter->first->get_type() != t_const_value::CV_STRING) {\nthrow \"type error: \" + name + \" struct key must be string\";\n}\nt_type* field_type = NULL;\nfor (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {\nif ((*f_iter)->get_name() == v_iter->first->get_string()) {\nfield_type = (*f_iter)->get_type();\n}\n}\nif (field_type == NULL) {\nthrow \"type error: \" + type->get_name() + \" has no field \" + v_iter->first->get_string();\n}\n\nvalidate_const_rec(name + \".\" + v_iter->first->get_string(), field_type, v_iter->second);\n}\n} else if (type->is_map()) {\nt_type* k_type = ((t_map*)type)->get_key_type();\nt_type* v_type = ((t_map*)type)->get_val_type();\nconst map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();\nmap<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<key>\", k_type, v_iter->first);\nvalidate_const_rec(name + \"<val>\", v_type, v_iter->second);\n}\n} else if (type->is_list() || type->is_set()) {\nt_type* e_type;\nif (type->is_list()) {\ne_type = ((t_list*)type)->get_elem_type();\n} else {\ne_type = ((t_set*)type)->get_elem_type();\n}\nconst vector<t_const_value*>& val = value->get_list();\nvector<t_const_value*>::const_iterator v_iter;\nfor (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {\nvalidate_const_rec(name + \"<elem>\", e_type, *v_iter);\n}\n*/\n\t}\n}", "func (comp *compiler) extractConsts() map[string]*ConstInfo {\n\tinfos := make(map[string]*constInfo)\n\tfor _, decl := range comp.desc.Nodes {\n\t\tpos, _, _ := decl.Info()\n\t\tinfo := getConstInfo(infos, pos)\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Include:\n\t\t\tinfo.includeArray = append(info.includeArray, n.File.Value)\n\t\tcase *ast.Incdir:\n\t\t\tinfo.incdirArray = append(info.incdirArray, n.Dir.Value)\n\t\tcase *ast.Define:\n\t\t\tv := fmt.Sprint(n.Value.Value)\n\t\t\tswitch {\n\t\t\tcase n.Value.CExpr != \"\":\n\t\t\t\tv = n.Value.CExpr\n\t\t\tcase n.Value.Ident != \"\":\n\t\t\t\tv = n.Value.Ident\n\t\t\t}\n\t\t\tname := n.Name.Name\n\t\t\tinfo.defines[name] = v\n\t\t\tinfo.consts[name] = true\n\t\tcase *ast.Call:\n\t\t\tif comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, \"syz_\") {\n\t\t\t\tinfo.consts[comp.target.SyscallPrefix+n.CallName] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch decl.(type) {\n\t\tcase *ast.Call, *ast.Struct, *ast.Resource, *ast.TypeDef:\n\t\t\tcomp.foreachType(decl, func(t *ast.Type, desc *typeDesc,\n\t\t\t\targs []*ast.Type, _ prog.IntTypeCommon) {\n\t\t\t\tfor i, arg := range args {\n\t\t\t\t\tif desc.Args[i].Type.Kind == kindInt {\n\t\t\t\t\t\tif arg.Ident != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident] = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif arg.Ident2 != \"\" {\n\t\t\t\t\t\t\tinfo := getConstInfo(infos, arg.Pos2)\n\t\t\t\t\t\t\tinfo.consts[arg.Ident2] = true\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\tfor _, decl := range comp.desc.Nodes {\n\t\tswitch n := decl.(type) {\n\t\tcase *ast.Struct:\n\t\t\tfor _, attr := range n.Attrs {\n\t\t\t\tif attr.Ident == \"size\" {\n\t\t\t\t\tinfo := getConstInfo(infos, attr.Pos)\n\t\t\t\t\tinfo.consts[attr.Args[0].Ident] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomp.desc.Walk(ast.Recursive(func(n0 ast.Node) {\n\t\tif n, ok := n0.(*ast.Int); ok {\n\t\t\tinfo := getConstInfo(infos, n.Pos)\n\t\t\tinfo.consts[n.Ident] = true\n\t\t}\n\t}))\n\n\treturn convertConstInfo(infos)\n}", "func main() {\n\tconst a int = 80\n\t\n\t// const b int // ERROR: value is missing\n\tconst (\n\t\tb = 90\n\t\tc = \"A\"\n\t)\n\n\t// iota helps to define the sequence of constants\n\tconst (\n\t\tday1 = iota\n\t\tday2\n\t\tday3\n\t\tday4\n\t\tday5\n\t\tday6\n\t\tday7\n\t)\n\n\tconst (\n\t\tc1 = iota + 1\n\t\tc2\n\t\tc3\n\t\tc4\n\t)\n\n\tconst (\n\t\ts1 = string(iota + 65)\n\t\ts2\n\t\ts3\n\t\ts4\n\t)\n\n\tfmt.Println(a, b, c)\n\tfmt.Println(day1, day2, day3, day4, day5, day6, day7) // 0, 1, 2, 3, 4, 5, 6, 7\n\tfmt.Println(c1, c2, c3, c4) // 1, 2, 3, 4\n\tfmt.Println(s1, s2, s3, s4) // A, B, C, D\n}", "func execNewConst(_ int, p *gop.Context) {\n\targs := p.GetArgs(5)\n\tret := types.NewConst(token.Pos(args[0].(int)), args[1].(*types.Package), args[2].(string), args[3].(types.Type), args[4].(constant.Value))\n\tp.Ret(5, ret)\n}", "func Constants() {\n\tfmt.Printf(\"\\n****Running basic.Constants(), constants example \")\n\tconst World = \"世界\"\n\tfmt.Println(\"\\n Hello\", World)\n\tfmt.Println(\"Happy\", pi, \"Day\")\n\n\tconst Truth = true\n\tfmt.Println(\"Go rules?\", Truth)\n}", "func main() {\n\n\tconst owo = \"Hello\" // It's a constant we can't change the value\n\t// owo = \"a\" Error: cannot assign to owo (untyped string constant \"Hello\")\n\n\tfmt.Println(owo)\n\n\tvar one uint16 = 12 // unsigned 16-bit integer called one.\n\tvar two bool = false // A boolean value called two.\n\tvar three float32 = 3.34 // A 32-bit float called three.\n\n\tfmt.Println(one, two, three)\n\n\n}", "func TestConstants(t *testing.T) {\n\tif MaxRune != unicode.MaxRune {\n\t\tt.Errorf(\"utf8.MaxRune is wrong: %x should be %x\", MaxRune, unicode.MaxRune)\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tt.Errorf(\"utf8.RuneError is wrong: %x should be %x\", RuneError, unicode.ReplacementChar)\n\t}\n}", "func TestConst(t *testing.T) {\n\tfor val, out := range map[interface{}]string{\n\t\tadsbtype.CA0: \"adsbtype.CA: Level 1\",\n\t\tadsbtype.CC0: \"adsbtype.CC: Not supported\",\n\t\tadsbtype.CF0: \"adsbtype.CF: ADS-B message, non-transponder device with ICAO address\",\n\t\tadsbtype.DF0: \"adsbtype.DF: Short air-air surveillance (ACAS)\",\n\t\tadsbtype.DR0: \"adsbtype.DR: No request\",\n\t\tadsbtype.FS0: \"adsbtype.FS: No alert, no SPI, airborne\",\n\t\tadsbtype.RI0: \"adsbtype.RI: No ACAS\",\n\t\tadsbtype.SL0: \"adsbtype.SL: ACAS inoperative\",\n\t\tadsbtype.VS0: \"adsbtype.VS: Airborne\",\n\n\t\tadsbtype.ATS0: \"adsbtype.ATS: Barometric altitude\",\n\t\tadsbtype.BDS02: \"adsbtype.BDS: Linked Comm-B, segment 2\",\n\t\tadsbtype.SSS0: \"adsbtype.SSS: No condition information\",\n\t\tadsbtype.TRS0: \"adsbtype.TRS: No capability\",\n\n\t\tadsbtype.TYPE0: \"adsbtype.TYPE: No position information\",\n\t} {\n\t\tresult := fmt.Sprintf(\"%T: %s\", val, val)\n\t\tif result != out {\n\t\t\tt.Errorf(\"expected %s | received %s\\n\", out, result)\n\t\t}\n\t}\n}", "func fetchValues(arch string, vals []string, includes []string, incdirs []string, defines map[string]string, cflags []string) (map[string]uint64, error) {\n\tbin, out, err := runCompiler(arch, nil, includes, incdirs, nil, cflags, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t}\n\tos.Remove(bin)\n\n\tvalMap := make(map[string]bool)\n\tfor _, val := range vals {\n\t\tvalMap[val] = true\n\t}\n\n\tundeclared := make(map[string]bool)\n\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\tif err != nil {\n\t\tfor _, errMsg := range []string{\n\t\t\t\"error: ‘([a-zA-Z0-9_]+)’ undeclared\",\n\t\t\t\"note: in expansion of macro ‘([a-zA-Z0-9_]+)’\",\n\t\t} {\n\t\t\tre := regexp.MustCompile(errMsg)\n\t\t\tmatches := re.FindAllSubmatch(out, -1)\n\t\t\tfor _, match := range matches {\n\t\t\t\tval := string(match[1])\n\t\t\t\tif !undeclared[val] && valMap[val] {\n\t\t\t\t\tlogf(0, \"undefined const: %v\", val)\n\t\t\t\t\tundeclared[val] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbin, out, err = runCompiler(arch, vals, includes, incdirs, defines, cflags, undeclared)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to run gcc: %v\\n%v\", err, string(out))\n\t\t}\n\t}\n\tdefer os.Remove(bin)\n\n\tout, err = exec.Command(bin).CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to run flags binary: %v\\n%v\", err, string(out))\n\t}\n\n\tflagVals := strings.Split(string(out), \" \")\n\tif len(flagVals) != len(vals)-len(undeclared) {\n\t\tfailf(\"fetched wrong number of values %v != %v - %v\", len(flagVals), len(vals), len(undeclared))\n\t}\n\tres := make(map[string]uint64)\n\tj := 0\n\tfor _, v := range flagVals {\n\t\tname := vals[j]\n\t\tj++\n\t\tfor undeclared[name] {\n\t\t\tname = vals[j]\n\t\t\tj++\n\t\t}\n\t\tn, err := strconv.ParseUint(v, 10, 64)\n\t\tif err != nil {\n\t\t\tfailf(\"failed to parse value: %v (%v)\", err, v)\n\t\t}\n\t\tres[name] = n\n\t}\n\treturn res, nil\n}", "func GoShouldIncludeThisInItsStandardLibs(x int) int {\n\tif x < 0 {\n\t\treturn -x\n\t} else {\n\t\treturn x\n\t}\n}", "func Lint(description string) error {\n\treturn errors.New(\"Not implemented\")\n}", "func main() {\n\n\tconst pi = 3.14159\n\n\tconst (\n\t\tred = iota + 1\n\t\tyellow\n\t\tgreen\n\t\tbrown\n\t\tblue\n\t\tpink\n\t\tblack\n\t)\n\n\tfmt.Printf(\"Pi approximately: %v \\n\", pi)\n\tfmt.Printf(\"Red: %v point \\n\", red)\n\tfmt.Printf(\"Blue: %v points \\n\", blue)\n\tfmt.Printf(\"Black: %v points \\n\", black)\n}", "func main() {\n\tconst (\n\t\ttypedConstant int = 4\n\t\tuntypedConstant = \"hey\"\n\t)\n\n\tfmt.Printf(\"%T\\n\", typedConstant)\n\tfmt.Println(typedConstant)\n\n\tfmt.Printf(\"%T\\n\", untypedConstant)\n\tfmt.Println(untypedConstant)\n}", "func main() {\n\t// Call the checkFlag function to simulate an error of the\n\t// concrete type.\n\n\t// Check the concrete type and handle appropriately.\n\tswitch e := err.(type) {\n\t// Apply the case for the default error type.\n\n\t// Apply the default case.\n\t}\n}", "func main() {\r\n\t/*\r\n\t\tMultiLine\r\n\t\tcomments\r\n\r\n\t\tVERRY goOD samples at: http://blog.golang.org/\r\n\t*/\r\n\r\n\t// print a line to console\r\n\tfmt.Println(\"Hello World!\")\r\n\r\n\t// print formated to console\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", time.Now(), iGlobalMessage, iGlobalConst)\r\n\r\n\t// get user input by line(return)\r\n\tfmt.Println(\"enter new text for iGlobalMessage\")\r\n\tfmt.Scanln(&iGlobalMessage)\r\n\t// string concat with +\r\n\tfmt.Println(\"new global text:\" + iGlobalMessage)\r\n\r\n\t//# playing with vars\r\n\r\n\tvar someString string\r\n\tvar someStringWithText string = \"some text\"\r\n\t// vars can be autocasted to a type by its assigned value\r\n\tsomeStringToo := \"!<>some string<>!\"\r\n\t// we ALWAYS HAVE to use vars!\r\n\t// no var left behind! (the compiler does not like unused vars)\r\n\tfmt.Printf(\"'%s' - '%s' - '%s'\\n\", someString, someStringWithText, someStringToo)\r\n\r\n\tvar someInt int\r\n\tsomeIntToo := 22\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// change values\r\n\tsomeInt = 99\r\n\tsomeIntToo = 33\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\t// increment ints\r\n\tsomeInt++\r\n\tsomeIntToo += 1\r\n\tfmt.Printf(\"%d -- %d\\n\", someInt, someIntToo)\r\n\r\n\tvar multipleStrings1, multipleStrings2, multipleStrings3 string\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStrings1, multipleStrings2, multipleStrings3)\r\n\r\n\tmultipleStringsToo1, multipleStringsToo2, multipleStringsToo3 := \"foo1\", \"foo2\", \"foo3\"\r\n\tfmt.Printf(\"%s -- %s -- %s<br>\\n\", multipleStringsToo1, multipleStringsToo2, multipleStringsToo3)\r\n\r\n\t// you can ONLY instance a var once\r\n\t// this will fail:\r\n\t//someIntToo := 99\r\n\r\n\t//# functions\r\n\r\n\t// function without parameter and return value\r\n\tuselessPrint()\r\n\r\n\t// function with 1 parameter\r\n\tuselessPrintParameter(42)\r\n\r\n\t// function with 2 parameters\r\n\tuselessPrintMore(\"the answer to all:\", 23)\r\n\r\n\t// function with return value\r\n\tvar uselessReturnTemp string\r\n\tuselessReturnTemp = uselessReturn()\r\n\t// this would work too:\r\n\t//var uselessReturnTemp string = uselessReturn()\r\n\t//uselessReturnTempToo := uselessReturn()\r\n\t//fmt.Println(uselessReturn())\r\n\tfmt.Println(uselessReturnTemp)\r\n\r\n\t// function with multiple return values\r\n\ttheAnswerText, theAnserNumber := uselessMultipleReturn()\r\n\t// will work too\r\n\t/*\r\n\t\tvar theAnswerText string\r\n\t\tvar theAnserNumber int\r\n\t\ttheAnswerText, theAnserNumber = uselessMultipleReturn()\r\n\t*/\r\n\tfmt.Printf(\"%s: %s\\n\", theAnswerText, theAnserNumber)\r\n\r\n\t//# conditions\r\n\tvar matchMe int = 23\r\n\tif matchMe == 7 {\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\t} else if matchMe == 23 {\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\t} else {\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\tswitch {\r\n\tcase matchMe == 7:\r\n\t\tfmt.Println(\"the 7 is all\")\r\n\tcase matchMe == 23:\r\n\t\tfmt.Println(\"dont trust machines\")\r\n\tdefault:\r\n\t\tfmt.Println(\"this is not the value i am looking for\")\r\n\t}\r\n\r\n\t//# array, list of one type with unchangeable length\r\n\tvar myArray [3]int\r\n\tfmt.Println(myArray)\r\n\tmyArray[1] = 42\r\n\tfmt.Println(myArray)\r\n\r\n\t//# slice, list of one type that can vary in length\r\n\tvar mySlice []int\r\n\tfmt.Println(mySlice)\r\n\tmySlice = append(mySlice, 21, 42, 101)\r\n\tfmt.Println(mySlice)\r\n\tfmt.Println(mySlice[1])\r\n\r\n\t//# map, key/value pair of two types (dictionary)\r\n\tvar myMap map[string]int\r\n\t// you have to \"make\" them\r\n\tmyMap = make(map[string]int)\r\n\t// set some values\r\n\tmyMap[\"the answer\"] = 42\r\n\tmyMap[\"half_theTruth\"] = 11\r\n\tmyMap[\"weTrust\"] = 23\r\n\tfmt.Println(myMap)\r\n\t// access one value\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\t// change value\r\n\tmyMap[\"half_theTruth\"] = 21\r\n\tfmt.Println(myMap[\"half_theTruth\"])\r\n\r\n\t// access key->value pair\r\n\tfor key, value := range myMap {\r\n\t\tfmt.Println(\"Key:\", key, \"Value:\", value)\r\n\t}\r\n\r\n\t// delete key+value\r\n\tdelete(myMap, \"half_theTruth\")\r\n\tfmt.Println(myMap)\r\n}", "func init() { Go_version_1_13_required_for_compilation() }", "func init() { Go_version_1_5_required_for_compilation() }", "func TestConfigSecretsWarnGo(t *testing.T) {\n\t// TODO[pulumi/pulumi#7127]: Re-enabled the warning.\n\tt.Skip(\"Temporarily skipping test until we've re-enabled the warning - pulumi/pulumi#7127\")\n\tintegration.ProgramTest(t, &integration.ProgramTestOptions{\n\t\tDir: filepath.Join(\"config_secrets_warn\", \"go\"),\n\t\tDependencies: []string{\n\t\t\t\"github.com/pulumi/pulumi/sdk/v3\",\n\t\t},\n\t\tQuick: true,\n\t\tConfig: map[string]string{\n\t\t\t\"plainstr1\": \"1\",\n\t\t\t\"plainstr2\": \"2\",\n\t\t\t\"plainstr3\": \"3\",\n\t\t\t\"plainstr4\": \"4\",\n\t\t\t\"plainstr5\": \"5\",\n\t\t\t\"plainstr6\": \"6\",\n\t\t\t\"plainstr7\": \"7\",\n\t\t\t\"plainstr8\": \"8\",\n\t\t\t\"plainstr9\": \"9\",\n\t\t\t\"plainstr10\": \"10\",\n\t\t\t\"plainstr11\": \"11\",\n\t\t\t\"plainstr12\": \"12\",\n\t\t\t\"plainbool1\": \"true\",\n\t\t\t\"plainbool2\": \"true\",\n\t\t\t\"plainbool3\": \"true\",\n\t\t\t\"plainbool4\": \"true\",\n\t\t\t\"plainbool5\": \"true\",\n\t\t\t\"plainbool6\": \"true\",\n\t\t\t\"plainbool7\": \"true\",\n\t\t\t\"plainbool8\": \"true\",\n\t\t\t\"plainbool9\": \"true\",\n\t\t\t\"plainbool10\": \"true\",\n\t\t\t\"plainbool11\": \"true\",\n\t\t\t\"plainbool12\": \"true\",\n\t\t\t\"plainint1\": \"1\",\n\t\t\t\"plainint2\": \"2\",\n\t\t\t\"plainint3\": \"3\",\n\t\t\t\"plainint4\": \"4\",\n\t\t\t\"plainint5\": \"5\",\n\t\t\t\"plainint6\": \"6\",\n\t\t\t\"plainint7\": \"7\",\n\t\t\t\"plainint8\": \"8\",\n\t\t\t\"plainint9\": \"9\",\n\t\t\t\"plainint10\": \"10\",\n\t\t\t\"plainint11\": \"11\",\n\t\t\t\"plainint12\": \"12\",\n\t\t\t\"plainfloat1\": \"1.1\",\n\t\t\t\"plainfloat2\": \"2.2\",\n\t\t\t\"plainfloat3\": \"3.3\",\n\t\t\t\"plainfloat4\": \"4.4\",\n\t\t\t\"plainfloat5\": \"5.5\",\n\t\t\t\"plainfloat6\": \"6.6\",\n\t\t\t\"plainfloat7\": \"7.7\",\n\t\t\t\"plainfloat8\": \"8.8\",\n\t\t\t\"plainfloat9\": \"9.9\",\n\t\t\t\"plainfloat10\": \"10.1\",\n\t\t\t\"plainfloat11\": \"11.11\",\n\t\t\t\"plainfloat12\": \"12.12\",\n\t\t\t\"plainobj1\": \"{}\",\n\t\t\t\"plainobj2\": \"{}\",\n\t\t\t\"plainobj3\": \"{}\",\n\t\t\t\"plainobj4\": \"{}\",\n\t\t\t\"plainobj5\": \"{}\",\n\t\t\t\"plainobj6\": \"{}\",\n\t\t\t\"plainobj7\": \"{}\",\n\t\t\t\"plainobj8\": \"{}\",\n\t\t\t\"plainobj9\": \"{}\",\n\t\t\t\"plainobj10\": \"{}\",\n\t\t\t\"plainobj11\": \"{}\",\n\t\t\t\"plainobj12\": \"{}\",\n\t\t},\n\t\tSecrets: map[string]string{\n\t\t\t\"str1\": \"1\",\n\t\t\t\"str2\": \"2\",\n\t\t\t\"str3\": \"3\",\n\t\t\t\"str4\": \"4\",\n\t\t\t\"str5\": \"5\",\n\t\t\t\"str6\": \"6\",\n\t\t\t\"str7\": \"7\",\n\t\t\t\"str8\": \"8\",\n\t\t\t\"str9\": \"9\",\n\t\t\t\"str10\": \"10\",\n\t\t\t\"str11\": \"11\",\n\t\t\t\"str12\": \"12\",\n\t\t\t\"bool1\": \"true\",\n\t\t\t\"bool2\": \"true\",\n\t\t\t\"bool3\": \"true\",\n\t\t\t\"bool4\": \"true\",\n\t\t\t\"bool5\": \"true\",\n\t\t\t\"bool6\": \"true\",\n\t\t\t\"bool7\": \"true\",\n\t\t\t\"bool8\": \"true\",\n\t\t\t\"bool9\": \"true\",\n\t\t\t\"bool10\": \"true\",\n\t\t\t\"bool11\": \"true\",\n\t\t\t\"bool12\": \"true\",\n\t\t\t\"int1\": \"1\",\n\t\t\t\"int2\": \"2\",\n\t\t\t\"int3\": \"3\",\n\t\t\t\"int4\": \"4\",\n\t\t\t\"int5\": \"5\",\n\t\t\t\"int6\": \"6\",\n\t\t\t\"int7\": \"7\",\n\t\t\t\"int8\": \"8\",\n\t\t\t\"int9\": \"9\",\n\t\t\t\"int10\": \"10\",\n\t\t\t\"int11\": \"11\",\n\t\t\t\"int12\": \"12\",\n\t\t\t\"float1\": \"1.1\",\n\t\t\t\"float2\": \"2.2\",\n\t\t\t\"float3\": \"3.3\",\n\t\t\t\"float4\": \"4.4\",\n\t\t\t\"float5\": \"5.5\",\n\t\t\t\"float6\": \"6.6\",\n\t\t\t\"float7\": \"7.7\",\n\t\t\t\"float8\": \"8.8\",\n\t\t\t\"float9\": \"9.9\",\n\t\t\t\"float10\": \"10.1\",\n\t\t\t\"float11\": \"11.11\",\n\t\t\t\"float12\": \"12.12\",\n\t\t\t\"obj1\": \"{}\",\n\t\t\t\"obj2\": \"{}\",\n\t\t\t\"obj3\": \"{}\",\n\t\t\t\"obj4\": \"{}\",\n\t\t\t\"obj5\": \"{}\",\n\t\t\t\"obj6\": \"{}\",\n\t\t\t\"obj7\": \"{}\",\n\t\t\t\"obj8\": \"{}\",\n\t\t\t\"obj9\": \"{}\",\n\t\t\t\"obj10\": \"{}\",\n\t\t\t\"obj11\": \"{}\",\n\t\t\t\"obj12\": \"{}\",\n\t\t},\n\t\tOrderedConfig: []integration.ConfigValue{\n\t\t\t{Key: \"parent1.foo\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"parent1.bar\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"parent2.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent2.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"parent3.foo\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"parent3.bar\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names1[0]\", Value: \"plain1\", Path: true},\n\t\t\t{Key: \"names1[1]\", Value: \"secret1\", Path: true, Secret: true},\n\t\t\t{Key: \"names2[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names2[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t\t{Key: \"names3[0]\", Value: \"plain2\", Path: true},\n\t\t\t{Key: \"names3[1]\", Value: \"secret2\", Path: true, Secret: true},\n\t\t},\n\t\tExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {\n\t\t\tassert.NotEmpty(t, stackInfo.Events)\n\t\t\t//nolint:lll\n\t\t\texpectedWarnings := []string{\n\t\t\t\t\"Configuration 'config_secrets_go:str1' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str2' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str3' value is a secret; use `TrySecret` instead of `Try`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str7' value is a secret; use `GetSecret` instead of `Get`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str8' value is a secret; use `RequireSecret` instead of `Require`\",\n\t\t\t\t\"Configuration 'config_secrets_go:str9' value is a secret; use `TrySecret` instead of `Try`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:bool1' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool2' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool3' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool7' value is a secret; use `GetSecretBool` instead of `GetBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool8' value is a secret; use `RequireSecretBool` instead of `RequireBool`\",\n\t\t\t\t\"Configuration 'config_secrets_go:bool9' value is a secret; use `TrySecretBool` instead of `TryBool`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:int1' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int2' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int3' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int7' value is a secret; use `GetSecretInt` instead of `GetInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int8' value is a secret; use `RequireSecretInt` instead of `RequireInt`\",\n\t\t\t\t\"Configuration 'config_secrets_go:int9' value is a secret; use `TrySecretInt` instead of `TryInt`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:float1' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float2' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float3' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float7' value is a secret; use `GetSecretFloat64` instead of `GetFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float8' value is a secret; use `RequireSecretFloat64` instead of `RequireFloat64`\",\n\t\t\t\t\"Configuration 'config_secrets_go:float9' value is a secret; use `TrySecretFloat64` instead of `TryFloat64`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:obj1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj7' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj8' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:obj9' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:parent1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:parent3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\n\t\t\t\t\"Configuration 'config_secrets_go:names1' value is a secret; use `GetSecretObject` instead of `GetObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names2' value is a secret; use `RequireSecretObject` instead of `RequireObject`\",\n\t\t\t\t\"Configuration 'config_secrets_go:names3' value is a secret; use `TrySecretObject` instead of `TryObject`\",\n\t\t\t}\n\t\t\tfor _, warning := range expectedWarnings {\n\t\t\t\tvar found bool\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil && event.DiagnosticEvent.Severity == \"warning\" &&\n\t\t\t\t\t\tstrings.Contains(event.DiagnosticEvent.Message, warning) {\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert.True(t, found, \"expected warning %q\", warning)\n\t\t\t}\n\n\t\t\t// These keys should not be in any warning messages.\n\t\t\tunexpectedWarnings := []string{\n\t\t\t\t\"plainstr1\",\n\t\t\t\t\"plainstr2\",\n\t\t\t\t\"plainstr3\",\n\t\t\t\t\"plainstr4\",\n\t\t\t\t\"plainstr5\",\n\t\t\t\t\"plainstr6\",\n\t\t\t\t\"plainstr7\",\n\t\t\t\t\"plainstr8\",\n\t\t\t\t\"plainstr9\",\n\t\t\t\t\"plainstr10\",\n\t\t\t\t\"plainstr11\",\n\t\t\t\t\"plainstr12\",\n\t\t\t\t\"plainbool1\",\n\t\t\t\t\"plainbool2\",\n\t\t\t\t\"plainbool3\",\n\t\t\t\t\"plainbool4\",\n\t\t\t\t\"plainbool5\",\n\t\t\t\t\"plainbool6\",\n\t\t\t\t\"plainbool7\",\n\t\t\t\t\"plainbool8\",\n\t\t\t\t\"plainbool9\",\n\t\t\t\t\"plainbool10\",\n\t\t\t\t\"plainbool11\",\n\t\t\t\t\"plainbool12\",\n\t\t\t\t\"plainint1\",\n\t\t\t\t\"plainint2\",\n\t\t\t\t\"plainint3\",\n\t\t\t\t\"plainint4\",\n\t\t\t\t\"plainint5\",\n\t\t\t\t\"plainint6\",\n\t\t\t\t\"plainint7\",\n\t\t\t\t\"plainint8\",\n\t\t\t\t\"plainint9\",\n\t\t\t\t\"plainint10\",\n\t\t\t\t\"plainint11\",\n\t\t\t\t\"plainint12\",\n\t\t\t\t\"plainfloat1\",\n\t\t\t\t\"plainfloat2\",\n\t\t\t\t\"plainfloat3\",\n\t\t\t\t\"plainfloat4\",\n\t\t\t\t\"plainfloat5\",\n\t\t\t\t\"plainfloat6\",\n\t\t\t\t\"plainfloat7\",\n\t\t\t\t\"plainfloat8\",\n\t\t\t\t\"plainfloat9\",\n\t\t\t\t\"plainfloat10\",\n\t\t\t\t\"plainfloat11\",\n\t\t\t\t\"plainfloat12\",\n\t\t\t\t\"plainobj1\",\n\t\t\t\t\"plainobj2\",\n\t\t\t\t\"plainobj3\",\n\t\t\t\t\"plainobj4\",\n\t\t\t\t\"plainobj5\",\n\t\t\t\t\"plainobj6\",\n\t\t\t\t\"plainobj7\",\n\t\t\t\t\"plainobj8\",\n\t\t\t\t\"plainobj9\",\n\t\t\t\t\"plainobj10\",\n\t\t\t\t\"plainobj11\",\n\t\t\t\t\"plainobj12\",\n\t\t\t}\n\t\t\tfor _, warning := range unexpectedWarnings {\n\t\t\t\tfor _, event := range stackInfo.Events {\n\t\t\t\t\tif event.DiagnosticEvent != nil {\n\t\t\t\t\t\tassert.NotContains(t, event.DiagnosticEvent.Message, warning)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n}", "func helloGo() {\n\tvar ret = 100\n\tfmt.Println(ret)\n}", "func (c *config) init(strict bool) error {\n\tvar msgs []string\n\tc.tlaVars = c.vmc.TopLevelVars()\n\tc.tlaCodeVars = c.vmc.TopLevelCodeVars()\n\tc.vmc = c.vmc.WithLibPaths(c.app.LibPaths())\n\n\tvars := c.vmc.Vars()\n\tcodeVars := c.vmc.CodeVars()\n\n\tdeclaredExternals := c.app.DeclaredVars()\n\tdeclaredTLAs := c.app.DeclaredTopLevelVars()\n\n\tcheckStrict := func(tla bool, declared map[string]interface{}, varSources ...map[string]string) {\n\t\tkind := \"external\"\n\t\tif tla {\n\t\t\tkind = \"top level\"\n\t\t}\n\t\t// check that all specified variables have been declared\n\t\tfor _, src := range varSources {\n\t\t\tfor k := range src {\n\t\t\t\t_, ok := declared[k]\n\t\t\t\tif !ok {\n\t\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"specified %s variable '%s' not declared for app\", kind, k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// check that all declared variables have been specified\n\t\tvar fn func(string) bool\n\t\tif tla {\n\t\t\tfn = c.vmc.HasTopLevelVar\n\t\t} else {\n\t\t\tfn = c.vmc.HasVar\n\t\t}\n\t\tfor k := range declared {\n\t\t\tok := fn(k)\n\t\t\tif !ok {\n\t\t\t\tmsgs = append(msgs, fmt.Sprintf(\"declared %s variable '%s' not specfied for command\", kind, k))\n\t\t\t}\n\t\t}\n\t}\n\n\tif strict {\n\t\tcheckStrict(false, declaredExternals, vars, codeVars)\n\t\tcheckStrict(true, declaredTLAs, c.tlaVars, c.tlaCodeVars)\n\t\tif len(msgs) > 0 {\n\t\t\treturn fmt.Errorf(\"strict vars check failures\\n\\t%s\", strings.Join(msgs, \"\\n\\t\"))\n\t\t}\n\t}\n\n\t// apply default values for external vars\n\taddStrings, addCodes := map[string]string{}, map[string]string{}\n\n\tfor k, v := range declaredExternals {\n\t\tif c.vmc.HasVar(k) {\n\t\t\tcontinue\n\t\t}\n\t\tif v == nil {\n\t\t\tsio.Warnf(\"no/ nil default specified for variable %q\\n\", k)\n\t\t\tcontinue\n\t\t}\n\t\tswitch t := v.(type) {\n\t\tcase string:\n\t\t\taddStrings[k] = t\n\t\tdefault:\n\t\t\tb, err := json.Marshal(v)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"json marshal: unexpected error marshaling default for variable %s, %v\", k, err)\n\t\t\t}\n\t\t\taddCodes[k] = string(b)\n\t\t}\n\t}\n\tc.vmc = c.vmc.WithoutTopLevel().WithVars(addStrings).WithCodeVars(addCodes)\n\treturn nil\n}", "func Test_mdle_consts_(t *testing.T) {\n\tTBegin(t)\n\t//\n\t// error message constants\n\tTEqual(t, EFailedParsing, (\"Failed parsing\"))\n\tTEqual(t, EFailedReading, (\"Failed reading\"))\n\tTEqual(t, EFailedWriting, (\"Failed writing\"))\n\tTEqual(t, EInvalid, (\"Invalid\"))\n\tTEqual(t, EInvalidArg, (\"Invalid argument\"))\n\tTEqual(t, EInvalidType, (\"Invalid type\"))\n\tTEqual(t, ENil, (\"Value is nil\"))\n\tTEqual(t, ENilReceiver, (\"nil receiver\"))\n\tTEqual(t, ENoDef, (\"Not defined\"))\n\tTEqual(t, ENotFound, (\"Not found\"))\n\tTEqual(t, ENotHandled, (\"Not handled\"))\n\t//\n\t// other constants\n\tTEqual(t, LB, (\"\\r\\n\"))\n}", "func rcConstO(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := p.Consts.Get(code.B).Clone()\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {\n\tfor _, flag := range flags {\n\t\tflag = strings.TrimSpace(flag)\n\n\t\tif !strings.HasPrefix(flag, \"-\") {\n\t\t\tctx.PropertyErrorf(prop, \"Flag `%s` must start with `-`\", flag)\n\t\t} else if strings.HasPrefix(flag, \"-I\") || strings.HasPrefix(flag, \"-isystem\") {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag `%s`, use local_include_dirs or include_dirs instead\", flag)\n\t\t} else if inList(flag, config.IllegalFlags) {\n\t\t\tctx.PropertyErrorf(prop, \"Illegal flag `%s`\", flag)\n\t\t} else if flag == \"--coverage\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use native_coverage instead\", flag)\n\t\t} else if flag == \"-fwhole-program-vtables\" {\n\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s`, use whole_program_vtables instead\", flag)\n\t\t} else if flag == \"-Weverything\" {\n\t\t\tif !ctx.Config().IsEnvTrue(\"ANDROID_TEMPORARILY_ALLOW_WEVERYTHING\") {\n\t\t\t\tctx.PropertyErrorf(prop, \"-Weverything is not allowed in Android.bp files. \"+\n\t\t\t\t\t\"Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.\")\n\t\t\t}\n\t\t} else if strings.Contains(flag, \" \") {\n\t\t\targs := strings.Split(flag, \" \")\n\t\t\tif args[0] == \"-include\" {\n\t\t\t\tif len(args) > 2 {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"`-include` only takes one argument: `%s`\", flag)\n\t\t\t\t}\n\t\t\t\tpath := filepath.Clean(args[1])\n\t\t\t\tif strings.HasPrefix(\"/\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not be an absolute path: %s\", flag)\n\t\t\t\t} else if strings.HasPrefix(\"../\", path) {\n\t\t\t\t\tctx.PropertyErrorf(prop, \"Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory\", flag)\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(flag, \"-D\") && strings.Contains(flag, \"=\") {\n\t\t\t\t// Do nothing in this case.\n\t\t\t\t// For now, we allow space characters in -DNAME=def form to allow use cases\n\t\t\t\t// like -DNAME=\"value with string\". Later, this check should be done more\n\t\t\t\t// correctly to prevent multi flag cases like -DNAME=value -O2.\n\t\t\t} else {\n\t\t\t\tctx.PropertyErrorf(prop, \"Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?\", flag)\n\t\t\t}\n\t\t}\n\t}\n}", "func must(what string, err error) {\n\tif err != nil {\n\t\tlogrus.Warnf(\"squiryc2_compat: error %s: %s\", what, err)\n\t}\n}", "func init() {\n\tif MaxRune != unicode.MaxRune {\n\t\tpanic(\"utf8.MaxRune is wrong\")\n\t}\n\tif RuneError != unicode.ReplacementChar {\n\t\tpanic(\"utf8.RuneError is wrong\")\n\t}\n}", "func main() {\n\n\t/*\n\n\t\tMAIN TYPES\n\n\t\tstring\n\t\tbool\n\t\tint\n\t\tint int8 int16 int32 int64\n\t\tuint uint8 uint16 uint32 uint64 unitptr\n\t\tbyte - alias for int8\n\t\trune - alias for int32\n\t\tfloat32 float64\n\t\tcomplex64 complex128\n\n\t*/\n\n\t//Using var\n\t//var name string = \"Lokesh\" //ERR: data-type is automatically inferred\n\tvar name = \"Lokesh\" //FIX: devoid of keyword 'string' in the declaration\n\n\tfmt.Println(name)\n\n\t/*\n\t\tCommonly used formatters (placeholders)\n\n\t\tGeneral\n\t\t===========\n\t\t%v - prints the value\n\t\t%T - prints the Type\n\t\t%% - to print percent sign\n\n\t\tInteger\n\t\t============\n\t\t%d - base10\n\t\t%o - base8\n\n\t\tFloating point\n\t\t================\n\t\t%f - decimal but no exponent, e.g. 123.456\n\t\t%F - synonym for %f\n\t*/\n\n\tvar age = 29\n\tvar salary int32 = 50000000\n\t//var hasBlueEyes = false //ERR: unused variable throws compilation error\n\n\tconst hasPlaystation = true\n\t//hasPlaystation = false\t\t //ERR: cannot assign to constant variable over and over, compilation error\n\n\tfmt.Println(name, age)\n\tfmt.Printf(\"age: %v , type: %T \\n\", age, age) //returns 29 & int\n\tfmt.Printf(\"salary: %v , type: %T \\n\", salary, salary) //returns 50000000 & int32 (unless specified the type of int)\n\n\t//Shorthand\n\tcity := \"Bangalore\"\n\n\tfmt.Println(city)\n\n\t//Another shorthand (multiple variables declared at once)\n\tmajors, expInYears := \"CSE\", 7\n\n\tfmt.Println(majors, expInYears) //variables once declared cannot be left without using it (comment and see)\n}", "func init() { Go_version_1_7_required_for_compilation() }", "func f() {\n\t_ = 12 // nolint // want `\\Qremove a space between // and \"nolint\" directive`\n\n\t_ = 30 // nolint2 foo bar // want `\\Qsuggestion: //nolint2 foo bar`\n\n\t/*\n\t\tnolint // want `\\Qdon't put \"nolint\" inside a multi-line comment`\n\t*/\n\n\t//go:baddirective // want `\\Qdon't use baddirective go directive`\n\t//go:noinline\n\t//go:generate foo bar\n\n\t//nolint:gocritic // want `\\Qhey, this is kinda upsetting`\n\n\t// This is a begining // want `\\Q\"begining\" may contain a typo`\n\t// Of a bizzare text with typos. // want `\\Q\"bizzare\" may contain a typo`\n\n\t// I can't give you a buisness advice. // want `\\Q\"buisness advice\" may contain a typo`\n\n\t// calender // want `\\Qfirst=calender`\n\t// cemetary // want `\\Qsecond=cemetary`\n\n\t// collegue // want `\\Qx=\"collegue\"`\n\t// commitee // want `\\Qx=\"\"`\n}", "func TestMisspellPHPDocPositive(t *testing.T) {\n\ttest := linttest.NewSuite(t)\n\ttest.Config().TypoFixer = misspell.New()\n\ttest.AddFile(`<?php\n/**\n * This function is a pure perfektion.\n */\nfunction f1() {}\n\n/**\n * This class is our performace secret.\n */\nclass c1 {\n /**\n * This constant comment is very informitive.\n */\n const Foo = 0;\n\n /**\n * This property is not inefficeint.\n */\n private $prop = 1;\n\n /**\n * This method is never called, this is why it's inexpencive.\n */\n private static function secret() {}\n}\n`)\n\ttest.Expect = []string{\n\t\t`\"perfektion\" is a misspelling of \"perfection\"`,\n\t\t`\"performace\" is a misspelling of \"performance\"`,\n\t\t`\"informitive\" is a misspelling of \"informative\"`,\n\t\t`\"inexpencive\" is a misspelling of \"inexpensive\"`,\n\t\t`\"inefficeint\" is a misspelling of \"inefficient\"`,\n\t}\n\ttest.RunAndMatch()\n}", "func main() {\r\n err := errors.New(\"Mensagem relacionada ao novo erro\")\r\n}", "func _(n int) {\n\tre, _ := regexp.Compile(\"const pattern\")\n\tre.FindAllString(\"sdosdos\", -1)\n}", "func main() {\n\terrs(\"aaabbbbhaijjjm\")\n}", "func TestCheckBinaryExprIntGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= 4`, env, (4 >= 4), ConstBool)\n}", "func TestCheckBinaryExprIntGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 >= '@'`, env, (4 >= '@'), ConstBool)\n}", "func TestSpec_MustGetValidTypeObject(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidTypeObject(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidTypeObject(\"bool\").String() == \"type bool\" &&\n\t\ts.MustGetValidTypeObject(\"fmt\").String() == \"package fmt\" &&\n\t\ts.MustGetValidTypeObject(\"a\").String() == \"const haha.a untyped int\" &&\n\t\ts.MustGetValidTypeObject(\"b\").String() == \"var b float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func Lint() error {\n\tmg.Deps(GoVet)\n\tmg.Deps(GoLint)\n\tmg.Deps(GoFmt)\n\tmg.Deps(GoImports)\n\tmg.Deps(Errcheck)\n\tmg.Deps(Nakedret)\n\tmg.Deps(Staticcheck)\n\treturn nil\n}", "func Const(parser Parser, replaced interface{}) Parser {\n\treturn Transform(parser, func(value interface{}) (interface{}, error) {\n\t\treturn replaced, nil\n\t})\n}", "func init() { Go_version_1_6_required_for_compilation() }", "func libCause(err error) (bool, error) {\n\toriginal := err\n\tfor {\n\t\tswitch e := err.(type) {\n\t\tcase *driver.ResponseError:\n\t\t\terr = e.Err\n\t\tcase *net.DNSConfigError:\n\t\t\terr = e.Err\n\t\tcase *net.OpError:\n\t\t\terr = e.Err\n\t\tcase *os.SyscallError:\n\t\t\terr = e.Err\n\t\tcase *url.Error:\n\t\t\terr = e.Err\n\t\tdefault:\n\t\t\treturn err != original, err\n\t\t}\n\t}\n}", "func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) {\n\tpkg.defs = make(map[*ast.Ident]types.Object)\n\terrFn := func(err error) {\n\t\tcErr := err.(types.Error)\n\t\tif cErr.Soft {\n\t\t\treturn\n\t\t}\n\t\tif strings.Contains(cErr.Msg, \"has no field or method\") ||\n\t\t\tstrings.Contains(cErr.Msg, \"invalid operation: cannot call non-function\") ||\n\t\t\t//2016-01-11: Try and skip past issues with VendorExperiment\n\t\t\tstrings.Contains(cErr.Msg, \"vendor\") {\n\t\t\tlog.Printf(\"IGNORED: during package check: %s\", cErr.Msg)\n\t\t\treturn\n\t\t}\n\t\tlog.Fatalf(\"checking package: %s\", cErr.Msg)\n\t}\n\tconfig := types.Config{FakeImportC: true, Error: errFn, Importer: importer.ForCompiler(fs, \"source\", nil)}\n\tinfo := &types.Info{\n\t\tDefs: pkg.defs,\n\t}\n\ttypesPkg, _ := config.Check(pkg.dir, fs, astFiles, info)\n\tpkg.typesPkg = typesPkg\n}", "func TestCheckBinaryExprIntLssInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < 4`, env, (4 < 4), ConstBool)\n}", "func validateHardcodedVersion(wd string, version string) error {\n\tpkgs, err := packages.Load(&packages.Config{\n\t\tDir: filepath.Dir(wd),\n\t\tMode: packages.NeedName | packages.NeedFiles |\n\t\t\tpackages.NeedCompiledGoFiles | packages.NeedImports |\n\t\t\tpackages.NeedTypes | packages.NeedTypesSizes,\n\t}, \"golang.org/x/tools/gopls/internal/lsp/debug\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pkgs) != 1 {\n\t\treturn fmt.Errorf(\"expected 1 package, got %v\", len(pkgs))\n\t}\n\tpkg := pkgs[0]\n\tobj := pkg.Types.Scope().Lookup(\"Version\")\n\tc, ok := obj.(*types.Const)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no constant named Version\")\n\t}\n\thardcodedVersion, err := strconv.Unquote(c.Val().ExactString())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif semver.Prerelease(hardcodedVersion) != \"\" {\n\t\treturn fmt.Errorf(\"unexpected pre-release for hardcoded version: %s\", hardcodedVersion)\n\t}\n\t// Don't worry about pre-release tags and expect that there is no build\n\t// suffix.\n\tversion = strings.TrimSuffix(version, semver.Prerelease(version))\n\tif hardcodedVersion != version {\n\t\treturn fmt.Errorf(\"expected version to be %s, got %s\", *versionFlag, hardcodedVersion)\n\t}\n\treturn nil\n}", "func main() {\n\n\t// There is a function we called that shorthand but this we can prevent globally define value to call.\n\t// Always remember if value is declare but not used it will raise an error in Golang\n\t// This will print the output\n\tname := \"Gautam\"\n\tage := 34\n\tprice := 11.1\n\tcontact, email := 98765432, \"[email protected]\"\n\tfmt.Println(value1)\n\tfmt.Println(age)\n\tfmt.Println(price)\n\tfmt.Println(name)\n\tfmt.Println(contact)\n\tfmt.Println(email)\n\n\n}", "func main(){\n\tvar age int32 = 27\n\tconst isCool bool = true\n\tname := \"Brad\"\n\n\tname1, email1 := \"Louis\", \"[email protected]\"\n\n\tfmt.Println(name, age, isCool)\n\tfmt.Println(name1, email1)\n}", "func main() {\n const Hello = \"Hello World\" // How to define constant value\n fmt.Printf(\"%s\\n\", Hello) // How to Print\n}", "func main() {\n\tvar q string = \"Death and Taxes\"\n\tconst PI float64 = 3.14\n\n\tfmt.Println(\" p :\", p)\n\tfmt.Println(\" q :\", q)\n\n\tq = \"liva da revolution\"\n\tfmt.Println(\" q :\", q)\n\n\t/* error string set to int value\n\tq = 32\n\tfmt.Println(\" q :\", q)\n\t*/\n\n\tfmt.Println(\" PI :\", PI)\n}", "func cflags(p *build.Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {\n\tvar defaults string\n\tif def {\n\t\tdefaults = \"-g -O2\"\n\t}\n\n\tcppflags = stringList(envList(\"CGO_CPPFLAGS\", \"\"), p.CgoCPPFLAGS)\n\tcflags = stringList(envList(\"CGO_CFLAGS\", defaults), p.CgoCFLAGS)\n\tcxxflags = stringList(envList(\"CGO_CXXFLAGS\", defaults), p.CgoCXXFLAGS)\n\tldflags = stringList(envList(\"CGO_LDFLAGS\", defaults), p.CgoLDFLAGS)\n\treturn\n}", "func GuaranteeConst(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"GuaranteeConst\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func main() {\n\t// Call the function and get the error.\n\tif err := checkAmount(0); err != nil {\n\t\tswitch err {\n\t\t// Check if the error is an ErrInvalidValue.\n\t\tcase ErrInvalidValue:\n\t\t\tfmt.Println(\"Value provided is not valid.\")\n\t\t\treturn\n\n\t\t// Check if the error is an ErrAmountTooLarge.\n\t\tcase ErrAmountTooLarge:\n\t\t\tfmt.Println(\"Value provided is too large.\")\n\t\t\treturn\n\n\t\t// Handle the default error.\n\t\tdefault:\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Display everything is good.\n\tfmt.Println(\"Everything checks out.\")\n}", "func Const() Constants {\n\treturn Constants{\n\t\tPermissions: Permissions{\n\t\t\tSudo: \"sudo\",\n\t\t\tUser: getUserPermissions(),\n\t\t\tPermissions: getPermission(),\n\t\t\tMetrics: getMetricPermissions(),\n\t\t\tNotifications: getNotificationPermissions(),\n\t\t},\n\t}\n}", "func licenseWarnings(yada *libgin.RepositoryYAML, repoLicenseURL string, warnings []string) []string {\n\t// check datacite license URL, name and license file title to spot mismatches\n\tcommonLicenses := ReadCommonLicenses()\n\n\t// check if the datacite license can be matched to a common license via URL\n\tlicenseURL, ok := licFromURL(commonLicenses, yada.License.URL)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL (datacite) not found: '%s'\", yada.License.URL))\n\t}\n\n\t// check if the license can be matched to a common license via datacite license name\n\tlicenseName, ok := licFromName(commonLicenses, yada.License.Name)\n\tif !ok {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name (datacite) not found: '%s'\", yada.License.Name))\n\t}\n\n\t// check if the license can be matched to a common license via the header line of the license file\n\tvar licenseHeader DOILicense\n\tcontent, err := readFileAtURL(repoLicenseURL)\n\tif err != nil {\n\t\twarnings = append(warnings, \"Could not access license file\")\n\t} else {\n\t\theadstr := string(content)\n\t\tfileHeader := strings.Split(strings.Replace(headstr, \"\\r\\n\", \"\\n\", -1), \"\\n\")\n\t\tvar ok bool // false if fileHeader 0 or licFromName returns !ok\n\t\tif len(fileHeader) > 0 {\n\t\t\tlicenseHeader, ok = licFromName(commonLicenses, fileHeader[0])\n\t\t}\n\t\tif !ok {\n\t\t\t// Limit license file content in warning message\n\t\t\tif len(headstr) > 20 {\n\t\t\t\theadstr = fmt.Sprintf(\"%s...\", headstr[0:20])\n\t\t\t}\n\t\t\twarnings = append(warnings, fmt.Sprintf(\"License file content header not found: '%s'\", headstr))\n\t\t}\n\t}\n\n\t// check license URL against license name\n\tif licenseURL.Name != licenseName.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License URL/Name mismatch: '%s'/'%s'\", licenseURL.Name, licenseName.Name))\n\t}\n\n\t// check license name against license file header\n\tif licenseName.Name != licenseHeader.Name {\n\t\twarnings = append(warnings, fmt.Sprintf(\"License name/file header mismatch: '%s'/'%s'\", licenseName.Name, licenseHeader.Name))\n\t}\n\n\treturn warnings\n}", "func VPCONFLICTQ_BCST(ops ...operand.Op) { ctx.VPCONFLICTQ_BCST(ops...) }", "func TestCheckBinaryExprIntOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 | '@'`, env, NewConstRune(4 | '@'), ConstRune)\n}", "func bindConstants(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(ConstantsABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func TestCheckBinaryExprIntAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ '@'`, env, NewConstRune(4 &^ '@'), ConstRune)\n}", "func TestSpec_MustGetValidType(t *testing.T) {\n\tcode := `\npackage haha\nimport \"fmt\"\nconst a = 1\nfunc main() {\n var b = 2.0\n type c struct {\n d string\n }\n fmt.Println(a, b)\n}`\n\ttestGet := func(s *Spec, v string) (r string) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tr = fmt.Sprintf(\"%s\", err)\n\t\t\t}\n\t\t}()\n\t\ts.MustGetValidType(v)\n\t\treturn\n\t}\n\n\ts := NewSpec(code)\n\ts.SearchKind = SearchOnlyPackage\n\tif testGet(s, \"bool\") == \"find <bool> in code <\"+code+\"> failed\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchPackageAndUniverse\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ttestGet(s, \"fmt\") == \"find <fmt> in code <\"+code+\"> failed\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ttestGet(s, \"b\") == \"find <b> in code <\"+code+\"> failed\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n\ts.SearchKind = SearchAll\n\tif s.MustGetValidType(\"bool\").String() == \"bool\" &&\n\t\ts.MustGetValidType(\"fmt\").String() == \"invalid type\" &&\n\t\ts.MustGetValidType(\"a\").String() == \"untyped int\" &&\n\t\ts.MustGetValidType(\"b\").String() == \"float64\" {\n\t} else {\n\t\tt.Error(`test failed`)\n\t}\n}", "func TestCheckBinaryExprIntLssRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 < '@'`, env, (4 < '@'), ConstBool)\n}", "func importconst(pos src.XPos, s *types.Sym, t *types.Type, val constant.Value) *ir.Name {\n\tn := importobj(pos, s, ir.OLITERAL, ir.PEXTERN, t)\n\tn.SetVal(val)\n\treturn n\n}", "func checkExpr(expr parser.Expr) error {\n\tif expr == nil {\n\t\treturn nil\n\t}\n\tv := distSQLExprCheckVisitor{}\n\tparser.WalkExprConst(&v, expr)\n\treturn v.err\n}", "func (m *Module) irConstant(old ast.Constant) constant.Constant {\n\tswitch old := old.(type) {\n\t// Simple constants\n\tcase *ast.IntConst:\n\t\treturn constant.NewIntFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.FloatConst:\n\t\treturn constant.NewFloatFromString(old.Lit, m.irType(old.Type))\n\tcase *ast.NullConst:\n\t\treturn constant.NewNull(m.irType(old.Type))\n\n\t// Complex constants\n\tcase *ast.VectorConst:\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewVector(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"vector type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ArrayConst:\n\t\t// Handle empty array constants.\n\t\tif len(old.Elems) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor _, oldElem := range old.Elems {\n\t\t\telems = append(elems, m.irConstant(oldElem))\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.CharArrayConst:\n\t\t// Handle empty character array constants.\n\t\tif len(old.Lit) == 0 {\n\t\t\ttyp := m.irType(old.Type)\n\t\t\tt, ok := typ.(*types.ArrayType)\n\t\t\tif !ok {\n\t\t\t\tpanic(errors.Errorf(\"invalid array type; expected *types.ArrayType, got %T\", typ))\n\t\t\t}\n\t\t\tif t.Len != 0 {\n\t\t\t\tpanic(errors.Errorf(\"invalid number of array elements; expected 0, got %d\", t.Len))\n\t\t\t}\n\t\t\tc := &constant.Array{\n\t\t\t\tTyp: t,\n\t\t\t\tCharArray: true,\n\t\t\t}\n\t\t\treturn c\n\t\t}\n\t\tvar elems []constant.Constant\n\t\tfor i := 0; i < len(old.Lit); i++ {\n\t\t\tb := int64(old.Lit[i])\n\t\t\telem := constant.NewInt(b, types.I8)\n\t\t\telems = append(elems, elem)\n\t\t}\n\t\tc := constant.NewArray(elems...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"character array type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tc.CharArray = true\n\t\treturn c\n\tcase *ast.StructConst:\n\t\tvar fields []constant.Constant\n\t\tfor _, oldField := range old.Fields {\n\t\t\tfields = append(fields, m.irConstant(oldField))\n\t\t}\n\t\tc := constant.NewStruct(fields...)\n\t\tgot := c.Typ\n\t\toldType := m.irType(old.Type)\n\t\twant, ok := oldType.(*types.StructType)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid struct type; expected *types.StructType, got %T\", oldType))\n\t\t}\n\t\t// TODO: Figure out how to validate the bodies of got and want. After name\n\t\t// is copied from want to got, only name identity is used for type\n\t\t// equality.\n\t\tgot.Name = want.Name\n\t\tif !got.Equal(want) {\n\t\t\terr := errors.Errorf(\"struct type mismatch; expected `%v`, got `%v`\", want, got)\n\t\t\tm.errs = append(m.errs, err)\n\t\t}\n\t\treturn c\n\tcase *ast.ZeroInitializerConst:\n\t\treturn constant.NewZeroInitializer(m.irType(old.Type))\n\tcase *ast.UndefConst:\n\t\treturn constant.NewUndef(m.irType(old.Type))\n\n\t// Global variable and function addresses\n\tcase *ast.Global:\n\t\t// TODO: Validate old.Type against type of resolved global?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against global.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tglobal, ok := v.(*ir.Global)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid global type; expected *ir.Global, got %T\", v))\n\t\t}\n\t\treturn global\n\tcase *ast.Function:\n\t\t// TODO: Validate old.Type against type of resolved function?\n\t\t// Not possible currently, as globals have already been resolved by astx.\n\t\t// Consider postponing global resolution until irx, so that\n\t\t// *ast.GlobalDummy.Type may be compared against f.Type.\n\t\tv := m.getGlobal(old.Name)\n\t\tf, ok := v.(*ir.Function)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\"invalid function type; expected *ir.Function, got %T\", v))\n\t\t}\n\t\treturn f\n\n\t// Binary expressions\n\tcase *ast.ExprAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"add expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFAdd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFAdd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fadd expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFSub:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFSub(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fsub expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"mul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFMul:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFMul(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fmul expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewUDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"udiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFDiv:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFDiv(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fdiv expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprURem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewURem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"urem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"srem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFRem:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFRem(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"frem expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Bitwise expressions\n\tcase *ast.ExprShl:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewShl(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shl expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprLShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewLShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"lshr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAShr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAShr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ashr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAnd:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewAnd(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"and expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprOr:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewOr(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"or expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprXor:\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewXor(x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"xor expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Aggregate expressions\n\tcase *ast.ExprExtractValue:\n\t\tx := m.irConstant(old.X)\n\t\tc := constant.NewExtractValue(x, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertValue:\n\t\tx, elem := m.irConstant(old.X), m.irConstant(old.Elem)\n\t\tc := constant.NewInsertValue(x, elem, old.Indices)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertvalue expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Vector expressions\n\tcase *ast.ExprExtractElement:\n\t\tx, index := m.irConstant(old.X), m.irConstant(old.Index)\n\t\tc := constant.NewExtractElement(x, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"extractelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprInsertElement:\n\t\tx, elem, index := m.irConstant(old.X), m.irConstant(old.Elem), m.irConstant(old.Index)\n\t\tc := constant.NewInsertElement(x, elem, index)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"insertelement expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprShuffleVector:\n\t\tx, y, mask := m.irConstant(old.X), m.irConstant(old.Y), m.irConstant(old.Mask)\n\t\tc := constant.NewShuffleVector(x, y, mask)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"shufflevector expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Memory expressions\n\tcase *ast.ExprGetElementPtr:\n\t\tsrc := m.irConstant(old.Src)\n\t\tif srcType, ok := src.Type().(*types.PointerType); !ok {\n\t\t\tpanic(errors.Errorf(\"invalid source type; expected *types.PointerType, got %T\", src.Type()))\n\t\t} else if got, want := srcType.Elem, m.irType(old.Elem); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"source element type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\tvar indices []constant.Constant\n\t\tfor _, oldIndex := range old.Indices {\n\t\t\tindex := m.irConstant(oldIndex)\n\t\t\tindices = append(indices, index)\n\t\t}\n\t\tc := constant.NewGetElementPtr(src, indices...)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"getelementptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Conversion expressions\n\tcase *ast.ExprTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"trunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprZExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewZExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"zext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPTrunc:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPTrunc(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptrunc expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPExt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPExt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fpext expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToUI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToUI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptoui expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFPToSI:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewFPToSI(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fptosi expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprUIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewUIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"uitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSIToFP:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewSIToFP(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"sitofp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprPtrToInt:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewPtrToInt(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"ptrtoint expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprIntToPtr:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewIntToPtr(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"inttoptr expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprBitCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewBitCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"bitcast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprAddrSpaceCast:\n\t\tfrom := m.irConstant(old.From)\n\t\tto := m.irType(old.To)\n\t\tc := constant.NewAddrSpaceCast(from, to)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"addrspacecast expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\t// Other expressions\n\tcase *ast.ExprICmp:\n\t\tcond := constant.IntPred(irIntPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewICmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"icmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprFCmp:\n\t\tcond := constant.FloatPred(irFloatPred(old.Pred))\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewFCmp(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"fcmp expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\tcase *ast.ExprSelect:\n\t\tcond := m.irConstant(old.Cond)\n\t\tx, y := m.irConstant(old.X), m.irConstant(old.Y)\n\t\tc := constant.NewSelect(cond, x, y)\n\t\tif got, want := c.Type(), m.irType(old.Type); !got.Equal(want) {\n\t\t\tm.errs = append(m.errs, errors.Errorf(\"select expression type mismatch; expected `%v`, got `%v`\", want, got))\n\t\t}\n\t\treturn c\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"support for constant %T not yet implemented\", old))\n\t}\n}", "func mustBeUnique(label string) {\n\n\tif _, ok := functions[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as function\", label))\n\t}\n\n\tif _, ok := variables[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as variable\", label))\n\t}\n\n\tif _, ok := aliases[label]; ok {\n\t\tpanic(fmt.Sprintf(\"%s already defined as alias\", label))\n\t}\n}", "func main() {\n\t/*PERCOBAAN 1\n\tini akan mencetak sebuah variable baru bernama \"m\" dengan tipe data \"int\" dengan nilai 123\n\t*/\n\t// m:=123\n\t// fmt.Println(m)\n\t/* HASIL : \n\t\t$ go run test.go\n\t\t123\n\t*/\n\n\t/*PERCOBAAN 2\n\tnamun jika kita mencoba untuk memasukkan nilai baru kepada variable yang di deklarasikan menggunakan Short Assignment Statement terhadap variable Short Assignment Statement yang sudah kita buat sebelumnya (m), maka akan menghasilkan error\n\t*/\n\t// m:=123\n\t// m:=456\n\t// fmt.Println(m)\n\t/* HASIL :\n\t\t$ go run test.go\n\t\t# command-line-arguments\n\t\t.\\test.go:20:3: no new variables on left side of :=\n\t*/\n\n\t/*PERCOBAAN 3\n\tsekarang bagaimana jika kita mendapatkan dua atau lebih value dari function, dan kita ingin menggunakan variable yang sudah ada, untuk menampuk salah satu nilainya. Mana yang harus kita gunakan? := atau =?\n\tjawabannya adalah := silahkan lihat contoh dibawah\n\t*/\n\ti, k := 3, 4\n\tfmt.Println(i, \" \", k)\n\tj, k := 1, 2\n\n\tfmt.Println(i, \" \", k)\n\tfmt.Println(j, \" \", k)\n\t/* HASIL\n\t\t$ go run test.go\n\t\t3 4\n\t\t3 2\n\t\t1 2\n\n\t\tPenjelasan\n\t\tkarena vaiable J di baru saja deklarasikan pada saat statement kedua, maka kita boleh menggunakan := kepada j untuk melakukan inisialisasi, meskipun k sudah di definisikan pada statement sebelumnya\n\t*/\n}", "func checkReservedWords(field string) bool {\n\treservedWordsSet := []string{\"abstract\", \"and\", \"arguments\", \"as\", \"assert\", \"async\", \"await\", \"boolean\", \"break\", \"byte\",\n\t\t\"case\", \"catch\", \"char\", \"class\", \"const\", \"continue\", \"debugger\", \"def\", \"default\", \"del\", \"delete\", \"do\", \"double\", \"elif\",\n\t\t\"else\", \"enum\", \"eval\", \"except\", \"export\", \"extends\", \"false\", \"final\", \"finally\", \"float\", \"for\", \"from\", \"function\", \"global\",\n\t\t\"goto\", \"if\", \"implements\", \"import\", \"in\", \"instanceof\", \"int\", \"interface\", \"is\", \"lambda\", \"let\", \"long\", \"native\", \"new\", \"nonlocal\",\n\t\t\"not\", \"null\", \"or\", \"package\", \"pass\", \"private\", \"protected\", \"public\", \"raise\", \"return\", \"short\", \"static\", \"strictfp\",\n\t\t\"super\", \"switch\", \"synchronized\", \"this\", \"throw\", \"throws\", \"transient\", \"true\", \"try\", \"typeof\", \"var\", \"void\", \"volatile\",\n\t\t\"while\", \"with\", \"yield\"}\n\n\tfor _, segment := range strings.Split(field, \"_\") {\n\t\tresult := sort.SearchStrings(reservedWordsSet, segment)\n\t\tif result < len(reservedWordsSet) && reservedWordsSet[result] == segment {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func mapOpCodes(c *CpuCore) {\n\n\tc.opCodeMap[0xEA] = INSTR_JMP_FAR_PTR16\n\n\tc.opCodeMap[0xE9] = INSTR_JMP_NEAR_REL16\n\n\tc.opCodeMap[0xE3] = INSTR_JCXZ_SHORT_REL8\n\n\tc.opCodeMap[0x74] = INSTR_JZ_SHORT_REL8\n\tc.opCodeMap[0x75] = INSTR_JNZ_SHORT_REL8\n\n\tc.opCodeMap[0xFA] = INSTR_CLI\n\tc.opCodeMap[0xFC] = INSTR_CLD\n\n\tc.opCodeMap[0xE4] = INSTR_IN //imm to AL\n\tc.opCodeMap[0xE5] = INSTR_IN //DX to AL\n\tc.opCodeMap[0xEC] = INSTR_IN //imm to AX\n\tc.opCodeMap[0xED] = INSTR_IN //DX to AX\n\n\tc.opCodeMap[0xE6] = INSTR_OUT //AL to imm\n\tc.opCodeMap[0xE7] = INSTR_OUT //AX to imm\n\tc.opCodeMap[0xEE] = INSTR_OUT //AL to DX\n\tc.opCodeMap[0xEF] = INSTR_OUT //AX to DX\n\n\tc.opCodeMap[0xA8] = INSTR_TEST_AL\n\n\tc.opCodeMap[0xB0] = INSTR_MOV\n\tc.opCodeMap[0xBB] = INSTR_MOV\n\tc.opCodeMap[0xBC] = INSTR_MOV\n\n\tc.opCodeMap[0xB4] = INSTR_MOV\n\tc.opCodeMap[0x8B] = INSTR_MOV\n\tc.opCodeMap[0x8C] = INSTR_MOV\n\tc.opCodeMap[0x8E] = INSTR_MOV\n\n\tc.opCodeMap[0x3C] = INSTR_CMP\n\n\tc.opCodeMap[0x87] = INSTR_XCHG\n\n\tc.opCodeMap[0x90] = INSTR_NOP\n}", "func TestConstError(t *testing.T) {\n\tmsg := \"test\"\n\n\terr := athena.CreateConstError(msg)\n\n\tif err.Error() != msg {\n\t\tt.Errorf(\"err.Error() == %v (want %v)\", err.Error(), msg)\n\t}\n}", "func TestCheckBinaryExprFloatGeqRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `2.0 >= '@'`, env, (2.0 >= '@'), ConstBool)\n}", "func TestCheckBinaryExprStringGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `\"abc\" >= \"abc\"`, env, (\"abc\" >= \"abc\"), ConstBool)\n}", "func TestCheckBinaryExprRuneGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' >= 4`, env, ('@' >= 4), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_ext_name_constraints_not_critical\",\n\t\tDescription: \"If it is included, conforming CAs MUST mark the name constrains extension as critical\",\n\t\tCitation: \"RFC 5280: 4.2.1.10\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC2459Date,\n\t\tLint: &nameConstraintCrit{},\n\t})\n}", "func TestCheckBinaryExprIntAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 &^ 4`, env, NewConstInt64(4 &^ 4), ConstInt)\n}", "func TestCheckBinaryExprIntAndRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 & '@'`, env, NewConstRune(4 & '@'), ConstRune)\n}", "func TestCheckBinaryExprIntGtrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > '@'`, env, (4 > '@'), ConstBool)\n}", "func init() {\n\tlint.RegisterLint(&lint.Lint{\n\t\tName: \"e_subject_info_access_marked_critical\",\n\t\tDescription: \"Conforming CAs MUST mark the Subject Info Access extension as non-critical\",\n\t\tCitation: \"RFC 5280: 4.2.2.2\",\n\t\tSource: lint.RFC5280,\n\t\tEffectiveDate: util.RFC3280Date,\n\t\tLint: &siaCrit{},\n\t})\n}", "func (l *Linter) Lint(conf *config.Config) error {\n\tfor _, check := range l.checks {\n\t\tif err := check(conf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func TestCheckBinaryExprFloatAndNotRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 &^ '@'`, env,\n\t\t`illegal constant expression: untyped number &^ untyped number`,\n\t)\n\n}", "func Test_Errorcode_Build(t *testing.T) {\n\n\terrorCode := uerrors.NewCodeErrorWithPrefix(\"test\", \"test0001\")\n\n\terrorCode.WithMsgBody(\"this is error message content with param.\")\n\terrorCode.WithMsgBody(\"params: ${p1} , ${p2} , ${p3}.\")\n\n\t//log.Printf()\n\n\tres := errorCode.Build(\"hello-message \", \"my deal-other \", \"define\")\n\tfmt.Println(res)\n\n\tfmt.Println(\"case 2\")\n\tres = errorCode.Build(\"hello-message2 \", \"my deal-other2 \", \"define2\")\n\tfmt.Println(res)\n\n}", "func VPCONFLICTD_BCST(ops ...operand.Op) { ctx.VPCONFLICTD_BCST(ops...) }", "func TestCheckBinaryExprStringGeqInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `\"abc\" >= 4`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: \"abc\" >= 4 (mismatched types string and int)`,\n\t)\n\n}", "func sourceSanityCheck(source string, sa Source) {\n\tif len(sa.PrivateKey) > 0 {\n\t\tif _, err := os.Stat(sa.PrivateKey); err != nil {\n\t\t\tFatalf(\"resolvePuppetEnvironment(): could not find SSH private key \" + sa.PrivateKey + \" for source \" + source + \" in config file \" + configFile + \" Error: \" + err.Error())\n\t\t}\n\t}\n\tif len(sa.Basedir) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting basedir is not set for source \" + source + \" in config file \" + configFile)\n\t}\n\tif len(sa.Remote) <= 0 {\n\t\tFatalf(\"resolvePuppetEnvironment(): config setting remote is not set for source \" + source + \" in config file \" + configFile)\n\t}\n}", "func (c developerJargonChecker) check(ctx *checkContext) ([]ValidationComment, error) {\n\tjargon := []string{\n\t\t\"yarn\",\n\t\t\"nodejs\",\n\t}\n\n\tvar found []string\n\tfor _, word := range jargon {\n\t\tif bytes.Contains(ctx.Readme, []byte(word)) {\n\t\t\tfound = append(found, word)\n\t\t}\n\t}\n\n\tif len(found) > 0 {\n\t\treturn []ValidationComment{\n\t\t\t{\n\t\t\t\tSeverity: checkSeverityWarning,\n\t\t\t\tMessage: \"README contains developer jargon\",\n\t\t\t\tDetails: \"Grafana uses the README within the application to help users understand how to use your plugin. Instructions for building and testing the plugin can be confusing for the end user. You can maintain separate instructions for users and developers by replacing the README in the dist directory with the user documentation.\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\treturn nil, nil\n}", "func almostOkayFunction() {\n\treturn nil\n}", "func TestCheckBinaryExprIntGeqString(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `4 >= \"abc\"`, env,\n\t\t`cannot convert \"abc\" to type int`,\n\t\t`invalid operation: 4 >= \"abc\" (mismatched types int and string)`,\n\t)\n\n}", "func main() {\n\tif err := mainErr(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func TestCheckBinaryExprIntGtrInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 > 4`, env, (4 > 4), ConstBool)\n}", "func issue10148() {\n\tfor y /* ERROR \"declared and not used\" */ := range \"\" {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n\tfor y := range 1 /* ERROR \"cannot range over 1\" */ {\n\t\t_ = \"\" /* ERROR \"mismatched types untyped string and untyped int\" */ + 1\n\t}\n}", "func TestCheckBinaryExprFloatOrRune(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectCheckError(t, `2.0 | '@'`, env,\n\t\t`illegal constant expression: untyped number | untyped number`,\n\t)\n\n}", "func bug(err error) error {\n\treturn fmt.Errorf(\"BUG(go-landlock): This should not have happened: %w\", err)\n}", "func genJavaConstFile(pkg *compile.Package, env *compile.Env) *JavaFileInfo {\n\tif !shouldGenerateConstFile(pkg) {\n\t\treturn nil\n\t}\n\n\tclassName := \"Constants\"\n\n\tfiles := make([]constFile, len(pkg.Files))\n\tfor i, file := range pkg.Files {\n\t\tconsts := make([]constConst, len(file.ConstDefs))\n\t\tfor j, cnst := range file.ConstDefs {\n\t\t\tconsts[j].AccessModifier = accessModifierForName(cnst.Name)\n\t\t\tconsts[j].Doc = javaDoc(cnst.Doc, cnst.DocSuffix)\n\t\t\tconsts[j].Type = javaType(cnst.Value.Type(), false, env)\n\t\t\tconsts[j].Name = vdlutil.ToConstCase(cnst.Name)\n\t\t\tconsts[j].Value = javaConstVal(cnst.Value, env)\n\t\t}\n\t\tfiles[i].Name = file.BaseName\n\t\tfiles[i].Consts = consts\n\t}\n\n\tdata := struct {\n\t\tClassName string\n\t\tFileDoc string\n\t\tFiles []constFile\n\t\tPackagePath string\n\t\tSource string\n\t}{\n\t\tClassName: className,\n\t\tFileDoc: pkg.FileDoc,\n\t\tFiles: files,\n\t\tPackagePath: javaPath(javaGenPkgPath(pkg.GenPath)),\n\t\tSource: javaFileNames(pkg.Files),\n\t}\n\tvar buf bytes.Buffer\n\terr := parseTmpl(\"const\", constTmpl).Execute(&buf, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"vdl: couldn't execute const template: %v\", err)\n\t}\n\treturn &JavaFileInfo{\n\t\tName: className + \".java\",\n\t\tData: buf.Bytes(),\n\t}\n}", "func TestCheckBinaryExprIntQuoInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `4 / 4`, env, NewConstInt64(4 / 4), ConstInt)\n}", "func (state *compState) constRK(val value, reg, line int) (int, bool) {\n\tk := state.constK(val)\n\tif k > maxIndexRK {\n\t\tstate.addInst(createABx(opLoadK, reg, k), line)\n\t\treturn reg, true\n\t}\n\treturn rkAsK(k), false\n}", "func BvconstMinusOne(bits uint32) TermT {\n\treturn TermT(C.yices_bvconst_minus_one(C.uint32_t(bits)))\n}", "func TestCheckBinaryExprRuneAndNotInt(t *testing.T) {\n\tenv := MakeSimpleEnv()\n\n\texpectConst(t, `'@' &^ 4`, env, NewConstRune('@' &^ 4), ConstRune)\n}", "func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) {\n\ttestutils.SmallTest(t)\n\t// Both debug/release crashed with a stackoverflow.\n\tg := GCSPackage{\n\t\tDebug: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_debug.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_debug.err\")),\n\t\t},\n\t\tRelease: OutputFiles{\n\t\t\tAsan: testutils.MustReadFile(stacktrace(\"1bad_release.asan\")),\n\t\t\tDump: \"\",\n\t\t\tStdErr: testutils.MustReadFile(stacktrace(\"1grey_release.err\")),\n\t\t},\n\t\tFuzzCategory: \"skcodec\",\n\t\tFuzzArchitecture: \"mock_arm8\",\n\t}\n\n\tresult := ParseGCSPackage(g)\n\texpectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\texpectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow\n\tif result.Debug.Flags != expectedDebugFlags {\n\t\tt.Errorf(\"Parsed Debug flags were wrong. Expected %s, but was %s\", expectedDebugFlags.String(), result.Debug.Flags.String())\n\t}\n\tif result.Release.Flags != expectedReleaseFlags {\n\t\tt.Errorf(\"Parsed Release flags were wrong. Expected %s, but was %s\", expectedReleaseFlags.String(), result.Release.Flags.String())\n\t}\n\t// There was no catchsegv dump, so only one possibility for stacktrace for both of these.\n\tif result.Debug.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty debug stacktrace\")\n\t}\n\tif result.Release.StackTrace.IsEmpty() {\n\t\tt.Errorf(\"Should not have had empty release stacktrace\")\n\t}\n}", "func jsConfigTemplate() string {\n\treturn `\n{\n \"env\": {\n \"browser\": true,\n \"commonjs\": true,\n \"es6\": true,\n \"node\": true\n },\n \"extends\": \"eslint:recommended\",\n \"parserOptions\": {\n \"sourceType\": \"module\"\n },\n \"rules\": {\n \"indent\": [\n \"error\",\n \"tab\"\n ],\n \"linebreak-style\": [\n \"error\",\n \"unix\"\n ],\n \"quotes\": [\n \"error\",\n \"single\"\n ],\n \"semi\": [\n \"error\",\n \"always\"\n ]\n }\n}\n`\n}", "func constant(formatName string) string {\n\tswitch formatName {\n\tcase \"date-time\":\n\t\treturn \"goa.FormatDateTime\"\n\tcase \"email\":\n\t\treturn \"goa.FormatEmail\"\n\tcase \"hostname\":\n\t\treturn \"goa.FormatHostname\"\n\tcase \"ipv4\":\n\t\treturn \"goa.FormatIPv4\"\n\tcase \"ipv6\":\n\t\treturn \"goa.FormatIPv6\"\n\tcase \"ip\":\n\t\treturn \"goa.FormatIP\"\n\tcase \"uri\":\n\t\treturn \"goa.FormatURI\"\n\tcase \"mac\":\n\t\treturn \"goa.FormatMAC\"\n\tcase \"cidr\":\n\t\treturn \"goa.FormatCIDR\"\n\tcase \"regexp\":\n\t\treturn \"goa.FormatRegexp\"\n\tcase \"rfc1123\":\n\t\treturn \"goa.FormatRFC1123\"\n\t}\n\tpanic(\"unknown format\") // bug\n}", "func cgounimpl() {\n\tthrow(\"cgo not implemented\")\n}" ]
[ "0.58951914", "0.5789157", "0.56343776", "0.55349874", "0.5516496", "0.54126674", "0.5380506", "0.53651625", "0.5303207", "0.5297547", "0.52558833", "0.52072686", "0.51567554", "0.51085794", "0.508947", "0.5007158", "0.50040805", "0.49892417", "0.4960484", "0.49534518", "0.49490517", "0.49424648", "0.49373418", "0.49367136", "0.49357283", "0.48906133", "0.4879801", "0.48414347", "0.4835298", "0.4810418", "0.4810253", "0.4806392", "0.47960514", "0.47785494", "0.47633868", "0.47411403", "0.47214967", "0.4721041", "0.47165513", "0.47153512", "0.47133312", "0.46809536", "0.46801886", "0.46794483", "0.46776083", "0.46707362", "0.46633914", "0.46626285", "0.4657592", "0.46561047", "0.46463773", "0.46384448", "0.4625341", "0.46210644", "0.46170443", "0.46095508", "0.46059948", "0.45982367", "0.45978078", "0.4596986", "0.45850873", "0.45840323", "0.4570754", "0.45618755", "0.4548203", "0.45382392", "0.4538029", "0.45360819", "0.45342618", "0.45304775", "0.45291564", "0.452381", "0.45203948", "0.45201117", "0.4518946", "0.45164886", "0.45164186", "0.45093197", "0.45046136", "0.4500351", "0.44988295", "0.4498462", "0.44921872", "0.4490083", "0.44874597", "0.44859907", "0.44797602", "0.44794062", "0.4478887", "0.44747335", "0.447302", "0.44706154", "0.4470536", "0.44703138", "0.4469773", "0.44673866", "0.44593135", "0.44589624", "0.44488844", "0.4447977", "0.44471195" ]
0.0
-1
return store instance to interact with db
func NewCatStore(db *gorm.DB) *CatStore { return &CatStore{ db: db, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Store() *bolt.DB {\n\treturn store\n}", "func Store() store.Store {\n\treturn pg.New(config.GetDbURL())\n}", "func GetStore() KVStore {\n\treturn dbConn\n}", "func Instance() *gorm.DB {\n return database\n}", "func (s *Store) Store() backend.Store {\n\treturn s.store\n}", "func NewStore()(*Store) {\n m := &Store{\n Entity: *iadcd81124412c61e647227ecfc4449d8bba17de0380ddda76f641a29edf2b242.NewEntity(),\n }\n return m\n}", "func newStore(ts service.Service, config *Config) (*Store, error) {\n\tif config.Datastore == nil {\n\t\tdatastore, err := newDefaultDatastore(config.RepoPath, config.LowMem)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tconfig.Datastore = datastore\n\t}\n\tif config.EventCodec == nil {\n\t\tconfig.EventCodec = newDefaultEventCodec(config.JsonMode)\n\t}\n\tif !managedDatastore(config.Datastore) {\n\t\tif config.Debug {\n\t\t\tif err := util.SetLogLevels(map[string]logging.LogLevel{\"store\": logging.LevelDebug}); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tctx, cancel := context.WithCancel(context.Background())\n\ts := &Store{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t\tdatastore: config.Datastore,\n\t\tdispatcher: newDispatcher(config.Datastore),\n\t\teventcodec: config.EventCodec,\n\t\tmodelNames: make(map[string]*Model),\n\t\tjsonMode: config.JsonMode,\n\t\tlocalEventsBus: &localEventsBus{bus: broadcast.NewBroadcaster(0)},\n\t\tstateChangedNotifee: &stateChangedNotifee{},\n\t\tservice: ts,\n\t}\n\n\tif s.jsonMode {\n\t\tif err := s.reregisterSchemas(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\ts.dispatcher.Register(s)\n\treturn s, nil\n}", "func New() (Store, error) {\n dbUsername := os.Getenv(\"DB_USERNAME\")\n dbPassword := os.Getenv(\"DB_PASSWORD\")\n dbHost := os.Getenv(\"DB_HOST\")\n dbTable := os.Getenv(\"DB_TABLE\")\n dbPort := os.Getenv(\"DB_PORT\")\n dbSSLMode := os.Getenv(\"DB_SSL_MODE\")\n\n connectionString := fmt.Sprintf(\n \"host=%s port=%s user=%s dbname=%s password=%s sslmode=%s\",\n dbHost, dbPort, dbUsername, dbTable, dbPassword, dbSSLMode,\n )\n\n db, err := sqlx.Connect(\"postgres\", connectionString)\n if err != nil {\n return Store{}, err\n }\n\n return Store{\n db: db,\n }, nil\n}", "func NewStore(c *cli.Context) Store {\n\treturn &datastore{\n\t\tDB: open(c.String(\"database-config\")),\n\t}\n}", "func Get() *Store {\n\treturn coreStore\n}", "func New(opts ...StoreOption) (*Store, error) {\n\tso := storeOptions{}\n\n\tfor _, opt := range opts {\n\t\topt.apply(&so)\n\t}\n\n\tdbOptions := url.Values{}\n\tdbOptions.Set(\"_foreign_keys\", \"true\")\n\n\tdbURL := url.URL{\n\t\tScheme: \"file\",\n\t\tPath: so.path,\n\t\tRawQuery: dbOptions.Encode(),\n\t}\n\n\tdb, err := sqlx.Connect(\"sqlite3\", dbURL.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdb.Mapper = reflectx.NewMapperFunc(\"json\", strings.ToLower)\n\n\treturn &Store{\n\t\tdb: db,\n\t}, nil\n}", "func (s *baseStore[T, E, TPtr, EPtr]) DB() *gosql.DB {\n\treturn s.db\n}", "func (engine *Engine) Store() {\n\t// if engine.initOptions.UseStore {\n\terr := os.MkdirAll(engine.initOptions.StoreFolder, 0700)\n\tif err != nil {\n\t\tlog.Fatalf(\"Can not create directory: %s ; %v\",\n\t\t\tengine.initOptions.StoreFolder, err)\n\t}\n\n\t// 打开或者创建数据库\n\tengine.dbs = make([]store.Store, engine.initOptions.StoreShards)\n\tfor shard := 0; shard < engine.initOptions.StoreShards; shard++ {\n\t\tdbPath := engine.initOptions.StoreFolder + \"/\" +\n\t\t\tStoreFilePrefix + \".\" + strconv.Itoa(shard)\n\n\t\tdb, err := store.OpenStore(dbPath, engine.initOptions.StoreEngine)\n\t\tif db == nil || err != nil {\n\t\t\tlog.Fatal(\"Unable to open database \", dbPath, \": \", err)\n\t\t}\n\t\tengine.dbs[shard] = db\n\t}\n\n\t// 从数据库中恢复\n\tfor shard := 0; shard < engine.initOptions.StoreShards; shard++ {\n\t\tgo engine.storeInitWorker(shard)\n\t}\n\n\t// 等待恢复完成\n\tfor shard := 0; shard < engine.initOptions.StoreShards; shard++ {\n\t\t<-engine.storeInitChan\n\t}\n\n\tfor {\n\t\truntime.Gosched()\n\n\t\tengine.loc.RLock()\n\t\tnumDoced := engine.numIndexingReqs == engine.numDocsIndexed\n\t\tengine.loc.RUnlock()\n\n\t\tif numDoced {\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\t// 关闭并重新打开数据库\n\tfor shard := 0; shard < engine.initOptions.StoreShards; shard++ {\n\t\tengine.dbs[shard].Close()\n\t\tdbPath := engine.initOptions.StoreFolder + \"/\" +\n\t\t\tStoreFilePrefix + \".\" + strconv.Itoa(shard)\n\n\t\tdb, err := store.OpenStore(dbPath, engine.initOptions.StoreEngine)\n\t\tif db == nil || err != nil {\n\t\t\tlog.Fatal(\"Unable to open database \", dbPath, \": \", err)\n\t\t}\n\t\tengine.dbs[shard] = db\n\t}\n\n\tfor shard := 0; shard < engine.initOptions.StoreShards; shard++ {\n\t\tgo engine.storeIndexDocWorker(shard)\n\t}\n\t// }\n}", "func NewStore(schema Schema, options ...CeousOption) *BaseStore {\n\tstore := &BaseStore{\n\t\tschema: schema,\n\t}\n\tfor _, option := range options {\n\t\toption(store)\n\t}\n\tif !store.disableCache {\n\t\tstore.runner = store._runner\n\t} else {\n\t\tstore.runner = sq.NewStmtCacher(store._runner)\n\t}\n\treturn store\n}", "func NewStore() (*gorm.DB, sqlmock.Sqlmock, error) {\n\tsqldb, mock, err := sqlmock.New()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tdb, err := gorm.Open(postgres.New(postgres.Config{\n\t\tConn: sqldb,\n\t}), &gorm.Config{})\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn db, mock, nil\n}", "func NewStore(db *sql.DB) *Store {\n\n\treturn &Store{\n\t\tdb: db,\n\t\tQueries: New(db), //defined in db.go by sqlc\n\t}\n}", "func (r *Repository) Store() Store {\n\treturn r.store\n}", "func New(ctx context.Context, cfg *config.Config, logger *logrus.Logger) (*Store, error) {\n\tvar store Store\n\n\tstore.config = cfg\n\tstore.logger = logger\n\n\t// connect to postgres\n\tpgConn, err := postgres.NewConnect(cfg.Postgres)\n\tif err != nil {\n\t\treturn &store, errpath.Err(err)\n\t}\n\tstore.Pg = pgConn\n\n\tif pgConn != nil {\n\t\tgo store.keepAlivePg()\n\t}\n\n\treturn &store, nil\n}", "func New() *Store {\n\treturn &Store{\n\t\tmu: sync.Mutex{},\n\t\tsess: make(map[string]*entities.Session),\n\t}\n}", "func New() *thingsStore {\n\tdb, err := gorm.Open(\"postgres\", \"host=localhost port=5432 user=postgres dbname=gorming sslmode=disable\")\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn &thingsStore{\n\t\tdb: db,\n\t}\n}", "func NewStore() *Store {\n\treturn &Store{\n\t\tES: MustOpenConnection(),\n\t}\n}", "func (h *Handler) Store() Store {\n\treturn h.store\n}", "func (p *Provider) OpenStore(name string) (storage.Store, error) {\n\tp.mux.Lock()\n\tdefer p.mux.Unlock()\n\n\tif p.dbPrefix != \"\" {\n\t\tname = p.dbPrefix + \"_\" + name\n\t}\n\n\t// Check cache first\n\tcachedStore, existsInCache := p.dbs[name]\n\tif existsInCache {\n\t\treturn cachedStore, nil\n\t}\n\n\t// If it's not in the cache, then let's ask the CouchDB server if it exists\n\texistsOnServer, err := p.couchDBClient.DBExists(context.Background(), name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(dbExistsCheckFailure, err)\n\t}\n\n\tif !existsOnServer {\n\t\treturn nil, storage.ErrStoreNotFound\n\t}\n\n\tdb := p.couchDBClient.DB(context.Background(), name)\n\n\t// db.Err() won't return an error if the database doesn't exist, hence the need for the explicit DBExists call above\n\tif dbErr := db.Err(); dbErr != nil {\n\t\treturn nil, fmt.Errorf(failureWhileConnectingToDBErrMsg, dbErr)\n\t}\n\n\tstore := &CouchDBStore{db: db, marshal: json.Marshal, readAll: ioutil.ReadAll, unquote: strconv.Unquote}\n\n\tp.dbs[name] = store\n\n\treturn store, nil\n}", "func newStore(c *Config) (*Store, error) {\n\tif c == nil {\n\t\tc = defaultConfig()\n\t}\n\tmutex := &sync.RWMutex{}\n\tstore := new(Store)\n\tstartTime := time.Now().UTC()\n\tfileWatcher, err := newWatcher(\".\")\n\tif err != nil {\n\t\tlog.Info(fmt.Sprintf(\"unable to init file watcher: %v\", err))\n\t}\n\tif c.Monitoring {\n\t\tmonitoring.Init()\n\t}\n\tstore.fileWatcher = fileWatcher\n\tstore.store = makeStorage(\"\")\n\tstore.keys = []string{}\n\tstore.compression = c.Compression\n\tstore.dbs = make(map[string]*DB)\n\tstore.lock = mutex\n\tstore.stat = new(stats.Statistics)\n\tstore.stat.Start = startTime\n\tstore.indexes = make(map[string]*index)\n\tc.setMissedValues()\n\tstore.config = c\n\tif c.LoadPath != \"\" {\n\t\terrLoad := loadData(store, c.LoadPath)\n\t\tif errLoad != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to load data: %v\", errLoad)\n\t\t}\n\t}\n\tstore.writer, err = newWriter(c.LoadPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create writer: %v\", err)\n\t}\n\treturn store, nil\n}", "func New(c *Config) *sqlstore {\n\tdsn := c.DSN()\n\tdbx, err := sqlx.Connect(c.Driver, dsn)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error connecting to database: %s\", err)\n\t}\n\tdb := &sqlstore{dbx, c.Driver, c}\n\n\tif c.Host == \"\" || c.Driver == SQLITE {\n\t\tlog.Printf(\"Connected to %s database: %s\", c.Driver, c.Dbname())\n\t} else {\n\t\tlog.Printf(\"Connected to %s database: %s on %s\", c.Driver, c.Dbname(), c.Host)\n\t}\n\n\t// apply database migrations (if any)\n\tdb.Migrate()\n\n\treturn db\n}", "func newStore(c *Config, httpAddr, raftAddr string) *store {\n\tinternalData := meta.Data{\n\t\tIndex: 1,\n\t}\n\ts := store{\n\t\tdata: &Data{\n\t\t\tData: internalData,\n\t\t},\n\t\tclosing: make(chan struct{}),\n\t\tdataChanged: make(chan struct{}),\n\t\tpath: c.Dir,\n\t\tconfig: c,\n\t\thttpAddr: httpAddr,\n\t\traftAddr: raftAddr,\n\t\tlogger: zap.New(zap.NullEncoder()),\n\t}\n\n\treturn &s\n}", "func (sess *Session) Store() Store {\n\treturn sess.store\n}", "func NewStore(db *sql.DB) *Store {\n\treturn &Store{\n\t\tdb: db,\n\t\tQueries: New(db), // New creates and returns a queries object\n\t}\n}", "func OpenStore() (*Store, error) {\n\tdb, errConnect := sqlx.Connect(\"pgx\", os.Getenv(\"POSTGRES_SERVER_URL\"))\n\tif errConnect != nil {\n\t\treturn nil, fmt.Errorf(\"error opening database: %w\", errConnect)\n\t}\n\n\t// Connection settings\n\tmaxConn, _ := strconv.Atoi(os.Getenv(\"POSTGRES_MAX_CONNECTIONS\"))\n\tmaxIdleConn, _ := strconv.Atoi(os.Getenv(\"POSTGRES_MAX_IDLE_CONNECTIONS\"))\n\tmaxLifetimeConn, _ := strconv.Atoi(os.Getenv(\"POSTGRES_MAX_LIFETIME_CONNECTIONS\"))\n\n\tdb.SetMaxOpenConns(maxConn) // The default is 0 (unlimited)\n\tdb.SetMaxIdleConns(maxIdleConn) // defaultMaxIdleConns = 2\n\tdb.SetConnMaxLifetime(time.Duration(maxLifetimeConn)) // 0, connections are reused forever\n\n\tif errPing := db.Ping(); errPing != nil {\n\t\tdb.Close()\n\t\treturn nil, fmt.Errorf(\"error connecting to database: %w\", errPing)\n\t}\n\n\treturn &Store{\n\t\tAuthStore: &AuthStore{DB: db},\n\t\tUserStore: &UserStore{DB: db},\n\t\tProjectStore: &ProjectStore{DB: db},\n\t\tTokenStore: &TokenStore{DB: db},\n\t}, nil\n}", "func NewStore() (StoreType, error) {\n\tconnection, err := config.DBConnectionString()\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tdb, err := sqlx.Connect(driver, connection)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\ts := &Store{\n\t\tdb: db,\n\t}\n\n\treturn s, nil\n}", "func New(opt StoreOptions) *Store {\n\tstore := &Store{}\n\n\tfmt.Println(opt.toString())\n\tsession, err := mgo.Dial(opt.toString())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tstore.cli = session\n\tstore.database = opt.Database\n\treturn store\n}", "func NewStore(db database.Client) Store {\n\treturn &store{\n\t\tdb: db,\n\t}\n}", "func (s *Store) DB() *leveldb.DB {\n\treturn s.db\n}", "func New(options Options) *Store {\n\tif options.Codec == nil {\n\t\toptions.Codec = DefaultOptions.Codec\n\t}\n\n\tif options.Interval == 0 {\n\t\toptions.Interval = DefaultOptions.Interval\n\t}\n\n\tif options.TableName == \"\" {\n\t\toptions.TableName = DefaultOptions.TableName\n\t}\n\n\tsql := newSqlSvr(options.User, options.Pwd, options.Host, options.Db, options.TableName, options.Split)\n\tif sql == nil {\n\t\treturn nil\n\t}\n\n\ts := &Store{\n\t\tSql: sql,\n\t\tCodec: options.Codec,\n\t}\n\n\t//go s.autoGC(options.Interval)\n\n\treturn s\n}", "func NewStore(dbName string) *Store {\n\tdb, err := bolt.Open(dbName, 0600, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn &Store{db: db}\n}", "func NewStore(p string) (Store, error) {\n\tp = path.Join(p, SQLiteDBName)\n\tdb, err := sql.Open(\"sqlite3\", fmt.Sprintf(\"file:%s?mode=ro\", p))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstmt, err := db.Prepare(\"select value from entries where key = ?\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcache, err := lru.New(DirCacheSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\taclCache, err := lru.New(AccessCacheSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &sqlStore{\n\t\tdb: db,\n\t\tstmt: stmt,\n\t\tcache: cache,\n\t\tacl: aclCache,\n\n\t\tusers: make(map[string]int),\n\t\tgroups: make(map[string]int),\n\t}, nil\n}", "func (m *Mongo) Instance() (*mgo.Database, *mgo.Session) {\n\ts := m.Session.Copy()\n\treturn s.DB(m.Settings.Database), s\n}", "func New(c Config) (*Store, error) {\n\tstore := &Store{config: c}\n\tdb, err := sqlx.Connect(\"postgres\", fmt.Sprintf(\"user=%s password=%s dbname=%s host=%s port=%d sslmode=disable\", c.User, c.Password, c.Database, c.Host, c.Port))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdb.DB.SetMaxOpenConns(c.MaxConnections)\n\tstore.DB = db\n\treturn store, nil\n}", "func NewStore(db *sql.DB) Store {\n\treturn &SQLStore{\n\t\tdb:\t\tdb, \n\t\tQueries: New(db),\n\t}\n}", "func NewStore(client dbClient, validSec int) *Store {\n\treturn &Store{\n\t\tclient: client,\n\t\tvalid: time.Duration(validSec) * time.Second,\n\t}\n}", "func New() *Store {\n\treturn &Store{}\n}", "func New() *Store {\n\treturn &Store{}\n}", "func (sp *StoreProvider) OpenStore(ledgerID string) (storeapi.Store, error) {\n\treturn &store{}, nil\n}", "func NewStore(l log.Logger, dsn string) (hydrocarbon.PrimitiveStore, error) {\n\tdb, err := sqlx.Connect(\"postgres\", dsn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdb.Mapper = reflectx.NewMapperFunc(\"json\", strings.ToLower)\n\n\terr = Migrate(l, db)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Store{\n\t\tdb: db,\n\t}, nil\n}", "func getStore(c *template.Context) (st *store, err error) {\n\t// Recover panics and return the error message.\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\terr = fmt.Errorf(\"%v\", e)\n\t\t}\n\t}()\n\n\t// The store ID is the context's root ID.\n\tid := c.RootID()\n\n\t// Create the context execution value key.\n\tcKey := contextValueKeyStorePrefix + id\n\n\t// If the store was already previously obtained and added\n\t// to the context execution values, then use this value\n\t// instead of getting it again from the database.\n\tstoreI, _ := c.Get(cKey, func() interface{} {\n\t\t// Get the session pointer.\n\t\tsession := c.Session()\n\n\t\t// Get a boolean if the edit mode is active for\n\t\t// the current session.\n\t\teditModeActive := editmode.IsActive(session)\n\n\t\t// The store was not found in the context\n\t\t// execution values. Obtain it...\n\t\tdata, err := dbGetStore(id, editModeActive)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t} else if data == nil {\n\t\t\t// Create a new db store.\n\t\t\tdata = newDBStore(id)\n\t\t}\n\n\t\t// Create a new store value.\n\t\ts := newStore(data)\n\n\t\treturn s\n\t})\n\n\t// Assert and return.\n\treturn storeI.(*store), nil\n}", "func (s Store) Open(path string, cfg *config.Config) (driver.IDB, error) {\n\tmockDB := MockDB{mock: s.Mock}\n\treturn &mockDB, nil\n}", "func New(ctx context.Context, log logger.Logger, db *db.Store, cache *cache.Cache) (*Store, error) {\n\ts := &Store{\n\t\tlog: log,\n\t\tcache: cache,\n\t}\n\n\t// Set configuration\n\ts.setConfig()\n\n\tvar err error\n\n\tswitch s.typeStore {\n\tcase \"postgres\":\n\t\tfallthrough\n\tdefault:\n\t\ts.store, err = postgres.New(ctx, db)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tlog.Info(\"init queryStore\", field.Fields{\n\t\t\"db\": s.typeStore,\n\t})\n\n\treturn s, nil\n}", "func getStore() (storage.Store, error) {\n\topts, err := storage.DefaultStoreOptions(unshare.IsRootless(), unshare.GetRootlessUID())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tstore, err := storage.GetStore(opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif store == nil {\n\t\treturn nil, fmt.Errorf(\"unable to instantiate storage\")\n\t}\n\tis.Transport.SetStore(store)\n\treturn store, nil\n}", "func New(ctx context.Context, log logger.Logger, db *db.Store, cache *cache.Cache) (*Store, error) { // nolint:gocognit\n\ts := &Store{\n\t\tlog: log,\n\t\tcache: cache,\n\t}\n\n\t// Set configuration\n\ts.setConfig()\n\n\tvar err error\n\n\tswitch s.typeStore {\n\tcase \"postgres\":\n\t\ts.store, err = postgres.New(ctx, db)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"mongo\":\n\t\ts.store, err = mongo.New(ctx, db)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"redis\":\n\t\ts.store, err = redis.New(ctx, db)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"dgraph\":\n\t\ts.store, err = dgraph.New(ctx, db, log)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"leveldb\":\n\t\ts.store, err = leveldb.New(ctx, db)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"badger\":\n\t\ts.store, err = badger.New(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase \"ram\":\n\t\tfallthrough\n\tdefault:\n\t\ts.store, err = ram.New(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tlog.Info(\"init linkStore\", field.Fields{\n\t\t\"db\": s.typeStore,\n\t})\n\n\treturn s, nil\n}", "func New(observationCtx *observation.Context, db database.DB) Store {\n\treturn &store{\n\t\tlogger: logger.Scoped(\"uploads.store\", \"\"),\n\t\tdb: basestore.NewWithHandle(db.Handle()),\n\t\toperations: newOperations(observationCtx),\n\t}\n}", "func GetDatastore (spec DStoreSpec) (ds Datastore, err error ) {\n\n\tmongoDBDialInfo := &mgo.DialInfo{\n\t\tAddrs: []string{spec.Hostaddr},\n\t\tTimeout: 60 * time.Second,\n\t\tDatabase: spec.Dbname,\n\t\tUsername: spec.Dbuser,\n\t\tPassword: spec.Dbpwd,\n\t}\n\t\n\t// Create a session which maintains a pool of socket connections\n\t// to our MongoDB.\n\tmongoSession, err := mgo.DialWithInfo(mongoDBDialInfo)\n\tif err != nil {\n\t\tlog.Fatalf(\"CreateSession: %s\\n\", err)\n\t\treturn nil, err\n\t}\n\n\tmongoSession.SetMode(mgo.Monotonic, true)\n\n\t//c := mongoSession.DB(\"test\").C(\"mytable\")\n // err = c.Insert(bson.M{\"name\":\"Asta1\"})\n\n // if err != nil {\n // log.Fatal(err)\n // }\n \n\n\treturn &Mongostore{session: mongoSession, dbspec:spec}, nil\n}", "func newStore() storage.Store {\n\tdata := `{\n \"management_chain\": {\n \"bob\": [\n \"ken\",\n \"janet\"\n ],\n \"alice\": [\n \"janet\"\n ]\n }\n}`\n\n\tvar json map[string]interface{}\n\n\terr := util.UnmarshalJSON([]byte(data), &json)\n\tif err != nil {\n\t\t// Handle error.\n\t}\n\n\t// Manually create the storage layer. inmem.NewFromObject returns an\n\t// in-memory store containing the supplied data.\n\tstore := inmem.NewFromObject(json)\n\treturn store\n}", "func GetStore() StoreIf {\n\treturn metadataStore\n}", "func (dbProvider *dbProvider) Instance() *gorm.DB {\n\treturn dbProvider.instance\n}", "func Open(ns walletdb.ReadBucket, chainParams *chaincfg.Params) (*Store, er.R) {\n\t// Open the store.\n\terr := openStore(ns)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts := &Store{chainParams, clock.NewDefaultClock(), nil} // TODO: set callbacks\n\treturn s, nil\n}", "func New(uri string, name string) (*Store, error) {\r\n\tclientOptions := options.Client().ApplyURI(uri)\r\n\r\n\tclient, err := mongo.Connect(context.TODO(), clientOptions)\r\n\tif err != nil {\r\n\t\tlog.Println(\"Error connecting to the database\")\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tdb := client.Database(name)\r\n\treturn &Store{db, client}, nil\r\n}", "func NewStore() *Store {\n\tvar st Store\n\tst.Records = make(map[string]HostSet)\n\tst.Netviews = make(map[string]string)\n\tst.Cidrs = make(map[string]string)\n\treturn &st\n}", "func (client MongoClient) Store(ctx context.Context, app apps.App) error {\n\n\tdata, err := bson.Marshal(app)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcoll := client.conn.Database(nameDB).Collection(nameColl)\n\t_, err = coll.InsertOne(ctx, data)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func NewStore(db *cockroach.DB, logger *zap.Logger) *Store {\n\treturn &Store{\n\t\tdb: db,\n\t\tlogger: logger,\n\t\tclock: DefaultClock,\n\t}\n}", "func NewStore(db *database.DB, collection string) Store {\n\treturn &store{db, collection}\n}", "func NewStore(d *db.DB) *Store {\n\treturn &Store{\n\t\tdb: d,\n\t}\n}", "func (s *Discovery) Store() store.Store {\n\treturn s.store\n}", "func NewStore() (*Store, error) {\n\tpgDB, err := db.Dial()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"store.Dial\")\n\t}\n\n\tlog.Println(\"Running PostgreSQL migrations...\")\n\tif err := db.RunPgMigrations(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"store.runPgMigrations\")\n\t}\n\n\tstore := &Store{\n\t\tDB: pgDB,\n\t\tArticles: repositories.NewArticlesRepository(pgDB),\n\t\tFeeds: repositories.NewFeedsRepository(pgDB),\n\t\tCategories: repositories.NewCategoryRepository(pgDB),\n\t\tSubcategories: repositories.NewSubcategoryRepository(pgDB),\n\t}\n\n\treturn store, nil\n}", "func (d Driver) Open(path string) (kv.Storage, error) {\n\tmc.mu.Lock()\n\tdefer mc.mu.Unlock()\n\n\tu, err := url.Parse(path)\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\n\tengineSchema := filepath.Join(u.Host, u.Path)\n\tif store, ok := mc.cache[engineSchema]; ok {\n\t\t// TODO: check the cache store has the same engine with this Driver.\n\t\tlog.Info(\"[kv] cache store\", engineSchema)\n\t\treturn store, nil\n\t}\n\n\tdb, err := d.Driver.Open(engineSchema)\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\n\tlog.Info(\"[kv] New store\", engineSchema)\n\ts := &dbStore{\n\t\ttxns: make(map[uint64]*dbTxn),\n\t\tkeysLocked: make(map[string]uint64),\n\t\tuuid: uuid.NewV4().String(),\n\t\tpath: engineSchema,\n\t\tdb: db,\n\t\tcompactor: newLocalCompactor(localCompactDefaultPolicy, db),\n\t\tclosed: false,\n\t}\n\ts.recentUpdates, err = segmentmap.NewSegmentMap(100)\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tregionServers := buildLocalRegionServers(s)\n\tvar infos []*regionInfo\n\tfor _, rs := range regionServers {\n\t\tri := &regionInfo{startKey: rs.startKey, endKey: rs.endKey, rs: rs}\n\t\tinfos = append(infos, ri)\n\t}\n\ts.pd.SetRegionInfo(infos)\n\tmc.cache[engineSchema] = s\n\ts.compactor.Start()\n\treturn s, nil\n}", "func New() *Store {\n\treturn &Store{\n\t\tingredient.NewStore(),\n\t\trecipe.NewStore(),\n\t}\n}", "func NewStore() *Store {\n\treturn &Store{\n\t\topaStore: inmem.New(),\n\t}\n}", "func NewStore(db *sql.DB) (*Store, error) {\n\tunprepared := map[string]string{\n\t\tQueryCreateItem: `\n\t\t\tINSERT INTO todo.items (title, description)\n\t\t\tVALUES(?, ?);\n\t\t`,\n\t\tQueryDeleteItem: `\n\t\t\tDELETE FROM todo.items\n\t\t\tWHERE id = ?;\n\t\t`,\n\t\tQueryFindItemByID: `\n\t\t\tSELECT i.id, i.title, i.description, i.completed, i.created_at, i.updated_at\n\t\t\tFROM todo.items i\n\t\t\tWHERE id = ?;\n\t\t`,\n\t\tQueryUpdateItemByID: `\n\t\t\tUPDATE todo.items i\n\t\t\tSET \n\t\t\t\ti.title = ?,\n\t\t\t\ti.description = ?,\n\t\t\t\ti.completed = ?\n\t\t\tWHERE i.id = ?;\n\t\t`,\n\t}\n\n\t// prepare all statements to verify syntax\n\tstmts, err := prepareStmts(db, unprepared)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := Store{\n\t\tdb: db,\n\t\tstmts: stmts,\n\t}\n\n\treturn &s, nil\n}", "func (me *Model) Store(\n\tctx context.Context,\n\tcol *mongo.Collection,\n) (err error) {\n\tvar res *mongo.InsertOneResult\n\tres, err = col.InsertOne(ctx, me)\n\tif err != nil {\n return\n }\n\tid, ok := res.InsertedID.(primitive.ObjectID)\n\tif !ok {\n\t\terr = errors.New(\"The returned ID was not ObjectID\")\n\t\tlog.Println(\"[WARN]\" + err.Error())\n\t\treturn\n\t}\n\tme.ID = id\n\treturn\n}", "func New(ds datastore.Datastore) *Store {\n\treturn &Store{\n\t\tds: ds,\n\t}\n}", "func NewStore() *Store {\n\treturn &Store{}\n}", "func NewStore() *Store {\n\treturn &Store{}\n}", "func NewStore() *Store {\n\treturn &Store{}\n}", "func NewStore() *Store {\n\treturn &Store{commands: make(map[string]*Config, 0)}\n}", "func NewStore(c *Config) *Store {\n\t// create a new store\n\tstore := Store{}\n\tstore.config = c\n\tstore.DBname = c.DBname\n\t// check if the file exists\n\tvar build bool\n\t_, err := os.Stat(c.DBname)\n\tif err != nil {\n\t\tlogger.Critical(\"error on stat , %s\", err)\n\t\tbuild = true\n\t}\n\t// if it is a new file build some tables\n\tif build {\n\t\tstore.Build(c)\n\t}\n\tstore.leases = Load(c.DBname)\n\treturn &store\n}", "func initStore(logger *logging.Logger, connectionString string) *db.Store {\n\tlogger.Debug(\"Initializing Store\")\n\t// establish a store and connection to the db\n\tstore, err := db.NewStore(connectionString)\n\tif err != nil {\n\t\tsentry.CaptureException(err)\n\t\tlogger.Fatal(\"Failed to initialize store:\" + err.Error())\n\t}\n\tlogger.Debug(\"Store established with database connection\")\n\treturn store\n}", "func (st *Storage) store(r scope.StoreIDer) (*TableStore, error) {\n\tif r == nil {\n\t\treturn nil, ErrStoreNotFound\n\t}\n\tif c, ok := r.(scope.StoreCoder); ok && c.StoreCode() != \"\" {\n\t\treturn st.stores.FindByCode(c.StoreCode())\n\t}\n\treturn st.stores.FindByStoreID(r.StoreID())\n}", "func (c *Client) Store(agmi models.AgencyMonthlyInfo) error {\n\tif err := c.Db.Store(agmi); err != nil {\n\t\treturn fmt.Errorf(\"Store() error: %q\", err)\n\t}\n\treturn nil\n}", "func NewStore() *Store {\n\tdata := `{\n\t\t\"contacts\": [{\n\t\t\t\"name\": \"郭仲杰\",\n\t\t\t\"department\": \"公司其他组织/TME商业广告部\",\n\t\t\t\"title\": \"员工\",\n\t\t\t\"phoneNumber\": \"0755-86013388-75789\",\n\t\t\t\"email\": \"[email protected]\"\n\t\t}]\n\t}`\n\ts := &Store{}\n\terr := json.Unmarshal([]byte(data), s)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn s\n}", "func NewStore() Store {\n\treturn &store{\n\t\thosts: make(map[string][]*v1alpha3.ServiceEntry_Endpoint),\n\t\tm: &sync.RWMutex{},\n\t}\n}", "func NewStore(host, notice, dbPath string) *Store {\n\ts := &Store{\n\t\thost: host,\n\t\tdbPath: dbPath,\n\t\tuser: newUserDB(dbPath),\n\t\tmessage: newMessageDB(dbPath),\n\t\tgroup: newGroupDB(dbPath),\n\t}\n\n\ts.friend = newFriendDB(s.user)\n\ts.postman = newPostman(notice, s.user, s.friend, s.group)\n\n\treturn s\n}", "func (c *Component) DB() (*mgo.Database, *mgo.Session) {\n\treturn c.GM.DB.Instance()\n}", "func newDBStore(db *leveldbhelper.DBHandle, dbName string) *store {\n\treturn &store{db, dbName}\n}", "func New(tableName string, accessor Accessor) (*Store, error) {\n\tstore := &Store{\n\t\ttableName: tableName,\n\t\taccessor: accessor,\n\t}\n\n\treturn store, nil\n}", "func NewStore(conn string) *Store {\n\tcc, _ := pgxpool.ParseConfig(conn)\n\tcc.ConnConfig.Logger = zapadapter.NewLogger(logger.Logger)\n\n\tpgxPool, err := pgxpool.ConnectConfig(context.Background(), cc)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn &Store{\n\t\tdb: &DB{Pool: pgxPool},\n\t}\n}", "func New(c *sqlstore.Config) Datastore {\n\treturn sqlstore.New(c)\n}", "func Open() (Store, error) {\n\treturn openStore()\n}", "func DB() Database {\n\treturn db\n}", "func NewStore() *Store {\n\treturn &Store{syncmap.NewSyncMap()}\n}", "func New(ctx context.Context, alias, path string, cfgdir string) (*Store, error) {\n\tpath = fsutil.CleanPath(path)\n\ts := &Store{\n\t\talias: alias,\n\t\tpath: path,\n\t\tsync: gitmock.New(),\n\t}\n\n\t// init store backend\n\tswitch backend.GetStoreBackend(ctx) {\n\tcase backend.FS:\n\t\ts.store = fs.New(path)\n\t\tout.Debug(ctx, \"Using Store Backend: fs\")\n\tcase backend.KVMock:\n\t\ts.store = kvmock.New()\n\t\tout.Debug(ctx, \"Using Store Backend: kvmock\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unknown store backend\")\n\t}\n\n\t// init sync backend\n\tswitch backend.GetSyncBackend(ctx) {\n\tcase backend.GoGit:\n\t\tout.Cyan(ctx, \"WARNING: Using experimental sync backend 'go-git'\")\n\t\tgit, err := gogit.Open(path)\n\t\tif err != nil {\n\t\t\tout.Debug(ctx, \"Failed to initialize sync backend 'gogit': %s\", err)\n\t\t} else {\n\t\t\ts.sync = git\n\t\t\tout.Debug(ctx, \"Using Sync Backend: go-git\")\n\t\t}\n\tcase backend.GitCLI:\n\t\tgpgBin, _ := gpgcli.Binary(ctx, \"\")\n\t\tgit, err := gitcli.Open(path, gpgBin)\n\t\tif err != nil {\n\t\t\tout.Debug(ctx, \"Failed to initialize sync backend 'git': %s\", err)\n\t\t} else {\n\t\t\ts.sync = git\n\t\t\tout.Debug(ctx, \"Using Sync Backend: git-cli\")\n\t\t}\n\tcase backend.GitMock:\n\t\t// no-op\n\t\tout.Debug(ctx, \"Using Sync Backend: git-mock\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unknown Sync Backend\")\n\t}\n\n\t// init crypto backend\n\tswitch backend.GetCryptoBackend(ctx) {\n\tcase backend.GPGCLI:\n\t\tgpg, err := gpgcli.New(ctx, gpgcli.Config{\n\t\t\tUmask: fsutil.Umask(),\n\t\t\tArgs: gpgcli.GPGOpts(),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ts.crypto = gpg\n\t\tout.Debug(ctx, \"Using Crypto Backend: gpg-cli\")\n\tcase backend.XC:\n\t\t//out.Red(ctx, \"WARNING: Using highly experimental crypto backend!\")\n\t\tcrypto, err := xc.New(cfgdir, client.New(cfgdir))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ts.crypto = crypto\n\t\tout.Debug(ctx, \"Using Crypto Backend: xc\")\n\tcase backend.GPGMock:\n\t\t//out.Red(ctx, \"WARNING: Using no-op crypto backend (NO ENCRYPTION)!\")\n\t\ts.crypto = gpgmock.New()\n\t\tout.Debug(ctx, \"Using Crypto Backend: gpg-mock\")\n\tcase backend.OpenPGP:\n\t\tcrypto, err := openpgp.New(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ts.crypto = crypto\n\t\tout.Debug(ctx, \"Using Crypto Backend: openpgp\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"no valid crypto backend selected\")\n\t}\n\n\treturn s, nil\n}", "func (st *Storage) Store(r scope.StoreIDer) (*Store, error) {\n\ts, err := st.store(r)\n\tif err != nil {\n\t\treturn nil, errgo.Mask(err)\n\t}\n\tw, err := st.website(scope.MockID(s.WebsiteID))\n\tif err != nil {\n\t\treturn nil, errgo.Mask(err)\n\t}\n\tg, err := st.group(scope.MockID(s.GroupID))\n\tif err != nil {\n\t\treturn nil, errgo.Mask(err)\n\t}\n\tns := NewStore(s, w, g, SetStoreConfig(st.cr))\n\tns.Website.SetGroupsStores(st.groups, st.stores)\n\tns.Group.SetStores(st.stores, w)\n\treturn ns, nil\n}", "func Store() gorillaSessions.Store {\n\n}", "func NewStore() Store {\n\treturn Store{cmap.New()}\n}", "func (p *Person) Store(client *mongo.Client) (result *mongo.InsertOneResult, err error) {\r\n\tcollection := client.Database(\"MyApp\").Collection(\"person\")\r\n\tctx, _ := context.WithTimeout(context.Background(), 10*time.Second)\r\n\tresult, err = collection.InsertOne(ctx, p)\r\n\treturn result, err\r\n}", "func Factory(file string) (db.Store, error) {\n\treturn sqlite.MakeDatastore(file)\n}", "func NewStore(host string) *Store {\n\tclient, err := elastic.NewClient(\n\t\t\t\telastic.SetURL(host),\n\t\t\t\t// elastic.SetTraceLog(logger),\n\t)\n\n if err != nil {\n logger.Fatal(err)\n }\n\tstore := &Store{\n\t\tclient: client,\n\t}\n\treturn store\n}", "func (mp *Provider) Get(sessionID []byte) (session.Storer, error) {\n\tcurrentStore := mp.memoryDB.GetBytes(sessionID)\n\tif currentStore != nil {\n\t\treturn currentStore.(*Store), nil\n\t}\n\n\tnewStore := mp.acquireStore(sessionID, mp.expiration)\n\tmp.memoryDB.SetBytes(sessionID, newStore)\n\n\treturn newStore, nil\n}", "func Open(ns walletdb.ReadBucket, chainParams *chaincfg.Params) (*Store, error) {\n\n\t// Open the store.\n\terr := openStore(ns)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts := &Store{chainParams, clock.NewDefaultClock(), nil} // TODO: set callbacks\n\treturn s, nil\n}", "func newDataStore(driver, dsn string) (*dataStore, error) {\r\n\r\n\tvar this *dataStore\r\n\r\n\tif db, err := sqlx.Open(driver, dsn); err != nil {\r\n\t\treturn nil, err\r\n\t} else if err := db.Ping(); err != nil {\r\n\t\treturn nil, err\r\n\t} else {\r\n\t\tthis = &dataStore{\r\n\t\t\tDB: db,\r\n\t\t\tconnPool: new(ConnPool),\r\n\t\t\tnamedStmts: make(map[string]map[string]*namedStmt),\r\n\t\t}\r\n\t}\r\n\r\n\treturn this, nil\r\n}", "func (kv KV) DB() interface{} {\n\treturn kv.db\n}", "func (kv KV) DB() interface{} {\n\treturn kv.db\n}", "func New(dburl string) *Store {\n\treturn &Store{\n\t\tDatabaseURL: dburl,\n\t}\n}" ]
[ "0.7613458", "0.67639315", "0.6701285", "0.65773106", "0.6572337", "0.65669346", "0.6475751", "0.64663815", "0.641933", "0.641262", "0.6412358", "0.64015996", "0.6391207", "0.6363214", "0.6360533", "0.63537705", "0.63418376", "0.6340086", "0.6324563", "0.6293636", "0.6260166", "0.6258729", "0.62469816", "0.62415063", "0.62397224", "0.6230954", "0.6229392", "0.62279904", "0.622404", "0.6220317", "0.62162405", "0.62058145", "0.61834836", "0.61712205", "0.61610246", "0.6151898", "0.61518633", "0.61440617", "0.61288637", "0.6126818", "0.6126149", "0.6126149", "0.6124317", "0.6123232", "0.61148113", "0.61109567", "0.61056364", "0.609458", "0.6079224", "0.6070478", "0.6066159", "0.6056121", "0.6044508", "0.604339", "0.6033639", "0.60333127", "0.60308284", "0.6017462", "0.6012219", "0.60100585", "0.6009838", "0.60076356", "0.6004311", "0.6003367", "0.60017276", "0.5997027", "0.59821725", "0.5977015", "0.5976592", "0.59757894", "0.59757894", "0.59757894", "0.5967905", "0.5965994", "0.596154", "0.59611815", "0.5959518", "0.59420055", "0.5937105", "0.59296536", "0.5928318", "0.5926264", "0.5916766", "0.59137744", "0.5909498", "0.59057736", "0.59044313", "0.5902355", "0.5889424", "0.5884806", "0.5882566", "0.58786017", "0.58742195", "0.58635545", "0.58608717", "0.5860687", "0.5852746", "0.58486414", "0.5847606", "0.5847606", "0.5834506" ]
0.0
-1
Get retrieves a byte buffer from the pool and resets it so that it is ready to use.
func (p *bufferPool) Get() *bytes.Buffer { buf := p.underlying.Get().(*bytes.Buffer) buf.Reset() return buf }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (bp *BufferPool) Get() *bytes.Buffer {\n\tvar buff *bytes.Buffer\n\tselect {\n\tcase buff = <-bp.pool:\n\tdefault:\n\t\tbuff = &bytes.Buffer{}\n\t}\n\treturn buff\n}", "func Get() *bytes.Buffer {\n\treturn gPool.Get().(*bytes.Buffer)\n}", "func (bp *BufferPool) Get() *bytes.Buffer {\n\tbuffer := bp.pool.Get().(*bytes.Buffer)\n\treturn buffer\n}", "func (bp *SizedBufferPool) Get() *bytes.Buffer {\n\tselect {\n\tcase b := <-bp.c:\n\t\treturn b\n\tdefault:\n\t\tb := bytes.NewBuffer(make([]byte, 0, bp.a))\n\t\treturn b\n\t}\n}", "func (bp *BufferPool) Get() *bytes.Buffer {\n\treturn bp.Pool.Get().(*bytes.Buffer)\n}", "func (bp bufferPool) get() *bytes.Buffer {\n\tbuf := bp.p.Get().(*bytes.Buffer)\n\treturn buf\n}", "func (p *Pool) Get() (b *Buffer) {\n\tp.lock.Lock()\n\tif b = p.free; b == nil {\n\t\tp.grow()\n\t\tb = p.free\n\t}\n\tp.free = b.next\n\tp.freeNum--\n\tp.lock.Unlock()\n\tb.Reset()\n\treturn\n}", "func (p *BufferPool) Get() []byte {\n\treturn p.p.Get().([]byte)\n}", "func GetBuffer() *bytes.Buffer {\n\tbuf := bufPool.Get().(*bytes.Buffer)\n\tbuf.Reset()\n\treturn buf\n}", "func GetBuffer() Buffer {\n\treturn pool.get()\n}", "func GetBuffer() *bytes.Buffer {\n\treturn defaultPool.pool.Get().(*bytes.Buffer)\n}", "func GetBuf() *Buffer {\n\tbuf := bufferPool.Get().(*Buffer)\n\tbuf.Reset()\n\treturn buf\n}", "func getBuffer() *bytes.Buffer {\n\treturn bufferPool.Get().(*bytes.Buffer)\n}", "func netbufGet() (buf []byte) {\n\tbufInterface := poolNetBuffers.Get()\n\tif bufInterface == nil {\n\t\tbuf = make([]byte, NETBUF_SIZE)\n\t} else {\n\t\tbuf = bufInterface.([]byte)\n\t\t// prevent data leak\n\t\tfor i := range buf {\n\t\t\tbuf[i] = 0\n\t\t}\n\n\t}\n\treturn buf\n}", "func (bp bufferPool) Get() intermediateBuffer {\n\tselect {\n\tcase buf := <-bp.c:\n\t\treturn buf\n\tdefault:\n\t\treturn bp.f()\n\t}\n}", "func (p *BufferBucketPool) Get() *BufferBucket {\n\treturn p.pool.Get().(*BufferBucket)\n}", "func (this *BytesPool) Get() (rv []byte) {\n\treturn *this.pool.Get().(*[]byte) // use ptr to avoid allocation\n}", "func (_ BufferPtrPool1M) Get() *[]byte {\n\treturn GetBytesSlicePtr1M()\n}", "func (p *Pool) Get() ([]byte, error) {\n\tif b, ok := p.tryPop(); ok {\n\t\treturn b, nil\n\t}\n\n\tp.Lock()\n\tdefer p.Unlock()\n\n\tif len(p.allocated) == p.maxBlocks {\n\t\treturn nil, ErrPoolFull\n\t}\n\tresult, err := alloc(p.initOpts.blockSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tk := &result[0]\n\tp.allocated[k] = struct{}{}\n\treturn result, nil\n}", "func (_ BufferPtrPool8M) Get() *[]byte {\n\treturn GetBytesSlicePtr8M()\n}", "func GetBytesBuffer() *bytes.Buffer {\n\tbuf := defaultPool.Get().(*bytes.Buffer)\n\tbufCap := buf.Cap()\n\tif bufCap >= minBufCap && bufCap <= maxBufCap && poolObjectNumber.Load() > 0 {\n\t\tpoolObjectNumber.Dec()\n\t}\n\n\treturn buf\n}", "func (_ BufferPtrPool8K) Get() *[]byte {\n\treturn GetBytesSlicePtr8K()\n}", "func (_ BufferPtrPool1K) Get() *[]byte {\n\treturn GetBytesSlicePtr1K()\n}", "func getBuf(l int) []byte {\n\tx := bufPool.Get()\n\tif x == nil {\n\t\treturn make([]byte, l)\n\t}\n\tbuf := x.([]byte)\n\tif cap(buf) < l {\n\t\treturn make([]byte, l)\n\t}\n\treturn buf[:l]\n}", "func (bp *bufferPool) getBuffer() *buffer {\n\tbp.lock.Lock()\n\tb := bp.freeList\n\tif b != nil {\n\t\tbp.freeList = b.next\n\t\tbp.freeBufNum--\n\t}\n\tbp.lock.Unlock()\n\n\tif b == nil {\n\t\tb = new(buffer)\n\t\tb.Grow(512)\n\t} else {\n\t\tb.next = nil\n\t\tb.Reset()\n\t}\n\treturn b\n}", "func (bufferP *BufferPool) Get(size int) (data []byte, err error) {\n\tif size == util.PacketHeaderSize {\n\t\tatomic.AddInt64(&headBuffersCount, 1)\n\t\tid := atomic.AddUint64(&headBufAllocId, 1)\n\t\treturn bufferP.getHead(id), nil\n\t} else if size == util.BlockSize {\n\t\tatomic.AddInt64(&normalBuffersCount, 1)\n\t\tid := atomic.AddUint64(&normalBufAllocId, 1)\n\t\treturn bufferP.getNoraml(id), nil\n\t} else if size == util.DefaultTinySizeLimit {\n\t\tatomic.AddInt64(&tinyBuffersCount, 1)\n\t\treturn bufferP.tinyPool.Get().([]byte), nil\n\t}\n\treturn nil, fmt.Errorf(\"can only support 45 or 65536 bytes\")\n}", "func (_ BufferPtrPool2M) Get() *[]byte {\n\treturn GetBytesSlicePtr2M()\n}", "func (_ BufferPtrPool2K) Get() *[]byte {\n\treturn GetBytesSlicePtr2K()\n}", "func Get() *Buffer {\n\treturn freeList.get()\n}", "func getBuf(size int) *[]byte {\n\tx := bufPool.Get()\n\tif x == nil {\n\t\tb := make([]byte, size)\n\t\treturn &b\n\t}\n\tbuf := x.(*[]byte)\n\tif cap(*buf) < size {\n\t\tb := make([]byte, size)\n\t\treturn &b\n\t}\n\t*buf = (*buf)[:size]\n\treturn buf\n}", "func (_ BufferPtrPool64K) Get() *[]byte {\n\treturn GetBytesSlicePtr64K()\n}", "func (_ BufferPtrPool16K) Get() *[]byte {\n\treturn GetBytesSlicePtr16K()\n}", "func (_ BufferPtrPool16M) Get() *[]byte {\n\treturn GetBytesSlicePtr16M()\n}", "func (_ BufferPtrPool256K) Get() *[]byte {\n\treturn GetBytesSlicePtr256K()\n}", "func (_ BufferPtrPool128K) Get() *[]byte {\n\treturn GetBytesSlicePtr128K()\n}", "func (c *Client) GetByteBuffer(url string) (*bytes.Buffer, error) {\n\tbuf := bytes.NewBuffer(nil)\n\n\tresp, err := c.Get(url)\n\tif err != nil {\n\t\treturn buf, err\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn buf, fmt.Errorf(\"failed to fetch %s : %s\", url, resp.Status)\n\t}\n\n\t_, err = io.Copy(buf, resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = resp.Body.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error when closing the response body %s\", err)\n\t}\n\treturn buf, err\n}", "func (_ BufferPtrPool256) Get() *[]byte {\n\treturn GetBytesSlicePtr256()\n}", "func Getbuf() (_ Buf, wr *Bwr) { //nolint:golint\n\twr = bufPool.Get().(*Bwr)\n\treturn wr.b, wr\n}", "func (_ BufferPtrPool4M) Get() *[]byte {\n\treturn GetBytesSlicePtr4M()\n}", "func (_ BufferPtrPool512K) Get() *[]byte {\n\treturn GetBytesSlicePtr512K()\n}", "func (_ BufferPtrPool4K) Get() *[]byte {\n\treturn GetBytesSlicePtr4K()\n}", "func GetBuffer() *Buffer {\n\tfreeListMu.Lock()\n\tb := freeList\n\tif b != nil {\n\t\tfreeList = b.next\n\t\tfreeListLen--\n\t}\n\tfreeListMu.Unlock()\n\tif b == nil {\n\t\tb = new(Buffer)\n\t} else {\n\t\tb.next = nil\n\t\tb.Reset()\n\t}\n\treturn b\n}", "func (_ BufferPtrPool512) Get() *[]byte {\n\treturn GetBytesSlicePtr512()\n}", "func Acquire() *Buffer {\n\tv := pool.Get()\n\tif v == nil {\n\t\treturn &Buffer{\n\t\t\tB: make([]byte, 0, defaultByteBufferSize),\n\t\t}\n\t}\n\treturn v.(*Buffer)\n}", "func (p Pool) Get() *logf.Buffer {\n\tbuf := p.p.Get().(*logf.Buffer)\n\tbuf.Reset()\n\n\treturn buf\n}", "func (pool *FixedBytePool) Get(index int32) []byte {\n\tstart := int(index) * pool.elemSize\n\tend := start + pool.elemSize\n\n\treturn pool.buf[start:end]\n}", "func Get(size int) []byte {\n\treturn builtinPool.Get(size)\n}", "func (r *bufferingReaderAt) grabBuf() []byte {\n\tif len(r.pool) != 0 {\n\t\tb := r.pool[len(r.pool)-1]\n\t\tr.pool = r.pool[:len(r.pool)-1]\n\t\treturn b\n\t}\n\treturn make([]byte, r.blockSize)\n}", "func (p *Pool) Get(size int) (buf []byte) {\n\tif size <= 0 {\n\t\treturn nil\n\t}\n\tif size > math.MaxInt32 {\n\t\treturn make([]byte, size)\n\t}\n\tidx := index(uint32(size))\n\tptr, _ := p.pools[idx].Get().(unsafe.Pointer)\n\tif ptr == nil {\n\t\treturn make([]byte, 1<<idx)[:size]\n\t}\n\tsh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))\n\tsh.Data = uintptr(ptr)\n\tsh.Len = size\n\tsh.Cap = 1 << idx\n\truntime.KeepAlive(ptr)\n\treturn\n}", "func (bp *BufReaderPool) Get(r io.Reader) *BufReader {\n\tvar item *BufReader\n\tselect {\n\tcase item = <-bp.pool:\n\t\titem.Reset(r)\n\tdefault:\n\t\titem = &BufReader{\n\t\t\tReader: bufio.NewReaderSize(r, bp.rdSize),\n\t\t\tpool: bp,\n\t\t}\n\t}\n\treturn item\n}", "func (p *BufferBucketVersionsPool) Get() *BufferBucketVersions {\n\treturn p.pool.Get().(*BufferBucketVersions)\n}", "func (_ BufferPtrPool32K) Get() *[]byte {\n\treturn GetBytesSlicePtr32K()\n}", "func (p *Pool) Acquire() *Buffer {\n\tv := p.p.Get()\n\tif v == nil {\n\t\treturn &Buffer{\n\t\t\tB: make([]byte, 0, p.Size),\n\t\t}\n\t}\n\treturn v.(*Buffer)\n}", "func Get(reader io.Reader) (r *bufio.Reader) {\n\treturn defaultPool.Get(reader)\n}", "func Acquire() *[]byte {\n\treturn bufPool.Get().(*[]byte)\n}", "func (self Memo) Get() interface{} {\n\tresponse := make(chan interface{})\n\tself.requestChan <- response\n\treturn <-response\n}", "func getNetBuf(size int) (*netBuf, []byte) {\n\tfor i, s := range netBufPoolSizes {\n\t\tif size <= s {\n\t\t\tnb := netBufPools[i].Get().(*netBuf)\n\t\t\tatomic.AddInt64(&netBufGet[i], 1)\n\t\t\treturn nb, nb.buf\n\t\t}\n\t}\n\treturn newNetBuf(size)\n}", "func (this *byteBuffer) Get(seq int64) ([]byte, error) {\n\tslot := seq & int64(this.slotMask)\n\tindex := slot * int64(this.slotSize)\n\n\tn := int(binary.LittleEndian.Uint16(this.buffer[index : index+SlotOverhead]))\n\tif n > MaxDataSize {\n\t\treturn nil, ErrDataExceedsMaxSize\n\t}\n\n\tindex += SlotOverhead\n\n\tif index+int64(n) < this.bufferSize {\n\t\treturn this.buffer[index : index+int64(n)], nil\n\t}\n\n\tif n > len(this.tmpbuf) {\n\t\tthis.tmpbuf = make([]byte, n)\n\t}\n\tl, i := 0, 0\n\n\tfor n > 0 {\n\t\tl = copy(this.tmpbuf[i:], this.buffer[index:])\n\t\tn -= l\n\t\ti += l\n\n\t\tif n > 0 {\n\t\t\tindex = 0\n\t\t}\n\t}\n\n\treturn this.tmpbuf[:i], nil\n}", "func (p *Pool) Get() interface{}", "func (this *ByteQueue) Get() byte {\n\tif this.undo { // Return last read character\n\t\tthis.undo = false\n\t} else if this.idx == (len(this.current) - 1) { // Consider new slice of bytes\n\t\tif !this.recordReset { // If recording, stash this slice\n\t\t\tthis.recordSlices = append(this.recordSlices, this.current[this.sliceIdx:])\n\t\t}\n\t\tthis.current = <-this.slices // Consider next slice of unread bytes\n\t\tthis.idx = 0\n\t\tthis.sliceIdx = 0 // Reset token index. Continue recording from beginning of this slice.\n\t} else {\n\t\tthis.idx++\n\t}\n\n\tif this.recordReset {\n\t\tthis.recordReset = false\n\t\tthis.sliceIdx = this.idx // Start recording current slice's bytes from this index\n\t\tthis.recordSlices = this.recordSlices[0:0]\n\t}\n\n\treturn this.current[this.idx] // Here's your byte. All that for one little byte.\n}", "func Get() *Builder {\n\tb := pool.Get().(*Builder)\n\tb.bb.Reset()\n\tb.locked = false\n\treturn b\n}", "func (s *Pool) Get() (net.Conn, error) {\n\tif cn := s.pop(); cn != nil {\n\t\treturn cn, nil\n\t}\n\n\treturn s.factory()\n}", "func Get(capacity int) *[]byte {\n\tid, capacityNeeded := getPoolIDAndCapacity(capacity)\n\tfor i := 0; i < 2; i++ {\n\t\tif id < 0 || id >= len(pools) {\n\t\t\tbreak\n\t\t}\n\t\tif v := pools[id].Get(); v != nil {\n\t\t\tatomic.AddInt64(&stats[id], 1)\n\t\t\treturn v.(*[]byte)\n\t\t}\n\t\tid++\n\t}\n\tatomic.AddInt64(&overflow, 1)\n\tb := make([]byte, 0, capacityNeeded)\n\treturn &b\n}", "func Get(w io.Writer) *bufio.Writer {\n\tbw := bwPool.Get().(*bufio.Writer)\n\tbw.Reset(w)\n\treturn bw\n}", "func (b *BufferPool) GetContent() []byte {\n\treturn b.Data\n}", "func Get(key string) ([]byte, error) {\n\tconn := pool.Get()\n\tdefer conn.Close()\n\n\tvar data []byte\n\n\tr, err := redis.DoWithTimeout(conn, time.Millisecond*100, \"GET\", key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdata, err2 := redis.Bytes(r, err)\n\tif err2 != nil {\n\t\treturn data, fmt.Errorf(\"error getting key %s: %v\", key, err2)\n\t}\n\n\treturn data, nil\n}", "func (c *GorCache) Get(name string) []byte {\n\tgetter := &getterItem{ //TODO make pool for this\n\t\tname: name,\n\t\tresponce: make(chan []byte, 1),\n\t}\n\tc.getChan <- getter\n\treturn <-getter.responce\n}", "func (cp *ComposerPool) Get() (result *Composer) {\n\tlogger.Debug(\"Entering ComposerPool.Get\")\n\tdefer func() { logger.Debug(\"Exiting ComposerPool.Get\", result) }()\n\n\t// lock the pool and check to see how many Composer objects\n\t// have been created if the channel buffer is currently empty\n\tcp.PoolMutex.Lock()\n\n\tif len(cp.Pool) == 0 && cp.PoolCount < cp.PoolMax {\n\t\tcp.Pool <- NewComposer()\n\t\tcp.PoolCount++\n\t}\n\tcp.PoolMutex.Unlock()\n\n\t// we will get the newly created one, or wait for one. Potentially\n\t// we could have had one put back during this time which we could\n\t// have used if a new one was created, but never mind.\n\tresult = <-cp.Pool\n\treturn result\n}", "func (p *intPool) get() *big.Int {\n\tif p.pool.len() > 0 {\n\t\treturn p.pool.pop()\n\t}\n\treturn new(big.Int)\n}", "func GetBytes(size int) *[]byte {\n\treturn bbPool.take(size)\n}", "func (c *boundedPool) Get() (net.Conn, error) {\n\tconns := c.getConns()\n\tif conns == nil {\n\t\treturn nil, pool.ErrClosed\n\t}\n\n\t// Try and grab a connection from the pool\n\tselect {\n\tcase conn := <-conns:\n\t\tif conn == nil {\n\t\t\treturn nil, pool.ErrClosed\n\t\t}\n\t\treturn c.wrapConn(conn), nil\n\tdefault:\n\t\t// Could not get connection, can we create a new one?\n\t\tif atomic.LoadInt32(&c.total) < int32(cap(conns)) {\n\t\t\tconn, err := c.factory()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tatomic.AddInt32(&c.total, 1)\n\n\t\t\treturn c.wrapConn(conn), nil\n\t\t}\n\t}\n\n\t// The pool was empty and we couldn't create a new one to\n\t// retry until one is free or we timeout\n\tselect {\n\tcase conn := <-conns:\n\t\tif conn == nil {\n\t\t\treturn nil, pool.ErrClosed\n\t\t}\n\t\treturn c.wrapConn(conn), nil\n\tcase <-time.After(c.timeout):\n\t\treturn nil, fmt.Errorf(\"timed out waiting for free connection\")\n\t}\n\n}", "func (R *RAND) GetByte() byte {\n\tr := R.pool[R.pool_ptr]\n\tR.pool_ptr++\n\tif R.pool_ptr >= 32 {\n\t\tR.fill_pool()\n\t}\n\treturn byte(r & 0xff)\n}", "func Get() *Message {\n\tmsg := Pool.Get().(*Message)\n\tmsg.reset()\n\treturn msg\n}", "func NewBuffer() *Buffer { return globalPool.NewBuffer() }", "func (pool *BufferPool) New() (buf *bytes.Buffer) {\n\tselect {\n\tcase buf = <-pool.Buffers:\n\tdefault:\n\t\tbuf = &bytes.Buffer{}\n\t}\n\treturn\n}", "func (r *bufferingReaderAt) recycleBuf(b []byte) {\n\tif cap(b) != r.blockSize {\n\t\tpanic(\"trying to return a buffer not initially requested via grabBuf\")\n\t}\n\tif len(r.pool)+1 > cap(r.pool) {\n\t\tpanic(\"unexpected growth of byte buffer pool beyond capacity\")\n\t}\n\tr.pool = append(r.pool, b[:cap(b)])\n}", "func (self Source) GetBuffer() (buffer Buffer) {\n\treturn Buffer(self.Geti(AlBuffer))\n}", "func (rp *resourcePool) Get() interface{} {\n\trp.Lock()\n\tdefer rp.Unlock()\n\n\tfor rp.start != nil {\n\t\tcurr := rp.start\n\t\trp.remove(curr)\n\t\tif !rp.expiredFn(curr.value) {\n\t\t\treturn curr.value\n\t\t}\n\t\trp.closeFn(curr.value)\n\t\trp.totalSize--\n\t}\n\treturn nil\n}", "func (c *channelPool) Get() (RpcAble, error) {\n\trconns := c.getRconns()\n\tif rconns == nil {\n\t\treturn nil, ErrClosed\n\t}\n\n\t// wrap our rconns with out custom RpcAble implementation (wrapRconn\n\t// method) that puts the RPC-able connection back to the pool if it's closed.\n\tselect {\n\tcase rconn := <-rconns:\n\t\tif rconn == nil {\n\t\t\treturn nil, ErrClosed\n\t\t}\n\n\t\treturn c.wrapRconn(rconn), nil\n\tdefault:\n\t\trconn, err := c.factory()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn c.wrapRconn(rconn), nil\n\t}\n}", "func (p *byteBufferPool) take(size int) *[]byte {\n\tslot := p.slot(size)\n\tif slot == errSlot {\n\t\tb := newBytes(size)\n\t\treturn &b\n\t}\n\tv := p.pool[slot].pool.Get()\n\tif v == nil {\n\t\tb := newBytes(p.pool[slot].defaultSize)\n\t\tb = b[0:size]\n\t\treturn &b\n\t}\n\tb := v.(*[]byte)\n\t*b = (*b)[0:size]\n\treturn b\n}", "func (p *Pool) Get() (x interface{}) {\n\tp.init()\n\treturn p.p.Get()\n}", "func (p *Pool) Get(ctx context.Context) (*ClientConn, error) {\n\tif p == nil {\n\t\treturn nil, ErrClosed\n\t}\n\n\tclient := make(chan *ClientConn, 1)\n\tp.clientQueue(client)\n\n\tselect {\n\tcase conn := <-client:\n\t\tconn.use()\n\t\treturn conn, nil\n\tcase <-ctx.Done():\n\t\treturn nil, ErrTimeout\n\t}\n}", "func (c *ChannelPool) Get() (net.Conn, error) {\n\tconns := c.getConns()\n\tif conns == nil {\n\t\treturn nil, ErrClosed\n\t}\n\n\tselect {\n\tcase conn := <-conns:\n\t\tif conn == nil {\n\t\t\treturn nil, ErrClosed\n\t\t}\n\t\treturn conn, nil\n\tdefault:\n\t\treturn c.factory()\n\t}\n}", "func (p *Buffer) release() []byte {\n\tbytes := p.buf\n\tp.buf = nil\n\tp.index = 0\n\tp.Immutable = false\n\tp.err = nil\n\tp.array_indexes = nil\n\tbuffer_pool.Put(p)\n\treturn bytes\n}", "func (c redisClient) Get(key string) ([]byte, error) {\n\tconn := c.pool.Get()\n\tdefer conn.Close()\n\n\tvar data []byte\n\tdata, err := redis.Bytes(conn.Do(\"GET\", key))\n\tif err != nil {\n\t\treturn data, err\n\t}\n\treturn data, err\n}", "func (m *MultiConnPool) Get() *pgx.ConnPool {\n\tif len(m.Pools) == 1 {\n\t\treturn m.Pools[0]\n\t}\n\ti := atomic.AddUint32(&m.counter, 1) - 1\n\treturn m.Pools[i%uint32(len(m.Pools))]\n}", "func (p *ResourcePool) Get() (resource ResourceWrapper, err error) {\n\treturn p.getWait()\n}", "func (q *BytesQueue) Get(index int) ([]byte, error) {\n\tdata, _, err := q.peek(index)\n\treturn data, err\n}", "func (s *Stubs) Get() ioStub {\n\tif len(s.queue) == 0 {\n\t\treturn nil\n\t}\n\n\tfirst := s.queue[0]\n\ts.queue = s.queue[1:]\n\treturn first\n}", "func (p *DecoderPool) Get(r io.Reader) (*zstd.Decoder, error) {\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\n\tif p.head == nil {\n\t\treturn zstd.NewReader(r, p.opts...)\n\t}\n\n\thead := p.head\n\tp.head = head.next\n\tp.available--\n\n\thead.d.Reset(r)\n\n\treturn head.d, nil\n}", "func (p *IdlePool) Get() io.Closer {\n\tp.Lock()\n\tdefer p.Unlock()\n\tfor i, c := range p.elems {\n\t\tif c == nil {\n\t\t\tcontinue\n\t\t}\n\t\tp.elems[i] = nil\n\t\treturn c\n\t}\n\treturn nil\n}", "func (c *Connection) GetBuffer(src, mode string, timeout uint) ([]byte, error) {\n\t// Use PASV to set up the data port.\n\tpasvCode, pasvLine, err := c.Cmd(\"PASV\", \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpasvErr := checkResponseCode(2, pasvCode)\n\tif pasvErr != nil {\n\t\tmsg := fmt.Sprintf(\"Cannot set PASV. Error: %v\", pasvErr)\n\t\treturn nil, fmt.Errorf(msg)\n\t}\n\tdataPort, err := extractDataPort(pasvLine)\n\t/*_, err = extractDataPort(pasvLine)*/\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Set the TYPE (ASCII or Binary)\n\ttypeCode, typeLine, err := c.Cmd(\"TYPE\", mode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttypeErr := checkResponseCode(2, typeCode)\n\tif typeErr != nil {\n\t\tmsg := fmt.Sprintf(\"Cannot set TYPE. Error: '%v'. Line: '%v'\", typeErr, typeLine)\n\t\treturn nil, fmt.Errorf(msg)\n\t}\n\n\t// Can't use Cmd() for RETR because it doesn't return until *after* you've\n\t// downloaded the requested file.\n\tcommand := []byte(\"RETR \" + src + CRLF)\n\t_, err = c.control.Write(command)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Open connection to remote data port.\n\tremoteConnectString := c.hostname + \":\" + fmt.Sprintf(\"%d\", dataPort)\n\tdownloadConn, err := net.Dial(\"tcp\", remoteConnectString)\n\tdefer downloadConn.Close()\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"Couldn't connect to server's remote data port. Error: %v\", err)\n\t\treturn nil, fmt.Errorf(msg)\n\t}\n\n\t// Buffer for downloading and writing to file\n\tbufLen := 1024\n\tbuf := make([]byte, bufLen)\n\tvar result bytes.Buffer\n\tresult.Grow(2 ^ (1024 * 1024))\n\tif timeout > 0 {\n\t\tsetReadDeadline(downloadConn, timeout)\n\t}\n\n\t// Read from the server and write the contents to a file\n\tfor {\n\t\tbytesRead, readErr := downloadConn.Read(buf)\n\t\tif bytesRead > 0 {\n\t\t\tfor i, n := 0, 0; i < bytesRead; i += n {\n\t\t\t\tn, readErr = result.Write(buf[0:bytesRead])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, readErr\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif readErr == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif readErr != nil {\n\t\t\treturn nil, readErr\n\t\t}\n\t}\n\treturn result.Bytes(), nil\n}", "func ReserveByteBuffer() []byte {\n\treturn bufPool.Get().([]byte)[:0]\n}", "func Get(queue <-chan byte, number int) ([]byte, error) {\n\tvar result []byte\n\nReadLoop:\n\tfor {\n\t\tselect {\n\t\tcase i, ok := <-queue:\n\t\t\tif ok {\n\t\t\t\tresult = append(result, i)\n\t\t\t\tif len(result) == number {\n\t\t\t\t\tbreak ReadLoop\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn nil, errors.New(\"queue channel is closed\")\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result, nil\n}", "func (p *Pool[T]) Get() T {\n\treturn p.p.Get().(T)\n}", "func (p *pool) get() (*channel, error) {\n\tif p.closed {\n\t\treturn nil, ErrPoolClosed\n\t}\n\n\tactiveChannel, ok := <-p.readyChannel\n\tif !ok {\n\t\treturn nil, ErrPoolClosed\n\t}\n\n\treturn activeChannel, nil\n}", "func (p *Pool) Get() *Hasher {\n\tt := <-p.c\n\treturn &Hasher{\n\t\tConf: p.Conf,\n\t\tresult: make(chan []byte),\n\t\terrc: make(chan error, 1),\n\t\tspan: make([]byte, SpanSize),\n\t\tbmt: t,\n\t}\n}", "func (bp *Pool) Get(params ...interface{}) interface{} {\n\tres := bp.pool.Poll()\n\tif (res == nil || (bp.IsUsable != nil && !bp.IsUsable(res, params...))) && bp.New != nil {\n\t\tres = bp.New(params...)\n\t}\n\n\treturn res\n}", "func (hash * SpaceHash) getEmptyBin() (* SpaceHashBin) {\n bin := hash.pooledBins\n \n if bin != nil {\n hash.pooledBins = bin.next\n return bin\n } \n // Pool is exhausted, make more\n count := 100\n buffer := make([]SpaceHashBin, count)\n hash.allocatedBuffers.Push(buffer)\n \n // push all but the first one, return the first instead\n for i:=1; i<count; i++ { \n hash.recycleBin(&buffer[i])\n } \n return &buffer[0] \n}", "func (p *BufferedReadSeekerWriteToPool) GetWriteTo(seeker io.ReadSeeker) (r s3manager.ReadSeekerWriteTo, cleanup func()) {\n\tbuffer, _ := p.pool.Get().([]byte)\n\tif buffer == nil {\n\t\tbuffer = make([]byte, p.size)\n\t}\n\n\tr = &s3manager.BufferedReadSeekerWriteTo{BufferedReadSeeker: s3manager.NewBufferedReadSeeker(seeker, buffer)}\n\tcleanup = func() {\n\t\tp.pool.Put(buffer)\n\t}\n\n\treturn r, cleanup\n}" ]
[ "0.80125904", "0.7854275", "0.785205", "0.77734995", "0.7718327", "0.76411927", "0.7631384", "0.7628094", "0.76028615", "0.7544255", "0.7519572", "0.7511184", "0.74695724", "0.72912955", "0.72753537", "0.7266877", "0.7258527", "0.72441524", "0.72260463", "0.7162879", "0.7138222", "0.7093199", "0.70495224", "0.70183104", "0.7006674", "0.6978882", "0.6933189", "0.689454", "0.6860424", "0.6789487", "0.673342", "0.6705201", "0.6693797", "0.6683448", "0.6681872", "0.6680424", "0.66713154", "0.6670979", "0.6665564", "0.6665542", "0.6651453", "0.66455895", "0.66371715", "0.66227", "0.6619646", "0.65933084", "0.6584871", "0.6582678", "0.6578953", "0.6557635", "0.65343976", "0.647236", "0.64661455", "0.6366545", "0.6330635", "0.62447923", "0.623879", "0.6232835", "0.6184606", "0.6183071", "0.6174622", "0.61535627", "0.61496013", "0.6137612", "0.61349434", "0.6061966", "0.6041164", "0.6018564", "0.59949976", "0.5989964", "0.5975884", "0.5968919", "0.59465176", "0.59200627", "0.59097177", "0.58784026", "0.5877356", "0.58571607", "0.5854012", "0.58209795", "0.58150685", "0.58108145", "0.58092576", "0.58021", "0.57993937", "0.57883865", "0.57872176", "0.57719976", "0.5770775", "0.57690173", "0.5747602", "0.5744661", "0.5743301", "0.5727934", "0.5726886", "0.5716072", "0.5708263", "0.56804246", "0.56761307", "0.5673416" ]
0.81058604
0
ApplyOptions implementation of the Actionable interface
func (ci *createIndex) ApplyOptions() Actionable { ci.options = ci.context.Options().(*options.CreateIndexOptions) ci.indexer.SetOptions(&golastic.IndexOptions{Timeout: ci.options.TimeoutInSeconds()}) return ci }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *snapshot) ApplyOptions() Actionable {\n\ts.options = s.context.Options().(*options.SnapshotOptions)\n\n\tif len(s.options.Name) == 0 {\n\t\ts.options.Name = \"github.com/alejandro-carstens/scrubber-\" + time.Now().Format(\"1992-06-02\")\n\t}\n\n\tif !s.options.Exists(\"wait_for_completion\") {\n\t\ts.options.WaitForCompletion = DEFAULT_WAIT_FOR_COMPLETION\n\t}\n\n\tif !s.options.WaitForCompletion {\n\t\tif !s.options.Exists(\"max_wait\") {\n\t\t\ts.options.MaxWait = DEFAULT_MAX_WAIT\n\t\t}\n\n\t\tif !s.options.Exists(\"wait_interval\") {\n\t\t\ts.options.WaitInterval = DEFAULT_WAIT_INTERVAL\n\t\t}\n\t}\n\n\ts.indexer.SetOptions(&golastic.IndexOptions{\n\t\tTimeout: s.options.TimeoutInSeconds(),\n\t\tWaitForCompletion: s.options.WaitForCompletion,\n\t\tPartial: s.options.Partial,\n\t\tIncludeGlobalState: s.options.IncludeGlobalState,\n\t\tIgnoreUnavailable: s.options.IgnoreUnavailable,\n\t})\n\n\treturn s\n}", "func ActionOptions() carapace.Action {\n\treturn carapace.ActionMultiParts(\"=\", func(c carapace.Context) carapace.Action {\n\t\toptions := map[string]carapace.Action{\n\t\t\t\"AddKeysToAgent\": carapace.ActionValues(\"yes\", \"ask\", \"confirm\", \"no\"),\n\t\t\t\"AddressFamily\": carapace.ActionValues(\"any\", \"inet\", \"inet6\"),\n\t\t\t\"BatchMode\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"BindAddress\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"CanonicalDomains\": carapace.ActionValues(),\n\t\t\t\"CanonicalizeFallbackLocal\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"CanonicalizeHostname\": carapace.ActionValues(\"yes\", \"no\", \"always\"),\n\t\t\t\"CanonicalizeMaxDots\": carapace.ActionValues(),\n\t\t\t\"CanonicalizePermittedCNAMEs\": carapace.ActionValues(),\n\t\t\t\"CASignatureAlgorithms\": carapace.ActionValues(),\n\t\t\t\"CertificateFile\": carapace.ActionFiles(),\n\t\t\t\"ChallengeResponseAuthentication\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"CheckHostIP\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"Ciphers\": ActionCiphers(),\n\t\t\t\"ClearAllForwardings\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"Compression\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"ConnectionAttempts\": carapace.ActionValues(),\n\t\t\t\"ConnectTimeout\": carapace.ActionValues(),\n\t\t\t\"ControlMaster\": carapace.ActionValues(\"yes\", \"no\", \"ask\", \"auto\", \"autoask\"),\n\t\t\t\"ControlPath\": carapace.ActionValues(),\n\t\t\t\"ControlPersist\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"DynamicForward\": carapace.ActionValues(),\n\t\t\t\"EscapeChar\": carapace.ActionValues(),\n\t\t\t\"ExitOnForwardFailure\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"FingerprintHash\": carapace.ActionValues(\"md5\", \"sha256\"),\n\t\t\t\"ForwardAgent\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"ForwardX11\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"ForwardX11Timeout\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"ForwardX11Trusted\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"GatewayPorts\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"GlobalKnownHostsFile\": carapace.ActionFiles(),\n\t\t\t\"GSSAPIAuthentication\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"HashKnownHosts\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"Host\": net.ActionHosts(),\n\t\t\t\"HostbasedAuthentication\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"HostbasedKeyTypes\": carapace.ActionValues(),\n\t\t\t\"HostKeyAlgorithms\": ActionHostKeyAlgorithms(),\n\t\t\t\"HostKeyAlias\": carapace.ActionValues(),\n\t\t\t\"Hostname\": carapace.ActionValues(),\n\t\t\t\"IdentitiesOnly\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"IdentityAgent\": carapace.ActionValues(),\n\t\t\t\"IdentityFile\": carapace.ActionFiles(),\n\t\t\t\"IPQoS\": carapace.ActionValues(\"af11\", \"af12\", \"af13\", \"af21\", \"af22\", \"af23\", \"af31\", \"af32\", \"af33\", \"af41\", \"af42\", \"af43\", \"cs0\", \"cs1\", \"cs2\", \"cs3\", \"cs4\", \"cs5\", \"cs6\", \"cs7\", \"ef\", \"le\", \"lowdelay\", \"throughput\", \"reliability\", \"none\"),\n\t\t\t\"KbdInteractiveAuthentication\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"KbdInteractiveDevices\": carapace.ActionValues(),\n\t\t\t\"KexAlgorithms\": carapace.ActionValues(),\n\t\t\t\"LocalCommand\": carapace.ActionValues(),\n\t\t\t\"LocalForward\": carapace.ActionValues(),\n\t\t\t\"LogLevel\": carapace.ActionValues(\"QUIET\", \"FATAL\", \"ERROR\", \"INFO\", \"VERBOSE\", \"DEBUG\", \"DEBUG1\", \"DEBUG2\", \"DEBUG3\"),\n\t\t\t\"MACs\": carapace.ActionValues(),\n\t\t\t\"Match\": carapace.ActionValues(),\n\t\t\t\"NoHostAuthenticationForLocalhost\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"NumberOfPasswordPrompts\": carapace.ActionValues(),\n\t\t\t\"PasswordAuthentication\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"PermitLocalCommand\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"PKCS11Provider\": carapace.ActionValues(),\n\t\t\t\"Port\": net.ActionPorts(),\n\t\t\t\"PreferredAuthentications\": carapace.ActionValues(),\n\t\t\t\"ProxyCommand\": carapace.ActionValues(),\n\t\t\t\"ProxyJump\": carapace.ActionValues(),\n\t\t\t\"ProxyUseFdpass\": carapace.ActionValues(),\n\t\t\t\"PubkeyAcceptedKeyTypes\": carapace.ActionValues(),\n\t\t\t\"PubkeyAuthentication\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"RekeyLimit\": carapace.ActionValues(),\n\t\t\t\"RemoteCommand\": carapace.ActionValues(),\n\t\t\t\"RemoteForward\": carapace.ActionValues(),\n\t\t\t\"RequestTTY\": carapace.ActionValues(\"yes\", \"no\", \"force\", \"auto\"),\n\t\t\t\"SendEnv\": carapace.ActionValues(),\n\t\t\t\"ServerAliveInterval\": carapace.ActionValues(),\n\t\t\t\"ServerAliveCountMax\": carapace.ActionValues(),\n\t\t\t\"SetEnv\": carapace.ActionValues(),\n\t\t\t\"StreamLocalBindMask\": carapace.ActionValues(),\n\t\t\t\"StreamLocalBindUnlink\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"StrictHostKeyChecking\": carapace.ActionValues(\"yes\", \"no\", \"ask\"),\n\t\t\t\"TCPKeepAlive\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"Tunnel\": carapace.ActionValues(\"yes\", \"point-to-point\", \"ethernet\", \"no\"),\n\t\t\t\"TunnelDevice\": carapace.ActionValues(),\n\t\t\t\"UpdateHostKeys\": carapace.ActionValues(\"yes\", \"no\", \"ask\"),\n\t\t\t\"User\": os.ActionUsers(),\n\t\t\t\"UserKnownHostsFile\": carapace.ActionFiles(),\n\t\t\t\"VerifyHostKeyDNS\": carapace.ActionValues(\"yes\", \"no\", \"ask\"),\n\t\t\t\"VisualHostKey\": carapace.ActionValues(\"yes\", \"no\"),\n\t\t\t\"XAuthLocation\": carapace.ActionFiles(),\n\t\t}\n\n\t\tswitch len(c.Parts) {\n\t\tcase 0:\n\t\t\tkeys := make([]string, 0, len(options))\n\t\t\tfor key := range options {\n\t\t\t\tkeys = append(keys, key)\n\t\t\t}\n\t\t\treturn carapace.ActionValues(keys...).Invoke(c).Suffix(\"=\").ToA()\n\t\tcase 1:\n\t\t\tif val, ok := options[c.Parts[0]]; ok {\n\t\t\t\treturn val\n\t\t\t} else {\n\t\t\t\treturn carapace.ActionValues()\n\t\t\t}\n\t\tdefault:\n\t\t\treturn carapace.ActionValues()\n\t\t}\n\t})\n}", "func (p *Porter) applyActionOptionsToInstallation(ctx context.Context, ba BundleAction, inst *storage.Installation) error {\n\tctx, span := tracing.StartSpan(ctx)\n\tdefer span.EndSpan()\n\n\to := ba.GetOptions()\n\n\tbundleRef, err := o.GetBundleReference(ctx, p)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbun := bundleRef.Definition\n\n\t// Update the installation with metadata from the options\n\tinst.TrackBundle(bundleRef.Reference)\n\tinst.Status.Modified = time.Now()\n\n\t//\n\t// 1. Record the parameter and credential sets used on the installation\n\t// if none were specified, reuse the previous sets from the installation\n\t//\n\tspan.SetAttributes(\n\t\ttracing.ObjectAttribute(\"override-parameter-sets\", o.ParameterSets),\n\t\ttracing.ObjectAttribute(\"override-credential-sets\", o.CredentialIdentifiers))\n\tif len(o.ParameterSets) > 0 {\n\t\tinst.ParameterSets = o.ParameterSets\n\t}\n\tif len(o.CredentialIdentifiers) > 0 {\n\t\tinst.CredentialSets = o.CredentialIdentifiers\n\t}\n\n\t//\n\t// 2. Parse parameter flags from the command line and apply to the installation as overrides\n\t//\n\t// This contains resolved sensitive values, so only trace it in special dev builds (nothing is traced for release builds)\n\tspan.SetSensitiveAttributes(tracing.ObjectAttribute(\"override-parameters\", o.Params))\n\tparsedOverrides, err := storage.ParseVariableAssignments(o.Params)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Default the porter-debug param to --debug\n\tif o.DebugMode {\n\t\tparsedOverrides[\"porter-debug\"] = \"true\"\n\t}\n\n\t// Apply overrides on to of any pre-existing parameters that were specified previously\n\tif len(parsedOverrides) > 0 {\n\t\tfor name, value := range parsedOverrides {\n\t\t\t// Do not resolve parameters from dependencies\n\t\t\tif strings.Contains(name, \"#\") {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Replace previous value if present\n\t\t\treplaced := false\n\t\t\tparamStrategy := storage.ValueStrategy(name, value)\n\t\t\tfor i, existingParam := range inst.Parameters.Parameters {\n\t\t\t\tif existingParam.Name == name {\n\t\t\t\t\tinst.Parameters.Parameters[i] = paramStrategy\n\t\t\t\t\treplaced = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !replaced {\n\t\t\t\tinst.Parameters.Parameters = append(inst.Parameters.Parameters, paramStrategy)\n\t\t\t}\n\t\t}\n\n\t\t// Keep the parameter overrides sorted, so that comparisons and general troubleshooting is easier\n\t\tsort.Sort(inst.Parameters.Parameters)\n\t}\n\t// This contains resolved sensitive values, so only trace it in special dev builds (nothing is traced for release builds)\n\tspan.SetSensitiveAttributes(tracing.ObjectAttribute(\"merged-installation-parameters\", inst.Parameters.Parameters))\n\n\t//\n\t// 3. Resolve named parameter sets\n\t//\n\tresolvedParams, err := p.loadParameterSets(ctx, bun, o.Namespace, inst.ParameterSets)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to process provided parameter sets: %w\", err)\n\t}\n\n\t// This contains resolved sensitive values, so only trace it in special dev builds (nothing is traced for release builds)\n\tspan.SetSensitiveAttributes(tracing.ObjectAttribute(\"resolved-parameter-sets-keys\", resolvedParams))\n\n\t//\n\t// 4. Resolve the installation's internal parameter set\n\tresolvedOverrides, err := p.Parameters.ResolveAll(ctx, inst.Parameters)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// This contains resolved sensitive values, so only trace it in special dev builds (nothing is traced for release builds)\n\tspan.SetSensitiveAttributes(tracing.ObjectAttribute(\"resolved-installation-parameters\", inst.Parameters.Parameters))\n\n\t//\n\t// 5. Apply the overrides on top of the parameter sets\n\t//\n\tfor k, v := range resolvedOverrides {\n\t\tresolvedParams[k] = v\n\t}\n\n\t//\n\t// 6. Separate out params for the root bundle from the ones intended for dependencies\n\t// This only applies to the dep v1 implementation, in dep v2 you can't specify rando params for deps\n\t//\n\to.depParams = make(map[string]string)\n\tfor k, v := range resolvedParams {\n\t\tif strings.Contains(k, \"#\") {\n\t\t\to.depParams[k] = v\n\t\t\tdelete(resolvedParams, k)\n\t\t}\n\t}\n\n\t// This contains resolved sensitive values, so only trace it in special dev builds (nothing is traced for release builds)\n\tspan.SetSensitiveAttributes(tracing.ObjectAttribute(\"user-specified-parameters\", resolvedParams))\n\n\t//\n\t// 7. When a parameter is not specified, fallback to a parameter source or default\n\t//\n\tfinalParams, err := p.finalizeParameters(ctx, *inst, bun, ba.GetAction(), resolvedParams)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// This contains resolved sensitive values, so only trace it in special dev builds (nothing is traced for release builds)\n\tspan.SetSensitiveAttributes(tracing.ObjectAttribute(\"final-parameters\", finalParams))\n\n\t// Remember the final set of parameters so we don't have to resolve them more than once\n\to.finalParams = finalParams\n\n\t// Ensure we aren't storing any secrets on the installation resource\n\tif err = p.sanitizeInstallation(ctx, inst, bundleRef.Definition); err != nil {\n\t\treturn err\n\t}\n\n\t// re-validate the installation since we modified it here\n\treturn inst.Validate(ctx, p.GetSchemaCheckStrategy(ctx))\n}", "func (o *Options) Apply() {\n\tif o == nil {\n\t\treturn\n\t}\n\tif len(o.ShowHiddenMetricsForVersion) > 0 {\n\t\tSetShowHidden()\n\t}\n\t// set disabled metrics\n\tfor _, metricName := range o.DisabledMetrics {\n\t\tSetDisabledMetric(metricName)\n\t}\n\tif o.AllowListMapping != nil {\n\t\tSetLabelAllowListFromCLI(o.AllowListMapping)\n\t}\n}", "func (opts *Options) Apply(options ...Option) error {\n\tfor _, o := range options {\n\t\tif err := o(opts); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (o Options) Apply(i *Important) {\n\tfor _, opt := range o {\n\t\topt(i)\n\t}\n}", "func applyOptions(c *Container, opts ...Option) error {\n\tfor _, opt := range opts {\n\t\tif err := opt.set(c); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (o *Options) Apply(opts ...Option) error {\n\tfor i, opt := range opts {\n\t\tif err := opt(o); err != nil {\n\t\t\treturn fmt.Errorf(\"dht option %d failed: %s\", i, err)\n\t\t}\n\t}\n\treturn nil\n}", "func (o *MatchOptions) ApplyOptions(opts []MatchOption) *MatchOptions {\n\tfor _, opt := range opts {\n\t\topt.ApplyToMatcher(o)\n\t}\n\treturn o\n}", "func (o optionFunc) ApplyOption(opts *Options) {\n\to(opts)\n}", "func (o *Options) Apply(opts ...Option) error {\n\tfor i, opt := range opts {\n\t\tif err := opt(o); err != nil {\n\t\t\treturn fmt.Errorf(\"option %d failed: %s\", i, err)\n\t\t}\n\t}\n\treturn nil\n}", "func (c *queueInformerConfig) apply(options []Option) {\n\tfor _, option := range options {\n\t\toption(c)\n\t}\n}", "func (uo *SubResourceUpdateOptions) ApplyOptions(opts []SubResourceUpdateOption) *SubResourceUpdateOptions {\n\tfor _, o := range opts {\n\t\to.ApplyToSubResourceUpdate(uo)\n\t}\n\n\treturn uo\n}", "func (ro *RequesterOptions) apply(opts ...RequesterOption) {\n\tfor _, opt := range opts {\n\t\topt(ro)\n\t}\n}", "func (o Opts) ApplyOpts(opts *redisconn.Opts) {\n\n\tif o.DB != nil {\n\t\topts.DB = *o.DB\n\t}\n\tif o.WritePause > 0 {\n\t\topts.WritePause = o.WritePause\n\t}\n\tif o.ReconnectPause > 0 {\n\t\topts.ReconnectPause = o.ReconnectPause\n\t}\n\tif o.TCPKeepAlive > 0 {\n\t\topts.TCPKeepAlive = o.TCPKeepAlive\n\t}\n\to.Timeouts.ApplyOpts(opts)\n}", "func (c *operatorConfig) apply(options []OperatorOption) {\n\tfor _, option := range options {\n\t\toption(c)\n\t}\n}", "func (opt option) apply(o interface{}) error {\n\tswitch v := o.(type) {\n\tcase *TableEncoder:\n\t\tif opt.table != nil {\n\t\t\treturn opt.table(v)\n\t\t}\n\t\treturn nil\n\tcase *ExpandedEncoder:\n\t\tif opt.expanded != nil {\n\t\t\treturn opt.expanded(v)\n\t\t}\n\t\treturn nil\n\tcase *JSONEncoder:\n\t\tif opt.json != nil {\n\t\t\treturn opt.json(v)\n\t\t}\n\t\treturn nil\n\tcase *UnalignedEncoder:\n\t\tif opt.unaligned != nil {\n\t\t\treturn opt.unaligned(v)\n\t\t}\n\t\treturn nil\n\tcase *TemplateEncoder:\n\t\tif opt.template != nil {\n\t\t\treturn opt.template(v)\n\t\t}\n\t\treturn nil\n\tcase *CrosstabView:\n\t\tif opt.crosstab != nil {\n\t\t\treturn opt.crosstab(v)\n\t\t}\n\t\treturn nil\n\tcase *errEncoder:\n\t\tif opt.err != nil {\n\t\t\treturn opt.err(v)\n\t\t}\n\t\treturn nil\n\t}\n\tpanic(fmt.Sprintf(\"option cannot be applied to %T\", o))\n}", "func (d *OverloadServiceDesc) Apply(oo ...transport.DescOption) {\n\tfor _, o := range oo {\n\t\to.Apply(&d.opts)\n\t}\n}", "func ApplyOptions(f *pflag.Flag, opts ...FlagOption) {\n\tfor _, opt := range opts {\n\t\topt(f)\n\t}\n}", "func (o *DeleteOptions) ApplyOptions(opts []DeleteOption) {\n\tfor _, opt := range opts {\n\t\topt.ApplyToDeleteOptions(o)\n\t}\n}", "func ApplyOptions() metav1.ApplyOptions {\n\treturn metav1.ApplyOptions{\n\t\tForce: true,\n\t\tFieldManager: ReflectionFieldManager,\n\t}\n}", "func (o *PatchOptions) ApplyOptions(opts []PatchOption) {\n\tfor _, opt := range opts {\n\t\topt.ApplyToHelper(o)\n\t}\n}", "func (eeo EncodingErrorOption) argApply(o *argOptions) {\n\to.opts = append(o.opts, eeo)\n}", "func (o *JSONPb) ApplyOptions(options ...JSONPbOption) *JSONPb {\n\tfor _, opt := range options {\n\t\tif opt == nil {\n\t\t\tcontinue\n\t\t}\n\t\topt.apply(o)\n\t}\n\treturn o\n}", "func (po *SubResourcePatchOptions) ApplyOptions(opts []SubResourcePatchOption) *SubResourcePatchOptions {\n\tfor _, o := range opts {\n\t\to.ApplyToSubResourcePatch(po)\n\t}\n\n\treturn po\n}", "func (t Timeouts) ApplyOpts(opts *redisconn.Opts) {\n\tif t.Dial > 0 {\n\t\topts.DialTimeout = t.Dial\n\t}\n\tif t.IO > 0 {\n\t\topts.IOTimeout = t.IO\n\t}\n}", "func (c *MockClient) ApplyOption(opt MockClientOption) {\n\topt(c)\n}", "func ApplyOptions(optsGetter Getter, store *genericetcd.Etcd, etcdPrefix string) error {\n\tif store.QualifiedResource.IsEmpty() {\n\t\treturn fmt.Errorf(\"store must have a non-empty qualified resource\")\n\t}\n\tif store.NewFunc == nil {\n\t\treturn fmt.Errorf(\"store for %s must have NewFunc set\", store.QualifiedResource.String())\n\t}\n\tif store.NewListFunc == nil {\n\t\treturn fmt.Errorf(\"store for %s must have NewListFunc set\", store.QualifiedResource.String())\n\t}\n\tif store.CreateStrategy == nil {\n\t\treturn fmt.Errorf(\"store for %s must have CreateStrategy set\", store.QualifiedResource.String())\n\t}\n\n\topts, err := optsGetter.GetRESTOptions(store.QualifiedResource)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error building RESTOptions for %s store: %v\", store.QualifiedResource.String(), err)\n\t}\n\n\tstore.DeleteCollectionWorkers = opts.DeleteCollectionWorkers\n\tstore.Storage = opts.Decorator(opts.Storage, UseConfiguredCacheSize, store.NewFunc(), etcdPrefix, store.CreateStrategy, store.NewListFunc)\n\treturn nil\n\n}", "func (lOpts *logOptions) apply(options ...Option) {\n\tfor _, opt := range options {\n\t\topt(lOpts)\n\t}\n}", "func (o *SAControllerOptions) ApplyTo(cfg *serviceaccountconfig.SAControllerConfiguration) error {\n\tif o == nil {\n\t\treturn nil\n\t}\n\n\tcfg.ServiceAccountKeyFile = o.ServiceAccountKeyFile\n\tcfg.ConcurrentSATokenSyncs = o.ConcurrentSATokenSyncs\n\tcfg.RootCAFile = o.RootCAFile\n\n\treturn nil\n}", "func (_ *Index) Options(resource *restish.Resource, action string) (*restish.Resource, restish.StatusCode) {\n\tswitch {\n\tcase restish.ActionRead == action:\n\t\treturn resource, restish.StatusOk\n\n\t}\n\n\treturn resource, restish.StatusUnauthorized\n}", "func (getOpt *SubResourceGetOptions) ApplyOptions(opts []SubResourceGetOption) *SubResourceGetOptions {\n\tfor _, o := range opts {\n\t\to.ApplyToSubResourceGet(getOpt)\n\t}\n\n\treturn getOpt\n}", "func ApplyOptions(opt ...Option) Options {\n\topts := Options{\n\t\tMaxTraversalLinks: math.MaxInt64, //default: traverse all\n\t\tMaxAllowedHeaderSize: carv1.DefaultMaxAllowedHeaderSize,\n\t\tMaxAllowedSectionSize: carv1.DefaultMaxAllowedSectionSize,\n\t}\n\tfor _, o := range opt {\n\t\to(&opts)\n\t}\n\t// Set defaults for zero valued fields.\n\tif opts.IndexCodec == 0 {\n\t\topts.IndexCodec = multicodec.CarMultihashIndexSorted\n\t}\n\tif opts.MaxIndexCidSize == 0 {\n\t\topts.MaxIndexCidSize = DefaultMaxIndexCidSize\n\t}\n\treturn opts\n}", "func(t *TargImp) Apply(a Action) os.Error {\n\n\tif !t.commandSent {\n\t\tt.commandSent = true\n\t\treturn a(t)\n\t}\n\treturn nil\n}", "func (co *SubResourceCreateOptions) ApplyOptions(opts []SubResourceCreateOption) *SubResourceCreateOptions {\n\tfor _, o := range opts {\n\t\to.ApplyToSubResourceCreate(co)\n\t}\n\n\treturn co\n}", "func (e *Exclusive) CallWithOptions(options ...ExclusiveOption) <-chan *ExclusiveOutcome {\n\tvar config exclusiveConfig\n\tfor _, option := range options {\n\t\toption(&config)\n\t}\n\tfor _, wrapper := range config.wrappers {\n\t\tconfig.work = wrapper(config.work)\n\t}\n\tconfig.wrappers = nil\n\treturn e.call(config)\n}", "func (o *EphemeralVolumeControllerOptions) ApplyTo(cfg *ephemeralvolumeconfig.EphemeralVolumeControllerConfiguration) error {\n\tif o == nil {\n\t\treturn nil\n\t}\n\n\tcfg.ConcurrentEphemeralVolumeSyncs = o.ConcurrentEphemeralVolumeSyncs\n\n\treturn nil\n}", "func (c *AppConfig) Apply(opts []AppOption) error {\r\n\tfor _, o := range opts {\r\n\t\tif err := o(c); err != nil {\r\n\t\t\treturn err\r\n\t\t}\r\n\t}\r\n\treturn nil\r\n}", "func (tr *Transport) Options(url string, fn HandlerFunc, options ...HandlerOption) {\n\ttr.mux.Handler(net_http.MethodOptions, url, encapsulate(fn, tr.options, options))\n}", "func ApplyCounterOptions(opts *Options, cos ...CounterOptionApplier) {\n\tfor _, o := range cos {\n\t\to.ApplyCounterOption(opts)\n\t}\n}", "func (APIResourceBase) Options(session *Session, url string, queries url.Values, body io.Reader) (APIStatus, interface{}) {\n\treturn FailSimple(http.StatusMethodNotAllowed), nil\n}", "func (cfg *Config) Apply(opts ...Option) error {\n\tfor _, opt := range opts {\n\t\tif opt == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif err := opt(cfg); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Options(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"OPTIONS\", path)\n\n\tinfoMutex.Lock()\n\tr.OPTIONS(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func (o *ListImplementationRevisionsOptions) Apply(opts ...GetImplementationOption) {\n\tfor _, opt := range opts {\n\t\topt(o)\n\t}\n}", "func (o *Number[T]) ApplyOptions(options ...NumberOption[T]) *Number[T] {\n\tfor _, opt := range options {\n\t\tif opt == nil {\n\t\t\tcontinue\n\t\t}\n\t\topt.apply(o)\n\t}\n\treturn o\n}", "func (f OptionFunc) Apply(ratelimiter Ratelimiter) error {\n\treturn f(ratelimiter)\n}", "func OptOpenAction(action Actioner) Option {\n\treturn func(b *Breaker) {\n\t\tb.OpenAction = action\n\t}\n}", "func (options *ApplyWorkspaceCommandOptions) SetActionOptions(actionOptions *WorkspaceActivityOptionsTemplate) *ApplyWorkspaceCommandOptions {\n\toptions.ActionOptions = actionOptions\n\treturn options\n}", "func (e *ExternalService) Apply(opts ...func(*ExternalService)) {\n\tif e == nil {\n\t\treturn\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(e)\n\t}\n}", "func (opt ArgJoiner) argApply(o *argOptions) {\n\to.joiner = string(opt)\n}", "func (o SecurityPolicyRuleRateLimitOptionsOutput) ConformAction() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v SecurityPolicyRuleRateLimitOptions) *string { return v.ConformAction }).(pulumi.StringPtrOutput)\n}", "func (f *FlagBase[T, C, V]) RunAction(ctx context.Context, cmd *Command) error {\n\tif f.Action != nil {\n\t\treturn f.Action(ctx, cmd, f.Get(cmd))\n\t}\n\n\treturn nil\n}", "func (_m *Option) Execute(_a0 *bidi.options) {\n\t_m.Called(_a0)\n}", "func (a *ApproveTransaction) Options(t *bind.TransactOpts) error {\n\ta.TransactOpts = t\n\treturn nil\n}", "func Apply(rw ReadWriter, options ...Option) ReadWriter {\n\tfor _, option := range options {\n\t\toption(rw)\n\t}\n\treturn applyOptionsForState(rw)\n}", "func (op *ReadOptions) Apply(opts ...ReadOption) {\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n}", "func SendOptions(ctx context.Context, response http.ResponseWriter,\n\trequest *http.Request, pipeline filter.Pipeline) {\n\tresponse.Header().Add(\"Allow\", \"OPTIONS, GET, HEAD\")\n\tresponse.WriteHeader(http.StatusNoContent)\n\tmedia := strings.NewReader(\"\")\n\terr := error(nil)\n\tif len(pipeline) > 0 {\n\t\t// use a filter pipeline\n\t\t_, err = filter.PipelineCopy(ctx, response, media, request, pipeline)\n\t} else {\n\t\t// unfiltered, simple copy\n\t\t_, err = io.Copy(response, media)\n\t}\n\tif err != nil {\n\t\tlog.Error().Msgf(\"SendOptions: %v\", err)\n\t}\n}", "func (ctl Controller) Options(ctx *gin.Context) {\n\n\tMethodNotAllowedJSON(ctx)\n}", "func (cu *CodeUtils) HandleOptions(args []string) error {\n\tvar name, value string\nnext:\n\tfor _, a := range args {\n\t\tparts := strings.SplitN(a, \"=\", 2)\n\t\tswitch len(parts) {\n\t\tcase 0:\n\t\t\tcontinue\n\t\tcase 1:\n\t\t\tname, value = parts[0], \"\"\n\t\tcase 2:\n\t\t\tname, value = parts[0], parts[1]\n\t\t}\n\n\t\tfor _, p := range allParams {\n\t\t\tif p.match(name) {\n\t\t\t\terr := p.action(value, cu)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tcu.Info(\"option:\", a)\n\t\t\t\tcontinue next\n\t\t\t}\n\t\t}\n\t\tcu.Info(\"unsupported option:\", a)\n\t}\n\treturn nil\n}", "func (pd *ParameterDefinition) UpdateApplyTo(m *Manifest) {\n\tif pd.exemptFromInstall() {\n\t\tapplyTo := []string{claim.ActionUninstall}\n\t\t// The core action \"Upgrade\" is technically still optional\n\t\t// so only add it if it is declared in the manifest\n\t\tif m.Upgrade != nil {\n\t\t\tapplyTo = append(applyTo, claim.ActionUpgrade)\n\t\t}\n\t\t// Add all custom actions\n\t\tfor action := range m.CustomActions {\n\t\t\tapplyTo = append(applyTo, action)\n\t\t}\n\t\tsort.Strings(applyTo)\n\t\tpd.ApplyTo = applyTo\n\t}\n}", "func (c ConvertOpts) Execute(_ []string) (err error) {\n\tif Opts.Debug {\n\t\tfmt.Fprintf(os.Stderr, \"Options: %#v\\n\", Opts)\n\t}\n\tset, err := mapping.NewMappingSet(Opts.Mapping)\n\tif err != nil {\n\t\treturn\n\t}\n\tif Opts.Debug {\n\t\tfmt.Fprintf(os.Stderr, \"Mapping Set: %#v\\n\", set)\n\t}\n\n\tinputs := mapping.NewInputsFromFlags(Opts.Inputs)\n\n\toutput := operator.NewOperatorOutput(Opts.Target)\n\tset.GenerateOutput(inputs, output)\n\tif Opts.Debug {\n\t\tfmt.Fprintf(os.Stderr, \"OperatorOutput: %#v\\n\", output)\n\t}\n\n\tif Opts.Target == \"\" {\n\t\tfmt.Println(output)\n\t} else {\n\t\tvar data []byte = []byte(output.String())\n\t\tif err = ioutil.WriteFile(Opts.Target, data, 0600); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn nil\n}", "func (bo *BoolOptions) Apply(n models.ConfigurationMap, changed ChangedFunc, data interface{}) int {\n\tchanges := []changedOptions{}\n\n\tbo.optsMU.Lock()\n\tfor k, v := range n {\n\t\tval, ok := bo.Opts[k]\n\n\t\tif boolVal, _ := NormalizeBool(v); boolVal {\n\t\t\t/* Only enable if not enabled already */\n\t\t\tif !ok || !val {\n\t\t\t\tbo.enable(k)\n\t\t\t\tchanges = append(changes, changedOptions{key: k, value: true})\n\t\t\t}\n\t\t} else {\n\t\t\t/* Only disable if enabled already */\n\t\t\tif ok && val {\n\t\t\t\tbo.disable(k)\n\t\t\t\tchanges = append(changes, changedOptions{key: k, value: false})\n\t\t\t}\n\t\t}\n\t}\n\tbo.optsMU.Unlock()\n\n\tfor _, change := range changes {\n\t\tchanged(change.key, change.value, data)\n\t}\n\n\treturn len(changes)\n}", "func (ca *Appender) SetOptions(args ...interface{}) *Appender {\n\tops, idx, _ := driver.ArgsToMap(args...)\n\tfor _, k := range idx {\n\t\tca.Set(k, ops[k])\n\t}\n\treturn ca\n}", "func EnableAction(c *gcli.Context) {\n\tval, _ := getVal(\"type\", c)\n\tswitch val {\n\tcase \"policy\":\n\t\tcli, err := NewPolicyClient(c)\n\t\tif err != nil {\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\treq := policy.EnablePolicyRequest{}\n\t\tif val, success := getVal(\"id\", c); success {\n\t\t\treq.Id = val\n\t\t}\n\t\tif val, success := getVal(\"teamId\", c); success {\n\t\t\treq.TeamId = val\n\t\t}\n\t\tif val, success := getVal(\"policyType\", c); success {\n\t\t\treq.Type = policy.PolicyType(val)\n\t\t}\n\t\tprintMessage(DEBUG,\"Enable policy request prepared from flags, sending request to Opsgenie..\")\n\t\t_, err = cli.EnablePolicy(nil, &req)\n\t\tif err != nil {\n\t\t\tprintMessage(ERROR, err.Error())\n\t\t\tos.Exit(1)\n\t\t}\n\t\tprintMessage(INFO,\"Policy enabled successfuly\")\n\n\tcase \"integration\":\n\t\tcli, err := NewIntegrationClient(c)\n\t\tif err != nil {\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\treq := integration.EnableIntegrationRequest{}\n\t\tif val, success := getVal(\"id\", c); success {\n\t\t\treq.Id = val\n\t\t}\n\t\tprintMessage(DEBUG,\"Enable integration request prepared from flags, sending request to Opsgenie..\")\n\t\t_, err = cli.Enable(nil, &req)\n\t\tif err != nil {\n\t\t\tprintMessage(ERROR, err.Error())\n\t\t\tos.Exit(1)\n\t\t}\n\t\tprintMessage(INFO,\"Integration enabled successfuly\")\n\tdefault:\n\t\tprintMessage(INFO,\"Invalid type option \" + val + \", specify either integration or policy\")\n\t\tgcli.ShowCommandHelp(c, \"enable\")\n\t\tos.Exit(1)\n\t}\n}", "func applyAction(userValue reflect.Value, e fsmEvent, cb callback) error {\n\tif cb.action == nil {\n\t\treturn nil\n\t}\n\tvalues := make([]reflect.Value, 0, len(e.args)+1)\n\tvalues = append(values, userValue)\n\tfor _, arg := range e.args {\n\t\tvalues = append(values, reflect.ValueOf(arg))\n\t}\n\tres := reflect.ValueOf(cb.action).Call(values)\n\n\tif res[0].Interface() != nil {\n\t\treturn xerrors.Errorf(\"Error applying event transition `%+v`: %w\", e.name, res[0].Interface().(error))\n\t}\n\treturn nil\n}", "func (a *ahaAPIApplier) Apply(src, target *Plan) error {\n\tplanner := TargetBasedPlanner(reconfigureSwitch, reconfigureThermostat)\n\tactions, err := planner.Plan(src, target)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfanOutChan, wg := a.fanOut(actions)\n\tfanInChan := a.fanIn(fanOutChan)\n\twg.Wait()\n\tclose(fanOutChan)\n\terr = <-fanInChan\n\tclose(fanInChan)\n\treturn err\n}", "func Options(opts ...Option) Option {\n\treturn optionFunc(func(app *App) {\n\t\tfor _, opt := range opts {\n\t\t\topt.apply(app)\n\t\t}\n\t})\n}", "func (o *DB) ApplyOptions(options ...DBOption) *DB {\n\tfor _, opt := range options {\n\t\tif opt == nil {\n\t\t\tcontinue\n\t\t}\n\t\topt.apply(o)\n\t}\n\treturn o\n}", "func (a Args) ApplyTo(i interface{}) (err error) {\n\tif len(a) > 0 {\n\t\tvar b []byte\n\t\tb, err = json.Marshal(a)\n\t\tif err == nil {\n\t\t\terr = json.Unmarshal(b, i)\n\t\t}\n\t}\n\n\treturn\n}", "func (s *LCOWOption) Apply(interface{}) error {\n\treturn nil\n}", "func (a *APIUpdatingApplicator) Apply(ctx context.Context, o client.Object, ao ...ApplyOption) error {\n\tm, ok := o.(Object)\n\tif !ok {\n\t\treturn errors.New(\"cannot access object metadata\")\n\t}\n\n\tif m.GetName() == \"\" && m.GetGenerateName() != \"\" {\n\t\treturn errors.Wrap(a.client.Create(ctx, o), \"cannot create object\")\n\t}\n\n\tcurrent := o.DeepCopyObject().(client.Object)\n\n\terr := a.client.Get(ctx, types.NamespacedName{Name: m.GetName(), Namespace: m.GetNamespace()}, current)\n\tif kerrors.IsNotFound(err) {\n\t\t// TODO: Apply ApplyOptions here too?\n\t\treturn errors.Wrap(a.client.Create(ctx, m), \"cannot create object\")\n\t}\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"cannot get object\")\n\t}\n\n\tfor _, fn := range ao {\n\t\tif err := fn(ctx, current, m); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// NOTE: we must set the resource version of the desired object\n\t// to that of the current or the update will always fail.\n\tm.SetResourceVersion(current.(metav1.Object).GetResourceVersion())\n\treturn errors.Wrap(a.client.Update(ctx, m), \"cannot update object\")\n}", "func ApplyMeasureOptions(opts *Options, mos ...MeasureOptionApplier) {\n\tfor _, o := range mos {\n\t\to.ApplyMeasureOption(opts)\n\t}\n}", "func Apply(cmd *cli.Cmd) {\n\tcmd.Spec = \"[-f=<FILENAME>] [--keep-weights] [--allowed-actions=<ACTIONS_SPEC>]\"\n\tvar (\n\t\tapplyFile = cmd.StringOpt(\"f\", \"/etc/ipvsctl.yaml\", \"File to apply. Use - for STDIN\")\n\t\tkeepWeights = cmd.BoolOpt(\"keep-weights\", false, \"Leave weights as they are when updating destinations\")\n\t\tactionSpec = cmd.StringOpt(\"allowed-actions\", \"*\", `\nComma-separated list of allowed actions.\nas=Add service, us=update service, ds=delete service,\nad=Add destination, ud=update destination, dd=delete destination.\nDefault * for all actions.\n`)\n\t)\n\n\tcmd.Action = func() {\n\n\t\tif *applyFile == \"\" {\n\t\t\tfmt.Fprintf(os.Stderr, \"Must specify an input file or - for stdin\\n\")\n\t\t\tos.Exit(exitInvalidFile)\n\t\t}\n\n\t\t// read new config from file\n\t\tnewConfig, err := readModelFromInput(applyFile)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Error reading model: %s\\n\", err)\n\t\t\tos.Exit(exitValidateErr)\n\t\t}\n\n\t\tresolvedConfig, err := resolveParams(newConfig)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Error resolving parameters: %s\\n\", err)\n\t\t\tos.Exit(exitParamErr)\n\t\t}\n\n\t\t// validate model before applying\n\t\terr = resolvedConfig.Validate()\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Error validation model: %s\\n\", err)\n\t\t\tos.Exit(exitValidateErr)\n\t\t}\n\n\t\tallowedSet, err := parseAllowedActions(actionSpec)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"unable to process allowed actions: %s\\n\", err)\n\t\t\tos.Exit(exitInvalidInput)\n\t\t}\n\n\t\t// apply new configuration\n\t\terr = MustGetCurrentConfig().Apply(resolvedConfig, integration.ApplyOpts{\n\t\t\tKeepWeights: *keepWeights,\n\t\t\tAllowedActions: allowedSet,\n\t\t})\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Error applying updates: %s\\n\", err)\n\t\t\tos.Exit(exitApplyErr)\n\t\t}\n\t\tfmt.Printf(\"Applied configuration from %s\\n\", *applyFile)\n\t}\n}", "func (b *Baa) Options(pattern string, h ...HandlerFunc) RouteNode {\n\treturn b.Router().Add(\"OPTIONS\", pattern, h)\n}", "func(s *SetImp) Apply(t Target, a Action) os.Error {\n\tif err := t.ApplyPreq(a); err != nil { return err }\n\tif err := t.Apply(a); err != nil { return err }\n\treturn nil\n}", "func (m pActionArchive) Extend(fnct func(m.UserSet)) pActionArchive {\n\treturn pActionArchive{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (c *BaseController) Options(w http.ResponseWriter, r *Request) {\n\thttp.Error(w, \"Method Not Allowed\", 405)\n}", "func Apply(t *testing.T, options *Options) string {\n\tout, err := ApplyE(options)\n\trequire.NoError(t, err)\n\treturn out\n}", "func (a *APIPatchingApplicator) Apply(ctx context.Context, o client.Object, ao ...ApplyOption) error {\n\tif o.GetNamespace() == \"\" {\n\t\to.SetNamespace(\"default\")\n\t}\n\n\tm, ok := o.(metav1.Object)\n\tif !ok {\n\t\treturn errors.New(\"cannot access object metadata\")\n\t}\n\n\tif m.GetName() == \"\" && m.GetGenerateName() != \"\" {\n\t\treturn errors.Wrap(a.client.Create(ctx, o), \"cannot create object\")\n\t}\n\n\tdesired := o.DeepCopyObject()\n\n\terr := a.client.Get(ctx, types.NamespacedName{Name: m.GetName(), Namespace: m.GetNamespace()}, o)\n\tif kerrors.IsNotFound(err) {\n\t\t// TODO: Apply ApplyOptions here too?\n\t\treturn errors.Wrap(a.client.Create(ctx, o), \"cannot create object\")\n\t}\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"cannot get object\")\n\t}\n\n\tfor _, fn := range ao {\n\t\tif err := fn(ctx, o, desired); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// TODO: Allow callers to override the kind of patch used.\n\treturn errors.Wrap(a.client.Patch(ctx, o, &patch{desired.(client.Object)}), \"cannot patch object\")\n}", "func (sso *StartSpanOptions) Apply(opt opentracing.StartSpanOption) {\n\topt.Apply(&sso.OpenTracingOptions)\n\tif o, ok := opt.(StartSpanOption); ok {\n\t\to.ApplyBP(sso)\n\t}\n}", "func (o SecurityPolicyRuleRateLimitOptionsOutput) ExceedAction() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v SecurityPolicyRuleRateLimitOptions) *string { return v.ExceedAction }).(pulumi.StringPtrOutput)\n}", "func (c *Controller) Options() {\n\thttp.Error(c.Ctx.ResponseWriter, \"Method Not Allowed\", http.StatusMethodNotAllowed)\n}", "func (r *Route) Options(handler http.Handler) *Route {\n\tr.handlers[http.MethodOptions] = handler\n\treturn r\n}", "func (game Game) applyAction(action GameAction, coords objects.GridCoords) {\n\tswitch action {\n\tcase Explore:\n\t\tgame.grid[coords.Row][coords.Col] |= Explored\n\t\tif game.grid[coords.Row][coords.Col]&Bomb == 0 &&\n\t\t\tgame.grid.countNeighbourBombs(coords) == 0 {\n\t\t\tgame.exploreNeighbours(coords)\n\t\t}\n\n\tcase Flag:\n\t\tif game.grid[coords.Row][coords.Col]&Flagged == 0 {\n\t\t\tgame.grid[coords.Row][coords.Col] |= Flagged\n\t\t} else {\n\t\t\tgame.grid[coords.Row][coords.Col] &= ^Flagged\n\t\t}\n\n\tdefault:\n\t\tpanic(\"Invalid action\")\n\t}\n}", "func (o *ValidatingAdmissionPolicyStatusControllerOptions) ApplyTo(cfg *validatingadmissionpolicystatusconfig.ValidatingAdmissionPolicyStatusControllerConfiguration) error {\n\tif o == nil {\n\t\treturn nil\n\t}\n\n\tcfg.ConcurrentPolicySyncs = o.ConcurrentPolicySyncs\n\n\treturn nil\n}", "func (e *evictAction) DoAction(conflicting bool, data interface{}) (*ActionResult, error) {\n\treturn nil, nil\n}", "func (r *Router) Options(path, title string, fn Handle) {\n\tr.addRoute(\"OPTIONS\", path, title, fn)\n}", "func (o ClusterOpts) ApplyOpts(opts *rediscluster.Opts) {\n\tif o.Name != \"\" {\n\t\topts.Name = o.Name\n\t}\n}", "func (o *overrideOpts) Execute() error {\n\tdir := o.dir()\n\tswitch o.iacTool {\n\tcase cdkIaCTool:\n\t\tif err := override.ScaffoldWithCDK(o.fs, dir, o.resources, o.requiresEnv); err != nil {\n\t\t\treturn fmt.Errorf(\"scaffold CDK application under %q: %v\", dir, err)\n\t\t}\n\t\tlog.Successf(\"Created a new CDK application at %q to override resources\\n\", displayPath(dir))\n\tcase yamlPatch:\n\t\tif err := override.ScaffoldWithPatch(o.fs, dir); err != nil {\n\t\t\treturn fmt.Errorf(\"scaffold CFN YAML patches under %q: %v\", dir, err)\n\t\t}\n\t\tlog.Successf(\"Created a YAML patch file under %q to override resources\\n\", displayPath(dir))\n\t}\n\treturn nil\n}", "func (o *Options) apply(featureGate featuregate.FeatureGate) {\n\tcontextualLoggingEnabled := contextualLoggingDefault\n\tif featureGate != nil {\n\t\tcontextualLoggingEnabled = featureGate.Enabled(ContextualLogging)\n\t}\n\n\t// if log format not exists, use nil loggr\n\tfactory, _ := registry.LogRegistry.Get(o.Config.Format)\n\tif factory == nil {\n\t\tklog.ClearLogger()\n\t} else {\n\t\t// This logger will do its own verbosity checking, using the exact same\n\t\t// configuration as klog itself.\n\t\tlog, flush := factory.Create(o.Config)\n\t\t// Therefore it can get called directly. However, we only allow that\n\t\t// when the feature is enabled.\n\t\tklog.SetLoggerWithOptions(log, klog.ContextualLogger(contextualLoggingEnabled), klog.FlushLogger(flush))\n\t}\n\tif err := loggingFlags.Lookup(\"v\").Value.Set(o.Config.Verbosity.String()); err != nil {\n\t\tpanic(fmt.Errorf(\"internal error while setting klog verbosity: %v\", err))\n\t}\n\tif err := loggingFlags.Lookup(\"vmodule\").Value.Set(o.Config.VModule.String()); err != nil {\n\t\tpanic(fmt.Errorf(\"internal error while setting klog vmodule: %v\", err))\n\t}\n\tklog.StartFlushDaemon(o.Config.FlushFrequency)\n\tklog.EnableContextualLogging(contextualLoggingEnabled)\n}", "func FunctionalOptions(value ...interface{}) *FunctionalOptionsArgument {\n\treturn &FunctionalOptionsArgument{\n\t\tvalue: value,\n\t}\n}", "func (i *Index) Options(options ...IndexOption) {\n\tfor _, option := range options {\n\t\ti.SetOption(option)\n\t}\n}", "func (s *Style) MergeFromOptions(options map[string]any) error {\n\tassignColor := func(val any, colorField *Color) string {\n\t\tif val == \"default\" {\n\t\t\t*colorField = nil\n\t\t\treturn \"\"\n\t\t} else if s, ok := val.(string); ok {\n\t\t\tcolor := parseColor(s)\n\t\t\tif color != nil {\n\t\t\t\t*colorField = color\n\t\t\t\treturn \"\"\n\t\t\t}\n\t\t}\n\t\treturn \"valid color string\"\n\t}\n\tassignBool := func(val any, attrField *bool) string {\n\t\tif b, ok := val.(bool); ok {\n\t\t\t*attrField = b\n\t\t} else {\n\t\t\treturn \"bool value\"\n\t\t}\n\t\treturn \"\"\n\t}\n\n\tfor k, v := range options {\n\t\tvar need string\n\n\t\tswitch k {\n\t\tcase \"fg-color\":\n\t\t\tneed = assignColor(v, &s.Fg)\n\t\tcase \"bg-color\":\n\t\t\tneed = assignColor(v, &s.Bg)\n\t\tcase \"bold\":\n\t\t\tneed = assignBool(v, &s.Bold)\n\t\tcase \"dim\":\n\t\t\tneed = assignBool(v, &s.Dim)\n\t\tcase \"italic\":\n\t\t\tneed = assignBool(v, &s.Italic)\n\t\tcase \"underlined\":\n\t\t\tneed = assignBool(v, &s.Underlined)\n\t\tcase \"blink\":\n\t\t\tneed = assignBool(v, &s.Blink)\n\t\tcase \"inverse\":\n\t\t\tneed = assignBool(v, &s.Inverse)\n\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unrecognized option '%s'\", k)\n\t\t}\n\n\t\tif need != \"\" {\n\t\t\treturn fmt.Errorf(\"value for option '%s' must be a %s\", k, need)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (sug *Suggester) Options(opts ...Option) {\n\tfor _, opt := range opts {\n\t\topt(sug)\n\t}\n}", "func (c *Client) Options(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodOptions, url, data...)\n}", "func (o SecurityPolicyRuleRateLimitOptionsResponseOutput) ConformAction() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SecurityPolicyRuleRateLimitOptionsResponse) string { return v.ConformAction }).(pulumi.StringOutput)\n}", "func (fdp *fakeDataPrivacy) RedactionOptions(_ context.Context) (*distributedpb.RedactionOptions, error) {\n\treturn fdp.Options, nil\n}", "func (m pExecuteO2MActions) Extend(fnct func(m.UserSet, models.FieldName, *models.FieldInfo, interface{}) interface{}) pExecuteO2MActions {\n\treturn pExecuteO2MActions{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func SetOptions(options Options) {\n\tops = options\n}", "func PossibleActionValues() []Action {\n\treturn []Action{Allow}\n}" ]
[ "0.7005766", "0.6385246", "0.62773436", "0.6115748", "0.58998954", "0.5832392", "0.5778075", "0.56691056", "0.5668067", "0.5614631", "0.56125396", "0.55785906", "0.55463755", "0.55210423", "0.5516695", "0.5509331", "0.5503785", "0.5501453", "0.5478226", "0.54261357", "0.54245645", "0.5360252", "0.532618", "0.53250337", "0.53222257", "0.52999043", "0.5283372", "0.52661943", "0.5246969", "0.52037674", "0.52011234", "0.5172243", "0.5147319", "0.5140146", "0.51304877", "0.5120234", "0.506973", "0.5061112", "0.5045092", "0.49765253", "0.4947084", "0.49300742", "0.4926399", "0.4920593", "0.49193972", "0.49106765", "0.48815417", "0.48603192", "0.48534384", "0.48448002", "0.48410872", "0.48362133", "0.4833586", "0.4831366", "0.48193824", "0.4814994", "0.4806553", "0.47831866", "0.4771169", "0.47690952", "0.47643694", "0.47618055", "0.47597957", "0.47563964", "0.47356036", "0.47345167", "0.4726238", "0.47028446", "0.46990332", "0.46883467", "0.46868783", "0.46741748", "0.46589786", "0.46476653", "0.46450928", "0.4630989", "0.46252513", "0.46248826", "0.46141", "0.4612592", "0.46003348", "0.45895797", "0.4573803", "0.45707905", "0.45602396", "0.45599577", "0.45576298", "0.45559186", "0.45519578", "0.45507112", "0.45502314", "0.45468676", "0.454371", "0.45421684", "0.45395425", "0.45374477", "0.4536491", "0.45222795", "0.4521053", "0.45136666" ]
0.6105199
4
Perform implementation of the actionable interface
func (ci *createIndex) Perform() Actionable { exists, err := ci.indexer.Exists(ci.options.Name) if err != nil { ci.errorContainer.push(ci.options.Name, ci.name, err) return ci } if exists { ci.errorContainer.push(ci.options.Name, ci.name, errors.New("Index already exists")) return ci } schema, err := mapToString(ci.options.ExtraSettings) if err != nil { ci.errorContainer.push(ci.options.Name, ci.name, err) return ci } if err := ci.indexer.CreateIndex(ci.options.Name, schema); err != nil { ci.errorContainer.push(ci.options.Name, ci.name, err) } if len(ci.errorContainer.list()) > 0 && ci.retryCount < ci.context.GetRetryCount() { ci.retryCount = ci.retryCount + 1 ci.Perform() } ci.notifiableList = append(ci.notifiableList, ci.options.Name) return ci }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Card) Action(_ context.Context, _ *int, _ time.Time, _ interface{}) (done bool, err error) {\n\treturn true, nil\n}", "func (m *Bigo) Action(handler Handler) {\n\tvalidateHandler(handler)\n\tm.action = handler\n}", "func (e *evictAction) DoAction(conflicting bool, data interface{}) (*ActionResult, error) {\n\treturn nil, nil\n}", "func (a *Armory) DoAction() {\n\tswitch a.componentType {\n\tcase utils.BOMB:\n\tcase utils.MISSILE:\n\tcase utils.COMBOSHOT:\n\tcase utils.MULTISHOT:\n\tdefault:\n\t}\n}", "func defaultAction(interface{}, Event) error { return nil }", "func (agent *ActionAgent) dispatchAction(actionPath, data string) error {\n\tagent.actionMutex.Lock()\n\tdefer agent.actionMutex.Unlock()\n\n\tlog.Infof(\"action dispatch %v\", actionPath)\n\tactionNode, err := actionnode.ActionNodeFromJson(data, actionPath)\n\tif err != nil {\n\t\tlog.Errorf(\"action decode failed: %v %v\", actionPath, err)\n\t\treturn nil\n\t}\n\n\tcmd := []string{\n\t\tagent.vtActionBinFile,\n\t\t\"-action\", actionNode.Action,\n\t\t\"-action-node\", actionPath,\n\t\t\"-action-guid\", actionNode.ActionGuid,\n\t}\n\tcmd = append(cmd, logutil.GetSubprocessFlags()...)\n\tcmd = append(cmd, topo.GetSubprocessFlags()...)\n\tcmd = append(cmd, dbconfigs.GetSubprocessFlags()...)\n\tcmd = append(cmd, mysqlctl.GetSubprocessFlags()...)\n\tlog.Infof(\"action launch %v\", cmd)\n\tvtActionCmd := exec.Command(cmd[0], cmd[1:]...)\n\n\tstdOut, vtActionErr := vtActionCmd.CombinedOutput()\n\tif vtActionErr != nil {\n\t\tlog.Errorf(\"agent action failed: %v %v\\n%s\", actionPath, vtActionErr, stdOut)\n\t\t// If the action failed, preserve single execution path semantics.\n\t\treturn vtActionErr\n\t}\n\n\tlog.Infof(\"Agent action completed %v %s\", actionPath, stdOut)\n\tagent.afterAction(actionPath, actionNode.Action == actionnode.TABLET_ACTION_APPLY_SCHEMA)\n\treturn nil\n}", "func (f *Flame) Action(h Handler) {\n\tf.action = validateAndWrapHandler(h, nil)\n}", "func (s *snapshot) Perform() Actionable {\n\tsnapshotsInProgress, err := s.checkForSnapshotsInProgress(s.options.Repository)\n\n\tif err != nil {\n\t\treturn s.logError(err)\n\t}\n\n\tif snapshotsInProgress {\n\t\treturn s.logError(errors.New(\"There is a snapshot currently in progress\"))\n\t}\n\n\tif s.options.WaitForCompletion {\n\t\tif err := s.runAndWaitForCompletion(); err != nil {\n\t\t\treturn s.logError(err)\n\t\t}\n\n\t\treturn s\n\t}\n\n\tresponse, err := s.indexer.Snapshot(s.options.Repository, s.options.Name, s.list...)\n\n\tif err != nil {\n\t\treturn s.logError(err)\n\t}\n\n\tif accepted, _ := response.S(\"accepted\").Data().(bool); !accepted {\n\t\treturn s.logError(errors.New(\"Snapshot was not accepted\"))\n\t}\n\n\tif err := s.checkActionStatus(); err != nil {\n\t\treturn s.logError(err)\n\t}\n\n\treturn s\n}", "func (op Print) Action(c *Computer) (err error) {\n\tif c.A, _, err = c.Load(1); err != nil {\n\t\treturn err\n\t}\n\tif len(c.OutputHandlers) > 0 {\n\t\tfor _, handler := range c.OutputHandlers {\n\t\t\thandler(c.A)\n\t\t}\n\t} else {\n\t\tfmt.Println(c.A)\n\t}\n\treturn nil\n}", "func (g *Game) performAction(abbr string) {\n\tm := make(map[Phase]func(*Action))\n\tm[Development] = func(a *Action) { g.performDevelopmentAction(a) }\n\tm[Capacity] = func(a *Action) { g.performCapacityAction(a) }\n\tm[Production] = func(a *Action) { g.performProductionAction(a) }\n\n\ta := g.findAction(abbr)\n\tif a == nil {\n\t\tlog.Printf(\"Couldn't find action for abbreviation %s\", abbr)\n\t}\n\n\tm[g.Phase](a)\n}", "func (client *Client) performInterfaceAction(sa *InterfaceAction) (changeID string, err error) {\n\tb, err := json.Marshal(sa)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn client.doAsync(\"POST\", \"/v2/interfaces\", nil, nil, bytes.NewReader(b))\n}", "func (c *ColumnBase) DoAction(ctx context.Context, params action.Params) {}", "func (sf *ShardFixer) Action(ctx context.Context, name string) error {\n\tif name == \"Create\" {\n\t\treturn sf.ts.CreateShard(ctx, sf.keyspace, sf.shard)\n\t}\n\tif name == \"Delete\" {\n\t\treturn sf.ts.DeleteShard(ctx, sf.keyspace, sf.shard)\n\t}\n\treturn fmt.Errorf(\"unknown ShardFixer action: %v\", name)\n}", "func (core *coreService) Action(actionHash string, checkPending bool) (*iotexapi.ActionInfo, error) {\n\tif err := core.checkActionIndex(); err != nil {\n\t\treturn nil, err\n\t}\n\tactHash, err := hash.HexStringToHash256(actionHash)\n\tif err != nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, err.Error())\n\t}\n\tact, err := core.getAction(actHash, checkPending)\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Unavailable, err.Error())\n\t}\n\treturn act, nil\n}", "func Action(baseURL, resourceType, id, action string, payload jsh.Sendable) (*jsh.Document, *http.Response, error) {\n\trequest, err := ActionRequest(baseURL, resourceType, id, action, payload)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn Do(request, jsh.ObjectMode)\n}", "func (sc *ServiceController) Action(action map[string]interface{}) (bool, string) {\n\turl := urlServiceAction(sc.ID)\n\n\treturn sc.c.boolResponse(\"POST\", url, action)\n}", "func (ref *UIElement) Perform(action string) {\n\tif ref == nil {\n\t\treturn\n\t}\n\tif ref.obj == nil {\n\t\treturn\n\t}\n\ta := cfstr(action)\n\tdefer C.CFRelease((C.CFTypeRef)(a))\n\tC.AXUIElementPerformAction(ref.obj, a)\n}", "func (f *FlagBase[T, C, V]) RunAction(ctx context.Context, cmd *Command) error {\n\tif f.Action != nil {\n\t\treturn f.Action(ctx, cmd, f.Get(cmd))\n\t}\n\n\treturn nil\n}", "func (i *Interval) Action() func() error {\n\treturn i.action\n}", "func (node *Node) action(action ActionOnNodeFunc) error {\n\tnode.mutex.Lock()\n\tdefer node.mutex.Unlock()\n\n\treturn action(node)\n}", "func (m *Basic) Action(card *model.Card, face *int, startTime time.Time, payload interface{}) (bool, error) {\n\tquery := convertQuery(payload)\n\tlog.Debugf(\"Submit recieved for face %d: %v\\n\", *face, query)\n\tbutton := studyview.Button(query.Submit)\n\tlog.Debugf(\"Button %s pressed\\n\", button)\n\tswitch *face {\n\tcase QuestionFace:\n\t\t// Any input is fine; the only options are the right button, or 'ENTER' in a text field.\n\tcase AnswerFace:\n\t\tkey := buttonsKey(card, *face)\n\t\tif _, valid := buttonMaps[key][button]; !valid {\n\t\t\treturn false, errors.Errorf(\"Unexpected button press %s\", button)\n\t\t}\n\tdefault:\n\t\treturn false, errors.Errorf(\"Unexpected face %d\", *face)\n\t}\n\tswitch *face {\n\tcase QuestionFace:\n\t\t*face++\n\t\ttypedAnswers := query.TypedAnswers\n\t\tif len(typedAnswers) > 0 {\n\t\t\tresults := make(map[string]answer)\n\t\t\tfor _, fieldName := range card.Fields() {\n\t\t\t\tif typedAnswer, ok := typedAnswers[fieldName]; ok {\n\t\t\t\t\tfv := card.FieldValue(fieldName)\n\t\t\t\t\tif fv == nil {\n\t\t\t\t\t\tpanic(\"No field value for field\")\n\t\t\t\t\t}\n\t\t\t\t\tcorrect, d := diff.Diff(fv.Text, typedAnswer)\n\t\t\t\t\tresults[fieldName] = answer{\n\t\t\t\t\t\tText: d,\n\t\t\t\t\t\tCorrect: correct,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcard.Context = map[string]interface{}{\n\t\t\t\tcontextKeyTypedAnswers: results,\n\t\t\t}\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, nil\n\tcase AnswerFace:\n\t\tlog.Debugf(\"Old schedule: Due %s, Interval: %s, Ease: %f, ReviewCount: %d\\n\", card.Due, card.Interval, card.EaseFactor, card.ReviewCount)\n\t\tif err := model.Schedule(card, time.Now().Sub(startTime), quality(button)); err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tlog.Debugf(\"New schedule: Due %s, Interval: %s, Ease: %f, ReviewCount: %d\\n\", card.Due, card.Interval, card.EaseFactor, card.ReviewCount)\n\t\tcard.Context = nil // Clear any saved answers\n\t\treturn true, nil\n\t}\n\tlog.Printf(\"Unexpected face/button combo: %d / %+v\\n\", *face, button)\n\treturn false, nil\n}", "func (c *ArithmeticController) Action() {\n\n\tvar err error\n\tvar x, y, answer int\n\tvar action = c.Ctx.Input.Param(\":action\")\n\tvar arithmetic func(int, int) (int, error)\n\tvar ok bool\n\tcached := false\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tc.Data[\"json\"] = m.Result{Action: action, Error: err.Error()}\n\t\t\tc.Ctx.Output.SetStatus(500)\n\t\t\tlogs.Error(\"Error... %s\", err.Error())\n\t\t} else {\n\t\t\tc.Data[\"json\"] = m.Result{Action: action, Answer: answer, Cached: cached, X: x, Y: y}\n\t\t}\n\t\tc.configurer.ServeJSON(&c.Controller, true)\n\t}()\n\n\tif x, y, err = c.validate(); err != nil {\n\t\treturn\n\t} else if arithmetic, ok = actionMap[action]; !ok {\n\t\terr = fmt.Errorf(\"'%s' is not a recognizable action \", action)\n\t\treturn\n\t} else if answer, ok = resultCache[createCacheKey(arithmetic, x, y)]; ok {\n\t\tcached = true\n\t\treturn\n\t} else if answer, err = arithmetic(x, y); err != nil {\n\t\treturn\n\t}\n\n\tresultCache[createCacheKey(arithmetic, x, y)] = answer\n\tlogs.Info(\"%+v\", resultCache)\n\n}", "func (c *Client) Action(msg *Message) bool {\n\tif msg.ActionID() == \"\" {\n\t\tmsg.AddActionID()\n\t}\n\n\tif err := c.write(msg.Bytes()); err != nil {\n\t\tc.emitError(err)\n\t\treturn false\n\t}\n\treturn true\n}", "func (vm *VM) Perform(target, locals Interface, msg *Message) Interface {\n\tif v, proto := GetSlot(target, msg.Name()); proto != nil {\n\t\tx := v.Activate(vm, target, locals, proto, msg)\n\t\tif x != nil {\n\t\t\treturn x\n\t\t}\n\t\treturn vm.Nil\n\t}\n\tif forward, fp := GetSlot(target, \"forward\"); fp != nil {\n\t\tx := forward.Activate(vm, target, locals, fp, msg)\n\t\tif x != nil {\n\t\t\treturn x\n\t\t}\n\t\treturn vm.Nil\n\t}\n\treturn vm.RaiseExceptionf(\"%s does not respond to %s\", vm.TypeName(target), msg.Name())\n}", "func (DefaultCounter) Actions(int, int, int) {\n}", "func (c *RBController) Action(a Action) http.HandlerFunc {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif err := a(w, r); err != nil {\n\t\t\tc.RenderError(w, http.StatusInternalServerError,\n\t\t\t\t\"Internal server error\\n\"+err.Error())\n\t\t}\n\t})\n}", "func (ra *RecoverableAction) Action(action Action) string {\n\tra.actionChan <- action\n\n\treturn <-ra.replyChan\n}", "func (game *Game) DoAction() {\n\tswitch game.Request.Action {\n\tcase \"game_start\":\n\t\tgame.Ai.GameStart(game)\n\tcase \"turn\":\n\t\tgame.Ai.Turn(game)\n\tcase \"game_over\":\n\t\tgame.Ai.GameOver(game)\n\tcase \"ping\":\n\t\tgame.Ai.Ping(game)\n\t}\n}", "func (c *baseController) Action(a Action) http.HandlerFunc {\n\treturn http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {\n\t\tif err, status_code := a(rw, r); err != nil {\n\t\t\t//extract error message\n\t\t\terror_message := err.Error()\n\n\t\t\t//default to status code 500 on error\n\t\t\tif status_code == 0 {\n\t\t\t\tstatus_code = http.StatusInternalServerError\n\t\t\t}\n\n\t\t\t//overwrite the default error, which is often \"sql: no rows in result set\" in case of 404\n\t\t\tif status_code == http.StatusNotFound {\n\t\t\t\terror_message = \"404 not found\"\n\t\t\t}\n\n\t\t\t//return error message and code\n\t\t\thttp.Error(rw, error_message, status_code)\n\t\t} else if status_code > 0 {\n\t\t\trw.WriteHeader(status_code)\n\t\t} // else - assume the controller has written a status code already when rendering output, so do nothing to avoid multiple write header calls\n\t})\n}", "func (d *DDL) ActionInterface(action string) (*Action, error) {\n\tfor _, act := range d.Actions {\n\t\tif act.Name == action {\n\t\t\treturn act, nil\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"could not found an action called %s#%s\", d.Metadata.Name, action)\n}", "func (tc *STemplateController) action(action map[string]interface{}) error {\n\turl := urlTemplateAction(tc.ID)\n\n\treturn tc.c.boolResponse(\"POST\", url, action)\n}", "func (o IPRuleOutput) Action() ActionPtrOutput {\n\treturn o.ApplyT(func(v IPRule) *Action { return v.Action }).(ActionPtrOutput)\n}", "func (r *Resolver) Action() generated.ActionResolver { return &actionResolver{r} }", "func (a * Action)Do(b Board,info InfoAction)bool {\n\treturn a.action.Do(b,info)\n}", "func (client *SOAPClient) PerformAction(actionNamespace, actionName string, inAction interface{}, outAction interface{}) error {\n\treturn client.PerformActionCtx(context.Background(), actionNamespace, actionName, inAction, outAction)\n}", "func (a *Action) Invoke(action *models.Action, body string) error {\n\t_, err := a.GetClient().Post(fmt.Sprintf(ACTION_INVOKE, action.GetDevice().ID, action.Name), body, &models.ClientOptions{\n\t\tTextPlain: true,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (l *Label) Action() {\n\t// Labels take no action\n}", "func (res *Resource) actionHandler(ctx context.Context, w http.ResponseWriter, r *http.Request, storage store.Get) {\n\tid := pat.Param(ctx, \"id\")\n\n\tresponse, err := storage(ctx, id)\n\tif err != nil && reflect.ValueOf(err).IsNil() == false {\n\t\tSendHandler(ctx, w, r, err)\n\t\treturn\n\t}\n\n\tSendHandler(ctx, w, r, response)\n}", "func Action(c *cli.Context) error {\n\tw, err := NewWalker()\n\tif err != nil {\n\t\treturn xerrors.Errorf(\": %w\", err)\n\t}\n\tdir, err := targetDir()\n\tif err != nil {\n\t\treturn xerrors.Errorf(\": %w\", err)\n\t}\n\tif err = filepath.Walk(dir, w.walk); err != nil {\n\t\treturn xerrors.Errorf(\": %w\", err)\n\t}\n\theader := resultHeader(w)\n\tsubject, err := resultSubject(w)\n\tif err != nil {\n\t\treturn xerrors.Errorf(\": %w\", err)\n\t}\n\tbody := bytes.NewBuffer(header)\n\t_, _ = body.Write([]byte{'\\n', '\\n'})\n\tresultBody(body, w)\n\tLogBytes(c, body.Bytes())\n\tif c.Bool(\"mail\") {\n\t\tif err := Mail(subject, body.Bytes()); err != nil {\n\t\t\treturn xerrors.Errorf(\": %w\", err)\n\t\t}\n\t}\n\treturn nil\n}", "func (d *DeltaTrace) Action() (*ActionTrace, error) {\n\treturn nil, NotActionError{}\n}", "func (r *Rule) action(key item, l *lexer) error {\n\tif key.typ != itemAction {\n\t\tpanic(\"item is not an action\")\n\t}\n\tif !inSlice(key.value, []string{\"alert\", \"drop\", \"pass\"}) {\n\t\treturn fmt.Errorf(\"invalid action: %v\", key.value)\n\t}\n\tr.Action = key.value\n\treturn nil\n}", "func (a *Agent) Action(state, goal *tensor.Dense) (action int, err error) {\n\ta.steps++\n\tdefer func() { a.epsilon.Set(a.Epsilon.Value()) }()\n\tif rand.Float64() < a.epsilon.Scalar() {\n\t\t// explore\n\t\taction, err = a.env.SampleAction()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tlog.Infov(\"taking random action\", action)\n\t\treturn\n\t}\n\taction, err = a.action(state, goal)\n\tlog.Infov(\"taking action\", action)\n\treturn\n}", "func Execute(a *Action) error {\n\tseen := make(map[*Action]error)\n\treturn execute(seen, a)\n}", "func (p *pawn) act() {\n\tif p.asUnit.intent == nil {\n\t\tp.asUnit.intent = &intent{itype: INTENT_RETURN_HOME}\n\t}\n\tswitch p.asUnit.intent.itype {\n\tcase INTENT_BUILD:\n\t\tp.executeBuildIntent()\n\tcase INTENT_RETURN_HOME:\n\t\tp.executeReturnHome()\n\t}\n}", "func (l *logAction) DoAction(conflicting bool, data interface{}) (*ActionResult, error) {\n\tif conflicting {\n\t\tmsg := data.(string)\n\t\talarm.SendAlarm(msg)\n\t}\n\treturn nil, nil\n}", "func (oe *OraErr) Action() string { return oe.action }", "func (act *ActionTrace) Action() (*ActionTrace, error) {\n\treturn act, nil\n}", "func (m *metadata) Action(method string) Action {\n\n\tmethod = cleanMethod(method)\n\n\t// check if action exists\n\tif _, ok := m.actions[method]; !ok {\n\t\tna := NewAction()\n\n\t\t// if debug is enabled, action must too\n\t\tif m.isDebug() {\n\t\t\tna.Debug()\n\t\t}\n\n\t\tm.actions[method] = na\n\t}\n\n\treturn m.actions[method]\n}", "func (a *App) Action(handler Handler) {\n\tvalidateHandler(handler)\n\ta.action = handler\n}", "func RegulatedAction() {\n\t// Some expensive action goes on here\n}", "func (a AnyMessage) Action() Action {\n\tif action, ok := a[KeyAction].(string); ok {\n\t\treturn Action(action)\n\t}\n\treturn ActionEmpty\n}", "func (o IPRuleResponseOutput) Action() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IPRuleResponse) *string { return v.Action }).(pulumi.StringPtrOutput)\n}", "func (a *ActionRequestManager) PerformAction(state octant.State, payload action.Payload) error {\n\tctx := context.TODO()\n\n\tactionName, err := payload.String(\"action\")\n\tif err != nil {\n\t\t// TODO: alert the user this action doesn't exist\n\t\treturn nil\n\t}\n\n\tif err := state.Dispatch(ctx, actionName, payload); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (self *procImpl) Do(a Action) error {\n\treturn self.DoLater(a)\n}", "func (s *Scanner) Action(state State, char byte) (a Action) {\n\n\tswitch state {\n\n\tcase StartState:\n\t\tswitch {\n\n\t\tcase s.isAlpha(char), s.isNumeric(char), s.isColon(char),\n\t\t\ts.isDash(char):\n\t\t\ta = MoveAppend\n\n\t\tcase s.isWhitespace(char):\n\t\t\ta = MoveNoAppend\n\n\t\tcase s.isPlus(char), s.isSemicolon(char), s.isLParen(char),\n\t\t\ts.isRParen(char), s.isComma(char), s.isEquals(char):\n\t\t\ta = HaltAppend\n\n\t\tcase s.isEof(char):\n\t\t\ta = HaltNoAppend\n\n\t\tdefault:\n\t\t\ta = ActionError\n\t\t}\n\n\tcase ScanAlpha:\n\t\tif s.isAlpha(char) || s.isNumeric(char) || s.isUnderscore(char) {\n\t\t\ta = MoveAppend\n\t\t} else {\n\t\t\ta = HaltReuse\n\t\t}\n\n\tcase ScanWhitespace:\n\t\tif s.isWhitespace(char) {\n\t\t\ta = MoveNoAppend\n\t\t} else {\n\t\t\ta = MoveAppend\n\t\t}\n\n\tcase ScanNumeric:\n\t\tif s.isNumeric(char) {\n\t\t\ta = MoveAppend\n\t\t} else {\n\t\t\ta = HaltReuse\n\t\t}\n\n\tcase ScanColon:\n\t\tif s.isEquals(char) {\n\t\t\ta = HaltAppend\n\t\t} else {\n\t\t\ta = ActionError\n\t\t}\n\n\tcase ScanDash:\n\t\tif s.isDash(char) {\n\t\t\ta = MoveAppend\n\t\t} else {\n\t\t\ta = HaltReuse\n\t\t}\n\n\tcase ProcessPlusOp, ProcessSemicolon, ProcessLParen, ProcessRParen,\n\t\tProcessComma, ProcessAssign, ProcessComment:\n\t\ta = HaltReuse\n\n\tcase ScanComment:\n\t\ta = MoveNoAppend\n\n\tdefault:\n\t\ta = ActionError\n\t}\n\n\treturn\n}", "func (a *Action) Perform() error {\n\trv := reflect.ValueOf(a.resource)\n\tcolv := rv.Elem().FieldByName(\"Collection\")\n\tfnv := colv.MethodByName(a.ActionName)\n\n\tretv := fnv.Call([]reflect.Value{\n\t\treflect.ValueOf(rv.Interface().(Resource)),\n\t})\n\n\tret := retv[0].Interface()\n\tif ret != nil {\n\t\treturn ret.(error)\n\t}\n\treturn nil\n}", "func (g *Game) HandleAction(action gamework.Action) gamework.GameState {\n\n}", "func (conn *Conn) Action(t, msg string) { conn.Ctcp(t, ACTION, msg) }", "func (ai *actionItem) Action() llapi.HsmAction {\n\treturn ai.hai.Action\n}", "func (o VirtualNetworkRuleOutput) Action() ActionPtrOutput {\n\treturn o.ApplyT(func(v VirtualNetworkRule) *Action { return v.Action }).(ActionPtrOutput)\n}", "func processAction(a Animal, action string) {\r\n\tswitch strings.ToLower(action) {\r\n\tcase \"eat\":\r\n\t\ta.Eat()\r\n\tcase \"move\":\r\n\t\ta.Move()\r\n\tcase \"speak\":\r\n\t\ta.Speak()\r\n\tdefault:\r\n\t\tfmt.Println(\"Unknown action:\", action)\r\n\t}\r\n}", "func (d *Default) TakeAction(obj interface{}) {\n\tmessage := \"Default Action -> Namespace \" + obj.(v1.Namespace).Name + \" deleted\"\n\tlog.Printf(message)\n}", "func (t TableRecord) Action() func() {\n\n\treturn func() {\n\t\tinitTableRecordDir()\n\t}\n}", "func Action(c *cli.Context) {\n\texec := c.String(\"exec\")\n\tfmt.Printf(\"Action: %v\\n\", exec)\n}", "func (a *Agent) processActionResponse(response interface{}) {\n\tif taste, ok := response.(*world.Taste); ok {\n\t\ta.processTaste(taste)\n\t} else if aaiChange, ok := response.(*world.AtomicActionInterfaceChange); ok {\n\t\ta.processAAIChange(aaiChange)\n\t}\n}", "func (o ApiOutput) Action() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Api) pulumi.StringPtrOutput { return v.Action }).(pulumi.StringPtrOutput)\n}", "func (act *EffectedAction) Output() error {\n\t// do nothing.\n\treturn nil\n}", "func (o ConnectedRegistryNotificationOutput) Action() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ConnectedRegistryNotification) string { return v.Action }).(pulumi.StringOutput)\n}", "func (h HTTPAction) Execute(resultsChannel chan reporter.SampleReqResult, sessionMap map[string]string, vucontext *config.VUContext, vulog *log.Entry, playbook *config.TestDef) bool {\n\tvulog.Data[\"action\"] = h.Title\n\treturn DoHTTPRequest(h, resultsChannel, sessionMap, vucontext, vulog, playbook)\n}", "func (s *Store) Dispatch(a *Action) *Action {\n\treturn s.dispatcher(a)\n}", "func (f *List) Action(addr turn.Addr) Action {\n\tfor i := range f.rules {\n\t\ta := f.rules[i].Action(addr)\n\t\tif a == Pass {\n\t\t\tcontinue\n\t\t}\n\t\treturn a\n\t}\n\treturn f.action\n}", "func (tc *TransactionContext) DispatchAction(trace types.ActionTrace, act types.Action, receiver string, contxtfree bool, depth uint32) {\n\tapplyContext := NewApplyContext(tc, act)\n\n\tapplyContext.ContextFree = contxtfree\n\tapplyContext.Receiver = receiver\n\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\ttrace = applyContext.Trace\n\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\tapplyContext.Exec()\n\ttrace = applyContext.Trace\n\n}", "func (action *RevertStepsAction) ExecuteAction(input interface{}) (output interface{}, err error) {\n\tlog.Info(\"EXECUTE RevertStepsAction\")\n\treturn nil, errors.New(\"Intentionally reverting everything\")\n}", "func (b *AccessReviewRequestBuilder) Action(value string) *AccessReviewRequestBuilder {\n\tb.action = value\n\tb.bitmap_ |= 2\n\treturn b\n}", "func checkAction(expected, actual core.Action, t *testing.T) {\n\tif !(expected.Matches(actual.GetVerb(), actual.GetResource().Resource) && actual.GetSubresource() == expected.GetSubresource()) {\n\t\tt.Errorf(\"Expected\\n\\t%#v\\ngot\\n\\t%#v\", expected, actual)\n\t\treturn\n\t}\n\n\tif reflect.TypeOf(actual) != reflect.TypeOf(expected) {\n\t\tt.Errorf(\"Action has wrong type. Expected: %t. Got: %t\", expected, actual)\n\t\treturn\n\t}\n\n\tswitch a := actual.(type) {\n\tcase core.CreateActionImpl:\n\t\te, _ := expected.(core.CreateActionImpl)\n\t\texpObject := e.GetObject()\n\t\tobject := a.GetObject()\n\n\t\tif !reflect.DeepEqual(expObject, object) {\n\t\t\tt.Errorf(\"Action %s %s has wrong object\\nDiff:\\n %s\",\n\t\t\t\ta.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object))\n\t\t}\n\tcase core.UpdateActionImpl:\n\t\te, _ := expected.(core.UpdateActionImpl)\n\t\texpObject := e.GetObject()\n\t\tobject := a.GetObject()\n\n\t\tif !reflect.DeepEqual(expObject, object) {\n\t\t\tt.Errorf(\"Action %s %s has wrong object\\nDiff:\\n %s\",\n\t\t\t\ta.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object))\n\t\t}\n\tcase core.PatchActionImpl:\n\t\te, _ := expected.(core.PatchActionImpl)\n\t\texpPatch := e.GetPatch()\n\t\tpatch := a.GetPatch()\n\n\t\tif !reflect.DeepEqual(expPatch, patch) {\n\t\t\tt.Errorf(\"Action %s %s has wrong patch\\nDiff:\\n %s\",\n\t\t\t\ta.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expPatch, patch))\n\t\t}\n\tdefault:\n\t\tt.Errorf(\"Uncaptured Action %s %s, you should explicitly add a case to capture it\",\n\t\t\tactual.GetVerb(), actual.GetResource().Resource)\n\t}\n}", "func (a *Ability) websocketListenerAction(c *astiws.Client, eventName string, payload json.RawMessage) error {\n\t// Ability is not activated\n\ta.m.Lock()\n\tactivated := a.activated\n\ta.m.Unlock()\n\tif !activated {\n\t\tastilog.Error(\"astimousing: ability is not activated\")\n\t\treturn nil\n\t}\n\n\t// Unmarshal payload\n\tvar p PayloadAction\n\tif err := json.Unmarshal(payload, &p); err != nil {\n\t\tastilog.Error(errors.Wrapf(err, \"astimousing: json unmarshaling %s into %#v failed\", payload, p))\n\t\treturn nil\n\t}\n\n\t// Switch on action\n\tswitch p.Action {\n\tcase actionClickLeft:\n\t\tastilog.Debugf(\"astimousing: clicking left mouse button with double %v\", p.Double)\n\t\ta.ms.ClickLeft(p.Double)\n\tcase actionClickMiddle:\n\t\tastilog.Debugf(\"astimousing: clicking middle mouse button with double %v\", p.Double)\n\t\ta.ms.ClickMiddle(p.Double)\n\tcase actionClickRight:\n\t\tastilog.Debugf(\"astimousing: clicking right mouse button with double %v\", p.Double)\n\t\ta.ms.ClickRight(p.Double)\n\tcase actionMove:\n\t\tastilog.Debugf(\"astimousing: moving mouse to %dx%d\", p.X, p.Y)\n\t\ta.ms.Move(p.X, p.Y)\n\tcase actionScrollDown:\n\t\tastilog.Debugf(\"astimousing: scrolling down with x %d\", p.X)\n\t\ta.ms.ScrollDown(p.X)\n\tcase actionScrollUp:\n\t\tastilog.Debugf(\"astimousing: scrolling up with x %d\", p.X)\n\t\ta.ms.ScrollUp(p.X)\n\tdefault:\n\t\tastilog.Errorf(\"astimousing: unknown action %s\", p.Action)\n\t}\n\treturn nil\n}", "func (act *EffectedAction) Do() error {\n\t// query release info.\n\tif errCode, errMsg := act.queryRelease(); errCode != pbcommon.ErrCode_E_OK {\n\t\treturn act.Err(errCode, errMsg)\n\t}\n\n\t// check release effect timeout.\n\tif errCode, errMsg := act.checkEffectTimeout(); errCode != pbcommon.ErrCode_E_OK {\n\t\treturn act.Err(errCode, errMsg)\n\t}\n\n\t// query matched instance list.\n\tmatchedInstances, errCode, errMsg := act.queryMatchedAppInstanceList()\n\tif errCode != pbcommon.ErrCode_E_OK {\n\t\treturn act.Err(errCode, errMsg)\n\t}\n\tact.matchedInstances = matchedInstances\n\n\t// query effected instance list.\n\teffectedInstances, errCode, errMsg := act.queryEffectedAppInstanceList()\n\tif errCode != pbcommon.ErrCode_E_OK {\n\t\treturn act.Err(errCode, errMsg)\n\t}\n\tact.effectedInstances = effectedInstances\n\n\t// build effected instance result.\n\tif errCode, errMsg := act.effected(); errCode != pbcommon.ErrCode_E_OK {\n\t\treturn act.Err(errCode, errMsg)\n\t}\n\n\treturn nil\n}", "func (a Action) Print() {\n log.Printf(\"%+v\\n\", a)\n}", "func (a *Agent) act() {\n\t// assumes every object visited during observe is already in mind with importance\n\t// uses object information and changes to update activity\n\ta.mind.spawnThoughts()\n\ta.mind.mergeNewThoughts()\n\ta.startNewAction()\n\ta.stepActions()\n}", "func (p *EpFF) Action(ctx context.Context, upstreams []*upstream.Fs, path string) ([]*upstream.Fs, error) {\n\tif len(upstreams) == 0 {\n\t\treturn nil, fs.ErrorObjectNotFound\n\t}\n\tupstreams = filterRO(upstreams)\n\tif len(upstreams) == 0 {\n\t\treturn nil, fs.ErrorPermissionDenied\n\t}\n\tu, err := p.epff(ctx, upstreams, path)\n\treturn []*upstream.Fs{u}, err\n}", "func applyAction(userValue reflect.Value, e fsmEvent, cb callback) error {\n\tif cb.action == nil {\n\t\treturn nil\n\t}\n\tvalues := make([]reflect.Value, 0, len(e.args)+1)\n\tvalues = append(values, userValue)\n\tfor _, arg := range e.args {\n\t\tvalues = append(values, reflect.ValueOf(arg))\n\t}\n\tres := reflect.ValueOf(cb.action).Call(values)\n\n\tif res[0].Interface() != nil {\n\t\treturn xerrors.Errorf(\"Error applying event transition `%+v`: %w\", e.name, res[0].Interface().(error))\n\t}\n\treturn nil\n}", "func (res *Resource) Action(actionName string, storage store.Get) {\n\tmatcher := path.Join(patID, actionName)\n\n\tres.HandleFuncC(\n\t\tpat.Get(matcher),\n\t\tfunc(ctx context.Context, w http.ResponseWriter, r *http.Request) {\n\t\t\tres.actionHandler(ctx, w, r, storage)\n\t\t},\n\t)\n\n\tres.addRoute(patch, matcher)\n}", "func (s *GrpcClient) PerformAction(e entity.Entity, p types.Position) (entity.Entity, error) {\n\tlog.Debugf(\"%s, perform action\", e.ID)\n\tent := pb.Entity{\n\t\tID: e.ID,\n\t\tX: int32(p.X),\n\t\tY: int32(p.Y),\n\t\tTheta: int32(p.Theta),\n\t}\n\n\tresp, err := s.client.PerformAction(context.Background(), &pb.ActionRequest{Entity: &ent})\n\tif err != nil {\n\t\treturn entity.Entity{}, err\n\t}\n\n\treturn entity.Entity{\n\t\tID: resp.Entity.GetID(),\n\t\tPosition: types.Position{\n\t\t\ttypes.Coord{int(resp.Entity.GetX()),\n\t\t\t\tint(resp.Entity.GetY())},\n\t\t\tint(resp.Entity.GetTheta()),\n\t\t},\n\t\tOwner: \"\",\n\t}, nil\n}", "func (c *Creature) Action(a *area.Area) int {\n\tif i := a.Items[c.Coord()].Peek(); i != nil {\n\t\tc.PickUp(a)\n\t\treturn c.Speed\n\t}\n\tif c.Equipment.MainHand == nil && len(c.Inventory) > 0 {\n\t\tfor _, pos := range item.Positions {\n\t\t\tif i, ok := c.Inventory[pos]; ok {\n\t\t\t\tif !item.IsEquipable(i) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif i.Name() != \"Iron Sword\" {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tc.Equip(pos)\n\t\t\t\treturn c.Speed\n\t\t\t}\n\t\t}\n\t}\n\n\tvar col *area.Collision\n\tvar err error\n\tif c.X() < Hero.X() {\n\t\tcol, err = a.MoveRight(c)\n\t} else if c.X() > Hero.X() {\n\t\tcol, err = a.MoveLeft(c)\n\t} else if c.Y() < Hero.Y() {\n\t\tcol, err = a.MoveDown(c)\n\t} else if c.Y() > Hero.Y() {\n\t\tcol, err = a.MoveUp(c)\n\t}\n\tif err != nil {\n\t\t// log.Println(\"err / collide?\")\n\t\treturn c.Speed\n\t\t// return 0\n\t}\n\tif col == nil {\n\t\treturn c.Speed\n\t}\n\tif mob, ok := col.S.(*Creature); ok {\n\t\tif mob.IsHero() {\n\t\t\tc.Battle(mob, a)\n\t\t\treturn c.Speed\n\t\t}\n\t}\n\n\t// If all fails, creature waits.\n\treturn c.Speed\n}", "func (game *Game) DoItemAction(words []string, action *Action) string {\n\tif len(words) == 0 {\n\t\treturn strings.Title(action.Name) + \" what?\"\n\t}\n\n\troom := game.Rooms[game.Location]\n\titems := visibleItems(append(game.Inventory, room.BasicRoom().Items...), false, true)\n\n\tmsg, item, words := findTarget(words, items, false)\n\n\tif msg != \"\" {\n\t\treturn msg\n\t}\n\n\tisSyntaxFound := false\n\tif action.Syntax != \"\" {\n\t\twords, isSyntaxFound = findSyntax(words, action.Syntax)\n\t}\n\n\tif action.IsTargetRequired && len(words) == 0 && action.Syntax != \"\" {\n\t\treturn strings.Title(action.Name) + \" \" + action.Syntax + \" what?\"\n\t}\n\n\tif action.IsActorTarget {\n\t\tactors := filterActors(items)\n\t\tvar actor Actor\n\t\tvar msg string\n\n\t\tif len(actors) == 1 && !isSyntaxFound && action.Syntax != \"\" {\n\t\t\tactor = actors[0]\n\t\t} else {\n\t\t\tmsg, actor, _ = findActor(words, actors)\n\t\t\tif msg != \"\" {\n\t\t\t\treturn msg\n\t\t\t}\n\t\t}\n\n\t\tif action.IsTopicRequired {\n\t\t\tfor _, topic := range findTopics(strings.Split(item.Basic().Name, \" \"), actor) {\n\t\t\t\tif strings.Contains(topic.Action, action.Name) {\n\t\t\t\t\tif topic.IsItemConsumed {\n\t\t\t\t\t\tgame.ChangeParent(item, \"\")\n\t\t\t\t\t}\n\t\t\t\t\tmsg = actor.OnTopic(topic, action, item)\n\t\t\t\t\treturn msg\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn actor.OnTopic(nil, action, item)\n\t\t}\n\n\t\treturn game.finalizeItemAction(item, actor, action)\n\t}\n\n\tmsg, target, _ := findTarget(words, items, !action.IsTargetRequired)\n\n\tif !action.IsTargetRequired {\n\t\treturn game.finalizeItemAction(item, target, action)\n\t}\n\n\tif msg != \"\" {\n\t\treturn msg\n\t}\n\n\tif target == nil {\n\t\treturn strings.Title(action.Name) + \" \" + action.Syntax + \" what?\"\n\t}\n\n\treturn game.finalizeItemAction(item, target, action)\n}", "func (s *Sequence) Perform(ctx context.Context, writer *results.Writer) error {\n\twriter.Log(\"Performing sequence\")\n\tfor _, action := range s.actions {\n\t\tactionWriter := writer.NewFor(action.Name(), action.Kind())\n\t\tshouldContinue, err := action.Perform(ctx, actionWriter)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !shouldContinue {\n\t\t\treturn nil\n\t\t}\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil\n\t\tdefault:\n\t\t}\n\t}\n\treturn nil\n}", "func (c *Controller) AfterAction(action string) {\n}", "func (c *Controller) AfterAction(action string) {\n}", "func (b *bnkd) Act(p backend.Payload) error {\n\tlog.Printf(\"act payload bytes: %s\\n\", string(p.Bytes()))\n\tif p.Type() != \"pull_request\" {\n\t\tlog.Printf(\"type %s not supported for pr estimation\\n\", p.Type())\n\t\treturn nil\n\t}\n\n\tevent := github.PullRequestEvent{}\n\tif err := json.Unmarshal(p.Bytes(), &event); err != nil {\n\t\treturn fmt.Errorf(\"error unmarshaling event: %s\", err.Error())\n\t}\n\n\taction := *event.Action\n\tmerged := *event.PullRequest.Merged\n\tfullName := strings.Split(*event.Repo.FullName, \"/\")\n\tlog.Printf(\"action: %s, merged: %t, repository: %s\\n\", action, merged, *event.Repo.FullName)\n\tif action == \"closed\" && merged {\n\t\tif err := b.help.comment(b.client, fullName[0], fullName[1], event.PullRequest); err != nil {\n\t\t\treturn errors.New(\"error posting comment: \" + err.Error())\n\t\t}\n\t}\n\n\tlog.Println(\"successful act invocation\")\n\treturn nil\n}", "func (c *Client) ExecuteAction(ctx context.Context, ac *Action) (*repb.ActionResult, error) {\n\tlog.V(1).Infof(\"Executing action: %v\", ac.Args)\n\n\t// Construct the action we're trying to run.\n\tacDg, res, err := c.PrepAction(ctx, ac)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// If we found a result in the cache, return that.\n\tif res != nil {\n\t\treturn res, nil\n\t}\n\n\t// Upload any remaining inputs.\n\tif err := c.WriteBlobs(ctx, ac.InputFiles); err != nil {\n\t\treturn nil, gerrors.WithMessage(err, \"uploading input files to the CAS\")\n\t}\n\n\tlog.V(1).Info(\"Executing job\")\n\tres, err = c.executeJob(ctx, ac.SkipCache, acDg)\n\tif err != nil {\n\t\treturn res, gerrors.WithMessage(err, \"executing an action\")\n\t}\n\n\treturn res, nil\n}", "func (pr *replica) addAction(act action) {\n\tif err := pr.actions.Put(act); err != nil {\n\t\treturn\n\t}\n\tpr.notifyWorker()\n}", "func ActionableErr(cfg interface{}, phase constants.Phase, err error) *proto.ActionableErr {\n\terrCode, suggestions := getErrorCodeFromError(cfg, phase, err)\n\treturn &proto.ActionableErr{\n\t\tErrCode: errCode,\n\t\tMessage: err.Error(),\n\t\tSuggestions: suggestions,\n\t}\n}", "func (act *AuthorizeAction) Do() error {\n\t// authorize.\n\tif errCode, errMsg := act.authorize(); errCode != pbcommon.ErrCode_E_OK {\n\t\treturn act.Err(errCode, errMsg)\n\t}\n\treturn nil\n}", "func (client *AMIClient) Action(action string, params Params, actionTimeout time.Duration) (*AMIResponse, error) {\n\tvar ActionID string\n\n\tif _, ok := params[\"ActionID\"]; !ok {\n\t\tActionID = uuid.NewV4().String()\n\t\tparams[\"ActionID\"] = ActionID\n\t} else {\n\t\tActionID = params[\"ActionID\"]\n\t}\n\tresp, err := client.AsyncAction(action, params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttime.AfterFunc(actionTimeout, func() {\n\t\tclient.mutexAsyncAction.Lock()\n\t\tif c, exists := client.response[ActionID]; exists {\n\t\t\tdelete(client.response, ActionID)\n\t\t\tclient.mutexAsyncAction.Unlock()\n\t\t\tresponse := &AMIResponse{ID: ActionID, Status: \"Error\", Params: make(map[string]string)}\n\t\t\tresponse.Params[\"Error\"] = \"Timeout\"\n\t\t\tc <- response\n\t\t\tclose(c)\n\t\t\treturn\n\t\t}\n\t\tclient.mutexAsyncAction.Unlock()\n\t})\n\tresponse := <-resp\n\treturn response, nil\n}", "func (o VirtualNetworkRuleResponseOutput) Action() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v VirtualNetworkRuleResponse) *string { return v.Action }).(pulumi.StringPtrOutput)\n}", "func (machine* Dishwasher) Append(action func() (string, error)) {\r\n machine.Actions = append(machine.Actions, action)\r\n}", "func (ButtonPressedAction) isEngineAction() {}", "func (s *MachineActionExecutor) Execute(vmDTO *TurboActionExecutorInput) (*TurboActionExecutorOutput, error) {\n\tnodeName := vmDTO.ActionItems[0].GetTargetSE().GetDisplayName()\n\tvar actionType ActionType\n\tvar diff int32\n\tswitch vmDTO.ActionItems[0].GetActionType() {\n\tcase proto.ActionItemDTO_PROVISION:\n\t\tactionType = ProvisionAction\n\t\tdiff = 1\n\tcase proto.ActionItemDTO_SUSPEND:\n\t\tactionType = SuspendAction\n\t\tdiff = -1\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported action type %v\", vmDTO.ActionItems[0].GetActionType())\n\t}\n\t// Get on with it.\n\tcontroller, key, err := newController(s.cAPINamespace, nodeName, diff, actionType, s.executor.clusterScraper)\n\tif err != nil {\n\t\treturn nil, err\n\t} else if key == nil {\n\t\treturn nil, fmt.Errorf(\"the target machine deployment has no name\")\n\t}\n\tscaleDirection := \"up\"\n\tscaleAmount := diff\n\tif diff < 0 {\n\t\tscaleDirection = \"down\"\n\t\tscaleAmount = -diff\n\t}\n\tglog.V(2).Infof(\"Starting to scale %s the machineSet %s by %d replica\", scaleDirection, *key, scaleAmount)\n\t// See if we already have this.\n\t_, ok := s.cache.Get(*key)\n\tif ok {\n\t\treturn nil, fmt.Errorf(\"the action against the %s is already running\", *key)\n\t}\n\ts.cache.Add(*key, key)\n\tdefer s.unlock(*key)\n\t// Check other preconditions.\n\terr = controller.checkPreconditions()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = controller.executeAction()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = controller.checkSuccess()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tglog.V(2).Infof(\"Completed scaling %s the machineSet %s by %d replica\", scaleDirection, *key, scaleAmount)\n\treturn &TurboActionExecutorOutput{Succeeded: true}, nil\n}", "func (r *TestRequest) Action() llapi.HsmAction {\n\treturn r.action\n}", "func (d *Device) Execute(op string, payload string) (result ExecuteResult, err *dbus.Error) {\n\td.logger.Print(\"Device.Execute() not implemented\")\n\treturn result, err\n}", "func (game Game) applyAction(action GameAction, coords objects.GridCoords) {\n\tswitch action {\n\tcase Explore:\n\t\tgame.grid[coords.Row][coords.Col] |= Explored\n\t\tif game.grid[coords.Row][coords.Col]&Bomb == 0 &&\n\t\t\tgame.grid.countNeighbourBombs(coords) == 0 {\n\t\t\tgame.exploreNeighbours(coords)\n\t\t}\n\n\tcase Flag:\n\t\tif game.grid[coords.Row][coords.Col]&Flagged == 0 {\n\t\t\tgame.grid[coords.Row][coords.Col] |= Flagged\n\t\t} else {\n\t\t\tgame.grid[coords.Row][coords.Col] &= ^Flagged\n\t\t}\n\n\tdefault:\n\t\tpanic(\"Invalid action\")\n\t}\n}" ]
[ "0.6321835", "0.628808", "0.6212448", "0.6210594", "0.6196974", "0.61947316", "0.6190128", "0.6157147", "0.60914505", "0.6066623", "0.60116875", "0.59964776", "0.5961889", "0.5958526", "0.59500957", "0.59466", "0.5925344", "0.5824236", "0.57868105", "0.5785024", "0.57547855", "0.5748708", "0.57458353", "0.57364714", "0.57320195", "0.572776", "0.56997436", "0.5691501", "0.5684686", "0.5677957", "0.5653411", "0.56381994", "0.5632352", "0.56099737", "0.55653214", "0.5545433", "0.5537789", "0.5520485", "0.5517491", "0.5514837", "0.55139583", "0.5512267", "0.55032396", "0.5502813", "0.55006725", "0.54897475", "0.5488637", "0.5472963", "0.54718935", "0.5453124", "0.5440645", "0.5422812", "0.54196256", "0.5418703", "0.54181087", "0.5408394", "0.5399005", "0.5388331", "0.53839886", "0.53817046", "0.53652185", "0.5359155", "0.53579724", "0.53519714", "0.5336359", "0.5334009", "0.53314805", "0.53283775", "0.5325168", "0.53138757", "0.53119975", "0.5311065", "0.5304722", "0.5303937", "0.53019017", "0.52867776", "0.5280771", "0.5268277", "0.5266572", "0.5255522", "0.5247425", "0.52425605", "0.52367306", "0.52215075", "0.5211602", "0.5210861", "0.5207481", "0.5207481", "0.5206308", "0.5192686", "0.5185623", "0.51742506", "0.5173598", "0.5170234", "0.5158859", "0.51488537", "0.51443005", "0.51414025", "0.51331675", "0.51227593", "0.5120783" ]
0.0
-1
ApplyFilters implementation of the actionable interface
func (ci *createIndex) ApplyFilters() error { return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Apply(m []AuthenticatedResource) {\n\tfor _, a := range m {\n\t\tvar fc revel.FilterConfigurator\n\t\tif reflect.TypeOf(a.Resource).Kind() == reflect.Func {\n\t\t\tfc = revel.FilterAction(a.Resource)\n\t\t} else {\n\t\t\tfc = revel.FilterController(a.Resource)\n\t\t}\n\t\tfc.Add(SessionAuthenticationFilter)\n\t}\n}", "func (set ActionSet) Filter(f func(*Action) (bool, error)) (out ActionSet, err error) {\n\tvar ok bool\n\tout = ActionSet{}\n\tfor i := range set {\n\t\tif ok, err = f(set[i]); err != nil {\n\t\t\treturn\n\t\t} else if ok {\n\t\t\tout = append(out, set[i])\n\t\t}\n\t}\n\n\treturn\n}", "func Filters(f ...Filter) Modifier {\n\treturn func(r *http.Request) error {\n\t\tfor _, filter := range f {\n\t\t\tfilter(r)\n\t\t}\n\t\treturn nil // Or should filter return err?\n\t}\n}", "func (f FilterFunc) Apply(ctx context.Context, w http.ResponseWriter, r *http.Request, next Handler) {\n\tf(ctx, w, r, next)\n}", "func (f Filters) Apply(context operations.Context, item gh.Item) bool {\n\tfor _, filter := range f {\n\t\tif !filter.Apply(context, item) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (f *Filter) Apply(context operations.Context, item gh.Item) bool {\n\tswitch {\n\tcase item.IsIssue():\n\t\tif f, ok := f.Strategy.(issueFilter); ok {\n\t\t\treturn f.ApplyIssue(context, item.Issue)\n\t\t}\n\tcase item.IsPullRequest():\n\t\tif f, ok := f.Strategy.(pullRequestFilter); ok {\n\t\t\treturn f.ApplyPullRequest(context, item.PullRequest)\n\t\t}\n\tdefault:\n\t\tpanic(\"unreachable\")\n\t}\n\treturn true\n}", "func ApplyFilters(o *GrowManifestOptions, rii RegInvImage) (RegInvImage, error) {\n\t// If nothing to filter, short-circuit.\n\tif len(rii) == 0 {\n\t\treturn rii, nil\n\t}\n\n\t// Now perform some filtering, if any.\n\tif len(o.FilterImage) > 0 {\n\t\trii = FilterByImage(rii, o.FilterImage)\n\t}\n\n\tif len(o.FilterTag) > 0 {\n\t\trii = FilterByTag(rii, string(o.FilterTag))\n\t}\n\n\tif len(o.FilterDigest) > 0 {\n\t\trii = FilterByDigest(rii, o.FilterDigest)\n\t}\n\n\t// Remove any other tags that should still be filtered.\n\texcludeTags := map[Tag]bool{latestTag: true}\n\trii = ExcludeTags(rii, excludeTags)\n\n\tif len(rii) == 0 {\n\t\treturn RegInvImage{}, xerrors.New(\n\t\t\t\"no images survived filtering; double-check your --filter_* flag(s) for typos\",\n\t\t)\n\t}\n\n\treturn rii, nil\n}", "func (stream *TokenStream) Filter(filters ...Filter) *TokenStream {\n\toutgoing := stream\n\tfor _, f := range filters {\n\t\toutgoing = f(outgoing)\n\t}\n\treturn outgoing\n}", "func (u UserListFilter) Apply(queryset *gorm.DB) *gorm.DB {\n\tif u.IsActive != nil {\n\t\tqueryset = ApplyFilterFuncs(queryset, FFWhere(\"is_active = ?\", u.IsActive))\n\t}\n\treturn queryset\n}", "func (c *Config) applyFilters(message *Message) bool {\n\tfor _, filter := range c.Filters {\n\t\tif filter.apply(message) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (_VisaApplicationContract *VisaApplicationContractFilterer) FilterApplying(opts *bind.FilterOpts) (*VisaApplicationContractApplyingIterator, error) {\n\n\tlogs, sub, err := _VisaApplicationContract.contract.FilterLogs(opts, \"Applying\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &VisaApplicationContractApplyingIterator{contract: _VisaApplicationContract.contract, event: \"Applying\", logs: logs, sub: sub}, nil\n}", "func (cf ContainerFilter) Apply(c []*Container) []*Container {\n\tvar containers []*Container\n\tfor _, cont := range c {\n\t\tif cf(cont) {\n\t\t\tcontainers = append(containers, cont)\n\t\t}\n\t}\n\treturn containers\n}", "func (c *Switch) Filter(fs ...mod.Filter) {\n\tc.lock.RLock()\n\tfor _, r := range c.subRenderables {\n\t\tr.Filter(fs...)\n\t}\n\tc.lock.RUnlock()\n}", "func passFilters(obj *unstructured.Unstructured, filter *v1alpha1.ResourceFilter) bool {\n\t// check prefix\n\tif !strings.HasPrefix(obj.GetName(), filter.Prefix) {\n\t\tlog.Printf(\"FILTERED: resource name '%s' does not match prefix '%s'\", obj.GetName(), filter.Prefix)\n\t\treturn false\n\t}\n\t// check creation timestamp\n\tcreated := obj.GetCreationTimestamp()\n\tif !filter.CreatedBy.IsZero() && created.UTC().After(filter.CreatedBy.UTC()) {\n\t\tlog.Printf(\"FILTERED: resource creation timestamp '%s' is after createdBy '%s'\", created.UTC(), filter.CreatedBy.UTC())\n\t\treturn false\n\t}\n\t// check labels\n\tif ok := checkMap(filter.Labels, obj.GetLabels()); !ok {\n\t\tlog.Printf(\"FILTERED: resource labels '%s' do not match filter labels '%s'\", obj.GetLabels(), filter.Labels)\n\t\treturn false\n\t}\n\t// check annotations\n\tif ok := checkMap(filter.Annotations, obj.GetAnnotations()); !ok {\n\t\tlog.Printf(\"FILTERED: resource annotations '%s' do not match filter annotations '%s'\", obj.GetAnnotations(), filter.Annotations)\n\t\treturn false\n\t}\n\treturn true\n}", "func (l *Limiter) Filter(fn ...Filter) {\n\tl.filters = append(l.filters, fn...)\n}", "func (c *Configuration) DoFilters() error {\n\tfor f, filters := range c.Filters {\n\t\tif c.BaseDir != \"\" {\n\t\t\tf = filepath.Join(c.BaseDir, f)\n\t\t}\n\n\t\tLogger.Println(\"Filtering\", f)\n\t\tif err := ExecFilter(f, filters); err != nil {\n\t\t\tLogger.Println(\"[ERROR] Failed filtering template\", err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (f *AccountFilter) Apply(q *orm.Query) (*orm.Query, error) {\n\tq = q.Apply(f.Pager.Pagination)\n\tq = q.Apply(f.Filter.Filters)\n\tq = q.Order(f.Order...)\n\treturn q, nil\n}", "func (il *List) Filter(filterFunc FilterFunc) *List {\n\n\tvar filtered []v1.Ingress\n\n\tfor _, ingress := range il.items {\n\t\tif filterFunc(ingress, il.appConfig) {\n\t\t\tfiltered = append(filtered, ingress)\n\t\t}\n\t}\n\n\t// Replace original ingresses with filtered\n\til.items = filtered\n\treturn il\n}", "func (w Predicates) ApplyToWatches(opts *WatchesInput) {\n\topts.predicates = w.predicates\n}", "func (c *CommandFilters) RunFilters(args kvserverbase.FilterArgs) *roachpb.Error {\n\tc.RLock()\n\tdefer c.RUnlock()\n\n\tif c.replayProtection != nil {\n\t\treturn c.replayProtection(args)\n\t}\n\treturn c.runFiltersInternal(args)\n}", "func (o GoogleCloudRetailV2alphaRuleFilterActionOutput) Filter() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v GoogleCloudRetailV2alphaRuleFilterAction) *string { return v.Filter }).(pulumi.StringPtrOutput)\n}", "func (filters *Filters) Filter(event common.MapStr) common.MapStr {\n\n\t// Check if filters are set, just return event if not\n\tif len(filters.list) == 0 {\n\t\treturn event\n\t}\n\n\t// clone the event at first, before starting filtering\n\tfiltered := event.Clone()\n\tvar err error\n\n\tfor _, filter := range filters.list {\n\t\tfiltered, err = filter.Filter(filtered)\n\t\tif err != nil {\n\t\t\tlogp.Debug(\"filter\", \"fail to apply filtering rule %s: %s\", filter, err)\n\t\t}\n\t\tif filtered == nil {\n\t\t\t// drop event\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn filtered\n}", "func (f *Filter) Apply(res *benchfmt.Result) (bool, error) {\n\tm, err := f.Match(res)\n\treturn m.Apply(res), err\n}", "func (r *Request) Filter(fn FilterRequestFunc) *Request {\n\tr.Filters = append(r.Filters, fn)\n\treturn r\n}", "func (bp *BasePayload) ApplyFilter(f *Filter) bool {\n\treturn f.Regexp.Match(bp.GetPayload())\n}", "func passAllFilterFuncs(ctx context.Context, filterFuncs []FilterFunc, req *request.Request) bool {\n\tfor _, ff := range filterFuncs {\n\t\tif !ff(ctx, req) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func Filter(b *Block) {\n\n\ttype filterRule struct {\n\t\tOperator string\n\t\tPath string\n\t\tComparator interface{}\n\t\tInvert bool\n\t}\n\n\toperators = make(map[string]opFunc)\n\n\toperators[\"eq\"] = equals\n\toperators[\"gt\"] = greaterthan\n\toperators[\"lt\"] = lessthan\n\toperators[\"subset\"] = subsetof\n\toperators[\"keyin\"] = keyin\n\n\tvar rule *filterRule\n\n\tfor {\n\t\tselect {\n\t\tcase msg := <-b.InChan:\n\t\t\tif rule == nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tvalues := getKeyValues(msg, rule.Path)\n\t\t\tfor _, value := range values {\n\t\t\t\tif operators[rule.Operator](value, rule.Comparator) == !rule.Invert {\n\t\t\t\t\tbroadcast(b.OutChans, msg)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif len(values) == 0 && rule.Invert {\n\t\t\t\tbroadcast(b.OutChans, msg)\n\t\t\t}\n\n\t\tcase msg := <-b.Routes[\"set_rule\"]:\n\t\t\tif rule == nil {\n\t\t\t\trule = &filterRule{}\n\t\t\t}\n\n\t\t\tunmarshal(msg, rule)\n\t\tcase msg := <-b.Routes[\"get_rule\"]:\n\t\t\tif rule == nil {\n\t\t\t\tmarshal(msg, &filterRule{})\n\t\t\t} else {\n\t\t\t\tmarshal(msg, rule)\n\t\t\t}\n\t\tcase msg := <-b.AddChan:\n\t\t\tupdateOutChans(msg, b)\n\t\tcase <-b.QuitChan:\n\t\t\tquit(b)\n\t\t\treturn\n\t\t}\n\t}\n\n}", "func filterInformerActions(actions []k8stesting.Action) []k8stesting.Action {\n\tret := []k8stesting.Action{}\n\tfor _, action := range actions {\n\t\tif action.Matches(\"get\", \"workflows\") ||\n\t\t\taction.Matches(\"list\", \"workflows\") ||\n\t\t\taction.Matches(\"watch\", \"workflows\") {\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, action)\n\t}\n\n\treturn ret\n}", "func ApplyFilters(secret v1.Secret, sub *appv1alpha1.Subscription) (v1.Secret, bool) {\n\tif klog.V(utils.QuiteLogLel) {\n\t\tfnName := utils.GetFnName()\n\t\tklog.Infof(\"Entering: %v()\", fnName)\n\n\t\tdefer klog.Infof(\"Exiting: %v()\", fnName)\n\t}\n\n\tsecret = CleanUpObject(secret)\n\n\tif sub.Spec.PackageFilter != nil {\n\t\tif sub.Spec.Package != \"\" && sub.Spec.Package != secret.GetName() {\n\t\t\tklog.Info(\"Name does not match, skiping:\", sub.Spec.Package, \"|\", secret.GetName())\n\t\t\treturn secret, false\n\t\t}\n\n\t\tsubAnno := sub.GetAnnotations()\n\t\tklog.V(10).Info(\"checking annotations filter:\", subAnno)\n\n\t\tif subAnno != nil {\n\t\t\tsecretsAnno := secret.GetAnnotations()\n\t\t\tfor k, v := range subAnno {\n\t\t\t\tif secretsAnno[k] != v {\n\t\t\t\t\tklog.Info(\"Annotation filter does not match:\", k, \"|\", v, \"|\", secretsAnno[k])\n\t\t\t\t\treturn secret, false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn secret, true\n}", "func Apply(r io.ReadCloser, cb func(io.ReadCloser) error) error {\n\tfor r != nil {\n\t\tif err := cb(r); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif f, ok := r.(Filter); ok {\n\t\t\tr = f.Source()\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn nil\n}", "func (filter nameFilter) apply(options *lateInitOptions) {\n\toptions.nameFilters = append(options.nameFilters, filter)\n}", "func (c *TokenFilterConditional) Filter(filter ...string) *TokenFilterConditional {\n\tc.filter = append(c.filter, filter...)\n\treturn c\n}", "func (e *EventEmitter) Filter(fn func(*Event) (execute bool)) *EventEmitter {\n\te.filterFuncs = append(e.filterFuncs, fn)\n\treturn e\n}", "func (f *MutateFilter) Run(batch []*event.Event) []*event.Event {\n\tfor _, event := range batch {\n\t\tswitch f.config.action {\n\t\tcase \"remove_field\":\n\t\t\tf.removeField(event)\n\t\t}\n\t}\n\treturn f.next.Run(batch)\n}", "func (f FilterParams) ApplyToDeploySettings(d *bosun.DeploySettings) {\n\tif !f.IsEmpty() {\n\t\tchain := f.Chain()\n\t\td.Filter = &chain\n\t}\n}", "func (_VisaApplicationContract *VisaApplicationContractFilterer) FilterApplied(opts *bind.FilterOpts) (*VisaApplicationContractAppliedIterator, error) {\n\n\tlogs, sub, err := _VisaApplicationContract.contract.FilterLogs(opts, \"Applied\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &VisaApplicationContractAppliedIterator{contract: _VisaApplicationContract.contract, event: \"Applied\", logs: logs, sub: sub}, nil\n}", "func filterInformerActions(actions []core.Action) []core.Action {\n\tret := []core.Action{}\n\tfor _, action := range actions {\n\t\tif action.Matches(\"list\", \"rollouts\") ||\n\t\t\taction.Matches(\"watch\", \"rollouts\") ||\n\t\t\taction.Matches(\"list\", \"replicaSets\") ||\n\t\t\taction.Matches(\"watch\", \"replicaSets\") ||\n\t\t\taction.Matches(\"list\", \"services\") ||\n\t\t\taction.Matches(\"watch\", \"services\") {\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, action)\n\t}\n\n\treturn ret\n}", "func (filters *FilterList) Filter(event common.MapStr) common.MapStr {\n\n\t// Check if filters are set, just return event if not\n\tif len(filters.filters) == 0 {\n\t\treturn event\n\t}\n\n\t// clone the event at first, before starting filtering\n\tfiltered := event.Clone()\n\tvar err error\n\n\tfor _, filter := range filters.filters {\n\t\tfiltered, err = filter.Filter(filtered)\n\t\tif err != nil {\n\t\t\tlogp.Debug(\"filter\", \"fail to apply filtering rule %s: %s\", filter, err)\n\t\t}\n\t}\n\n\treturn filtered\n}", "func applyFilter(models []*indexedTestModel, filter filter) []*indexedTestModel {\n\tvar filterFunc func(m *indexedTestModel) bool\n\n\tswitch filter.fieldSpec.indexKind {\n\tcase numericIndex:\n\t\tfilterFunc = func(m *indexedTestModel) bool {\n\t\t\tfieldVal := reflect.ValueOf(m).Elem().FieldByName(filter.fieldSpec.name).Convert(reflect.TypeOf(0.0)).Float()\n\t\t\tfilterVal := numericScore(filter.value)\n\t\t\tswitch filter.op {\n\t\t\tcase equalOp:\n\t\t\t\treturn fieldVal == filterVal\n\t\t\tcase notEqualOp:\n\t\t\t\treturn fieldVal != filterVal\n\t\t\tcase greaterOp:\n\t\t\t\treturn fieldVal > filterVal\n\t\t\tcase lessOp:\n\t\t\t\treturn fieldVal < filterVal\n\t\t\tcase greaterOrEqualOp:\n\t\t\t\treturn fieldVal >= filterVal\n\t\t\tcase lessOrEqualOp:\n\t\t\t\treturn fieldVal <= filterVal\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\n\tcase booleanIndex:\n\t\tfilterFunc = func(m *indexedTestModel) bool {\n\t\t\tfieldVal := reflect.ValueOf(m).Elem().FieldByName(filter.fieldSpec.name)\n\t\t\tfilterVal := filter.value\n\t\t\tswitch filter.op {\n\t\t\tcase equalOp:\n\t\t\t\treturn fieldVal.Bool() == filterVal.Bool()\n\t\t\tcase notEqualOp:\n\t\t\t\treturn fieldVal.Bool() != filterVal.Bool()\n\t\t\tcase greaterOp:\n\t\t\t\treturn boolScore(fieldVal) > boolScore(filterVal)\n\t\t\tcase lessOp:\n\t\t\t\treturn boolScore(fieldVal) < boolScore(filterVal)\n\t\t\tcase greaterOrEqualOp:\n\t\t\t\treturn boolScore(fieldVal) >= boolScore(filterVal)\n\t\t\tcase lessOrEqualOp:\n\t\t\t\treturn boolScore(fieldVal) <= boolScore(filterVal)\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\n\tcase stringIndex:\n\t\tfilterFunc = func(m *indexedTestModel) bool {\n\t\t\tfieldVal := reflect.ValueOf(m).Elem().FieldByName(filter.fieldSpec.name).String()\n\t\t\tfilterVal := filter.value.String()\n\t\t\tswitch filter.op {\n\t\t\tcase equalOp:\n\t\t\t\treturn fieldVal == filterVal\n\t\t\tcase notEqualOp:\n\t\t\t\treturn fieldVal != filterVal\n\t\t\tcase greaterOp:\n\t\t\t\treturn fieldVal > filterVal\n\t\t\tcase lessOp:\n\t\t\t\treturn fieldVal < filterVal\n\t\t\tcase greaterOrEqualOp:\n\t\t\t\treturn fieldVal >= filterVal\n\t\t\tcase lessOrEqualOp:\n\t\t\t\treturn fieldVal <= filterVal\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn filterModels(models, filterFunc)\n}", "func (m *MetricFilter) Filter(filter shared.Filter) *MetricFilter {\n\tm.filterList = append(m.filterList, filter)\n\treturn m\n}", "func (f *PermissionFilter) ByActions(actions ...string) *PermissionFilter {\n\tf.Actions = actions\n\treturn f\n}", "func Filtered(t stackvm.Tracer, p action.Predicate) stackvm.Tracer {\n\tswitch p {\n\tcase nil:\n\t\treturn nil\n\tcase action.Never:\n\t\treturn nil\n\tcase action.Always:\n\t\treturn t\n\tdefault:\n\t\treturn filter{t, p}\n\t}\n}", "func (w *Walker) Filter(f Predicate) *Walker {\n\t//func (w *Walker) Filter(f func(*Node) (*Node, error)) *Walker {\n\tif w == nil {\n\t\treturn nil\n\t}\n\tif f == nil {\n\t\tw.pipe.errors <- ErrInvalidFilter\n\t} else {\n\t\terr := w.appendFilterForTask(clientFilter, f, 0) // hook in this filter\n\t\tif err != nil {\n\t\t\tT().Errorf(err.Error())\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn w\n}", "func (Var) Filter(pred func(*VarFilterContext) bool) bool { return boolResult }", "func (m *RouteMux) Filter(filter http.HandlerFunc) {\n\tm.filters = append(m.filters, filter)\n}", "func (a *AppBuilder) Filters(filters ...restful.FilterFunction) *AppBuilder {\n\ta.filters = append(a.filters, filters...)\n\treturn a\n}", "func _filter() {\n\n}", "func Filter(filterBy []Card) Rule {\n\treturn func(deck []Card) []Card {\n\t\treturn filterDeck(deck, filterBy)\n\t}\n}", "func (sf *SanitizingFilter) Filter(args []interface{}) []interface{} {\n\tfor i, v := range args {\n\t\ttypes := datapol.Verify(v)\n\t\tif len(types) > 0 {\n\t\t\treturn []interface{}{fmt.Sprintf(datapolMsgFmt, i, types)}\n\t\t}\n\t}\n\treturn args\n}", "func ApplyFilter(fargs FilterArgs) bool {\n\tgf := gslbutils.GetGlobalFilter()\n\tif gf == nil {\n\t\tgslbutils.Errf(\"cname: %s, msg: global filter doesn't exist, returning false\", fargs.Cluster)\n\t\treturn false\n\t}\n\tmetaobj, ok := fargs.Obj.(k8sobjects.FilterableObject)\n\tif !ok {\n\t\tgslbutils.Warnf(\"cname: %s, msg: not a meta object, returning\", fargs.Cluster)\n\t\treturn false\n\t}\n\n\t// First see, if there's a namespace filter set for this object's namespace, if not, apply\n\t// the global filter.\n\tgf.GlobalLock.RLock()\n\tdefer gf.GlobalLock.RUnlock()\n\n\tif gf.AppFilter == nil && gf.NSFilter == nil {\n\t\treturn false\n\t}\n\treturn metaobj.ApplyFilter()\n}", "func (res *Resource) Filter(filter *Filter) {\n\tfilter.Resource = res\n\n\tif filter.Label == \"\" {\n\t\tfilter.Label = utils.HumanizeString(filter.Name)\n\t}\n\n\tif filter.Config != nil {\n\t\tfilter.Config.ConfigureQORAdminFilter(filter)\n\t}\n\n\tif filter.Handler == nil {\n\t\t// generate default handler\n\t\tfilter.Handler = func(db *gorm.DB, filterArgument *FilterArgument) *gorm.DB {\n\t\t\tif metaValue := filterArgument.Value.Get(\"Value\"); metaValue != nil {\n\t\t\t\treturn defaultFieldFilter(res, []string{filter.Name}, utils.ToString(metaValue.Value), db, filterArgument.Context)\n\t\t\t}\n\t\t\treturn db\n\t\t}\n\t}\n\n\tif filter.Type != \"\" {\n\t\tres.filters = append(res.filters, filter)\n\t} else {\n\t\tutils.ExitWithMsg(\"Invalid filter definition %v for resource %v\", filter.Name, res.Name)\n\t}\n}", "func (r Resources) Filter(t func(r Resource) bool) (resources Resources) {\n\tfor _, resource := range r {\n\t\tif t(resource) {\n\t\t\tresources = append(resources, resource)\n\t\t}\n\t}\n\treturn\n}", "func NewFilter(action Action, rules ...Rule) *List { return &List{rules: rules, action: action} }", "func (m Manager) Filter(clauses ...sol.Clause) Manager {\n\treturn m.FilterDelete(clauses...).FilterUpdate(clauses...).FilterSelect(clauses...)\n}", "func Filter(filters ...FilterOption) Option {\n\treturn func(stackdriver *Stackdriver) {\n\t\tfor i, filterOpt := range filters {\n\t\t\tf := &filter{}\n\t\t\tfilterOpt(f)\n\n\t\t\tif i != 0 || len(stackdriver.Builder.Model.MetricQuery.Filters) != 0 {\n\t\t\t\tstackdriver.Builder.Model.MetricQuery.Filters = append(stackdriver.Builder.Model.MetricQuery.Filters, \"AND\")\n\t\t\t}\n\n\t\t\tstackdriver.Builder.Model.MetricQuery.Filters = append(stackdriver.Builder.Model.MetricQuery.Filters, f.leftOperand, f.operator, f.rightOperand)\n\t\t}\n\t}\n}", "func (f *Filter) Validate() error {\n\tif len(*f) == 0 {\n\t\treturn errors.New(\"Filter need to be at least one rule to be valid\")\n\t}\n\n\tfor _, r := range *f {\n\t\tif err := r.Validate(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (m *SavedFilter) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateContentTypes(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateCreated(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateDescription(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateLastUpdated(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateName(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateParameters(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateSlug(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateURL(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateWeight(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func ApplyFilter(u *task.List, f func(uint64, int) bool) {\n\tout := u.Uids[:0]\n\tfor i, uid := range u.Uids {\n\t\tif f(uid, i) {\n\t\t\tout = append(out, uid)\n\t\t}\n\t}\n\tu.Uids = out\n}", "func (sc *Scavenger) Filter(fn func(level, msg string) bool) *Scavenger {\n\tsc.mu.Lock()\n\tdefer sc.mu.Unlock()\n\n\tscav := NewScavenger()\n\tscav.entries = make([]LogEntry, 0, len(sc.entries))\n\tfor _, e := range sc.entries {\n\t\tif fn == nil || fn(e.Level, e.Message) {\n\t\t\tscav.entries = append(scav.entries, e)\n\t\t}\n\t}\n\treturn scav\n}", "func (a *AliasAddAction) Filter(filter Query) *AliasAddAction {\n\ta.filter = filter\n\treturn a\n}", "func filterInformerActions(actions []core.Action) []core.Action {\n\tret := []core.Action{}\n\tfor _, action := range actions {\n\t\tif len(action.GetNamespace()) == 0 &&\n\t\t\t(action.Matches(\"list\", \"machineconfigs\") ||\n\t\t\t\taction.Matches(\"watch\", \"machineconfigs\") ||\n\t\t\t\taction.Matches(\"list\", \"nodes\") ||\n\t\t\t\taction.Matches(\"watch\", \"nodes\")) {\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, action)\n\t}\n\n\treturn ret\n}", "func (pool *ComplexPool) Filter(filters ...Filter) {\n\tall := ApplyFilters(pool.All.List(), filters)\n\tunused := ApplyFilters(pool.Unused.List(), filters)\n\n\tpool.All = providers.NewSet()\n\tpool.Unused = providers.NewSet()\n\n\tfor _, p := range all {\n\t\tpool.All.Add(p)\n\t}\n\n\tfor _, p := range unused {\n\t\tpool.Unused.Add(p)\n\t}\n}", "func (m *stashModel) filterApplied() bool {\n\treturn m.filterState != unfiltered\n}", "func (h *Hodor) SetFilters(filters ...Filter) {\n\th.filter = MergeFilters(filters...)\n}", "func (h *Hodor) AddFilters(filters ...Filter) {\n\th.filter = MergeFilters(h.filter, MergeFilters(filters...))\n}", "func (expr *Action) Apply(val interface{}) interface{} {\n\treturn expr.functor(val)\n}", "func (a *Asset) Filter(filter StateFilter) bool {\n\tif len(filter.Select) == 0 {\n\t\treturn true\n\t}\n\tswitch filter.Match {\n\tcase \"n/a\", \"\":\n\t\treturn true\n\tcase \"all\":\n\t\treturn a.matchAll(filter)\n\tcase \"any\":\n\t\treturn a.matchAny(filter)\n\tcase \"none\":\n\t\treturn a.matchNone(filter)\n\tdefault:\n\t\tlog.Noticef(\"filterObject has unknown matchType in filter: %+v\", filter)\n\t\treturn true\n\t}\n}", "func FilterEnable(o OutPutter, f func(ctx context.Context, name string, level Level) bool) OutPutter {\n\tif o == nil {\n\t\treturn o\n\t}\n\treturn &OutPutFilter{\n\t\tunderlying: o,\n\t\tenableFunc: f,\n\t}\n}", "func (m Mixed) Filter(f func(interface{}) bool) Mixed {\n\tif f == nil || !m.IsPresent() || !f(m.mixed) {\n\t\treturn Mixed{}\n\t}\n\n\treturn m\n}", "func (m *Filter) Validate() error {\n\tif m == nil {\n\t\treturn nil\n\t}\n\n\t// no validation rules for Key\n\n\t// no validation rules for Value\n\n\t// no validation rules for Method\n\n\treturn nil\n}", "func (f FilterList) Apply(uuids []uint64, get func(uuid uint64) (Task, error)) []uint64 {\n\tresult := []uint64{}\n\tfor _, uuid := range uuids {\n\t\ttask, err := get(uuid)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Could not get task %d\\n\", uuid)\n\t\t\tgoto reject\n\t\t}\n\n\t\tfor _, filter := range f {\n\t\t\tif !filter.Apply(task, get) {\n\t\t\t\tgoto reject\n\t\t\t}\n\t\t}\n\n\t\tresult = append(result, uuid)\n\n\treject:\n\t}\n\n\treturn result\n}", "func (cm *ConnectionManager) RegisterFilters(source <-chan packet.Packet,\n\tfilters ...func(packet.Packet) packet.Packet) <-chan packet.Packet {\n\tsink := make(chan packet.Packet)\n\n\tgo func() {\n\t\tfor p := range source {\n\t\t\tfor _, filter := range filters {\n\t\t\t\tif pass := filter(p); pass != nil {\n\t\t\t\t\tsink <- pass\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn sink\n}", "func ApplyFilter(input []byte, filter []byte) (interface{}, error) {\n\tv, err := jsonfilter.FilterJsonFromTextWithFilterRunner(string(input), string(filter), func(command string, value string) (string, error) {\n\n\t\treturn value, nil\n\t})\n\n\treturn v, err\n}", "func (f *FilterWrap) addFilters(fl []interface{}) {\n\tif len(fl) > 1 {\n\t\tfc := fl[0]\n\t\tswitch fc.(type) {\n\t\tcase BoolClause, string:\n\t\t\tf.boolClause = fc.(string)\n\t\t\tfl = fl[1:]\n\t\t}\n\t}\n\tf.filters = append(f.filters, fl...)\n}", "func (b *RouteBuilder) Filter(filter FilterFunction) *RouteBuilder {\n\tb.filters = append(b.filters, filter)\n\treturn b\n}", "func (rr ACLRulesPipe) Filter(t func(r ACLRule) bool) (cout ACLRulesPipe) {\n\tch := make(chan ACLRule)\n\tcout = ch\n\tgo func() {\n\t\tfor r := range rr {\n\t\t\tif t(r) {\n\t\t\t\tch <- r\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn cout\n}", "func (p *ResourceCondition) ApplyPropertyConditionFilter(action string, data map[string]interface{}, updateCandidateData map[string]interface{}) error {\n\tfilters, ok := p.actionPropertyConditionFilter[action]\n\tif !ok {\n\t\treturn nil\n\t}\nFilterLoop:\n\tfor _, filter := range filters {\n\t\tfor key, rawAllowedValue := range filter {\n\t\t\tvalue, _ := data[key]\n\t\t\tswitch rawAllowedValue.(type) {\n\t\t\t// A policy should be map in case you need to use previous value & update candidate value\n\t\t\tcase map[string]interface{}:\n\t\t\t\tstringValue, ok := value.(string)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"Rejected by property filter\")\n\t\t\t\t}\n\t\t\t\tallowedValueMap, _ := rawAllowedValue.(map[string]interface{})\n\t\t\t\tallowedNextValue, ok := allowedValueMap[stringValue]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"Rejected by property filter %s %s\", allowedValueMap, value)\n\t\t\t\t}\n\t\t\t\tif updateCandidateData == nil {\n\t\t\t\t\tcontinue FilterLoop\n\t\t\t\t} else {\n\t\t\t\t\tif !util.Match(allowedNextValue, updateCandidateData[key]) {\n\t\t\t\t\t\treturn fmt.Errorf(\"Rejected by property filter %s %s\", allowedNextValue, updateCandidateData[stringValue])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif !util.Match(rawAllowedValue, value) {\n\t\t\t\t\treturn fmt.Errorf(\"Rejected by property filter %s %s\", rawAllowedValue, value)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func Filter(r io.Reader, w io.Writer, conf Config) error {\n\ts := bufio.NewScanner(r)\n\tfilters := compile(conf)\n\n\tfor s.Scan() {\n\t\tmetric := s.Bytes()\n\t\tparts := bytes.SplitN(metric, []byte(\"|\"), 2)\n\t\tname := parts[0]\n\n\t\tif len(name) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\ttail := parts[1]\n\n\t\tfor regexp, v := range filters {\n\t\t\tmatches := regexp.FindAllSubmatch(name, -1)\n\n\t\t\tif matches == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tswitch v.(type) {\n\t\t\tcase string:\n\t\t\t\tw.Write(replace([]byte(v.(string)), matches))\n\t\t\t\tw.Write([]byte(\"|\"))\n\t\t\t\tw.Write(tail)\n\t\t\t\tw.Write([]byte(\"\\n\"))\n\t\t\tcase bool:\n\t\t\t\tw.Write(metric)\n\t\t\t\tw.Write([]byte(\"\\n\"))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn s.Err()\n}", "func (me *XElemsFilter) Walk() (err error) {\n\tif fn := WalkHandlers.XElemsFilter; me != nil {\n\t\tif fn != nil {\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tfor _, x := range me.Filters {\n\t\t\tif err = x.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif fn != nil {\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func applyToWorld (world *World, actions []Action) {\n for _, action := range(actions) {\n action.Do(DummyPlayerApi{}, world)\n }\n}", "func (g *genControllerUtils) Filter(c *generator.Context, t *types.Type) bool {\n\tret := !g.controllerGenerated\n\tg.controllerGenerated = true\n\treturn ret\n}", "func (filterOrder *OrderFilters) AppendFilter(filters ...Filterer) {\n\tif cntFilters := len(filters); cntFilters > 0 {\n\t\tif filterOrder.filters == nil {\n\t\t\tfilterOrder.filters = []Filterer{}\n\t\t} else {\n\t\t\t// if already filterOrder have some filter so set next filter pointer\n\t\t\tfilterOrder.filters[len(filterOrder.filters)-1].SetNextFilter(&filters[0])\n\t\t}\n\t\tfor i := range filters {\n\t\t\tfilterOrder.filters = append(filterOrder.filters, filters[i]) // Save interface of filter\n\t\t\tfilters[i].SetSelfPointer(&filters[i]) // IMPORTANT! Save self interface pointer\n\t\t\tif i+1 != cntFilters {\n\t\t\t\tfilters[i].SetNextFilter(&filters[i+1]) // Save pointer to interface to next filter\n\t\t\t} else {\n\t\t\t\tfilters[i].SetNextFilter(nil) // flag end of filter\n\t\t\t}\n\t\t}\n\t}\n}", "func (es *Eventstore) FilterToReducer(ctx context.Context, searchQuery *SearchQueryBuilder, r reducer) error {\n\tevents, err := es.Filter(ctx, searchQuery)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tr.AppendEvents(events...)\n\n\treturn r.Reduce()\n}", "func (m Match) Filter() stathat.Filter {\n\tvar includes, excludes []stathat.Filter\n\tfor _, pattern := range m.Include {\n\t\tincludes = append(includes, statmatch.Name(pattern))\n\t}\n\tfor _, pattern := range m.Exclude {\n\t\texcludes = append(excludes, statmatch.Name(pattern))\n\t}\n\treturn statmatch.All(statmatch.Any(includes...), statmatch.None(excludes...))\n}", "func (f FilterFunc) Filter(a ble.Advertisement) bool {\n\treturn f(a)\n}", "func (gs *GoShot) ApplyFilters(full bool) {\n\tglog.V(2).Infof(\"ApplyFilters: %d filters\", len(gs.Filters))\n\tfilteredImage := image.Image(gs.OriginalScreenshot)\n\tfor _, filter := range gs.Filters {\n\t\tfilteredImage = filter.Apply(filteredImage)\n\t}\n\n\tif gs.Screenshot == gs.OriginalScreenshot || gs.Screenshot.Rect.Dx() != gs.CropRect.Dx() || gs.Screenshot.Rect.Dy() != gs.CropRect.Dy() {\n\t\t// Recreate image buffer.\n\t\tcrop := image.NewRGBA(image.Rect(0, 0, gs.CropRect.Dx(), gs.CropRect.Dy()))\n\t\tgs.Screenshot = crop\n\t\tfull = true // Regenerate the full buffer.\n\t}\n\tif full {\n\t\tdraw.Src.Draw(gs.Screenshot, gs.Screenshot.Rect, filteredImage, gs.CropRect.Min)\n\t} else {\n\t\tvar tgtRect image.Rectangle\n\t\ttgtRect.Min = image.Point{X: gs.viewPort.viewX, Y: gs.viewPort.viewY}\n\t\ttgtRect.Max = tgtRect.Min.Add(image.Point{X: gs.viewPort.viewW, Y: gs.viewPort.viewH})\n\t\tsrcPoint := gs.CropRect.Min.Add(tgtRect.Min)\n\t\tdraw.Src.Draw(gs.Screenshot, tgtRect, filteredImage, srcPoint)\n\t}\n\n\tif gs.viewPort != nil {\n\t\tgs.viewPort.renderCache()\n\t\tgs.viewPort.Refresh()\n\t}\n\tif gs.miniMap != nil {\n\t\tgs.miniMap.renderCache()\n\t\tgs.miniMap.Refresh()\n\t}\n}", "func (sg *SubGraph) applyFilter(ctx context.Context) error {\n\tif sg.Filter == nil { // No filter.\n\t\treturn nil\n\t}\n\tnewSorted, err := runFilter(ctx, sg.DestUIDs, sg.Filter)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsg.DestUIDs = newSorted\n\t// For each posting list, intersect with sg.destUIDs.\n\tfor _, l := range sg.uidMatrix {\n\t\talgo.IntersectSorted(l, sg.DestUIDs)\n\t}\n\treturn nil\n}", "func (c *CommandFilters) AppendFilter(\n\tfilter kvserverbase.ReplicaCommandFilter, idempotent bool,\n) func() {\n\n\tc.Lock()\n\tdefer c.Unlock()\n\tid := c.nextID\n\tc.nextID++\n\tc.filters = append(c.filters, struct {\n\t\tid int\n\t\tidempotent bool\n\t\tfilter kvserverbase.ReplicaCommandFilter\n\t}{id, idempotent, filter})\n\n\tif !idempotent {\n\t\tif c.numFiltersTrackingReplays == 0 {\n\t\t\tc.replayProtection =\n\t\t\t\tstorageutils.WrapFilterForReplayProtection(c.runFiltersInternal)\n\t\t}\n\t\tc.numFiltersTrackingReplays++\n\t}\n\n\treturn func() {\n\t\tc.removeFilter(id)\n\t}\n}", "func Filter(filters ...FilterFunc) ServerOption {\n\treturn func(o *Server) {\n\t\to.filters = filters\n\t}\n}", "func (rsa *RuleSetApplier) applyDefaultFilterPolicies() {\n\tvar model Model\n\tfor _, eventType := range model.GetEventTypes() {\n\t\tif !rsa.config.EnableKernelFilters {\n\t\t\t_ = rsa.applyFilterPolicy(eventType, PolicyModeNoFilter, math.MaxUint8)\n\t\t} else {\n\t\t\t_ = rsa.applyFilterPolicy(eventType, PolicyModeDeny, math.MaxUint8)\n\t\t}\n\t}\n}", "func (o *OptionsFilter) Filter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {\n\tif \"OPTIONS\" != req.Request.Method {\n\t\tchain.ProcessFilter(req, resp)\n\t\treturn\n\t}\n\n\tarchs := req.Request.Header.Get(restful.HEADER_AccessControlRequestHeaders)\n\t//methods := strings.Join(o.getContainer().ComputeAllowedMethods(req), \",\")\n\torigin := req.Request.Header.Get(restful.HEADER_Origin)\n\tif len(origin) == 0 {\n\t\torigin = \"*\"\n\t}\n\tlog.Printf(\"request >> origin:%s\\n\", origin)\n\tresp.AddHeader(restful.HEADER_Allow, \"*\")\n\tresp.AddHeader(restful.HEADER_AccessControlAllowOrigin, origin)\n\tresp.AddHeader(restful.HEADER_AccessControlAllowHeaders, archs)\n\tresp.AddHeader(restful.HEADER_AccessControlAllowMethods, \"*\")\n\tresp.AddHeader(restful.HEADER_AccessControlAllowCredentials, \"true\")\n}", "func (p *logicalProps) applyFilters(filters []*expr) {\n\tfor _, filter := range filters {\n\t\t// TODO(peter): !isNullTolerant(filter)\n\t\tfor v := filter.inputVars; v != 0; {\n\t\t\ti := bitmapIndex(bits.TrailingZeros64(uint64(v)))\n\t\t\tv.clear(i)\n\t\t\tp.notNullCols.set(i)\n\t\t}\n\t}\n}", "func (filters Filter) Filter(item Filterable) (bool, error) {\n\tif len(filters.Items) == 0 {\n\t\treturn true, nil\n\t}\n\n\tmatches := make([]bool, 0)\n\n\tfor _, filter := range filters.Items {\n\t\tvar result bool\n\t\tvar err error\n\n\t\tlog.Debugf(\"Applying filter: %s %s %s\", filter.Field, filter.Operator, filter.Value)\n\t\tfilterType := item.GetFieldType(filter.Field)\n\t\tswitch filterType {\n\t\tcase apitype.ColumnTypeString:\n\t\t\tlog.Debugf(\"Column %s is of string type\", filter.Field)\n\t\t\tresult, err = filterString(filter, item)\n\t\t\tif err != nil {\n\t\t\t\tlog.Debugf(\"Could not filter string type: %s\", err)\n\t\t\t\treturn false, err\n\t\t\t}\n\t\tcase apitype.ColumnTypeNumerical:\n\t\t\tlog.Debugf(\"Column %s is of numerical type\", filter.Field)\n\t\t\tresult, err = filterNumerical(filter, item)\n\t\t\tif err != nil {\n\t\t\t\tlog.Debugf(\"Could not filter numerical type: %s\", err)\n\t\t\t\treturn false, err\n\t\t\t}\n\t\tcase apitype.ColumnTypeArray:\n\t\t\tlog.Debugf(\"Column %s is of array type\", filter.Field)\n\t\t\tresult, err = filterArray(filter, item)\n\t\t\tif err != nil {\n\t\t\t\tlog.Debugf(\"Could not filter array type: %s\", err)\n\t\t\t\treturn false, err\n\t\t\t}\n\t\tdefault:\n\t\t\tlog.Debugf(\"Unknown type of field %s\", filter.Field)\n\t\t\treturn false, fmt.Errorf(\"%s: unknown field or field type\", filter.Field)\n\t\t}\n\n\t\tif filter.Not {\n\t\t\tmatches = append(matches, !result)\n\t\t} else {\n\t\t\tmatches = append(matches, result)\n\t\t}\n\t}\n\n\tif filters.LinkOperator == LinkOperatorOr {\n\t\tfor _, value := range matches {\n\t\t\tif value {\n\t\t\t\tlog.Debugf(\"Filter matched\")\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t}\n\n\t\tlog.Debugf(\"Filter did not match\")\n\t\treturn false, nil\n\t}\n\n\t// LinkOperator as \"and\" is the default:\n\tfor _, value := range matches {\n\t\tif !value {\n\t\t\tlog.Debugf(\"Filter did not match\")\n\t\t\treturn false, nil\n\t\t}\n\t}\n\n\tlog.Debugf(\"Filter did match\")\n\treturn true, nil\n}", "func AddFilters(handlers *beego.ControllerRegister) {\n\thandlers.InsertFilter(\"*\", beego.BeforeStatic, beforeStatic, false)\n}", "func (l LibsecurityRestful) toFilter() bool {\n\tif toFilterFlag == false {\n\t\tlogger.Info.Println(\"No filtering\")\n\t}\n\treturn toFilterFlag\n}", "func (pred *LikePredicate) Apply(c cm.Collection) error {\n\tcol := c.(*Table)\n\n\tlike := \"like\"\n\n\tif pred.CaseSensitive {\n\t\tlike = \"ilike\"\n\t}\n\n\tcol.filterStatements = append(col.filterStatements,\n\t\tfmt.Sprintf(\"%s %s ?\", pred.Column.Name(), like))\n\n\tcol.filterValues = append(col.filterValues, pred.Value)\n\n\treturn nil\n}", "func (filter *CombinedFilter) Add(filters ...Filter) {\n\tfilter.subFilters = append(filter.subFilters, filters...)\n}", "func (ctx *UpdateFilterContext) OK(r *Filter) error {\n\tif ctx.ResponseData.Header().Get(\"Content-Type\") == \"\" {\n\t\tctx.ResponseData.Header().Set(\"Content-Type\", \"application/json\")\n\t}\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 200, r)\n}", "func (o GoogleCloudRetailV2alphaRuleFilterActionPtrOutput) Filter() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *GoogleCloudRetailV2alphaRuleFilterAction) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Filter\n\t}).(pulumi.StringPtrOutput)\n}", "func (rsa *RuleSetApplier) Apply(rs *rules.RuleSet, approvers map[eval.EventType]rules.Approvers) (*Report, error) {\n\tif rsa.probe != nil {\n\t\t// based on the ruleset and the requested rules, select the probes that need to be activated\n\t\tif err := rsa.probe.SelectProbes(rs); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to select probes: %w\", err)\n\t\t}\n\n\t\tif err := rsa.probe.FlushDiscarders(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to flush discarders: %w\", err)\n\t\t}\n\t}\n\n\t// apply deny filter by default\n\trsa.applyDefaultFilterPolicies()\n\n\tfor _, eventType := range rs.GetEventTypes() {\n\t\tif err := rsa.setupFilters(rs, eventType, approvers[eventType]); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn rsa.reporter.GetReport(), nil\n}" ]
[ "0.6541863", "0.6425357", "0.6058154", "0.5973066", "0.59585464", "0.5934287", "0.5757698", "0.5753853", "0.573798", "0.5654189", "0.56025416", "0.56002575", "0.55881435", "0.5585381", "0.5567364", "0.5439903", "0.5408636", "0.53953284", "0.53719705", "0.5364307", "0.5357391", "0.5356656", "0.53564537", "0.53398186", "0.53319705", "0.5318717", "0.53145766", "0.52994615", "0.5299458", "0.5277321", "0.5275831", "0.52694273", "0.52506447", "0.52496254", "0.52455175", "0.52381", "0.52307034", "0.521014", "0.5206803", "0.5198374", "0.5185699", "0.5183821", "0.5169624", "0.5159009", "0.5144788", "0.51436096", "0.5141725", "0.51393807", "0.5129501", "0.51193535", "0.5118978", "0.5105885", "0.50989854", "0.5096147", "0.50905204", "0.5084494", "0.5080465", "0.50800717", "0.5071751", "0.5066735", "0.50612634", "0.5061152", "0.5058837", "0.50558084", "0.5051767", "0.50501275", "0.5037154", "0.5028233", "0.50211424", "0.50108063", "0.50105184", "0.50003", "0.49928018", "0.4984484", "0.49839473", "0.4983594", "0.49799863", "0.49786302", "0.49763042", "0.49717197", "0.49714926", "0.49661985", "0.4946318", "0.49431503", "0.49422914", "0.4941793", "0.4938732", "0.49334303", "0.4915345", "0.4912414", "0.49039847", "0.490152", "0.4895895", "0.48906377", "0.4887622", "0.4884942", "0.48648572", "0.48617843", "0.48606947", "0.4859245" ]
0.58346456
6
NewDefaultApiController creates a default api controller
func NewDefaultApiController(s DefaultApiServicer) Router { return &DefaultApiController{ service: s } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDefaultApiController(s DefaultApiServicer) Router {\n\treturn &DefaultApiController{service: s}\n}", "func NewDefaultApiController(s DefaultApiServicer, m func(http.Handler) http.Handler) Router {\n\treturn &DefaultApiController{service: s, middleware: m}\n}", "func NewAPIController(c *container.Container) *APIController {\n\treturn &APIController{\n\t\tController: NewController(c),\n\t}\n}", "func NewController(ctx context.Context, options *Options, resourceBaseURL string, objectType types.ObjectType, objectBlueprint func() types.Object, supportsCascadeDelete bool) *BaseController {\n\tpoolSize := options.OperationSettings.DefaultPoolSize\n\tfor _, pool := range options.OperationSettings.Pools {\n\t\tif pool.Resource == objectType.String() {\n\t\t\tpoolSize = pool.Size\n\t\t\tbreak\n\t\t}\n\t}\n\tcontroller := &BaseController{\n\t\trepository: options.Repository,\n\t\tresourceBaseURL: resourceBaseURL,\n\t\tobjectBlueprint: objectBlueprint,\n\t\tobjectType: objectType,\n\t\tDefaultPageSize: options.APISettings.DefaultPageSize,\n\t\tMaxPageSize: options.APISettings.MaxPageSize,\n\t\tscheduler: operations.NewScheduler(ctx, options.Repository, options.OperationSettings, poolSize, options.WaitGroup),\n\t\tsupportsCascadeDelete: supportsCascadeDelete,\n\t}\n\n\treturn controller\n}", "func NewController(client kubernetes.Interface) *Controller {\n\tshared := informers.NewSharedInformerFactory(client, time.Second*30)\n\tinform := shared.Apps().V1().Deployments()\n\tcontrl := &Controller{\n\t\tclient: client,\n\t\tinformer: inform.Informer(),\n\t\tlister: inform.Lister(),\n\t\tlogger: logrus.New(),\n\t\tqueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"regitseel\"),\n\t}\n\n\tinform.Informer().AddEventHandler(\n\t\tcache.ResourceEventHandlerFuncs{\n\t\t\tAddFunc: contrl.enqueue,\n\t\t\tUpdateFunc: func(old, new interface{}) {\n\t\t\t\tcontrl.enqueue(new)\n\t\t\t},\n\t\t\tDeleteFunc: func(obj interface{}) {\n\t\t\t\td := obj.(*appsv1.Deployment)\n\t\t\t\tif err := contrl.delete(d); err != nil {\n\t\t\t\t\tcontrl.logger.Errorf(\"failed to delete from api: %v\", d.Name)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t)\n\n\treturn contrl\n}", "func NewController(repository storage.Repository, resourceBaseURL string, objectType types.ObjectType, objectBlueprint func() types.Object) *BaseController {\n\treturn &BaseController{\n\t\trepository: repository,\n\t\tresourceBaseURL: resourceBaseURL,\n\t\tobjectBlueprint: objectBlueprint,\n\t\tobjectType: objectType,\n\t}\n}", "func NewDefaultApiService() DefaultApiServicer {\n\treturn &DefaultApiService{}\n}", "func NewDefaultApiService() DefaultApiServicer {\n\treturn &DefaultApiService{}\n}", "func NewDefaultApiService() DefaultApiServicer {\n\treturn &DefaultApiService{}\n}", "func NewDefaultApiService(db *Database) DefaultApiServicer {\n\treturn &DefaultApiService{db: db}\n}", "func Default() *API {\n\tapi := New()\n\tapi.Use(\n\t\ttimeout.Default(\"12s\"),\n\t\tlogging.Default(\"TONIC\"))\n\n\t// adding default encoders..\n\tapi.Encoder(\n\t\tencoding.JSON,\n\t\tencoding.XML,\n\t\tencoding.YAML,\n\t\tencoding.FORM)\n\n\treturn api\n}", "func newController(clusterCfg clusterConfig) (Controller, error) {\n\tcfg := &rest.Config{\n\t\tHost: clusterCfg.Host,\n\t\tTLSClientConfig: rest.TLSClientConfig{\n\t\t\tInsecure: false,\n\t\t\tCAData: []byte(clusterCfg.CACert),\n\t\t\tCertData: []byte(clusterCfg.ClientCert),\n\t\t\tKeyData: []byte(clusterCfg.ClientKey),\n\t\t},\n\t}\n\n\t// Init the knative serving client\n\tknsClientSet, err := knservingclientset.NewForConfig(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Init the k8s clientset\n\tk8sClientset, err := kubernetes.NewForConfig(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tistioClientSet, err := networkingv1alpha3.NewForConfig(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsparkClient, err := sparkclient.NewForConfig(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &controller{\n\t\tknServingClient: knsClientSet.ServingV1(),\n\t\tk8sCoreClient: k8sClientset.CoreV1(),\n\t\tk8sAppsClient: k8sClientset.AppsV1(),\n\t\tk8sBatchClient: k8sClientset.BatchV1(),\n\t\tk8sRBACClient: k8sClientset.RbacV1(),\n\t\tk8sSparkOperator: sparkClient.SparkoperatorV1beta2(),\n\t\tistioClient: istioClientSet,\n\t}, nil\n}", "func NewController() Controller {\n\treturn &controller{\n\t\tprojectMgr: project.Mgr,\n\t\tmetaMgr: metamgr.NewDefaultProjectMetadataManager(),\n\t\tallowlistMgr: allowlist.NewDefaultManager(),\n\t}\n}", "func NewController(userService user.Service) chi.Router {\n\tc := Controller{userService}\n\tr := chi.NewRouter()\n\n\tr.Post(\"/\", c.AddUser)\n\tr.Get(\"/{userID}\", c.GetUser)\n\tr.Put(\"/{userID}/name\", c.UpdateName)\n\n\treturn r\n}", "func NewControllerServiceAPIWithDefaults() *ControllerServiceAPI {\n\tthis := ControllerServiceAPI{}\n\treturn &this\n}", "func NewController() *Controller {\n controller := Controller{}\n\n return &controller\n}", "func NewAPI() *API {\n\tapi := &API{}\n\n\tapi.Router = api.NewRouter()\n\thttp.Handle(\"/\", api.Router)\n\n\treturn api\n}", "func New() *API {\n\tapi := &API{\n\t\trouter: router.New(),\n\t\tchain: []alice.Constructor{},\n\t\tEncoders: encoding.New(),\n\t}\n\tapi.RouteGroup = &RouteGroup{[]HandleFunc{}, \"/\", nil, api}\n\treturn api\n}", "func New() *API {\n\tapi := new(API)\n\tapi.msgCtrl = newMsgCtrl()\n\tapi.pingCtrl = newPingCtrl()\n\treturn api\n}", "func NewAPI(l log.Logger, dispatch dispatch.Dispatch) API {\n\tlogger := l.WithModule(\"api\")\n\tresponseHelper := http.Response{}\n\thttpHandler := action.NewHandler(\n\t\tresponseHelper, logger, http.NewValidator(), dispatch)\n\n\treturn &api{\n\t\tl: logger,\n\t\thttpHandler: httpHandler,\n\t\trsp: responseHelper,\n\t}\n}", "func NewDefaultKubernetesAPI(cli *servicecatalog.SDK) *ServiceCatalogAPI {\n\treturn &ServiceCatalogAPI{\n\t\tSDK: cli,\n\t\tbrokersInProgress: make(map[string]bool),\n\t\tlock: &sync.Mutex{},\n\t}\n}", "func NewController(cfg *config.Config) (*Controller, error) {\n\tsrv, err := service.NewService(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Controller{\n\t\tService: srv,\n\t}, nil\n}", "func NewController(namespace string) (*Controller, error) {\n\tconfig, err := clientcmd.BuildConfigFromFlags(*ClusterURL, \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclientset, err := typedv1.NewForConfig(config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar ns *v1.Namespace\n\tif namespace != \"\" {\n\t\tns, err = clientset.Namespaces().Get(namespace, metav1.GetOptions{})\n\t} else {\n\t\tns, err = createNamespace(clientset)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Controller{\n\t\tclient: clientset,\n\t\tnamespace: ns,\n\t\trestConfig: config,\n\t\tfixedNs: namespace != \"\",\n\t}, nil\n}", "func NewController() Controller {\n\treturn &controller{\n\t\tClient: client.NewClient(),\n\t}\n}", "func NewAPI(root string, logger logger.Logger) *API {\n\t// init\n\tapi := &API{\n\t\troot: root,\n\t\tcorsHosts: \"*\",\n\t\tcorsHeaders: \"*\",\n\t\tendpoints: make([]APIEndpoint, 0), // explicitly define an empty array\n\t\turlBuilder: URLDefaultBuilder,\n\t\tlogger: logger,\n\t}\n\n\treturn api\n}", "func NewBookingsApiController(s BookingsApiServicer) Router {\n\treturn &BookingsApiController{ service: s }\n}", "func New() *Controller {\n\tvar allHandlers []operation.Handler\n\n\trpService := operation.New()\n\n\thandlers := rpService.GetRESTHandlers()\n\n\tallHandlers = append(allHandlers, handlers...)\n\n\treturn &Controller{handlers: allHandlers}\n}", "func NewAPI() *WebAPI {\n\treturn &WebAPI{&Mux{}, nil}\n}", "func NewController() Controller {\n\treturn &controller{}\n}", "func NewController() Controller {\n\treturn &controller{\n\t\tprojectCtl: project.Ctl,\n\t}\n}", "func NewApi() *MkApi {\n\treturn &MkApi{\n\t\tapis: make (map[string]ApiInterface),\n\t\tConfig: &config.Config{\n\t\t\tOIDCIssuerURL: \"\",\n\t\t\tOIDCPollInterval: time.Second * 2,\n\t\t\tOIDCUsernameClaim: \"sub\",\n\t\t\tRS256PublicKey: &x509.Certificate{},\n\t\t\tJWKS: &config.JWKS{},\n\t\t},\n\t}\n}", "func New(provider keystore.Provider) *Controller {\n\top := operation.New(provider)\n\thandlers := op.GetRESTHandlers()\n\n\treturn &Controller{handlers: handlers}\n}", "func NewController() *Controller {\n\treturn &Controller{wrapper: NewWrapper()}\n}", "func NewAPI(t authorization.TokenGetter, client *http.Client, clientID string) (*API, error) {\n\tapi, err := i.NewAPI(t, client, clientID, i.DefaultHTTPRequestGenerator(\"configuration\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &API{api}, nil\n}", "func NewController() *Controller {\n\treturn &Controller{Logger: logger.NewLogger()}\n}", "func NewAPI() API {\n\treturn API{}\n}", "func New() *Controller {\n\treturn &Controller{}\n}", "func NewAPI(interactor *mydomain.MyUseCaseInteractor) *http.ServeMux {\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(`/foo`, func(w http.ResponseWriter, r *http.Request) {\n\t\treply, err := interactor.Foo(r.Context())\n\t\tif err != nil {\n\t\t\tcode := http.StatusInternalServerError\n\t\t\thttp.Error(w, http.StatusText(code), code)\n\t\t\treturn\n\t\t}\n\t\t_, _ = fmt.Fprint(w, reply)\n\t})\n\treturn mux\n}", "func New() *API {\n\treturn &API{\n\t\tprefix: \"/\",\n\t\tresources: make(map[string]Rest),\n\t\troutes: &node{},\n\t}\n}", "func NewController(backendPool pool.Interface) *Controller {\n\treturn &Controller{\n\t\tbackendPool: backendPool,\n\t}\n}", "func NewAPI(name string) *API {\n\treturn &API{\n\t\tName: name,\n\t\tMethods: []*APIMethod{},\n\t\tAuth: \"\",\n\t}\n}", "func NewApi(runningInKubernetes bool, metricSink *metricsink.MetricSink, historicalSource core.HistoricalSource) *Api {\n\tgkeMetrics := make(map[string]core.MetricDescriptor)\n\tgkeLabels := make(map[string]core.LabelDescriptor)\n\tfor _, val := range core.StandardMetrics {\n\t\tgkeMetrics[val.Name] = val.MetricDescriptor\n\t}\n\tfor _, val := range core.LabeledMetrics {\n\t\tgkeMetrics[val.Name] = val.MetricDescriptor\n\t}\n\tgkeMetrics[core.MetricCpuLimit.Name] = core.MetricCpuLimit.MetricDescriptor\n\tgkeMetrics[core.MetricMemoryLimit.Name] = core.MetricMemoryLimit.MetricDescriptor\n\n\tfor _, val := range core.CommonLabels() {\n\t\tgkeLabels[val.Key] = val\n\t}\n\tfor _, val := range core.ContainerLabels() {\n\t\tgkeLabels[val.Key] = val\n\t}\n\tfor _, val := range core.PodLabels() {\n\t\tgkeLabels[val.Key] = val\n\t}\n\n\treturn &Api{\n\t\trunningInKubernetes: runningInKubernetes,\n\t\tmetricSink: metricSink,\n\t\thistoricalSource: historicalSource,\n\t\tgkeMetrics: gkeMetrics,\n\t\tgkeLabels: gkeLabels,\n\t}\n}", "func NewController(name string) *Controller {\n\treturn &Controller{\n\t\tRoutes: NewRoutes(name),\n\t}\n}", "func newIngressController(name, defaultCertificateSecretName, domain string) operatorv1.IngressController {\n\tingresscontroller := operatorv1.IngressController{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: name,\n\t\t},\n\t\tStatus: operatorv1.IngressControllerStatus{\n\t\t\tDomain: domain,\n\t\t},\n\t}\n\tif len(defaultCertificateSecretName) != 0 {\n\t\tingresscontroller.Spec.DefaultCertificate = &corev1.LocalObjectReference{Name: defaultCertificateSecretName}\n\t}\n\treturn ingresscontroller\n}", "func NewController(\n\tkubeclientset kubernetes.Interface,\n\tsampleclientset clientset.Interface,\n\tdeploymentInformer appsinformers.DeploymentInformer,\n\tingressinformer externsionsv1beta1informers.IngressInformer,\n\tserviceInformer coreinformers.ServiceInformer,\n configmapInformer coreinformers.ConfigMapInformer,\n persistentVolumeClaimInformer coreinformers.PersistentVolumeClaimInformer,\n\tapimanagerInformer informers.APIManagerInformer) *Controller {\n\n\t// Create event broadcaster.\n\t// Add apim-controller types to the default Kubernetes Scheme so Events can be logged for apim-controller types.\n\tutilruntime.Must(samplescheme.AddToScheme(scheme.Scheme))\n\tklog.V(4).Info(\"Creating event broadcaster\")\n\teventBroadcaster := record.NewBroadcaster()\n\teventBroadcaster.StartLogging(klog.Infof)\n\teventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: kubeclientset.CoreV1().Events(\"\")})\n\trecorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName})\n\n\tcontroller := &Controller{\n\t\tkubeclientset: kubeclientset,\n\t\tsampleclientset: sampleclientset,\n\t\tdeploymentsLister: deploymentInformer.Lister(),\n\t\tdeploymentsSynced: deploymentInformer.Informer().HasSynced,\n\t\tservicesLister: serviceInformer.Lister(),\n\t\tingressLister: ingressinformer.Lister(),\n\t\tservicesSynced: serviceInformer.Informer().HasSynced,\n configMapLister: configmapInformer.Lister(),\n persistentVolumeClaimsLister: persistentVolumeClaimInformer.Lister(),\n\t\tapimanagerslister: apimanagerInformer.Lister(),\n\t\tapimanagersSynced: apimanagerInformer.Informer().HasSynced,\n\t\tworkqueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"Apimanagers\"),\n\t\trecorder: recorder,\n\t}\n\n\tklog.Info(\"Setting up event handlers\")\n\t// Set up an event handler for when Apimanager resources change\n\tapimanagerInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.enqueueApimanager,\n\t\tUpdateFunc: func(old, new interface{}) {\n\t\t\tcontroller.enqueueApimanager(new)\n\t\t},\n\t})\n\t// Set up an event handler for when Deployment resources change. This handler will lookup the owner of the given\n\t// Deployment, and if it is owned by a Apimanager resource will enqueue that Apimanager resource for processing.\n\t// This way, we don't need to implement custom logic for handling Deployment resources. More info on this pattern:\n\t// https://github.com/kubernetes/community/blob/8cafef897a22026d42f5e5bb3f104febe7e29830/contributors/devel/controllers.md\n\tdeploymentInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.handleObject,\n\t\tUpdateFunc: func(old, new interface{}) {\n\t\t\tnewDepl := new.(*appsv1.Deployment)\n\t\t\toldDepl := old.(*appsv1.Deployment)\n\t\t\tif newDepl.ResourceVersion == oldDepl.ResourceVersion {\n\t\t\t\t// Periodic resync will send update events for all known Deployments.\n\t\t\t\t// Two different versions of the same Deployment will always have different RVs.\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcontroller.handleObject(new)\n\t\t},\n\t\tDeleteFunc: controller.handleObject,\n\t})\n\tserviceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.handleObject,\n\t\tUpdateFunc: func(old, new interface{}) {\n\t\t\tnewServ := new.(*corev1.Service)\n\t\t\toldServ := old.(*corev1.Service)\n\t\t\tif newServ.ResourceVersion == oldServ.ResourceVersion {\n\t\t\t\t// Periodic resync will send update events for all known Services.\n\t\t\t\t// Two different versions of the same Service will always have different RVs.\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcontroller.handleObject(new)\n\t\t},\n\t\tDeleteFunc: controller.handleObject,\n\t})\n\n persistentVolumeClaimInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.handleObject,\n\t\tDeleteFunc: controller.handleObject,\n\t})\n\n\tconfigmapInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.handleObject,\n\t\tUpdateFunc: func(old, new interface{}) {\n\t\t\tnewConf := new.(*corev1.ConfigMap)\n\t\t\toldConf := old.(*corev1.ConfigMap)\n\t\t\tnewConf.ResourceVersion =\"\"\n\t\t\toldConf.ResourceVersion =\"\"\n\n\t\t\tcontroller.handleObject(new)\n\t\t},\n\t\tDeleteFunc: controller.handleObject,\n\t})\n\n\tingressinformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.handleObject,\n\t\tDeleteFunc: controller.handleObject,\n\t})\n\n\treturn controller\n}", "func New(\n\tctx context.Context,\n\tconf *apisettings.Service,\n\thandlers []Handler) *API {\n\n\tbaseHandler := newBaseHandler()\n\thandlers = append(handlers, baseHandler)\n\n\tapi := API{\n\t\tconf: conf,\n\t\thandlers: handlers}\n\n\tapi.initRouter(ctx)\n\treturn &api\n}", "func NewAPI(svc Service, config *Config) *API {\n\tif !config.Debug {\n\t\tgin.SetMode(gin.ReleaseMode)\n\t}\n\n\tapi := &API{\n\t\tRoutes: configureRoutes(svc, database.DB, !config.AuthDisabled, config.TokenURL),\n\t\tconfig: config,\n\t\t// database: svc.DataSource,\n\t\tTitle: \"DataHive RESTful APIs\",\n\t\tVersion: \"1.0\",\n\t}\n\n\t// enable pprof http endpoints in debug mode\n\tif config.Debug {\n\t\tpprof.Register(api.Routes.Engine, nil)\n\t}\n\n\t// set logrus logger to TextFormatter with no colors\n\tlog.SetFormatter(&log.TextFormatter{DisableColors: true})\n\n\tapi.server = &http.Server{\n\t\tAddr: config.Address,\n\t\tHandler: api.Routes.Engine,\n\t\tReadTimeout: 10 * time.Second,\n\t\tWriteTimeout: 10 * time.Second,\n\t}\n\n\tif !config.WellKnownDisabled {\n\t\tapi.Routes.configureWellKnown(svc.Healthy)\n\t}\n\n\t// configure healthz endpoint\n\tapi.Routes.GET(\"/healthz\", healthHandler(svc.Healthy))\n\n\t// configure info endpoint\n\t// api.Routes.GET(\"/info\", infoHandler(svc.Info))\n\n\treturn api\n}", "func New(c *core.Core, r *mux.Router, version string) *API {\n\ta := &API{}\n\ta.AppVersion = version\n\ta.c = c\n\ta.reqDecoder = schema.NewDecoder()\n\twireupRoutes(r, a)\n\treturn a\n}", "func CreateAPI(config JSONConfigurationAPI, insecure bool) *OsctrlAPI {\n\tvar a *OsctrlAPI\n\t// Prepare URL\n\tu, err := url.Parse(config.URL)\n\tif err != nil {\n\t\tlog.Fatalf(\"invalid url: %v\", err)\n\t}\n\t// Define client with correct TLS settings\n\tclient := &http.Client{}\n\tif u.Scheme == \"https\" {\n\t\tcertPool, err := x509.SystemCertPool()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"error loading x509 certificate pool: %v\", err)\n\t\t}\n\t\ttlsCfg := &tls.Config{RootCAs: certPool}\n\t\tif insecure {\n\t\t\ttlsCfg.InsecureSkipVerify = true\n\t\t}\n\t\tclient.Transport = &http.Transport{TLSClientConfig: tlsCfg}\n\t}\n\t// Prepare authentication\n\theaders := make(map[string]string)\n\theaders[Authorization] = fmt.Sprintf(\"Bearer %s\", config.Token)\n\theaders[ContentType] = JSONApplicationUTF8\n\ta = &OsctrlAPI{\n\t\tConfiguration: config,\n\t\tClient: client,\n\t\tHeaders: headers,\n\t}\n\treturn a\n}", "func NewController(logger *log.Logger, storageApiURL string, config resources.UbiquityPluginConfig) (*Controller, error) {\n\n\tremoteClient, err := remote.NewRemoteClient(logger, storageApiURL, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Controller{logger: logger, Client: remoteClient, exec: utils.NewExecutor()}, nil\n}", "func CloneDefault() *Controller { return defaultCtrl.Clone() }", "func NewController(cfg *rest.Config) *Controller {\n\tclient := appsv1client.NewForConfigOrDie(cfg)\n\tkubeClient := kubernetes.NewForConfigOrDie(cfg)\n\tqueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())\n\tstopCh := make(chan struct{}) // TODO: hook this up to SIGTERM/SIGINT\n\n\tcsif := externalversions.NewSharedInformerFactoryWithOptions(clusterclient.NewForConfigOrDie(cfg), resyncPeriod)\n\n\tc := &Controller{\n\t\tqueue: queue,\n\t\tclient: client,\n\t\tclusterLister: csif.Cluster().V1alpha1().Clusters().Lister(),\n\t\tkubeClient: kubeClient,\n\t\tstopCh: stopCh,\n\t}\n\tcsif.WaitForCacheSync(stopCh)\n\tcsif.Start(stopCh)\n\n\tsif := informers.NewSharedInformerFactoryWithOptions(kubeClient, resyncPeriod)\n\tsif.Apps().V1().Deployments().Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(obj interface{}) { c.enqueue(obj) },\n\t\tUpdateFunc: func(_, obj interface{}) { c.enqueue(obj) },\n\t})\n\tsif.WaitForCacheSync(stopCh)\n\tsif.Start(stopCh)\n\n\tc.indexer = sif.Apps().V1().Deployments().Informer().GetIndexer()\n\tc.lister = sif.Apps().V1().Deployments().Lister()\n\n\treturn c\n}", "func New(apiEndpoint *url.URL, user, password string, customHTTPClient *http.Client) (c *Controller, err error) {\n\t// handle url\n\tif apiEndpoint == nil {\n\t\terr = errors.New(\"apiEndpoint can't be nil\")\n\t\treturn\n\t}\n\tcopiedURL, err := url.Parse(apiEndpoint.String())\n\tif err != nil {\n\t\terr = fmt.Errorf(\"apiEndpoint can't be (re)parsed as URL: %v\", err) // weird\n\t\treturn\n\t}\n\t// handle http client\n\tif customHTTPClient == nil {\n\t\tcustomHTTPClient = cleanhttp.DefaultPooledClient()\n\t}\n\t// create the cookie jar if needed\n\tif customHTTPClient.Jar == nil {\n\t\tcustomHTTPClient.Jar, err = cookiejar.New(&cookiejar.Options{\n\t\t\tPublicSuffixList: publicsuffix.List,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\t// spawn the controller\n\tc = &Controller{\n\t\tuser: user,\n\t\tpassword: password,\n\t\turl: copiedURL,\n\t\tclient: customHTTPClient,\n\t}\n\treturn\n}", "func NewAPI() *API {\n\treturn &API{}\n}", "func New(\n\troute *gin.Engine,\n\tcommandBus *command.Bus,\n\tqueryBus *query.Bus,\n\tutil *util.Util,\n\tapi api.Interface,\n) *Controller {\n\tcontroller := &Controller{\n\t\troute: route,\n\t\tcommandBus: commandBus,\n\t\tqueryBus: queryBus,\n\t\tutil: util,\n\t\tapi: api,\n\t}\n\tcontroller.SetupRoutes()\n\treturn controller\n}", "func NewAPI(env *cfenv.App, b Broker, user, pass string, catalog *cf.Catalog) http.Handler {\n\t// create new router\n\tg := gin.Default()\n\n\tauthorised, err := withAuth(g, user, pass)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tapi := API{\n\t\tEnv: env,\n\t\tcatalog: catalog,\n\t\tBroker: &validatingBroker{\n\t\t\tBroker: b,\n\t\t},\n\t}\n\n\tauthorised.GET(\"/v2/catalog\", api.Catalog)\n\tauthorised.PUT(\"/v2/service_instances/:instance_id\", api.Provision)\n\tauthorised.DELETE(\"/v2/service_instances/:instance_id\", api.Deprovision)\n\tauthorised.PUT(\"/v2/service_instances/:instance_id/service_bindings/:binding_id\", api.Bind)\n\tauthorised.DELETE(\"/v2/service_instances/:instance_id/service_bindings/:binding_id\", api.Unbind)\n\n\treturn g\n}", "func NewController(todoService todo.UseCase) *Controller {\n\treturn &Controller{\n\t\ttodoService: todoService,\n\t}\n}", "func NewAPI(handler APIHandler, address string, port uint) (*API, error) {\n\tif handler == nil {\n\t\treturn nil, errors.New(\"An API handler is required\")\n\t}\n\tapi := new(API)\n\tapi.address = address\n\tapi.port = port\n\tapi.router = mux.NewRouter().StrictSlash(true)\n\tapi.router.HandleFunc(\"/\", handler.SlashRoot)\n\tapi.router.HandleFunc(\"/clients\", handler.ClientsHandler)\n\tapi.router.HandleFunc(\"/clients/{id}\", handler.ClientHandler)\n\tapi.router.HandleFunc(\"/clients/{id}/history\", handler.ClientHistoryHandler)\n\tapi.router.HandleFunc(\"/jobs\", handler.PendingJobsHandler)\n\tapi.router.HandleFunc(\"/jobs/{id}\", handler.JobHandler)\n\tapi.router.HandleFunc(\"/clients/kick/{id}\", handler.KickClientHandler).Methods(\"POST\")\n\tapi.router.HandleFunc(\"/terminate\", handler.TerminateHandler).Methods(\"POST\")\n\tapi.router.HandleFunc(\"/report\", handler.ReportHandler)\n\tapi.router.HandleFunc(\"/history\", handler.HistoryHandler)\n\tapi.router.HandleFunc(\"/configure\", handler.ConfigureHandler).Methods(\"POST\")\n\tapi.router.HandleFunc(\"/config\", handler.ConfigHandler)\n\tapi.router.HandleFunc(\"/target\", handler.TargetHandler)\n\n\treturn api, nil\n}", "func NewAPI(c AlertmanagerClient) *API {\n\ta := &API{client: c}\n\tr := mux.NewRouter()\n\ta.RegisterRoutes(r)\n\ta.Handler = r\n\treturn a\n}", "func NewController() *Controller {\n\treturn &Controller{}\n}", "func New(\n\troute *gin.Engine,\n\tcommandBus *command.Bus,\n\tqueryBus *query.Bus,\n\tutil *util.Util,\n\tconfig config.Interface,\n\tapi api.Interface,\n) *Controller {\n\tcontroller := &Controller{\n\t\troute: route,\n\t\tcommandBus: commandBus,\n\t\tqueryBus: queryBus,\n\t\tutil: util,\n\t\tconfig: config,\n\t\tapi: api,\n\t}\n\tcontroller.SetupRoutes()\n\treturn controller\n}", "func NewAPI(log *util.Logger, identity oauth2.TokenSource, brand, country string) *API {\n\tv := &API{\n\t\tHelper: request.NewHelper(log),\n\t\tbrand: brand,\n\t\tcountry: country,\n\t\tbaseURI: DefaultBaseURI,\n\t}\n\n\tv.Client.Transport = &oauth2.Transport{\n\t\tSource: identity,\n\t\tBase: v.Client.Transport,\n\t}\n\n\treturn v\n}", "func NewController() controller.Controller {\n\treturn &Controller{}\n}", "func NewAPI(config config.Config, logger log.Logger) *API {\n\tapi := &API{\n\t\tmux.NewRouter().StrictSlash(false),\n\t\tnewAuthMiddleware(config, logger),\n\t\tlog.NewLoggerWith(logger, \"component\", \"api\"),\n\t\tconfig,\n\t}\n\n\tapi.addRoute(\"\", http.MethodGet, \"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tif err := json.NewEncoder(w).Encode(NewAPIInfo(config.ExternalURL)); err != nil {\n\t\t\tjson.NewEncoder(w).Encode(Error{Code: 500, Message: err.Error()})\n\t\t}\n\t})\n\n\treturn api\n}", "func NewController(dao Dao) *Controller {\n\treturn &Controller{Dao: dao}\n}", "func NewControllerServiceAPI() *ControllerServiceAPI {\n\tthis := ControllerServiceAPI{}\n\treturn &this\n}", "func NewController() *Controller {\n\treturn &Controller{\n\t\tClouds: make(map[string]CloudProvider),\n\t\t// WorkerOptions: NewWorkerOptions(),\n\t\tprovisionErr: NewErrCloudProvision(),\n\t}\n}", "func SetupDefaultRoutes(r *mux.Router, namespaceHeaderName, namespaceHeaderPattern string, burst int, qps float32, clustersConfig kube.ClustersConfig) error {\n\tbackendHandler, err := kube.NewHandler(os.Getenv(\"POD_NAMESPACE\"), namespaceHeaderName, namespaceHeaderPattern, burst, qps, clustersConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/can-i\").Handler(http.HandlerFunc(CanI(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/namespaces\").Handler(http.HandlerFunc(GetNamespaces(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/apprepositories\").Handler(http.HandlerFunc(ListAppRepositories(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories\").Handler(http.HandlerFunc(ListAppRepositories(backendHandler)))\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories\").Handler(http.HandlerFunc(CreateAppRepository(backendHandler)))\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/validate\").Handler(http.HandlerFunc(ValidateAppRepository(backendHandler)))\n\tr.Methods(\"PUT\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/{name}\").Handler(http.HandlerFunc(UpdateAppRepository(backendHandler)))\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/{name}/refresh\").Handler(http.HandlerFunc(RefreshAppRepository(backendHandler)))\n\tr.Methods(\"DELETE\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/{name}\").Handler(http.HandlerFunc(DeleteAppRepository(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/namespaces/{namespace}/operator/{name}/logo\").Handler(http.HandlerFunc(GetOperatorLogo(backendHandler)))\n\treturn nil\n}", "func NewApi(ctx *pulumi.Context,\n\tname string, args *ApiArgs, opts ...pulumi.ResourceOption) (*Api, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.OrganizationId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'OrganizationId'\")\n\t}\n\treplaceOnChanges := pulumi.ReplaceOnChanges([]string{\n\t\t\"organizationId\",\n\t})\n\topts = append(opts, replaceOnChanges)\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Api\n\terr := ctx.RegisterResource(\"google-native:apigee/v1:Api\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewBasicController(service *goa.Service) *BasicController {\n\treturn &BasicController{Controller: service.NewController(\"BasicController\")}\n}", "func NewController(brigade brigade.Service) Controller {\n\treturn &controller{\n\t\tbrigade: brigade,\n\t}\n}", "func NewController(informer cache.SharedIndexInformer, conf *config.Config, defaultClient client.ValiClient,\n\tlogger log.Logger) (Controller, error) {\n\tcontroller := &controller{\n\t\tclients: make(map[string]ControllerClient, expectedActiveClusters),\n\t\tconf: conf,\n\t\tdefaultClient: defaultClient,\n\t\tlogger: logger,\n\t}\n\n\tinformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.addFunc,\n\t\tDeleteFunc: controller.delFunc,\n\t\tUpdateFunc: controller.updateFunc,\n\t})\n\n\tstopChan := make(chan struct{})\n\ttime.AfterFunc(conf.ControllerConfig.CtlSyncTimeout, func() {\n\t\tclose(stopChan)\n\t})\n\n\tif !cache.WaitForCacheSync(stopChan, informer.HasSynced) {\n\t\treturn nil, fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\treturn controller, nil\n}", "func (app *Application) NewController(resource *Resource) *Controller {\n\tc := &Controller{\n\t\tresource: resource,\n\t\tcustomHandlers: make(map[route]handlerChain),\n\t}\n\n\tapp.controllers[c.resource] = c\n\treturn c\n}", "func NewUserAPIController(s UserAPIServicer, opts ...UserAPIOption) Router {\n\tcontroller := &UserAPIController{\n\t\tservice: s,\n\t\terrorHandler: DefaultErrorHandler,\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(controller)\n\t}\n\n\treturn controller\n}", "func NewProductsApiController(s ProductsApiServicer) Router {\n\treturn &ProductsApiController{service: s}\n}", "func NewAPI(httpClient *http.Client, accountNumber string, token string) *API {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tapi := &API{\n\t\thttp: httpClient,\n\t}\n\n\tapi.SetAccountNumber(accountNumber)\n\tapi.SetToken(token)\n\tapi.SetBaseURL(BaseURL)\n\tapi.SetDebug(false)\n\tapi.SetUserAgent(userAgent)\n\tapi.SetMediaType(mediaType)\n\tapi.SetCharset(charset)\n\n\t// Services\n\tapi.Meta = NewMetaService(api)\n\tapi.Connector = NewConnectorService(api)\n\n\t// api.General = NewGeneralService(api)\n\t// api.CRM = NewCRMService(api)\n\t// api.Financial = NewFinancialService(api)\n\t// api.HR = NewHRService(api)\n\t// api.OrderManagement = NewOrderManagementService(api)\n\t// api.Projects = NewProjectsService(api)\n\t// api.Subscriptions = NewSubscriptionsService(api)\n\n\treturn api\n}", "func NewApp(config models.Config) (MainWebAPI, error) {\n\tvar err error\n\tvar wapp MainWebAPI\n\n\tmux := mux.NewRouter().StrictSlash(true)\n\n\tlog := log.New(os.Stdout, \"API\", log.LstdFlags)\n\twapp.Mux = mux\n\twapp.Config = config\n\twapp.Log = log\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn wapp, err\n}", "func NewController(s Service) *ProjectController {\n\treturn &ProjectController{\n\t\tservice: s,\n\t}\n}", "func NewController(repository Repository) Controller {\n\treturn controller{repository: repository}\n}", "func NewController(\n\tkubeClient kubernetes.Interface,\n\tserviceCatalogClient servicecatalogclientset.ServicecatalogV1beta1Interface,\n\tclusterServiceBrokerInformer informers.ClusterServiceBrokerInformer,\n\tserviceBrokerInformer informers.ServiceBrokerInformer,\n\tclusterServiceClassInformer informers.ClusterServiceClassInformer,\n\tserviceClassInformer informers.ServiceClassInformer,\n\tinstanceInformer informers.ServiceInstanceInformer,\n\tbindingInformer informers.ServiceBindingInformer,\n\tclusterServicePlanInformer informers.ClusterServicePlanInformer,\n\tservicePlanInformer informers.ServicePlanInformer,\n\tbrokerClientCreateFunc osb.CreateFunc,\n\tbrokerRelistInterval time.Duration,\n\tosbAPIPreferredVersion string,\n\trecorder record.EventRecorder,\n\treconciliationRetryDuration time.Duration,\n\toperationPollingMaximumBackoffDuration time.Duration,\n\tclusterIDConfigMapName string,\n\tclusterIDConfigMapNamespace string,\n) (Controller, error) {\n\tcontroller := &controller{\n\t\tkubeClient: kubeClient,\n\t\tserviceCatalogClient: serviceCatalogClient,\n\t\tbrokerClientCreateFunc: brokerClientCreateFunc,\n\t\tbrokerRelistInterval: brokerRelistInterval,\n\t\tOSBAPIPreferredVersion: osbAPIPreferredVersion,\n\t\trecorder: recorder,\n\t\treconciliationRetryDuration: reconciliationRetryDuration,\n\t\tclusterServiceBrokerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"cluster-service-broker\"),\n\t\tserviceBrokerQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"service-broker\"),\n\t\tclusterServiceClassQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"cluster-service-class\"),\n\t\tserviceClassQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"service-class\"),\n\t\tclusterServicePlanQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"cluster-service-plan\"),\n\t\tservicePlanQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"service-plan\"),\n\t\tinstanceQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"service-instance\"),\n\t\tbindingQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"service-binding\"),\n\t\tinstancePollingQueue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(pollingStartInterval, operationPollingMaximumBackoffDuration), \"instance-poller\"),\n\t\tbindingPollingQueue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(pollingStartInterval, operationPollingMaximumBackoffDuration), \"binding-poller\"),\n\t\tclusterIDConfigMapName: clusterIDConfigMapName,\n\t\tclusterIDConfigMapNamespace: clusterIDConfigMapNamespace,\n\t}\n\n\tcontroller.clusterServiceBrokerLister = clusterServiceBrokerInformer.Lister()\n\tclusterServiceBrokerInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.clusterServiceBrokerAdd,\n\t\tUpdateFunc: controller.clusterServiceBrokerUpdate,\n\t\tDeleteFunc: controller.clusterServiceBrokerDelete,\n\t})\n\n\tcontroller.clusterServiceClassLister = clusterServiceClassInformer.Lister()\n\tclusterServiceClassInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.clusterServiceClassAdd,\n\t\tUpdateFunc: controller.clusterServiceClassUpdate,\n\t\tDeleteFunc: controller.clusterServiceClassDelete,\n\t})\n\n\tcontroller.clusterServicePlanLister = clusterServicePlanInformer.Lister()\n\tclusterServicePlanInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.clusterServicePlanAdd,\n\t\tUpdateFunc: controller.clusterServicePlanUpdate,\n\t\tDeleteFunc: controller.clusterServicePlanDelete,\n\t})\n\n\tcontroller.instanceLister = instanceInformer.Lister()\n\tinstanceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.instanceAdd,\n\t\tUpdateFunc: controller.instanceUpdate,\n\t\tDeleteFunc: controller.instanceDelete,\n\t})\n\n\tcontroller.bindingLister = bindingInformer.Lister()\n\tbindingInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.bindingAdd,\n\t\tUpdateFunc: controller.bindingUpdate,\n\t\tDeleteFunc: controller.bindingDelete,\n\t})\n\n\tif utilfeature.DefaultFeatureGate.Enabled(scfeatures.NamespacedServiceBroker) {\n\t\tcontroller.serviceBrokerLister = serviceBrokerInformer.Lister()\n\t\tserviceBrokerInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\t\tAddFunc: controller.serviceBrokerAdd,\n\t\t\tUpdateFunc: controller.serviceBrokerUpdate,\n\t\t\tDeleteFunc: controller.serviceBrokerDelete,\n\t\t})\n\t\t// ERIK TODO: Uncomment when the controllers are brought in\n\t\tcontroller.serviceClassLister = serviceClassInformer.Lister()\n\t\t//serviceClassInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\t//AddFunc: controller.serviceClassAdd,\n\t\t//UpdateFunc: controller.serviceClassUpdate,\n\t\t//DeleteFunc: controller.serviceClassDelete,\n\t\t//})\n\t\tcontroller.servicePlanLister = servicePlanInformer.Lister()\n\t\t//servicePlanInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\t//AddFunc: controller.servicePlanAdd,\n\t\t//UpdateFunc: controller.servicePlanUpdate,\n\t\t//DeleteFunc: controller.servicePlanDelete,\n\t\t//})\n\t}\n\n\treturn controller, nil\n}", "func NewAPI(config *config.APIConfig) (*API, error) {\n\tapi := &API{}\n\tapi.log = log.NewLogger(&config.Log, \"api\").WithFields(logrus.Fields{\n\t\tlog.BaseURLField: config.BaseURL,\n\t\tlog.PortField: config.HTTP.Port,\n\t\tlog.UseTLSField: config.HTTP.UseTLS,\n\t\tlog.CertFileField: config.HTTP.CertFile,\n\t\tlog.KeyFileField: config.HTTP.KeyFile,\n\t})\n\tcontextLogger := api.log.WithField(log.FuncField, ref.GetFuncName())\n\n\tserver, err := createAPIServer(&config.HTTP, api)\n\tif err != nil {\n\t\tcontextLogger.WithError(err).Error(\"error creating mock API\")\n\t\treturn nil, err\n\t}\n\n\tapi.server = wrapper.NewServerOps(server)\n\tapi.baseURL = config.BaseURL\n\tapi.endpoints = config.Endpoints\n\tapi.handlers = make(map[string]map[string]func(http.ResponseWriter, *http.Request))\n\tapi.routeTree = route.NewRouteTree()\n\tapi.httpConfig = config.HTTP\n\tapi.file = &wrapper.FileOps{}\n\tapi.creator = newCreator(api.log)\n\n\tcontextLogger.Info(\"successfully created mock API\")\n\treturn api, nil\n}", "func New(\n\ta *api.App,\n\tstore sessions.Store,\n\tcookieName string,\n\tstaticFilePath string,\n\trepo *repository.Repository,\n) *chi.Mux {\n\tl := a.Logger()\n\tr := chi.NewRouter()\n\tauth := mw.NewAuth(store, cookieName, repo)\n\n\tr.Route(\"/api\", func(r chi.Router) {\n\t\tr.Use(mw.ContentTypeJSON)\n\n\t\t// health checks\n\t\tr.Method(\"GET\", \"/livez\", http.HandlerFunc(a.HandleLive))\n\t\tr.Method(\"GET\", \"/readyz\", http.HandlerFunc(a.HandleReady))\n\n\t\t// /api/users routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/users/{user_id}\",\n\t\t\tauth.DoesUserIDMatch(\n\t\t\t\trequestlog.NewHandler(a.HandleReadUser, l),\n\t\t\t\tmw.URLParam,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/users/{user_id}/projects\",\n\t\t\tauth.DoesUserIDMatch(\n\t\t\t\trequestlog.NewHandler(a.HandleListUserProjects, l),\n\t\t\t\tmw.URLParam,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/users\",\n\t\t\trequestlog.NewHandler(a.HandleCreateUser, l),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"DELETE\",\n\t\t\t\"/users/{user_id}\",\n\t\t\tauth.DoesUserIDMatch(\n\t\t\t\trequestlog.NewHandler(a.HandleDeleteUser, l),\n\t\t\t\tmw.URLParam,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/login\",\n\t\t\trequestlog.NewHandler(a.HandleLoginUser, l),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/auth/check\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleAuthCheck, l),\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/logout\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleLogoutUser, l),\n\t\t\t),\n\t\t)\n\n\t\t// /api/integrations routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/integrations/cluster\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleListClusterIntegrations, l),\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/integrations/registry\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleListRegistryIntegrations, l),\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/integrations/repo\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleListRepoIntegrations, l),\n\t\t\t),\n\t\t)\n\n\t\t// /api/templates routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/templates\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleListTemplates, l),\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/templates/{name}/{version}\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleReadTemplate, l),\n\t\t\t),\n\t\t)\n\n\t\t// /api/oauth routes\n\t\t// r.Method(\n\t\t// \t\"GET\",\n\t\t// \t\"/oauth/projects/{project_id}/github\",\n\t\t// \tauth.DoesUserHaveProjectAccess(\n\t\t// \t\trequestlog.NewHandler(a.HandleGithubOAuthStartProject, l),\n\t\t// \t\tmw.URLParam,\n\t\t// \t\tmw.WriteAccess,\n\t\t// \t),\n\t\t// )\n\n\t\t// r.Method(\n\t\t// \t\"GET\",\n\t\t// \t\"/oauth/github/callback\",\n\t\t// \trequestlog.NewHandler(a.HandleGithubOAuthCallback, l),\n\t\t// )\n\n\t\t// /api/projects routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleReadProject, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects\",\n\t\t\tauth.BasicAuthenticate(\n\t\t\t\trequestlog.NewHandler(a.HandleCreateProject, l),\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"DELETE\",\n\t\t\t\"/projects/{project_id}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleDeleteProject, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/clusters routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/clusters\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleListProjectClusters, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/clusters\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleCreateProjectCluster, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/clusters/{cluster_id}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleReadProjectCluster, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/clusters/{cluster_id}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleUpdateProjectCluster, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"DELETE\",\n\t\t\t\"/projects/{project_id}/clusters/{cluster_id}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleDeleteProjectCluster, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/clusters/candidates routes\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/clusters/candidates\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleCreateProjectClusterCandidates, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/clusters/candidates\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleListProjectClusterCandidates, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/clusters/candidates/{candidate_id}/resolve\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleResolveClusterCandidate, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/integrations routes\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/integrations/gcp\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleCreateGCPIntegration, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/integrations/aws\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleCreateAWSIntegration, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/registries routes\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/registries\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleCreateRegistry, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/registries\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\trequestlog.NewHandler(a.HandleListProjectRegistries, l),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/registries/{registry_id}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveRegistryAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleUpdateProjectRegistry, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"DELETE\",\n\t\t\t\"/projects/{project_id}/registries/{registry_id}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveRegistryAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleDeleteProjectRegistry, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/registries/{registry_id}/repositories routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/registries/{registry_id}/repositories\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveRegistryAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleListRepositories, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t// * is the repo name, which can itself be nested\n\t\t\t// for example, for GCR this is project-id/repo\n\t\t\t// need to use wildcard, see https://github.com/go-chi/chi/issues/243\n\t\t\t\"/projects/{project_id}/registries/{registry_id}/repositories/*\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveRegistryAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleListImages, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.WriteAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/releases routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/releases\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleListReleases, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/releases/{name}/{revision}/components\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleGetReleaseComponents, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/releases/{name}/{revision}/controllers\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleGetReleaseControllers, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/releases/{name}/history\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleListReleaseHistory, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/releases/{name}/upgrade\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleUpgradeRelease, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/releases/{name}/{revision}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleGetRelease, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/releases/{name}/rollback\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleRollbackRelease, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/repos routes\n\t\t// r.Method(\n\t\t// \t\"GET\",\n\t\t// \t\"/projects/{project_id}/repos\",\n\t\t// \tauth.DoesUserHaveProjectAccess(\n\t\t// \t\trequestlog.NewHandler(a.HandleListRepos, l),\n\t\t// \t\tmw.URLParam,\n\t\t// \t\tmw.ReadAccess,\n\t\t// \t),\n\t\t// )\n\n\t\t// r.Method(\n\t\t// \t\"GET\",\n\t\t// \t\"/projects/{project_id}/repos/{kind}/{name}/branches\",\n\t\t// \tauth.DoesUserHaveProjectAccess(\n\t\t// \t\trequestlog.NewHandler(a.HandleGetBranches, l),\n\t\t// \t\tmw.URLParam,\n\t\t// \t\tmw.ReadAccess,\n\t\t// \t),\n\t\t// )\n\n\t\t// r.Method(\n\t\t// \t\"GET\",\n\t\t// \t\"/projects/{project_id}/repos/{kind}/{name}/{branch}/contents\",\n\t\t// \tauth.DoesUserHaveProjectAccess(\n\t\t// \t\trequestlog.NewHandler(a.HandleGetBranchContents, l),\n\t\t// \t\tmw.URLParam,\n\t\t// \t\tmw.ReadAccess,\n\t\t// \t),\n\t\t// )\n\n\t\t// /api/projects/{project_id}/deploy routes\n\t\tr.Method(\n\t\t\t\"POST\",\n\t\t\t\"/projects/{project_id}/deploy/{name}/{version}\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleDeployTemplate, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\t// /api/projects/{project_id}/k8s routes\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/k8s/namespaces\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleListNamespaces, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/k8s/{namespace}/pod/{name}/logs\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleGetPodLogs, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/k8s/{kind}/status\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleStreamControllerStatus, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\n\t\tr.Method(\n\t\t\t\"GET\",\n\t\t\t\"/projects/{project_id}/k8s/pods\",\n\t\t\tauth.DoesUserHaveProjectAccess(\n\t\t\t\tauth.DoesUserHaveClusterAccess(\n\t\t\t\t\trequestlog.NewHandler(a.HandleListPods, l),\n\t\t\t\t\tmw.URLParam,\n\t\t\t\t\tmw.QueryParam,\n\t\t\t\t),\n\t\t\t\tmw.URLParam,\n\t\t\t\tmw.ReadAccess,\n\t\t\t),\n\t\t)\n\t})\n\n\tfs := http.FileServer(http.Dir(staticFilePath))\n\n\tr.Get(\"/*\", func(w http.ResponseWriter, r *http.Request) {\n\t\tif _, err := os.Stat(staticFilePath + r.RequestURI); os.IsNotExist(err) {\n\t\t\thttp.StripPrefix(r.URL.Path, fs).ServeHTTP(w, r)\n\t\t} else {\n\t\t\tfs.ServeHTTP(w, r)\n\t\t}\n\t})\n\n\treturn r\n}", "func NewAPI(httpClient HTTPClient) API {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\treturn API{client: httpClient}\n}", "func NewController(ctx context.Context, clientMap clientmap.ClientMap) (*Controller, error) {\n\tgardenClient, err := clientMap.GetClient(ctx, keys.ForGarden())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbackupBucketInformer, err := gardenClient.Cache().GetInformer(ctx, &gardencorev1beta1.BackupBucket{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get BackupBucket Informer: %w\", err)\n\t}\n\tbackupEntryInformer, err := gardenClient.Cache().GetInformer(ctx, &gardencorev1beta1.BackupEntry{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get BackupEntry Informer: %w\", err)\n\t}\n\tcontrollerDeploymentInformer, err := gardenClient.Cache().GetInformer(ctx, &gardencorev1beta1.ControllerDeployment{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get ControllerDeployment Informer: %w\", err)\n\t}\n\tcontrollerInstallationInformer, err := gardenClient.Cache().GetInformer(ctx, &gardencorev1beta1.ControllerInstallation{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get ControllerInstallation Informer: %w\", err)\n\t}\n\tcontrollerRegistrationInformer, err := gardenClient.Cache().GetInformer(ctx, &gardencorev1beta1.ControllerRegistration{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get ControllerRegistration Informer: %w\", err)\n\t}\n\tseedInformer, err := gardenClient.Cache().GetInformer(ctx, &gardencorev1beta1.Seed{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get Seed Informer: %w\", err)\n\t}\n\tshootInformer, err := gardenClient.Cache().GetInformer(ctx, &gardencorev1beta1.Shoot{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get Shoot Informer: %w\", err)\n\t}\n\n\tcontroller := &Controller{\n\t\tgardenClient: gardenClient.Client(),\n\n\t\tcontrollerRegistrationReconciler: NewControllerRegistrationReconciler(logger.Logger, gardenClient.Client()),\n\t\tcontrollerRegistrationSeedReconciler: NewControllerRegistrationSeedReconciler(logger.Logger, gardenClient),\n\t\tseedReconciler: NewSeedReconciler(logger.Logger, gardenClient.Client()),\n\n\t\tcontrollerRegistrationQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"controllerregistration\"),\n\t\tcontrollerRegistrationSeedQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"controllerregistration-seed\"),\n\t\tseedQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"seed\"),\n\t\tworkerCh: make(chan int),\n\t}\n\n\tbackupBucketInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.backupBucketAdd,\n\t\tUpdateFunc: controller.backupBucketUpdate,\n\t\tDeleteFunc: controller.backupBucketDelete,\n\t})\n\n\tbackupEntryInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.backupEntryAdd,\n\t\tUpdateFunc: controller.backupEntryUpdate,\n\t\tDeleteFunc: controller.backupEntryDelete,\n\t})\n\n\tcontrollerRegistrationInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(obj interface{}) { controller.controllerRegistrationAdd(ctx, obj) },\n\t\tUpdateFunc: func(oldObj, newObj interface{}) { controller.controllerRegistrationUpdate(ctx, oldObj, newObj) },\n\t\tDeleteFunc: controller.controllerRegistrationDelete,\n\t})\n\n\tcontrollerDeploymentInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(obj interface{}) { controller.controllerDeploymentAdd(ctx, obj) },\n\t\tUpdateFunc: func(oldObj, newObj interface{}) { controller.controllerDeploymentUpdate(ctx, oldObj, newObj) },\n\t})\n\n\tcontrollerInstallationInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.controllerInstallationAdd,\n\t\tUpdateFunc: controller.controllerInstallationUpdate,\n\t})\n\n\tseedInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(obj interface{}) { controller.seedAdd(obj, true) },\n\t\tUpdateFunc: controller.seedUpdate,\n\t\tDeleteFunc: controller.seedDelete,\n\t})\n\n\tshootInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: controller.shootAdd,\n\t\tUpdateFunc: controller.shootUpdate,\n\t\tDeleteFunc: controller.shootDelete,\n\t})\n\n\tcontroller.hasSyncedFuncs = append(controller.hasSyncedFuncs,\n\t\tbackupBucketInformer.HasSynced,\n\t\tbackupEntryInformer.HasSynced,\n\t\tcontrollerRegistrationInformer.HasSynced,\n\t\tcontrollerDeploymentInformer.HasSynced,\n\t\tcontrollerInstallationInformer.HasSynced,\n\t\tseedInformer.HasSynced,\n\t\tshootInformer.HasSynced,\n\t)\n\n\treturn controller, nil\n}", "func New(b *base.Controller, moduleID string, uu userUsecases.Usecase) *Controller {\n\treturn &Controller{\n\t\tb,\n\t\tmoduleID,\n\t\tuu,\n\t}\n}", "func New(logger logging.Logger) Service {\n\ta := &API{\n\t\tlogger: logger,\n\t}\n\n\ta.setupRouting()\n\n\treturn a\n}", "func ToAPI(api *Api) *v1.Api {\n\tcrd := &v1.Api{}\n\tcrd.TypeMeta.Kind = \"Api\"\n\tcrd.TypeMeta.APIVersion = v1.GroupVersion.Group + \"/\" + v1.GroupVersion.Version\n\n\tcrd.ObjectMeta.Name = api.ID\n\tcrd.ObjectMeta.Namespace = api.Namespace\n\tcrd.ObjectMeta.Labels = make(map[string]string)\n\tcrd.ObjectMeta.Labels[v1.ServiceunitLabel] = api.Serviceunit.ID\n\tcrd.Spec = v1.ApiSpec{\n\t\tName: api.Name,\n\t\tDescription: api.Description,\n\t\tServiceunit: api.Serviceunit,\n\t\tApplications: api.Applications,\n\t\tFrequency: api.Frequency,\n\t\tApiType: api.ApiType,\n\t\tAuthType: api.AuthType,\n\t\tTags: api.Tags,\n\t\tApiBackendType: api.Serviceunit.Type,\n\t\tMethod: api.Method,\n\t\tProtocol: api.Protocol,\n\t\tReturnType: api.ReturnType,\n\t\tRDBQuery: api.RDBQuery,\n\t\tDataWarehouseQuery: api.DataWarehouseQuery,\n\t\tApiDefineInfo: api.ApiDefineInfo,\n\t\tKongApi: api.KongApi,\n\t\tApiQueryInfo: api.ApiQueryInfo,\n\t\tApiReturnInfo: api.ApiReturnInfo,\n\t\tTraffic: api.Traffic,\n\t\tRestriction: api.Restriction,\n\t\tPublishInfo: api.PublishInfo,\n\t\tResponseTransformer: api.ResTransformer,\n\t}\n\n\tcrd.Status = v1.ApiStatus{\n\t\tStatus: v1.Init,\n\t\tAction: v1.Create,\n\t\t//create api update status to unreleased\n\t\tPublishStatus: v1.UnRelease,\n\t\tAccessLink: api.AccessLink,\n\t\tUpdatedAt: metav1.Now(),\n\t\tReleasedAt: metav1.Now(),\n\t\tApplicationCount: api.ApplicationCount,\n\t\tCalledCount: api.CalledCount,\n\t\tFailedCount: api.FailedCount,\n\t\tLatencyCount: api.LatencyCount,\n\t\tCallFrequency: api.CallFrequency,\n\t}\n\t// add user labels\n\tcrd.ObjectMeta.Labels = user.AddUsersLabels(api.Users, crd.ObjectMeta.Labels)\n\treturn crd\n}", "func CreateController(router *gin.RouterGroup, context *appcontext.Context, routeName string, controller ControllerInterface) {\n\tcontroller.SetContext(context)\n\n\t// Definisikan route\n\trouter = router.Group(routeName)\n\tcontroller.SetRoute(router)\n}", "func New(client vpnkit.Client, services corev1client.ServicesGetter) *Controller {\n\treturn &Controller{\n\t\tservices: services,\n\t\tclient: client,\n\t}\n}", "func NewController(ctx context.Context, prowJobClient prowv1.ProwJobInterface, op io.Opener,\n\tca *config.Agent, cookiefilePath, tokenPathOverride, lastSyncFallback string, workerPoolSize int, maxQPS, maxBurst int, inRepoConfigCache *config.InRepoConfigCache) *Controller {\n\n\tcfg := ca.Config\n\tprojectsOptOutHelpMap := map[string]sets.Set[string]{}\n\tif cfg().Gerrit.OrgReposConfig != nil {\n\t\tprojectsOptOutHelpMap = cfg().Gerrit.OrgReposConfig.OptOutHelpRepos()\n\t}\n\tlastSyncTracker := client.NewSyncTime(lastSyncFallback, op, ctx)\n\n\tif err := lastSyncTracker.Init(cfg().Gerrit.OrgReposConfig.AllRepos()); err != nil {\n\t\tlogrus.WithError(err).Fatal(\"Error initializing lastSyncFallback.\")\n\t}\n\tgerritClient, err := client.NewClient(nil, maxQPS, maxBurst)\n\tif err != nil {\n\t\tlogrus.WithError(err).Fatal(\"Error creating gerrit client.\")\n\t}\n\tc := &Controller{\n\t\tprowJobClient: prowJobClient,\n\t\tconfig: cfg,\n\t\tgc: gerritClient,\n\t\ttracker: lastSyncTracker,\n\t\tprojectsOptOutHelp: projectsOptOutHelpMap,\n\t\tcookieFilePath: cookiefilePath,\n\t\tconfigAgent: ca,\n\t\tinRepoConfigCache: inRepoConfigCache,\n\t\tinRepoConfigFailuresTracker: map[string]bool{},\n\t\tprojectsWithWorker: make(map[string]bool),\n\t\tworkerPoolSize: workerPoolSize,\n\t}\n\n\t// applyGlobalConfig reads gerrit configurations from global gerrit config,\n\t// it will completely override previously configured gerrit hosts and projects.\n\t// it will also by the way authenticate gerrit\n\torgRepoConfigGetter := func() *config.GerritOrgRepoConfigs {\n\t\treturn cfg().Gerrit.OrgReposConfig\n\t}\n\tc.gc.ApplyGlobalConfig(orgRepoConfigGetter, lastSyncTracker, cookiefilePath, tokenPathOverride, func() {\n\t\torgReposConfig := orgRepoConfigGetter()\n\t\tif orgReposConfig == nil {\n\t\t\treturn\n\t\t}\n\t\tc.lock.Lock()\n\t\t// Updates a map, lock to make sure it's thread safe.\n\t\tc.projectsOptOutHelp = orgReposConfig.OptOutHelpRepos()\n\t\tc.lock.Unlock()\n\t})\n\n\t// Authenticate creates a goroutine for rotating token secrets when called the first\n\t// time, afterwards it only authenticate once.\n\t// applyGlobalConfig calls authenticate only when global gerrit config presents,\n\t// call it here is required for cases where gerrit repos are defined as command\n\t// line arg(which is going to be deprecated).\n\tc.gc.Authenticate(cookiefilePath, tokenPathOverride)\n\n\treturn c\n}", "func NewAPI(root string) *API {\n\tapi := &API{\n\t\troot: root,\n\t}\n\treturn api\n}", "func New() IApi {\n\treturn &api{\n\t\tRouter: pat.New(),\n\t\titemStore: make(map[string]apiStore),\n\t}\n}", "func NewRestController(embed Controller) *RestController {\n\tret := &RestController{\n\t\tembed: embed,\n\t\tServices: finder.New(),\n\t\tLog: &ggt.VoidLog{},\n\t\tSession: &ggt.VoidSession{},\n\t\tUpload: &ggt.FileProvider{},\n\t}\n\tret.Log.Handle(nil, nil, nil, \"constructor\", \"RestController\")\n\treturn ret\n}", "func NewController(productService contract.ProductService) *Controller {\n\tonce.Do(func() {\n\t\tinstance = &Controller{\n\t\t\tproductService: productService,\n\t\t}\n\t})\n\treturn instance\n}", "func New(config *Config, db mongodb.DB, router *mux.Router) (*API, error) {\n\tapi := &API{\n\t\tconfig: config,\n\t\tdb: db,\n\t\tRouter: router,\n\t}\n\n\t// Endpoint for browser preflight requests\n\tapi.Router.Methods(\"OPTIONS\").HandlerFunc(api.corsMiddleware(api.preflightHandler))\n\n\t// Endpoint for healtcheck\n\tapi.Router.HandleFunc(\"/api/v1/health\", api.corsMiddleware(api.logMiddleware(api.healthHandler))).Methods(\"GET\")\n\n\t// User\n\tapi.Router.HandleFunc(\"/api/v1/auth\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.UserValidate)))).Methods(\"GET\")\n\tapi.Router.HandleFunc(\"/api/v1/auth/login\", api.corsMiddleware(api.logMiddleware(api.userLoginPostHandler))).Methods(\"POST\")\n\tapi.Router.HandleFunc(\"/api/v1/auth/signup\", api.corsMiddleware(api.logMiddleware(api.userSignupPostHandler))).Methods(\"POST\")\n\tapi.Router.HandleFunc(\"/api/v1/profile\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.userProfileGetHandler)))).Methods(\"GET\")\n\tapi.Router.HandleFunc(\"/api/v1/profile/{userid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.userProfileUpdateHandler)))).Methods(\"PUT\")\n\n\t// Home\n\tapi.Router.HandleFunc(\"/api/v1/f/{userid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.GetAllFormsHandler)))).Methods(\"GET\")\n\tapi.Router.HandleFunc(\"/api/v1/f/{userid}/less\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.GetAllFormsWithLessValueHandler)))).Methods(\"GET\")\n\tapi.Router.HandleFunc(\"/api/v1/f/{userid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.CreateFormHandler)))).Methods(\"POST\")\n\n\t// Form\n\tapi.Router.HandleFunc(\"/api/v1/f/{formid}/view\", api.corsMiddleware(api.logMiddleware(api.formViewGetHandler))).Methods(\"GET\")\n\tapi.Router.HandleFunc(\"/api/v1/f/{formid}/view\", api.corsMiddleware(api.logMiddleware(api.formViewPostHandler))).Methods(\"POST\")\n\tapi.Router.HandleFunc(\"/api/v1/f/{userid}/{formid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.formGetHandler)))).Methods(\"GET\")\n\tapi.Router.HandleFunc(\"/api/v1/f/{userid}/{formid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.formPutHandler)))).Methods(\"PUT\")\n\tapi.Router.HandleFunc(\"/api/v1/f/{userid}/{formid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.formDeleteHandler)))).Methods(\"DELETE\")\n\n\tapi.Router.HandleFunc(\"/api/v1/f/{userid}/{formid}/response\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.formResponseGetHandler)))).Methods(\"GET\")\n\n\tapi.Router.HandleFunc(\"/api/v1/q/{userid}/{formid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.questionPostHandler)))).Methods(\"POST\")\n\tapi.Router.HandleFunc(\"/api/v1/q/{userid}/{formid}/copy\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.questionPostCopyHandler)))).Methods(\"POST\")\n\tapi.Router.HandleFunc(\"/api/v1/q/{userid}/{formid}/{questionid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.questionPutHandler)))).Methods(\"PUT\")\n\tapi.Router.HandleFunc(\"/api/v1/q/{userid}/{formid}/{questionid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.questionDeleteHandler)))).Methods(\"DELETE\")\n\n\tapi.Router.HandleFunc(\"/api/v1/o/{userid}/{formid}/{questionid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.optionPostHandler)))).Methods(\"POST\")\n\tapi.Router.HandleFunc(\"/api/v1/o/{userid}/{formid}/{questionid}/{optionid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.optionPutHandler)))).Methods(\"PUT\")\n\tapi.Router.HandleFunc(\"/api/v1/o/{userid}/{formid}/{questionid}/{optionid}\", api.corsMiddleware(api.logMiddleware(api.jwtMiddleware(api.optionDeleteHandler)))).Methods(\"DELETE\")\n\n\treturn api, nil\n}", "func NewAPI(ctx Context) *API {\n\treturn &API{\n\t\tctx: ctx,\n\t}\n}", "func NewController() Controller {\n\treturn &controller{\n\t\treservedExpiration: defaultReservedExpiration,\n\t\tquotaMgr: quota.Mgr,\n\t}\n}", "func TestNewController(t *testing.T) {\n\tmessagingClientSet, err := clientset.NewForConfig(&rest.Config{})\n\tif err != nil {\n\t\tt.Fail()\n\t}\n\n\tmessagingInformerFactory := informers.NewSharedInformerFactory(messagingClientSet, 0)\n\tnatssChannelInformer := messagingInformerFactory.Messaging().V1alpha1().NatssChannels()\n\n\tc := NewController(reconciler.Options{\n\t\tKubeClientSet: fakekubeclientset.NewSimpleClientset(),\n\t\tDynamicClientSet: nil,\n\t\tNatssClientSet: nil,\n\t\tRecorder: nil,\n\t\tStatsReporter: nil,\n\t\tConfigMapWatcher: nil,\n\t\tLogger: logtesting.TestLogger(t),\n\t\tResyncPeriod: 0,\n\t\tStopChannel: nil,\n\t}, dispatchertesting.NewDispatcherDoNothing(), natssChannelInformer)\n\tif c == nil {\n\t\tt.Errorf(\"unable to create dispatcher controller\")\n\t}\n}" ]
[ "0.8075666", "0.8023453", "0.67176133", "0.64246213", "0.6235566", "0.62157035", "0.6152561", "0.6152561", "0.6152561", "0.6112844", "0.6106132", "0.6084419", "0.6062073", "0.60533047", "0.60165876", "0.60151273", "0.59801435", "0.5952995", "0.59251064", "0.58884543", "0.58722484", "0.5853857", "0.58521223", "0.58477116", "0.58314395", "0.5830468", "0.5827223", "0.58111167", "0.58038175", "0.5800226", "0.5791873", "0.5781063", "0.5756264", "0.5737393", "0.57285404", "0.57281077", "0.5720228", "0.5719584", "0.57166135", "0.5694618", "0.56891274", "0.56851864", "0.5682449", "0.56806237", "0.5673727", "0.56643337", "0.56579137", "0.5656248", "0.56521916", "0.56500536", "0.56482226", "0.56470346", "0.5640629", "0.5639827", "0.563663", "0.56326675", "0.563119", "0.56300193", "0.56229573", "0.5609049", "0.5603071", "0.5602935", "0.5596225", "0.5595082", "0.5591044", "0.5590224", "0.55884033", "0.5580633", "0.5579381", "0.55787194", "0.5572148", "0.55610347", "0.55587244", "0.55555534", "0.55495566", "0.5544784", "0.5541456", "0.55383575", "0.5534824", "0.552922", "0.5509614", "0.550959", "0.55063015", "0.55022866", "0.5499871", "0.5496081", "0.54848295", "0.54827446", "0.5482729", "0.5482", "0.54801035", "0.5474714", "0.5467681", "0.54619193", "0.5460029", "0.54572886", "0.54564786", "0.54481643" ]
0.8062977
2
Routes returns all of the api route for the DefaultApiController
func (c *DefaultApiController) Routes() Routes { return Routes{ { "GetJobOffer", strings.ToUpper("Get"), "/job_offer", c.GetJobOffer, }, { "GetOccupation", strings.ToUpper("Get"), "/occupation", c.GetOccupation, }, { "GetTotalPopulation", strings.ToUpper("Get"), "/total_population", c.GetTotalPopulation, }, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *DefaultApiController) Routes() Routes {\n\treturn Routes{ \n\t\t{\n\t\t\t\"AccountGet\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/api/v1/account\",\n\t\t\tc.AccountGet,\n\t\t},\n\t\t{\n\t\t\t\"EchoGet\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/api/v1/echo\",\n\t\t\tc.EchoGet,\n\t\t},\n\t}\n}", "func (c *DefaultApiController) Routes() Routes {\n\treturn Routes{ \n\t\t{\n\t\t\t\"PetsIdGet\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/pets/{id}\",\n\t\t\tc.PetsIdGet,\n\t\t},\n\t}\n}", "func (c *DefaultApiController) Routes() Routes {\n\treturn Routes{ \n\t\t{\n\t\t\t\"AddUser\",\n\t\t\tstrings.ToUpper(\"Post\"),\n\t\t\t\"/users\",\n\t\t\tc.AddUser,\n\t\t},\n\t\t{\n\t\t\t\"DeleteUser\",\n\t\t\tstrings.ToUpper(\"Delete\"),\n\t\t\t\"/users/${id}\",\n\t\t\tc.DeleteUser,\n\t\t},\n\t\t{\n\t\t\t\"GetUser\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/users/${id}\",\n\t\t\tc.GetUser,\n\t\t},\n\t\t{\n\t\t\t\"ListUsers\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/users\",\n\t\t\tc.ListUsers,\n\t\t},\n\t\t{\n\t\t\t\"UpdateUser\",\n\t\t\tstrings.ToUpper(\"Put\"),\n\t\t\t\"/users/${id}\",\n\t\t\tc.UpdateUser,\n\t\t},\n\t}\n}", "func (c *DefaultApiController) Routes() Routes {\n\treturn Routes{\n\t\t{\n\t\t\t\"DataDataIdDelete\",\n\t\t\thttp.MethodDelete,\n\t\t\t\"/data/{dataId}\",\n\t\t\tc.DataDataIdDelete,\n\t\t},\n\t\t{\n\t\t\t\"DataDataIdGet\",\n\t\t\thttp.MethodGet,\n\t\t\t\"/data/{dataId}\",\n\t\t\tc.DataDataIdGet,\n\t\t},\n\t\t{\n\t\t\t\"DataDataIdPost\",\n\t\t\thttp.MethodPost,\n\t\t\t\"/data/{dataId}\",\n\t\t\tc.DataDataIdPost,\n\t\t},\n\t\t{\n\t\t\t\"DataGet\",\n\t\t\thttp.MethodGet,\n\t\t\t\"/data\",\n\t\t\tc.DataGet,\n\t\t},\n\t\t{\n\t\t\t\"DataPost\",\n\t\t\thttp.MethodPost,\n\t\t\t\"/data\",\n\t\t\tc.DataPost,\n\t\t},\n\t}\n}", "func (controller *APIController) GetRoutes() []string {\n\treturn []string{\n\t\t\"api\",\n\t}\n}", "func (Http) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/http/cff_action/\",\n\t\t\"/api/objects/http/cff_action/{ref}\",\n\t\t\"/api/objects/http/cff_action/{ref}/usedby\",\n\t\t\"/api/objects/http/cff_profile/\",\n\t\t\"/api/objects/http/cff_profile/{ref}\",\n\t\t\"/api/objects/http/cff_profile/{ref}/usedby\",\n\t\t\"/api/objects/http/device_auth/\",\n\t\t\"/api/objects/http/device_auth/{ref}\",\n\t\t\"/api/objects/http/device_auth/{ref}/usedby\",\n\t\t\"/api/objects/http/domain_regex/\",\n\t\t\"/api/objects/http/domain_regex/{ref}\",\n\t\t\"/api/objects/http/domain_regex/{ref}/usedby\",\n\t\t\"/api/objects/http/exception/\",\n\t\t\"/api/objects/http/exception/{ref}\",\n\t\t\"/api/objects/http/exception/{ref}/usedby\",\n\t\t\"/api/objects/http/group/\",\n\t\t\"/api/objects/http/group/{ref}\",\n\t\t\"/api/objects/http/group/{ref}/usedby\",\n\t\t\"/api/objects/http/local_site/\",\n\t\t\"/api/objects/http/local_site/{ref}\",\n\t\t\"/api/objects/http/local_site/{ref}/usedby\",\n\t\t\"/api/objects/http/lsl_tag/\",\n\t\t\"/api/objects/http/lsl_tag/{ref}\",\n\t\t\"/api/objects/http/lsl_tag/{ref}/usedby\",\n\t\t\"/api/objects/http/pac_file/\",\n\t\t\"/api/objects/http/pac_file/{ref}\",\n\t\t\"/api/objects/http/pac_file/{ref}/usedby\",\n\t\t\"/api/objects/http/parent_proxy/\",\n\t\t\"/api/objects/http/parent_proxy/{ref}\",\n\t\t\"/api/objects/http/parent_proxy/{ref}/usedby\",\n\t\t\"/api/objects/http/profile/\",\n\t\t\"/api/objects/http/profile/{ref}\",\n\t\t\"/api/objects/http/profile/{ref}/usedby\",\n\t\t\"/api/objects/http/sp_category/\",\n\t\t\"/api/objects/http/sp_category/{ref}\",\n\t\t\"/api/objects/http/sp_category/{ref}/usedby\",\n\t\t\"/api/objects/http/sp_subcat/\",\n\t\t\"/api/objects/http/sp_subcat/{ref}\",\n\t\t\"/api/objects/http/sp_subcat/{ref}/usedby\",\n\t}\n}", "func RouteRootApis(acc *echo.Group, res *echo.Group, session *mgo.Session) {\n\n\t// instantiate new root controller\n\trootController := controllerv1.RootController{}\n\n\t// get resources home address\n\tacc.GET(\"/assethome\", rootController.GetAssetHomePath)\n}", "func APIRoutes() *echo.Echo {\n\tapi := echo.New()\n\tapi.Use(middleware.CORSWithConfig(middleware.CORSConfig{\n\t\tAllowOrigins: []string{\"*\"},\n\t\tAllowHeaders: []string{\"*\"},\n\t}))\n\n\tapi.Use(middleware.Logger())\n\tapi.Use(middleware.Recover())\n\n\tapi.GET(\"/\", controller.HomePage)\n\tapi.GET(\"/timestamp\", controller.Timestamp)\n\tapi.GET(\"/payment_status\", controller.PaymentStatus)\n\n\treturn api\n}", "func (this *RouteServiceProvider) mapApiRoutes() {\n\tFacades.Route().Group(map[string]string{\"prefix\": \"api\"}, Routes.Api)\n}", "func (RemoteSyslog) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/remote_syslog/group/\",\n\t\t\"/api/objects/remote_syslog/group/{ref}\",\n\t\t\"/api/objects/remote_syslog/group/{ref}/usedby\",\n\t\t\"/api/objects/remote_syslog/server/\",\n\t\t\"/api/objects/remote_syslog/server/{ref}\",\n\t\t\"/api/objects/remote_syslog/server/{ref}/usedby\",\n\t}\n}", "func (Snmp) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/snmp/group/\",\n\t\t\"/api/objects/snmp/group/{ref}\",\n\t\t\"/api/objects/snmp/group/{ref}/usedby\",\n\t\t\"/api/objects/snmp/trap/\",\n\t\t\"/api/objects/snmp/trap/{ref}\",\n\t\t\"/api/objects/snmp/trap/{ref}/usedby\",\n\t}\n}", "func (Spx) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/spx/group/\",\n\t\t\"/api/objects/spx/group/{ref}\",\n\t\t\"/api/objects/spx/group/{ref}/usedby\",\n\t\t\"/api/objects/spx/template/\",\n\t\t\"/api/objects/spx/template/{ref}\",\n\t\t\"/api/objects/spx/template/{ref}/usedby\",\n\t}\n}", "func (c *BaseController) Routes() []web.Route {\n\treturn []web.Route{\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodPost,\n\t\t\t\tPath: c.resourceBaseURL,\n\t\t\t},\n\t\t\tHandler: c.CreateObject,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodGet,\n\t\t\t\tPath: fmt.Sprintf(\"%s/{%s}\", c.resourceBaseURL, PathParamID),\n\t\t\t},\n\t\t\tHandler: c.GetSingleObject,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodGet,\n\t\t\t\tPath: c.resourceBaseURL,\n\t\t\t},\n\t\t\tHandler: c.ListObjects,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodDelete,\n\t\t\t\tPath: c.resourceBaseURL,\n\t\t\t},\n\t\t\tHandler: c.DeleteObjects,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodDelete,\n\t\t\t\tPath: fmt.Sprintf(\"%s/{%s}\", c.resourceBaseURL, PathParamID),\n\t\t\t},\n\t\t\tHandler: c.DeleteSingleObject,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodPatch,\n\t\t\t\tPath: fmt.Sprintf(\"%s/{%s}\", c.resourceBaseURL, PathParamID),\n\t\t\t},\n\t\t\tHandler: c.PatchObject,\n\t\t},\n\t}\n}", "func initalizeRoutes() {\n\n\tv1 := app.Group(\"/v1\")\n\n\t// Auth controller routes\n\taccountRoutes := v1.Group(\"/account\")\n\taccountRoutes.POST(\"/register\", accountController.Register)\n\taccountRoutes.POST(\"/login\", accountController.Login)\n\taccountRoutes.POST(\"/refresh-token\", accountController.RefreshToken)\n\n\t// Post controller routes\n\tpostRoutes := v1.Group(\"/posts\").Use(middleware.Authorization())\n\tpostRoutes.GET(\"/\", postController.GetAll)\n\n}", "func (c *BaseController) Routes() []web.Route {\n\treturn []web.Route{\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodPost,\n\t\t\t\tPath: c.resourceBaseURL,\n\t\t\t},\n\t\t\tHandler: c.CreateObject,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodGet,\n\t\t\t\tPath: fmt.Sprintf(\"%s/{%s}\", c.resourceBaseURL, web.PathParamResourceID),\n\t\t\t},\n\t\t\tHandler: c.GetSingleObject,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodGet,\n\t\t\t\tPath: fmt.Sprintf(\"%s/{%s}%s/{%s}\", c.resourceBaseURL, web.PathParamResourceID, web.ResourceOperationsURL, web.PathParamID),\n\t\t\t},\n\t\t\tHandler: c.GetOperation,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodGet,\n\t\t\t\tPath: c.resourceBaseURL,\n\t\t\t},\n\t\t\tHandler: c.ListObjects,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodDelete,\n\t\t\t\tPath: c.resourceBaseURL,\n\t\t\t},\n\t\t\tHandler: c.DeleteObjects,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodDelete,\n\t\t\t\tPath: fmt.Sprintf(\"%s/{%s}\", c.resourceBaseURL, web.PathParamResourceID),\n\t\t\t},\n\t\t\tHandler: c.DeleteSingleObject,\n\t\t},\n\t\t{\n\t\t\tEndpoint: web.Endpoint{\n\t\t\t\tMethod: http.MethodPatch,\n\t\t\t\tPath: fmt.Sprintf(\"%s/{%s}\", c.resourceBaseURL, web.PathParamResourceID),\n\t\t\t},\n\t\t\tHandler: c.PatchObject,\n\t\t},\n\t}\n}", "func (Itfparams) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/itfparams/bridge_port/\",\n\t\t\"/api/objects/itfparams/bridge_port/{ref}\",\n\t\t\"/api/objects/itfparams/bridge_port/{ref}/usedby\",\n\t\t\"/api/objects/itfparams/group/\",\n\t\t\"/api/objects/itfparams/group/{ref}\",\n\t\t\"/api/objects/itfparams/group/{ref}/usedby\",\n\t\t\"/api/objects/itfparams/link_aggregation_group/\",\n\t\t\"/api/objects/itfparams/link_aggregation_group/{ref}\",\n\t\t\"/api/objects/itfparams/link_aggregation_group/{ref}/usedby\",\n\t\t\"/api/objects/itfparams/primary/\",\n\t\t\"/api/objects/itfparams/primary/{ref}\",\n\t\t\"/api/objects/itfparams/primary/{ref}/usedby\",\n\t\t\"/api/objects/itfparams/secondary/\",\n\t\t\"/api/objects/itfparams/secondary/{ref}\",\n\t\t\"/api/objects/itfparams/secondary/{ref}/usedby\",\n\t}\n}", "func (ac *applicationController) GetRoutes() models.Routes {\n\troutes := models.Routes{\n\t\tmodels.Route{\n\t\t\tPath: rootPath + \"/applications\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.RegisterApplication,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath,\n\t\t\tMethod: \"PUT\",\n\t\t\tHandlerFunc: ac.ChangeRegistrationDetails,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath,\n\t\t\tMethod: \"PATCH\",\n\t\t\tHandlerFunc: ac.ModifyRegistrationDetails,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: rootPath + \"/applications\",\n\t\t\tMethod: \"GET\",\n\t\t\tHandlerFunc: ac.ShowApplications,\n\t\t\tKubeApiConfig: models.KubeApiConfig{\n\t\t\t\tQPS: 50,\n\t\t\t\tBurst: 100,\n\t\t\t},\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: rootPath + \"/applications/_search\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.SearchApplications,\n\t\t\tKubeApiConfig: models.KubeApiConfig{\n\t\t\t\tQPS: 100,\n\t\t\t\tBurst: 100,\n\t\t\t},\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath,\n\t\t\tMethod: \"GET\",\n\t\t\tHandlerFunc: ac.GetApplication,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath,\n\t\t\tMethod: \"DELETE\",\n\t\t\tHandlerFunc: ac.DeleteApplication,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/pipelines\",\n\t\t\tMethod: \"GET\",\n\t\t\tHandlerFunc: ac.ListPipelines,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/pipelines/build\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.TriggerPipelineBuild,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/pipelines/build-deploy\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.TriggerPipelineBuildDeploy,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/pipelines/promote\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.TriggerPipelinePromote,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/pipelines/deploy\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.TriggerPipelineDeploy,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/deploykey-valid\",\n\t\t\tMethod: \"GET\",\n\t\t\tHandlerFunc: ac.IsDeployKeyValidHandler,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/deploy-key-and-secret\",\n\t\t\tMethod: \"GET\",\n\t\t\tHandlerFunc: ac.GetDeployKeyAndSecret,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/regenerate-machine-user-token\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.RegenerateMachineUserTokenHandler,\n\t\t},\n\t\tmodels.Route{\n\t\t\tPath: appPath + \"/regenerate-deploy-key\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandlerFunc: ac.RegenerateDeployKeyHandler,\n\t\t},\n\t}\n\n\treturn routes\n}", "func (Interface) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/interface/bridge/\",\n\t\t\"/api/objects/interface/bridge/{ref}\",\n\t\t\"/api/objects/interface/bridge/{ref}/usedby\",\n\t\t\"/api/objects/interface/ethernet/\",\n\t\t\"/api/objects/interface/ethernet/{ref}\",\n\t\t\"/api/objects/interface/ethernet/{ref}/usedby\",\n\t\t\"/api/objects/interface/group/\",\n\t\t\"/api/objects/interface/group/{ref}\",\n\t\t\"/api/objects/interface/group/{ref}/usedby\",\n\t\t\"/api/objects/interface/ppp3g/\",\n\t\t\"/api/objects/interface/ppp3g/{ref}\",\n\t\t\"/api/objects/interface/ppp3g/{ref}/usedby\",\n\t\t\"/api/objects/interface/pppmodem/\",\n\t\t\"/api/objects/interface/pppmodem/{ref}\",\n\t\t\"/api/objects/interface/pppmodem/{ref}/usedby\",\n\t\t\"/api/objects/interface/pppoa/\",\n\t\t\"/api/objects/interface/pppoa/{ref}\",\n\t\t\"/api/objects/interface/pppoa/{ref}/usedby\",\n\t\t\"/api/objects/interface/pppoe/\",\n\t\t\"/api/objects/interface/pppoe/{ref}\",\n\t\t\"/api/objects/interface/pppoe/{ref}/usedby\",\n\t\t\"/api/objects/interface/tunnel/\",\n\t\t\"/api/objects/interface/tunnel/{ref}\",\n\t\t\"/api/objects/interface/tunnel/{ref}/usedby\",\n\t\t\"/api/objects/interface/vlan/\",\n\t\t\"/api/objects/interface/vlan/{ref}\",\n\t\t\"/api/objects/interface/vlan/{ref}/usedby\",\n\t}\n}", "func GetRoutes(context *context.Context) Routes {\n\troutes := Routes{\n\t\t// Index\n\t\tRoute{\"Index\", \"GET\", \"/\", index},\n\n\t\t// Articles\n\t\tRoute{\"CreateArticle\", \"POST\", \"/api/article\", context.ArticlesController.CreateArticle},\n\t\tRoute{\"AllArticles\", \"GET\", \"/api/articles\", context.ArticlesController.AllArticles},\n\t\tRoute{\"GetArticle\", \"GET\", \"/api/article/{id}\", context.ArticlesController.GetArticle},\n\t\tRoute{\"UpdateArticle\", \"PUT\", \"/api/article/{id}\", context.ArticlesController.UpdateArticle},\n\t\tRoute{\"DeleteArticle\", \"DELETE\", \"/api/article/{id}\", context.ArticlesController.DeleteArticle},\n\n\t\t// Users\n\t\tRoute{\"CreateUser\", \"POST\", \"/api/user/new\", context.UsersController.CreateUser},\n\t\tRoute{\"AllUsers\", \"GET\", \"/api/users\", context.UsersController.AllUsers},\n\t\tRoute{\"GetUser\", \"GET\", \"/api/user/{id}\", context.UsersController.GetUser},\n\t\tRoute{\"UpdateUser\", \"PUT\", \"/api/user/{id}\", context.UsersController.UpdateUser},\n\t\tRoute{\"DeleteUser\", \"DELETE\", \"/api/user/{id}\", context.UsersController.DeleteUser},\n\t\tRoute{\"Authenticate\", \"POST\", \"/api/login\", context.UsersController.Authenticate},\n\t}\n\n\treturn routes\n}", "func (Condition) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/condition/group/\",\n\t\t\"/api/objects/condition/group/{ref}\",\n\t\t\"/api/objects/condition/group/{ref}/usedby\",\n\t\t\"/api/objects/condition/objref/\",\n\t\t\"/api/objects/condition/objref/{ref}\",\n\t\t\"/api/objects/condition/objref/{ref}/usedby\",\n\t}\n}", "func (s *Server) GetRoutes() []Route {\n\treturn []Route{\n\t\tRoute{\n\t\t\tService: \"dapi\",\n\t\t\tName: \"index\",\n\t\t\tPath: \"/\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: false,\n\t\t\tHandlerFunc: s.GetIndex,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dapi\",\n\t\t\tName: \"docs\",\n\t\t\tPath: \"/docs\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: false,\n\t\t\tHandlerFunc: s.GetDocs,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dapi\",\n\t\t\tName: \"icon\",\n\t\t\tPath: \"/favicon.ico\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: false,\n\t\t\tHandlerFunc: s.GetIcon,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetTokens\",\n\t\t\tPath: \"/dauth/tokens\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetTokens,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetTokens\",\n\t\t\tPath: \"/dauth/tokens/{id}\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetTokenByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SaveTokens\",\n\t\t\tPath: \"/dauth/tokens\",\n\t\t\tMethod: \"POST\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PostTokens,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SaveTokens\",\n\t\t\tPath: \"/dauth/tokens/{id}\",\n\t\t\tMethod: \"PUT\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PutTokenByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteTokens\",\n\t\t\tPath: \"/dauth/tokens/old\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteTokensOld,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteTokens\",\n\t\t\tPath: \"/dauth/tokens/old/{age}\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteTokensOld,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteTokens\",\n\t\t\tPath: \"/dauth/tokens/{id}\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteTokenByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteTokens\",\n\t\t\tPath: \"/dauth/tokens}\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteTokens,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetUsers\",\n\t\t\tPath: \"/dauth/users\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetUsers,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetUsers\",\n\t\t\tPath: \"/dauth/users/{id}\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetUserByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SaveUsers\",\n\t\t\tPath: \"/dauth/users\",\n\t\t\tMethod: \"POST\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PostUsers,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SaveUsers\",\n\t\t\tPath: \"/dauth/users/{id}\",\n\t\t\tMethod: \"PUT\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PutUserByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteUsers\",\n\t\t\tPath: \"/dauth/users/{id}\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteUserByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteUsers\",\n\t\t\tPath: \"/dauth/users\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteUsers,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetPerms\",\n\t\t\tPath: \"/dauth/perms\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetPerms,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetPerms\",\n\t\t\tPath: \"/dauth/perms/{id}\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetPermByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SavePerms\",\n\t\t\tPath: \"/dauth/perms\",\n\t\t\tMethod: \"POST\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PostPerms,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SavePerms\",\n\t\t\tPath: \"/dauth/perms/{id}\",\n\t\t\tMethod: \"PUT\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PutPermByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeletePerms\",\n\t\t\tPath: \"/dauth/perms/{id}\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeletePermByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeletePerms\",\n\t\t\tPath: \"/dauth/perms\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeletePerms,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetUserPerms\",\n\t\t\tPath: \"/dauth/userperms\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetUserPerms,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"GetUserPerms\",\n\t\t\tPath: \"/dauth/userperms/{id}\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.GetUserPermByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SaveUserPerms\",\n\t\t\tPath: \"/dauth/userperms\",\n\t\t\tMethod: \"POST\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PostUserPerms,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"SaveUserPerms\",\n\t\t\tPath: \"/dauth/userperms/{id}\",\n\t\t\tMethod: \"PUT\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.PutUserPermByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteUserPerms\",\n\t\t\tPath: \"/dauth/userperms/{id}\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteUserPermByID,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"DeleteUserPerms\",\n\t\t\tPath: \"/dauth/userperms\",\n\t\t\tMethod: \"DELETE\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.DeleteUserPerms,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"Auth\",\n\t\t\tPath: \"/dauth/auth\",\n\t\t\tMethod: \"GET\",\n\t\t\tAuth: true,\n\t\t\tHandlerFunc: s.Authenticate,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"Login\",\n\t\t\tPath: \"/dauth/login\",\n\t\t\tMethod: \"POST\",\n\t\t\tAuth: false,\n\t\t\tHandlerFunc: s.Login,\n\t\t},\n\t\tRoute{\n\t\t\tService: \"dauth\",\n\t\t\tName: \"Logout\",\n\t\t\tPath: \"/dauth/logout\",\n\t\t\tMethod: \"POST\",\n\t\t\tAuth: false,\n\t\t\tHandlerFunc: s.Logout,\n\t\t},\n\t}\n}", "func (controller *WidgetsController) GetRoutes() []string {\n\treturn []string{\n\t\t\"api/widgets\",\n\t}\n}", "func (controller *WidgetController) GetRoutes() []string {\n\treturn []string{\n\t\t\"api/widgets/{{id}}\",\n\t}\n}", "func (Ca) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/ca/crl/\",\n\t\t\"/api/objects/ca/crl/{ref}\",\n\t\t\"/api/objects/ca/crl/{ref}/usedby\",\n\t\t\"/api/objects/ca/csr/\",\n\t\t\"/api/objects/ca/csr/{ref}\",\n\t\t\"/api/objects/ca/csr/{ref}/usedby\",\n\t\t\"/api/objects/ca/group/\",\n\t\t\"/api/objects/ca/group/{ref}\",\n\t\t\"/api/objects/ca/group/{ref}/usedby\",\n\t\t\"/api/objects/ca/host_cert/\",\n\t\t\"/api/objects/ca/host_cert/{ref}\",\n\t\t\"/api/objects/ca/host_cert/{ref}/usedby\",\n\t\t\"/api/objects/ca/host_key_cert/\",\n\t\t\"/api/objects/ca/host_key_cert/{ref}\",\n\t\t\"/api/objects/ca/host_key_cert/{ref}/usedby\",\n\t\t\"/api/objects/ca/http_verification_ca/\",\n\t\t\"/api/objects/ca/http_verification_ca/{ref}\",\n\t\t\"/api/objects/ca/http_verification_ca/{ref}/usedby\",\n\t\t\"/api/objects/ca/meta_crl/\",\n\t\t\"/api/objects/ca/meta_crl/{ref}\",\n\t\t\"/api/objects/ca/meta_crl/{ref}/usedby\",\n\t\t\"/api/objects/ca/meta_x509/\",\n\t\t\"/api/objects/ca/meta_x509/{ref}\",\n\t\t\"/api/objects/ca/meta_x509/{ref}/usedby\",\n\t\t\"/api/objects/ca/rsa/\",\n\t\t\"/api/objects/ca/rsa/{ref}\",\n\t\t\"/api/objects/ca/rsa/{ref}/usedby\",\n\t\t\"/api/objects/ca/signing_ca/\",\n\t\t\"/api/objects/ca/signing_ca/{ref}\",\n\t\t\"/api/objects/ca/signing_ca/{ref}/usedby\",\n\t\t\"/api/objects/ca/verification_ca/\",\n\t\t\"/api/objects/ca/verification_ca/{ref}\",\n\t\t\"/api/objects/ca/verification_ca/{ref}/usedby\",\n\t}\n}", "func (Dyndns) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/dyndns/dyndns/\",\n\t\t\"/api/objects/dyndns/dyndns/{ref}\",\n\t\t\"/api/objects/dyndns/dyndns/{ref}/usedby\",\n\t\t\"/api/objects/dyndns/group/\",\n\t\t\"/api/objects/dyndns/group/{ref}\",\n\t\t\"/api/objects/dyndns/group/{ref}/usedby\",\n\t}\n}", "func RegisterAPIRoutes(router *mux.Router) {\n\trouter.HandleFunc(\"/api/v1/word/today/\", GetWordToday).Methods(\"GET\")\n}", "func (u *Controller) Routes(r framework.Mux) {\n\t// This is a special route.\n\tif !swaggerRoute.Bool() {\n\t\treturn\n\t}\n\tm := r.NewGroup(\"/misc\")\n\n\tb, err := Asset(\"swagger/index.json\")\n\tassert.Nil(err)\n\n\tvar data = make(map[string]interface{})\n\terr = json.Unmarshal(b, &data)\n\tassert.Nil(err)\n\tdata = load(data)\n\n\tm.GET(\"controllers-Controller-panic\", \"/panic\", framework.Handler(\n\t\tfunc(_ context.Context, w http.ResponseWriter, r *http.Request) {\n\t\t\tif r.Header.Get(\"token\") == panicToken.String() {\n\t\t\t\tpanic(\"Don't worry. it's just a test\")\n\t\t\t}\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t_, _ = w.Write([]byte(\"Noop ;)\"))\n\t\t}))\n\n\tm.GET(\"controllers-Controller-swagger\", filepath.Join(\"/swagger/index.json\"),\n\t\tframework.Handler(func(_ context.Context, w http.ResponseWriter, r *http.Request) {\n\t\t\ttmp := data\n\t\t\ttmp[\"host\"] = r.Host\n\t\t\tframework.JSON(w, http.StatusOK, data)\n\t\t}))\n}", "func apikeyRoutes(r *mux.Router, c *apikey.Controller) {\n\tr.Handle(\"\", c.HandleIndex()).Methods(http.MethodGet)\n\tr.Handle(\"\", c.HandleCreate()).Methods(http.MethodPost)\n\tr.Handle(\"/new\", c.HandleCreate()).Methods(http.MethodGet)\n\tr.Handle(\"/{id:[0-9]+}/edit\", c.HandleUpdate()).Methods(http.MethodGet)\n\tr.Handle(\"/{id:[0-9]+}\", c.HandleShow()).Methods(http.MethodGet)\n\tr.Handle(\"/{id:[0-9]+}\", c.HandleUpdate()).Methods(http.MethodPatch)\n\tr.Handle(\"/{id:[0-9]+}/disable\", c.HandleDisable()).Methods(http.MethodPatch)\n\tr.Handle(\"/{id:[0-9]+}/enable\", c.HandleEnable()).Methods(http.MethodPatch)\n}", "func Routes() *chi.Mux {\n\tr := chi.NewRouter()\n\n\t// v1/api/admin/configs\n\tr.Route(\"/\", func(r chi.Router) {\n\t\tr.Mount(\"/contents\", ContentRoutes())\n\t\tr.Mount(\"/users\", UserRoutes())\n\t\tr.Mount(\"/trees\", TreeRoutes())\n\t\tr.Mount(\"/schemas\", SchemaRoutes())\n\t\tr.Mount(\"/widgets\", WidgetRoutes())\n\t\tr.Mount(\"/datasets\", DatasetRoutes())\n\t\tr.Mount(\"/groups\", GroupRoutes())\n\t\tr.Mount(\"/currencies\", CurrencyRoutes())\n\t\tr.Mount(\"/jobs\", JobRoutes())\n\t})\n\n\treturn r\n}", "func (s *Service) GetRoutes() []routes.Route {\n\treturn []routes.Route{\n\t\t{\n\t\t\tName: \"register_app_form\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/register_app\",\n\t\t\tHandlerFunc: s.registerAppForm,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"login_app_form\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/login_app\",\n\t\t\tHandlerFunc: s.loginAppForm,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"login_app\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/login_app\",\n\t\t\tHandlerFunc: s.loginApp,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"register_app\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/register_app\",\n\t\t\tHandlerFunc: s.registerApp,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"home_app\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/home_app\",\n\t\t\tHandlerFunc: s.homeApp,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"login_app_validate_client\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/validateClient\",\n\t\t\tHandlerFunc: s.validateClient,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"sendMail\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/sendMail\",\n\t\t\tHandlerFunc: s.sendMailToken,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"index\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/\",\n\t\t\tHandlerFunc: s.index,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"register_form\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/register\",\n\t\t\tHandlerFunc: s.registerForm,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"register\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/register\",\n\t\t\tHandlerFunc: s.register,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"login_form\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/login\",\n\t\t\tHandlerFunc: s.loginForm,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"login\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/login\",\n\t\t\tHandlerFunc: s.login,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewGuestMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"logout\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/logout\",\n\t\t\tHandlerFunc: s.logout,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewLoggedInMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"authorize_form\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/authorize\",\n\t\t\tHandlerFunc: s.authorizeForm,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewLoggedInMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"authorize\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/authorize\",\n\t\t\tHandlerFunc: s.authorize,\n\t\t\tMiddlewares: []negroni.Handler{\n\t\t\t\tnew(parseFormMiddleware),\n\t\t\t\tnewLoggedInMiddleware(s),\n\t\t\t\tnewClientMiddleware(s),\n\t\t\t},\n\t\t},\n\t}\n}", "func (c *RestController) GetRoutes() []net.Route {\n\treturn []net.Route{\n\t\tnet.Route{\n\t\t\tPath: \"/oauth/token\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandler: c.Token,\n\t\t},\n\t\tnet.Route{\n\t\t\tPath: \"/oauth/authorize\",\n\t\t\tMethod: \"POST\",\n\t\t\tHandler: c.Authorize,\n\t\t},\n\t\tnet.Route{\n\t\t\tPath: \"/oauth/check_token\",\n\t\t\tMethod: \"GET\",\n\t\t\tHandler: c.CheckToken,\n\t\t},\n\t}\n}", "func Routes(app *fiber.App, service Service) {\n\tapi := app.Group(\"/api/v1\")\n\n\tapi.Get(\"/health\", func(c *fiber.Ctx) error {\n\t\treturn c.Status(http.StatusOK).\n\t\t\tJSON(map[string]interface{}{\n\t\t\t\t\"health\": \"ok\",\n\t\t\t\t\"status\": http.StatusOK,\n\t\t\t})\n\t})\n\n\t// public endpoint\n\tapi.Get(\"/token/new\", GetNewAccessToken)\n\tapi.Get(\"/travels\", service.getTravels)\n\tapi.Get(\"/travels/:id\", service.getTravel)\n\n\t// private endpoint\n\tapi.Post(\"/travels\", JWTProtected(), service.createTravel)\n\tapi.Put(\"/travels/:id\", JWTProtected(), service.updateTravel)\n\tapi.Delete(\"/travels/:id\", JWTProtected(), service.deleteTravel)\n}", "func (c *ProductsApiController) Routes() Routes {\n\treturn Routes{\n\t\t{\n\t\t\t\"GetProducts\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/cloud/v1/products\",\n\t\t\tc.GetProducts,\n\t\t},\n\t}\n}", "func Routes(configuration *config.Config) *chi.Mux {\n\trouter := chi.NewRouter()\n\trouter.Use(\n\t\trender.SetContentType(render.ContentTypeJSON), // Set content-Type headers as application/json\n\t\tmiddleware.Logger, // Log API request calls\n\t\t//middleware.DefaultCompress, // Compress results, mostly gzipping assets and json\n\t\tmiddleware.RedirectSlashes, // Redirect slashes to no slash URL versions\n\t\tmiddleware.Recoverer, // Recover from panics without crashing server\n\t)\n\n\trouter.Route(\"/api\", func(r chi.Router) {\n\t\tr.Mount(\"/common\", handler.Routes(configuration))\n\t\tr.Mount(\"/vars\", handler.VarsRoutes(configuration))\n\t\tr.Mount(\"/prometheus\", handler.PromRoutes(configuration))\n\t})\n\trouter.Route(\"/api2\", func(r chi.Router) {\n\t\tr.Mount(\"/\", handler.Routes(configuration))\n\t})\n\treturn router\n}", "func FetchAPIRoutes(router *fasthttprouter.Router) {\n\tmw.Noop()\n\n\trouter.Handle(\"GET\", \"/hello/:name\", mw.NoLogging(hello))\n\n\trouter.Handle(\"GET\", \"/json\", mw.JSON(jsonTest))\n\n\trouter.Handle(\"GET\", \"/localmw\", mw.JSON(localMw(getlocalmw)),\n\t)\n\n\trouter.Handle(\"GET\", \"/localmw2\", mw.NoLogging(mw.JSON(getlocalmw2)),\n\t)\n\n\trouter.Handle(\"GET\", \"/test\",\n\t\tmw.VersionedRoute(mw.VersionedRouteMap{\n\t\t\t\"default\": testGet,\n\n\t\t\t\"v1\": testGetv1,\n\n\t\t\t\"v2\": testGet,\n\t\t}),\n\t)\n\n}", "func RegisterAPIRoutes(g *echo.Group, bind context.Binder) {\n\t// Store endpoints first since they are the most active\n\t//e.GET(\"/api/store/\", storeGetView)\n\t//e.POST(\"/api/store/\", storePostView)\n\n\t// TODO Can not register same handler for two different routes\n\t//g = g.Group(\"/store\")\n\t//g.GET(\"/\", storeGetView)\n\t//g.POST(\"/\", storePostView)\n\t// :project_id is [\\w_-]+\n\tg = g.Group(\"/:project_id/store\")\n\tg.GET(\"/\", storeGetView)\n\tg.POST(\"/\", bind.Base(storePostView))\n\t// :project_id is \\d+\n\tg = g.Group(\"/:project_id/csp-report\")\n\t// TODO is CspReportGetView needed?\n\tg.GET(\"/\", cspReportGetView)\n\tg.POST(\"/\", cspReportPostView)\n}", "func getRoutes() {\n\tv1 := router.Group(\"/v1\")\n\taddUserRoutes(v1)\n\taddPingRoutes(v1)\n\n\tv2 := router.Group(\"/v2\")\n\taddPingRoutes(v2)\n}", "func (c *MysqlUserController) Routes() openapi.Routes {\n\troutes := openapi.Routes{\n\t\t{\n\t\t\tName: \"CreateUser\",\n\t\t\tMethod: strings.ToUpper(\"Post\"),\n\t\t\tPattern: \"/user\",\n\t\t\tHandlerFunc: c.CreateUser,\n\t\t},\n\t\t{\n\t\t\tName: \"DeleteUser\",\n\t\t\tMethod: strings.ToUpper(\"Delete\"),\n\t\t\tPattern: \"/user/{user}\",\n\t\t\tHandlerFunc: c.DeleteUser,\n\t\t},\n\t\t{\n\t\t\tName: \"GetUserByName\",\n\t\t\tMethod: strings.ToUpper(\"Get\"),\n\t\t\tPattern: \"/user/{user}\",\n\t\t\tHandlerFunc: c.GetUserByName,\n\t\t},\n\t\t{\n\t\t\tName: \"GetUsers\",\n\t\t\tMethod: strings.ToUpper(\"Get\"),\n\t\t\tPattern: \"/user\",\n\t\t\tHandlerFunc: c.GetUsers,\n\t\t},\n\t}\n\treturn routes\n}", "func (c *UserAPIController) Routes() Routes {\n\treturn Routes{\n\t\t\"CreateUser\": Route{\n\t\t\tstrings.ToUpper(\"Post\"),\n\t\t\t\"/v2/user\",\n\t\t\tc.CreateUser,\n\t\t},\n\t\t\"CreateUsersWithArrayInput\": Route{\n\t\t\tstrings.ToUpper(\"Post\"),\n\t\t\t\"/v2/user/createWithArray\",\n\t\t\tc.CreateUsersWithArrayInput,\n\t\t},\n\t\t\"CreateUsersWithListInput\": Route{\n\t\t\tstrings.ToUpper(\"Post\"),\n\t\t\t\"/v2/user/createWithList\",\n\t\t\tc.CreateUsersWithListInput,\n\t\t},\n\t\t\"DeleteUser\": Route{\n\t\t\tstrings.ToUpper(\"Delete\"),\n\t\t\t\"/v2/user/{username}\",\n\t\t\tc.DeleteUser,\n\t\t},\n\t\t\"GetUserByName\": Route{\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/v2/user/{username}\",\n\t\t\tc.GetUserByName,\n\t\t},\n\t\t\"LoginUser\": Route{\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/v2/user/login\",\n\t\t\tc.LoginUser,\n\t\t},\n\t\t\"LogoutUser\": Route{\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/v2/user/logout\",\n\t\t\tc.LogoutUser,\n\t\t},\n\t\t\"UpdateUser\": Route{\n\t\t\tstrings.ToUpper(\"Put\"),\n\t\t\t\"/v2/user/{username}\",\n\t\t\tc.UpdateUser,\n\t\t},\n\t}\n}", "func ApplyRoutes(r *gin.Engine) {\n\troutes := r.Group(\"/api\")\n\t{\n\t\tauth.ApplyRoutes(routes)\n\t\tposts.ApplyRoutes(routes)\n\t\ttopic.ApplyRoutes(routes)\n\t}\n}", "func GetRoutes() *httprouter.Router {\n\trouter := httprouter.New()\n\t///////////////////////////////////////////////////////////\n\t// Main application routes\n\t///////////////////////////////////////////////////////////\n\n\tapplication := controllers.Application{}\n\trouter.GET(\"/\", route(application.Index))\n\trouter.GET(\"/api/products\", route(application.AllProducts))\n\trouter.GET(\"/api/products/match\", route(application.Match))\n\n\t///////////////////////////////////////////////////////////\n\t// Static routes\n\t// Caching Static files\n\t///////////////////////////////////////////////////////////\n\tfileServer := http.FileServer(http.Dir(\"public\"))\n\trouter.GET(\"/static/*filepath\", gzip.Middleware(func(res http.ResponseWriter, req *http.Request, pm httprouter.Params) {\n\t\tres.Header().Set(\"Vary\", \"Accept-Encoding\")\n\t\tres.Header().Set(\"Cache-Control\", \"public, max-age=7776000\")\n\t\treq.URL.Path = pm.ByName(\"filepath\")\n\t\tfileServer.ServeHTTP(res, req)\n\t}))\n\treturn router\n}", "func (p *Endpoint) Routes(router component.IRouter) {\n\trouter.Post(\"/v1/user\", p.Create)\n\trouter.Get(\"/v1/user/:user_id\", p.Show)\n\trouter.Get(\"/v1/userSelf\", p.ShowSelf)\n\trouter.Get(\"/v1/user\", p.Index)\n\trouter.Put(\"/v1/user/:user_id\", p.Update)\n\trouter.Delete(\"/v1/user/:user_id\", p.Destroy)\n\trouter.Delete(\"/v1/user\", p.DestroyAll)\n}", "func (c *BookingsApiController) Routes() Routes {\n\treturn Routes{ \n\t\t{\n\t\t\t\"AcceptAgencyOffer\",\n\t\t\tstrings.ToUpper(\"Put\"),\n\t\t\t\"/vms/api/v1/bookingRequests/{bookingRequestId}/offers/{offerId}/accept\",\n\t\t\tc.AcceptAgencyOffer,\n\t\t},\n\t\t{\n\t\t\t\"CancelBooking\",\n\t\t\tstrings.ToUpper(\"Delete\"),\n\t\t\t\"/vms/api/v1/bookings/{bookingId}\",\n\t\t\tc.CancelBooking,\n\t\t},\n\t\t{\n\t\t\t\"CancelBookingRequest\",\n\t\t\tstrings.ToUpper(\"Delete\"),\n\t\t\t\"/vms/api/v1/bookingRequests/{bookingRequestId}\",\n\t\t\tc.CancelBookingRequest,\n\t\t},\n\t\t{\n\t\t\t\"GetBooking\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/vms/api/v1/bookings/{bookingId}\",\n\t\t\tc.GetBooking,\n\t\t},\n\t}\n}", "func SetupApiRoutes(r *mux.Router, cache job.JobCache, defaultOwner string, disableDeleteAll bool,\n\tdisableLocalJobs bool) {\n\t// Route for creating a job\n\tr.HandleFunc(ApiJobPath, HandleAddJob(cache, defaultOwner, disableLocalJobs)).Methods(httpPost)\n\t// Route for deleting all jobs\n\tr.HandleFunc(ApiJobPath+\"all/\", HandleDeleteAllJobs(cache, disableDeleteAll)).Methods(httpDelete)\n\t// Route for deleting, editing and getting a job\n\tr.HandleFunc(ApiJobPath+\"{id}/\", HandleJobRequest(cache, disableLocalJobs)).Methods(httpDelete, httpGet, httpPut)\n\t// Route for updating a remote job's parameters.\n\tr.HandleFunc(ApiJobPath+\"{id}/params/\", HandleJobParamsRequest(cache)).Methods(httpGet, httpPut)\n\t// Route for listing all jops\n\tr.HandleFunc(ApiJobPath, HandleListJobsRequest(cache)).Methods(httpGet)\n\t// Route for manually start a job\n\tr.HandleFunc(ApiJobPath+\"start/{id}/\", HandleStartJobRequest(cache)).Methods(httpPost)\n\t// Route for manually start a job\n\tr.HandleFunc(ApiJobPath+\"enable/{id}/\", HandleEnableJobRequest(cache)).Methods(httpPost)\n\t// Route for manually disable a job\n\tr.HandleFunc(ApiJobPath+\"disable/{id}/\", HandleDisableJobRequest(cache)).Methods(httpPost)\n\t// Route for getting app-level metrics\n\tr.HandleFunc(ApiUrlPrefix+\"stats/\", HandleKalaStatsRequest(cache)).Methods(httpGet)\n\t// Route for a single job execution actions\n\tr.HandleFunc(ApiJobPath+\"{job_id}/executions/{id}/\", HandleJobRunRequest(cache)).Methods(httpGet, httpPut)\n\t// Route for a single job execution actions\n\tr.HandleFunc(ApiJobPath+\"{id}/executions/\", HandleListJobRunsRequest(cache)).Methods(httpGet)\n\tr.Use(job.AuthHandler)\n}", "func (rs dashboardResource) Routes() chi.Router {\n\tr := chi.NewRouter()\n\t// r.Use() // some middleware..\n\n\tr.Get(\"/:page\", rs.List) // GET /todos - read a list of todos\n\treturn r\n}", "func (c *GetImagesByAlbumApiController) Routes() Routes {\n\treturn Routes{\n\t\t{\n\t\t\t\"GetImagesByAlbum\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/albums/{id}/images\",\n\t\t\tc.GetImagesByAlbum,\n\t\t},\n\t}\n}", "func (handler *Handler) GetRoutes() []routing.Route {\n\n\t//Provide the user update and documentation by default\n\tvar routes = make([]routing.Route, 0)\n\n\t//If the user can create users append the routes\n\tif handler.allowUserCreation {\n\n\t\troutes = append(routes,\n\t\t\trouting.Route{ //Now for the user info\n\t\t\t\tName: \"UserCreate\",\n\t\t\t\tMethod: \"POST\",\n\t\t\t\tPattern: \"/users/new\",\n\t\t\t\tHandlerFunc: handler.handleUserCreate,\n\t\t\t\tPublic: true,\n\t\t\t},\n\t\t\trouting.Route{ //Allow the user to turn on their account\n\t\t\t\tName: \"User Activate\",\n\t\t\t\tMethod: \"POST\",\n\t\t\t\tPattern: \"/users/activate\",\n\t\t\t\tHandlerFunc: handler.handleUserActivationPut,\n\t\t\t\tPublic: true,\n\t\t\t},\n\t\t\trouting.Route{ //Allow the user to turn on their account\n\t\t\t\tName: \"User Activate\",\n\t\t\t\tMethod: \"GET\",\n\t\t\t\tPattern: \"/users/activate\",\n\t\t\t\tHandlerFunc: handler.handleUserActivationGet,\n\t\t\t\tPublic: true,\n\t\t\t},\n\t\t\trouting.Route{ //Allow the user to turn on their account\n\t\t\t\tName: \"Get User Activation Token\",\n\t\t\t\tMethod: \"GET\",\n\t\t\t\tPattern: \"/users/activate\",\n\t\t\t\tHandlerFunc: handler.handleUserActivationPut,\n\t\t\t\tPublic: true,\n\t\t\t},\n\t\t\trouting.Route{ //Allow for the user to get an update of them selves\n\t\t\t\tName: \"PasswordChange\",\n\t\t\t\tMethod: \"POST\",\n\t\t\t\tPattern: \"/users/password/change\",\n\t\t\t\tHandlerFunc: handler.handlePasswordUpdate,\n\t\t\t\tPublic: false,\n\t\t\t},\n\t\t\trouting.Route{ //Allow for the user to ask for a password change\n\t\t\t\tName: \"PasswordResetGet\",\n\t\t\t\tMethod: \"GET\",\n\t\t\t\tPattern: \"/users/password/reset\",\n\t\t\t\tHandlerFunc: handler.handlePasswordResetGet,\n\t\t\t\tPublic: true,\n\t\t\t},\n\t\t\trouting.Route{ //Allow the user to set their password\n\t\t\t\tName: \"PasswordResetPost\",\n\t\t\t\tMethod: \"POST\",\n\t\t\t\tPattern: \"/users/password/reset\",\n\t\t\t\tHandlerFunc: handler.handlePasswordResetPut,\n\t\t\t\tPublic: true,\n\t\t\t},\n\t\t)\n\n\t}\n\n\t//Add in the normal routes\n\troutes = append(routes,\n\t\trouting.Route{ //Allow for the user to login\n\t\t\tName: \"UserLogin\",\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/users/login\",\n\t\t\tHandlerFunc: handler.handleUserLogin,\n\t\t\tPublic: true,\n\t\t},\n\t\trouting.Route{ //Allow for the user to login\n\t\t\tName: \"User Api Documentation\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/api/users\",\n\t\t\tHandlerFunc: handler.handleUserDocumentation,\n\t\t\tPublic: true,\n\t\t},\n\t\trouting.Route{ //Allow for the user to update them selves\n\t\t\tName: \"UserUpdate\",\n\t\t\tMethod: \"PUT\",\n\t\t\tPattern: \"/users/\",\n\t\t\tHandlerFunc: handler.handleUserUpdate,\n\t\t\tPublic: false,\n\t\t},\n\t\trouting.Route{ //Allow for the user to get an update of them selves\n\t\t\tName: \"UserGet\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/users/\",\n\t\t\tHandlerFunc: handler.handleUserGet,\n\t\t\tPublic: false,\n\t\t},\n\t)\n\n\treturn routes\n\n}", "func (d *API) Routes(middlewares ...rest.Middleware) []*rest.Route {\n\troutes := []*rest.Route{\n\t\trest.Get(\"/state\", d.checkState),\n\t}\n\n\tfor _, route := range routes {\n\t\troute.Func = rest.WrapMiddlewares(middlewares, route.Func)\n\t}\n\treturn routes\n}", "func (api *API) routes() *chi.Mux {\n\trouter := chi.NewRouter()\n\trouter.NotFound(rest.HandleNotFound(api.Logger))\n\trouter.MethodNotAllowed(rest.HandleMethodNotAllowed(api.Logger))\n\n\t// Init middlewares - Do any set up of shared/third-party middleware and handlers\n\tif api.Cfg.REST.CompressionLevel > 0 {\n\t\tapi.Logger.Debug(\"using compression for all http routes\", zap.Int(\"level\", api.Cfg.REST.CompressionLevel))\n\t\trouter.Use(chimiddleware.Compress(api.Cfg.REST.CompressionLevel))\n\t}\n\n\tinstrument := middleware.NewInstrument(api.Cfg.MetricsNamespace)\n\trecoverer := middleware.Recoverer{Logger: api.Logger}\n\trouter.Use(\n\t\tmiddleware.Intercept,\n\t\trecoverer.Wrap,\n\t\tchimiddleware.RealIP,\n\t\tchimiddleware.URLFormat,\n\t\tinstrument.Wrap,\n\t\tchimiddleware.Timeout(15*time.Second),\n\t)\n\n\tif api.Cfg.PrintAccessLogs {\n\t\ta := middleware.NewAccessLog(api.Logger)\n\t\trouter.Use(a.Wrap)\n\t}\n\n\t// Private routes - these should only be accessible from within Kubernetes or a protected ingress\n\trouter.Group(func(r chi.Router) {\n\t\tr.Route(\"/admin\", func(r chi.Router) {\n\t\t\tr.Handle(\"/metrics\", promhttp.Handler())\n\t\t\tr.Handle(\"/health\", healthhttp.HandleHealthJSON(api.health))\n\t\t})\n\n\t\t// Path must be prefixed with /debug otherwise it will be overriden, see: https://golang.org/pkg/net/http/pprof/\n\t\tr.Mount(\"/debug\", chimiddleware.Profiler())\n\t})\n\n\t// API routes\n\trouter.Group(func(r chi.Router) {\n\t\tapi.Hooks.Route.ConfigAPIRouter(r)\n\n\t\tr.Route(\"/api\", func(r chi.Router) {\n\t\t\tr.Get(\"/cluster\", api.handleDescribeCluster())\n\t\t\tr.Get(\"/topics\", api.handleGetTopics())\n\t\t\tr.Get(\"/topics/{topicName}/partitions\", api.handleGetPartitions())\n\t\t\tr.Get(\"/topics/{topicName}/messages\", api.handleGetMessages())\n\t\t\tr.Get(\"/topics/{topicName}/configuration\", api.handleGetTopicConfig())\n\t\t\tr.Get(\"/consumer-groups\", api.handleGetConsumerGroups())\n\t\t})\n\t})\n\n\tif api.Cfg.REST.ServeFrontend {\n\t\t// Check if the frontend directory 'build' exists\n\t\tdir, err := filepath.Abs(\"./build\")\n\t\tif err != nil {\n\t\t\tapi.Logger.Fatal(\"given frontend directory is invalid\", zap.String(\"directory\", dir), zap.Error(err))\n\t\t}\n\n\t\t// SPA Files\n\t\tindex, err := api.getIndexFile(dir)\n\t\tif err != nil {\n\t\t\tapi.Logger.Fatal(\"cannot load frontend index file\", zap.String(\"directory\", dir), zap.Error(err))\n\t\t}\n\t\trouter.Group(func(r chi.Router) {\n\t\t\tapi.Hooks.Route.ConfigFrontendRouter(r)\n\t\t\tr.Use(cache)\n\n\t\t\tr.Get(\"/\", api.handleGetIndex(index))\n\t\t\tr.Get(\"/*\", api.handleGetStaticFile(index, dir))\n\t\t})\n\t} else {\n\t\tapi.Logger.Info(\"no static files will be served as serving the frontend has been disabled\")\n\t}\n\n\treturn router\n}", "func (s *Server) routes() {\n\ts.router.HandleFunc(\"/api/\", s.checkJWT(s.isAdmin(s.handleAPI()))).Methods(\"GET\")\n\ts.router.HandleFunc(\"/greetings\", s.handleGreeting(\"hello\"))\n\ts.router.HandleFunc(\"/greetings/{name}\", s.handleGreeting(\"hello\")).Methods(\"GET\")\n\ts.router.HandleFunc(\"/\", s.handleIndex()).Methods(\"GET\")\n}", "func GetRoutes(router *gin.Engine) {\n\n\trouter.GET(\"/test\", func(ctx *gin.Context) {\n\t\tctx.JSON(200, gin.H{\n\t\t\t\"message\": \"OK!\",\n\t\t})\n\t})\n\n\tuserRoutes := router.Group(\"/user\")\n\tuserRoutes.POST(\"/\", controller.AddUser)\n\tuserRoutes.GET(\"/:id\", controller.GetUser)\n\tuserRoutes.PUT(\"/:id\", controller.UpdateUser)\n\tuserRoutes.DELETE(\"/:id\", controller.DeleteUser)\n\n\twowRoutes := router.Group(\"/wow\")\n\twowRoutes.POST(\"/validate\", controller.Validate)\n\n\trouter.POST(\"/upload\", uploadFile)\n}", "func ApplyRoutes(r *gin.RouterGroup) {\n\tr.GET(\"/status\", GetStatus)\n\tr.GET(\"/status-page\", GetStatusPage)\n\tr.GET(\"/info\", GetInfo)\n}", "func Routes(router chi.Router) {\n\trouter.Get(\"/\", IndexHandeler)\n\n\trouter.Method(http.MethodGet, \"/talks\", Handler(getAllScheduledTalksHandler))\n\trouter.Method(http.MethodPost, \"/talks\", Handler(scheduleTalkHandler))\n}", "func AddRoutes(app *server.App) {\n\t// Internal routes\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /phone\",\n\t\tType: server.RouteTypeCustom,\n\t\tPublic: true,\n\t\tNoProtoCheck: true,\n\t\tHandler: controllers.PhoneController,\n\t}, server.RouteInternal)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /locked\",\n\t\tType: server.RouteTypeCustom,\n\t\tPublic: true,\n\t\tNoProtoCheck: true,\n\t\tHandler: controllers.LockedController,\n\t}, server.RouteInternal)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /cloud-init/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tPublic: true,\n\t\tNoProtoCheck: true,\n\t\tHandler: controllers.CloudInitController,\n\t}, server.RouteInternal)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /env\",\n\t\tType: server.RouteTypeCustom,\n\t\tPublic: true,\n\t\tNoProtoCheck: true,\n\t\tHandler: controllers.EnvController,\n\t}, server.RouteInternal)\n\n\t// API routes\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /log/history\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetLogHistoryController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /log\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.LogController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /vm\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListVMsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /vm/search\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.SearchVMsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /vm/config/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetVMConfigController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /vm/infos/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetVMInfosController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /vm/do-actions/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetVMDoActionsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /vm/console/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetVMConsoleController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /vm\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.NewVMSyncController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /vm-async\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.NewVMAsyncController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /vm/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.ActionVMController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"DELETE /vm/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.DeleteVMController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /version\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.VersionController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /seed\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListSeedController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /seed/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetSeedStatusController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /seed/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.ActionSeedController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /backup\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListBackupsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /backup\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.UploadBackupController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /backup/expire/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.SetBackupExpireController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /backup/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.DownloadBackupController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"DELETE /backup/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.DeleteBackupController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /key\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListKeysController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /key\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.NewKeyController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /key/right/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListKeyRightsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /key/right/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.NewKeyRightController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"DELETE /key/right/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.DeleteKeyRightController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /sshpair\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetKeyPairController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /status\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetStatusController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /state/zip\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetStateZipController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /peer\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListPeersController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /secret\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListSecretsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /secret/*\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.GetSecretController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /secret/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.SetSecretController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"DELETE /secret/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.DeleteSecretController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"POST /secret-sync\",\n\t\tHandler: controllers.SyncSecretsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /vm/with-secret/*\",\n\t\tHandler: controllers.GetVMsUsingSecretsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"GET /greenhouse\",\n\t\tType: server.RouteTypeCustom,\n\t\tHandler: controllers.ListGreenhouseVMsController,\n\t}, server.RouteAPI)\n\n\tapp.AddRoute(&server.Route{\n\t\tRoute: \"DELETE /greenhouse/*\",\n\t\tType: server.RouteTypeStream,\n\t\tHandler: controllers.AbordGreenhouseVMController,\n\t}, server.RouteAPI)\n\n}", "func (srv *VerbHandler) Routes() http.Handler {\n\n\tr := chi.NewRouter()\n\n\tr.Get(\"/\", srv.GetAll)\n\n\tr.Get(\"/exam\", srv.GetExam)\n\n\treturn r\n}", "func (c *WorkerDataApiController) Routes() Routes {\n\treturn Routes{ \n\t\t{\n\t\t\t\"RegisterWorker\",\n\t\t\tstrings.ToUpper(\"Post\"),\n\t\t\t\"/api/worker/v1/workers\",\n\t\t\tc.RegisterWorker,\n\t\t},\n\t}\n}", "func (c *controller) Routes() []web.Route {\n\treturn []web.Route{\n\t\t{\n\t\t\tPath: web.UsersURL,\n\t\t\tMethod: http.MethodGet,\n\t\t\tHandleFunc: c.listUsers,\n\t\t},\n\t\t{\n\t\t\tPath: web.UsersURL + \"/{id}\",\n\t\t\tMethod: http.MethodGet,\n\t\t\tHandleFunc: c.getUser,\n\t\t},\n\t\t{\n\t\t\tPath: web.UsersURL + \"/{id}\",\n\t\t\tMethod: http.MethodPatch,\n\t\t\tHandleFunc: c.patchUser,\n\t\t},\n\t\t{\n\t\t\tPath: web.UsersURL + \"/{id}\",\n\t\t\tMethod: http.MethodDelete,\n\t\t\tHandleFunc: c.deleteUser,\n\t\t},\n\t}\n}", "func AllRoutes() *mux.Router {\n\tvar AllRoutes = mux.NewRouter()\n\tAllRoutes.HandleFunc(\"/songs\", authMidware(songList)).Methods(\"GET\")\n\tAllRoutes.HandleFunc(\"/song/{id}\", authMidware(downloadSong)).Methods(\"GET\")\n\tAllRoutes.HandleFunc(\"/song\", authMidware(uploadSong)).Methods(\"POST\")\n\tAllRoutes.HandleFunc(\"/song/{id}\", authMidware(deleteSong)).Methods(\"DELETE\")\n\tAllRoutes.HandleFunc(\"/user/new\", newUser).Methods(\"POST\")\n\tAllRoutes.HandleFunc(\"/auth/login\", login).Methods(\"POST\")\n\tAllRoutes.HandleFunc(\"/auth/validate\", validate).Methods(\"GET\")\n\tAllRoutes.HandleFunc(\"/auth/google/token\", authMidware(updateAuthToken)).Methods(\"POST\")\n\n\treturn AllRoutes\n}", "func (Bgp) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/bgp/amazon_vpc/\",\n\t\t\"/api/objects/bgp/amazon_vpc/{ref}\",\n\t\t\"/api/objects/bgp/amazon_vpc/{ref}/usedby\",\n\t\t\"/api/objects/bgp/filter/\",\n\t\t\"/api/objects/bgp/filter/{ref}\",\n\t\t\"/api/objects/bgp/filter/{ref}/usedby\",\n\t\t\"/api/objects/bgp/group/\",\n\t\t\"/api/objects/bgp/group/{ref}\",\n\t\t\"/api/objects/bgp/group/{ref}/usedby\",\n\t\t\"/api/objects/bgp/neighbor/\",\n\t\t\"/api/objects/bgp/neighbor/{ref}\",\n\t\t\"/api/objects/bgp/neighbor/{ref}/usedby\",\n\t\t\"/api/objects/bgp/route_map/\",\n\t\t\"/api/objects/bgp/route_map/{ref}\",\n\t\t\"/api/objects/bgp/route_map/{ref}/usedby\",\n\t\t\"/api/objects/bgp/system/\",\n\t\t\"/api/objects/bgp/system/{ref}\",\n\t\t\"/api/objects/bgp/system/{ref}/usedby\",\n\t}\n}", "func (s *Server) Routes() {\n\tvar routes = Routes{\n\t\tRoute{\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/plan/{planId}\",\n\t\t\tHandlerFunc: s.GetPlan(),\n\t\t},\n\t\tRoute{\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/plan\",\n\t\t\tHandlerFunc: s.SavePlan(),\n\t\t},\n\t\tRoute{\n\t\t\tMethod: \"PUT\",\n\t\t\tPattern: \"/plan/{planId}\",\n\t\t\tHandlerFunc: s.UpdatePlan(),\n\t\t},\n\t\tRoute{\n\t\t\tMethod: \"DELETE\",\n\t\t\tPattern: \"/plan/{planId}\",\n\t\t\tHandlerFunc: s.DeletePlan(),\n\t\t},\n\t\tRoute{\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/userplans/{userId}\",\n\t\t\tHandlerFunc: s.GetUserPlans(),\n\t\t},\n\t\tRoute{\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/userfav/{userId}\",\n\t\t\tHandlerFunc: s.GetUsersFavorites(),\n\t\t},\n\t\tRoute{\n\t\t\tMethod: \"POST\",\n\t\t\tPattern: \"/userfav/{userId}/plan\",\n\t\t\tHandlerFunc: s.AddFavorite(),\n\t\t},\n\t\tRoute{\n\t\t\tMethod: \"DELETE\",\n\t\t\tPattern: \"/userfav/{userId}/plan/{planId}\",\n\t\t\tHandlerFunc: s.DelFavorite(),\n\t\t},\n\t}\n\n\tfor _, route := range routes {\n\t\tvar handler http.HandlerFunc\n\t\thandler = route.HandlerFunc\n\t\thandler = Logger(handler)\n\n\t\ts.Router.\n\t\t\tMethods(route.Method).\n\t\t\tPath(route.Pattern).\n\t\t\tHandler(handler)\n\n\t}\n}", "func (c *TempController) GetRoutes() Routes {\n\troutes := Routes{\n\t\tRoute{Name: \"GetCurrentTemperature\", Method: \"GET\", Pattern: \"/thermometer/temperature/now\", HandlerFunc: c.GetCurrentTemperature},\n\t\tRoute{Name: \"GetTemperatureHistory\", Method: \"GET\", Pattern: \"/thermometer/temperature\", HandlerFunc: c.GetHistoricalTemperatures},\n\t\tRoute{Name: \"Poll\", Method: \"PUT\", Pattern: \"/thermometer/poll\", HandlerFunc: c.Poll},\n\t}\n\n\treturn routes\n}", "func (controller *EchoController) GetRoutes() []string {\n\treturn []string{\n\t\t\"echo\",\n\t\t\"echo/{{toEcho}}\",\n\t}\n}", "func loadAPIEndpoints(router router.Router, repo api.Repository, ntf notifier.Notifier, guard jwt.Guard) {\n\tlog.Debug(\"Loading API Endpoints\")\n\n\t// Apis endpoints\n\thandler := api.NewController(repo, ntf)\n\tgroup := router.Group(\"/apis\")\n\tgroup.Use(jwt.NewMiddleware(guard).Handler)\n\t{\n\t\tgroup.GET(\"/\", handler.Get())\n\t\tgroup.GET(\"/{name}\", handler.GetBy())\n\t\tgroup.POST(\"/\", handler.Post())\n\t\tgroup.PUT(\"/{name}\", handler.PutBy())\n\t\tgroup.DELETE(\"/{name}\", handler.DeleteBy())\n\t}\n}", "func GetRoutes() *mux.Router {\n\trouter := mux.NewRouter()\n\trouter.HandleFunc(\"/api/V1/getInfoCurp/{encode_curp}\", getInfoCurp).Name(\"getInfoCurp\").Methods(\"GET\")\n\treturn router\n}", "func (h *ShortenerHandler) GetRoutes() chi.Router {\n\trouter := chi.NewRouter()\n\n\trouter.Post(\"/\", h.Store)\n\trouter.Get(\"/{shortURL}\", h.Find)\n\n\treturn router\n}", "func (a AuthController) GetRoutes() []Route {\n\treturn []Route{\n\t\t{\n\t\t\tPath: \"/authenticate\",\n\t\t\tMethod: []string{\"POST\"},\n\t\t\tHandler: a.Authenticate,\n\t\t},\n\t\t{\n\t\t\tPath: \"/logout\",\n\t\t\tMethod: []string{\"GET\"},\n\t\t\tHandler: a.Authenticate,\n\t\t},\n\t}\n}", "func (a *App) apiRoute(e *echo.Echo) error {\n\tapiUrl, err := a.conf.Get(\"api-url\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t//General API\n\tg := e.Group(apiUrl.(string))\n\t//auth\n\tg.Post(\"/auth\", a.login)\n\t//oauth\n\ta.fb, err = oauth.NewFacebook(a)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfbg := g.Group(\"/oauth\")\n\tfbg.Get(\"/facebook\", a.facebookAuth)\n\tfbg.Get(\"/facebook/redirect\", a.facebookRedirect)\n\t//tasks\n\ttokenizer := jwt.NewTokenizer(a)\n\ttg := g.Group(\"/tasks\", tokenizer.Check())\n\ttg.Post(\"\", a.create)\n\ttg.Get(\"/:id\", a.retrieve)\n\ttg.Get(\"\", a.retrieveAll)\n\ttg.Put(\"/:id\", a.update)\n\ttg.Delete(\"/:id\", a.delete)\n\treturn nil\n}", "func ApplyRoutes(r *gin.Engine, auth *auth.Authenticator, db *gorm.DB) {\n\tmodels.SetRepoDB(db)\n\tauthenticator = auth\n\tapiV1 := r.Group(\"/v1\")\n\t{\n\t\tapiV1.GET(\"/ping\", pingHandler)\n\t\tapiV1.POST(\"/login\", loginHandler)\n\t\tapiV1.POST(\"/comment\", commentHandler)\n\t\tapiV1.DELETE(\"/comment\", commentHandler)\n\t\tapiV1.POST(\"/users\", userHandler)\n\t\tapiV1.DELETE(\"/users\", userHandler)\n\n\t}\n}", "func (h *Command) Routes() rest.Routes {\n\treturn rest.Routes{\n\t\t// HelloWorld\n\t\trest.Route{\n\t\t\tName: \"Hello\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/hello\",\n\t\t\tHandlerFunc: h.hello},\n\t}\n}", "func (ro *Router) Routes() []routes.Route {\n\tmyRoutes := make([]routes.Route, 0)\n\n\tr := routes.Route{}\n\tr.Handler = ByeHandler\n\tr.Method = \"GET\"\n\tr.Path = \"/api/bye\"\n\tr.Middleware = []vestigo.Middleware{\n\t\tPluginLogger,\n\t\tPluginLogger2,\n\t}\n\n\tmyRoutes = append(myRoutes, r)\n\n\treturn myRoutes\n}", "func InitRoutes() *mux.Router {\n\trouter := mux.NewRouter()\n\n\trouter.HandleFunc(\"/questions\", controllers.GetQuestions).Methods(\"GET\")\n\trouter.HandleFunc(\"/answers\", controllers.ProcessAnswers).Methods(\"POST\")\n\n\treturn router\n}", "func Routes(e *echo.Echo) {\n\n\te.GET(\"/status\", func(c echo.Context) error {\n\t\tc.Logger().Debug(\"debug me...\\n\")\n\t\tc.Logger().Info(\"info me...\")\n\t\tc.Logger().Error(\"error me...\")\n\t\treturn c.JSON(200, \"API is Running....\")\n\t})\n\n\t//MYSQL CRUD\n\te.GET(\"/users\", handlers.ListUsers) //To List all the users\n\te.POST(\"/user\", handlers.AddUser) //To add a new user\n\te.PUT(\"/user/:id\", handlers.UpdateUser) //To update record of existing user\n\te.DELETE(\"/user/:id\", handlers.DeleteUser) //To delete record of existing user\n}", "func mapRoutes() {\n\t//http.HandleFunc(\"/user\", controllers.GetUser)\n}", "func InitRoutes(router *mux.Router) *mux.Router {\n\tlogger = log.Logger(\"apps.app\")\n\tappRouter := router.PathPrefix(\"/v1/cloud\").Subrouter()\n\tappRouter.Use(format.FormatResponseMiddleware)\n\tappRouter.HandleFunc(\"/region\", getRegion).Methods(\"GET\")\n\tappRouter.HandleFunc(\"/region\", createRegion).Methods(\"POST\")\n\tappRouter.HandleFunc(\"/sync\", syncHost).Methods(\"POST\")\n\treturn router\n}", "func Handlers() *httprouter.Router {\n\n\t// Create a new router\n\tr := apirouter.New()\n\n\t// Based on service mode\n\tif config.Values.ServiceMode == config.ServiceModeAPI {\n\t\t// r.CrossOriginAllowOriginAll = false\n\t\t// r.CrossOriginAllowOrigin = \"*\"\n\n\t\t// This is used for the \"Origin\" to be returned as the origin\n\t\tr.CrossOriginAllowOriginAll = true\n\n\t\t// Create a middleware stack:\n\t\t// s := apirouter.NewStack()\n\n\t\t// Use your middleware:\n\t\t// s.Use(passThrough)\n\n\t\tapi.RegisterRoutes(r)\n\t\tpersons.RegisterRoutes(r)\n\n\t} // else (another service mode?)\n\n\t// Return the router\n\treturn r.HTTPRouter.Router\n}", "func (c *Command) Routes() []types.RouteDetails {\n\treturn []types.RouteDetails{\n\t\ttypes.RouteDetails{\n\t\t\tEnabled: true, Path: \"\", Verb: \"GET\",\n\t\t\tHandler: c.GetAll,\n\t\t},\n\t\ttypes.RouteDetails{\n\t\t\tEnabled: true, Path: \"/:name\", Verb: \"GET\",\n\t\t\tHandler: c.GetSingle,\n\t\t},\n\t\ttypes.RouteDetails{\n\t\t\tEnabled: true, Path: \"/:name\", Verb: \"PATCH\",\n\t\t\tHandler: c.Update,\n\t\t},\n\t\ttypes.RouteDetails{\n\t\t\tEnabled: true, Path: \"/:name\", Verb: \"POST\",\n\t\t\tHandler: c.Create,\n\t\t},\n\t\ttypes.RouteDetails{\n\t\t\tEnabled: true, Path: \"/:name\", Verb: \"DELETE\",\n\t\t\tHandler: c.Delete,\n\t\t},\n\t}\n}", "func (c *cfService) Routes() Routes {\n\treturn newRouteAPI(c.Client)\n}", "func (s *Service) GetRoutes() []Route {\n\treturn []Route{\n\t\t{\n\t\t\tName: \"health_check\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/index\",\n\t\t\tHandlerFunc: s.index,\n\t\t},\n\t}\n}", "func InitRoutes(router *mux.Router) {\n\t//ping\n\trouter.HandleFunc(\"/ping\", ping).Methods(\"GET\")\n\n\t// modules routes\n\t// add new currency\n\trouter.HandleFunc(\"/v1/currency/addremove\", currency.AddRemoveCurrency).Methods(\"POST\")\n\t// get all currency\n\trouter.HandleFunc(\"/v1/currency/get\", currency.GetCurrency).Methods(\"GET\")\n\t// add new currency rates\n\trouter.HandleFunc(\"/v1/currency_rates/add\", currency.AddCurrencyRates).Methods(\"POST\")\n\t// get specific currency rates\n\trouter.HandleFunc(\"/v1/currency_rates/get/{date}\", currency.GetCurrencyRates).Methods(\"GET\")\n\t// get trend\n\trouter.HandleFunc(\"/v1/currency_rates/get/trend\", currency.GetCurrencyRatesTrend).Methods(\"POST\")\n\n\t// go templating routes\n\n\t// not found\n\trouter.MethodNotAllowedHandler = http.HandlerFunc(notfound)\n}", "func Routes(store Storager) {\n\thttp.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tHandleRootReuest(w, r, store)\n\t})\n}", "func (c *CommentApiController) Routes() Routes {\n\treturn Routes{\n\t\t{\n\t\t\t\"CreateComment\",\n\t\t\tstrings.ToUpper(\"Post\"),\n\t\t\t\"/v1/comments\",\n\t\t\tc.CreateComment,\n\t\t},\n\t\t{\n\t\t\t\"GetComment\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/v1/comments/{id}\",\n\t\t\tc.GetComment,\n\t\t},\n\t\t{\n\t\t\t\"GetUserComments\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/v1/users/{username}/comments\",\n\t\t\tc.GetUserComments,\n\t\t},\n\t\t{\n\t\t\t\"GetUserFeed\",\n\t\t\tstrings.ToUpper(\"Get\"),\n\t\t\t\"/v1/feed\",\n\t\t\tc.GetUserFeed,\n\t\t},\n\t}\n}", "func InitRoutes(e *gin.Engine) {\n\t// Default Routes\n\te.GET(APIPrefix+DefaultPrefix, defaultControllers.GetDefault)\n\n\t// Env Routes\n\te.GET(APIPrefix+EnvPrefix+\"/\", envController.GetEnv)\n\te.GET(APIPrefix+EnvPrefix+\"/:env\", envController.GetEnv)\n\n\t// Not Found\n\te.NoMethod(invalidMethod)\n\te.NoRoute(notFound)\n}", "func (s *server) routes(router *mux.Router) {\n\trouter.HandleFunc(\"/api/todos\", s.HandleGetTodos).Methods(\"GET\")\n\trouter.HandleFunc(\"/api/todos/{id}\", s.HandleGetTodo).Methods(\"GET\")\n\trouter.HandleFunc(\"/api/todos\", s.HandleCreateTodo).Methods(\"POST\")\n\trouter.HandleFunc(\"/api/todos/{id}\", s.HandleUpdateTodo).Methods(\"PUT\")\n\trouter.HandleFunc(\"/api/todos/{id}\", s.HandleDeleteTodo).Methods(\"DELETE\")\n\trouter.HandleFunc(\"/api/todos/{id}/toggle_completed\", s.HandleToggleTodo).Methods(\"POST\")\n}", "func (a *App) initializeRoutes() {\n\t// Root\n\ta.Router.HandleFunc(\"/\", authn(a.getRoot)).Methods(\"GET\")\n\t// AuthZ and AuthN\n\ta.Router.HandleFunc(\"/login\", a.getLogin).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/login\", a.processLogin).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/logout\", a.processLogout).Methods(\"GET\")\n\t// Images and stuff\n\ta.Router.PathPrefix(\"/resources/\").Handler(http.StripPrefix(\"/resources/\", http.FileServer(http.Dir(\"./resources/\"))))\n\t// Contacts\n\ta.Router.HandleFunc(\"/contacts\", authn(a.getContacts)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/contact/{id:[0-9]+}\", authn(a.editContact)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/contact/create\", authn(a.createContact)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/contact/save\", authn(a.saveContact)).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/contact/delete/{id:[0-9]+}\", authn(a.deleteContact)).Methods(\"GET\")\n\t// Customers\n\ta.Router.HandleFunc(\"/customers\", authn(a.getCustomers)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/customer/{id:[0-9]+}\", authn(a.editCustomer)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/customer/create\", authn(a.createCustomer)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/customer/save\", authn(a.saveCustomer)).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/customer/delete/{id:[0-9]+}\", a.deleteCustomer).Methods(\"GET\")\n\t// Projects\n\ta.Router.HandleFunc(\"/projects\", authn(a.getProjects)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/project/{id:[0-9]+}\", authn(a.editProject)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/project/create\", authn(a.createProject)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/project/save\", authn(a.saveProject)).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/project/delete/{id:[0-9]+}\", authn(a.deleteProject)).Methods(\"GET\")\n\t// Dashboard\n\ta.Router.HandleFunc(\"/dashboard\", authn(a.getDashboard)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/dashboard/notifications\", authn(a.getDashboardNotifications)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/dashboard/numberofprojects\", authn(a.getDashboardNumberOfProjects)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/dashboard/numberofhappy\", authn(a.getDashboardHappyCustomer)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/dashboard/completedtask\", authn(a.getDashboardCompletedTask)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/dashboard/resources\", authn(a.getDashboardResources)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/dashboard/tasks\", authn(a.getDashboardProjectTasksForUser)).Methods(\"GET\")\n\t// System Notification\n\ta.Router.HandleFunc(\"/notifications\", authn(a.getSystemNotifications)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/notification/{id:[0-9]+}\", authn(a.editSystemNotification)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/notification/create\", authn(a.createSystemNotification)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/notification/save\", authn(a.saveSystemNotification)).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/notification/delete/{id:[0-9]+}\", authn(a.deleteSystemNotification)).Methods(\"GET\")\n\t// Internal Resources\n\ta.Router.HandleFunc(\"/resources\", authn(a.getResources)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/resource/{id:[0-9]+}\", authn(a.editResource)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/resource/create\", authn(a.createResource)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/resource/save\", authn(a.saveResource)).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/resource/delete/{id:[0-9]+}\", authn(a.deleteResource)).Methods(\"GET\")\n\t// Project Task\n\ta.Router.HandleFunc(\"/tasks\", authn(a.getProjectTasks)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/task/{id:[0-9]+}\", authn(a.editProjectTask)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/task/create\", authn(a.createProjectTask)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/task/save\", authn(a.saveProjectTask)).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/task/delete/{id:[0-9]+}\", authn(a.deleteProjectTask)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/task/attachment\", authn(a.getAttachment)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/mytask/{id:[0-9]+}\", authn(a.getUserTasks)).Methods(\"GET\")\n\t// Settings\n\ta.Router.HandleFunc(\"/settings\", authn(a.getSettings)).Methods(\"GET\")\n\t// System Backup\n\ta.Router.HandleFunc(\"/backup\", authn(a.getBackup)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/backup/start\", authn(a.startBackup)).Methods(\"POST\")\n\t// Application Users\n\ta.Router.HandleFunc(\"/users\", authn(a.getUsers)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/user/create\", authn(a.createUser)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/user/save\", authn(a.saveUser)).Methods(\"POST\")\n\ta.Router.HandleFunc(\"/user/{id:[0-9]+}\", authn(a.editUser)).Methods(\"GET\")\n\ta.Router.HandleFunc(\"/user/delete/{id:[0-9]+}\", authn(a.deleteUser)).Methods(\"GET\")\n\t// Static Files\n\ta.Router.PathPrefix(\"/public/\").Handler(http.StripPrefix(\"/public/\", http.FileServer(rice.MustFindBox(\"public\").HTTPBox())))\n}", "func PublicRoutes(a *fiber.App) {\n\t// Create routes group.\n\troute := a.Group(\"/api/v1\")\n\n\t// Routes for GET method:\n\troute.Get(\"/books\", controllers.GetBooks) // get list of all books\n\troute.Get(\"/book/:id\", controllers.GetBook) // get one book by ID\n\n\t// Routes for POST method:\n\troute.Post(\"/user/sign/up\", controllers.UserSignUp) // register a new user\n\troute.Post(\"/user/sign/in\", controllers.UserSignIn) // auth, return Access & Refresh tokens\n}", "func generateUserAPIRoutes(router *mux.Router) {\n\tusers := router.PathPrefix(\"/users\").Subrouter()\n\tusers.Use(helpers.LoggingMiddleware)\n\tusers.HandleFunc(\"\", user.GetAll).Methods(\"GET\") // GET Request to handle all data present in the Database\n\n\tsub := router.PathPrefix(\"/user\").Subrouter()\n\tsub.Use(helpers.LoggingMiddleware)\n\t\n\tsub.HandleFunc(\"\", user.GetUser).Methods(\"GET\")\n}", "func (ex *blank) Routes(r chi.Router) {\n\tr.Get(\"/{id}\", ex.blankHandler)\n}", "func ApplyRoutes(r *gin.RouterGroup) {\n\tv1 := r.Group(\"/v1.0\")\n\t{\n\t\tv1.GET(\"/ping\", ping)\n\n\t\tstudents.ApplyRoutes(v1)\n\t\tteachers.ApplyRoutes(v1)\n\t\tclass.ApplyRoutes(v1)\n\t}\n}", "func Routes() http.Handler {\n\tMiddleWare = make([]vestigo.Middleware, 0)\n\trouter := vestigo.NewRouter()\n\n\t// CORS for testing purpose, should be disabled in production use!\n\trouter.SetGlobalCors(&vestigo.CorsAccessControl{\n\t\tAllowOrigin: []string{\"http://localhost:8080\"},\n\t\tAllowCredentials: true,\n\t\tExposeHeaders: []string{\"X-Header\", \"X-Y-Header\"},\n\t\tAllowHeaders: []string{\"authorization\", \"cache-control\", \"x-requested-with\", \"Content-Type\", \"set-cookie\"},\n\t})\n\n\trouter.Add(\"GET\", \"/api/hello\", HelloHandler, DefaultChain...)\n\n\tplug, err := plugin.Open(\"./plugin.so\")\n\n\tif err != nil {\n\t\tfmt.Printf(\"Could not load plugin\")\n\t}\n\n\trs, err := plug.Lookup(\"Mrouter\")\n\n\tif err != nil {\n\t\tfmt.Printf(\"Could not lookup plugin\")\n\t}\n\n\tmr, ok := rs.(ModuleRouter)\n\n\tif !ok {\n\t\tfmt.Printf(\"Cast fail\\n\")\n\t}\n\n\tmroutes := mr.Routes()\n\n\tfor _, t := range mroutes {\n\n\t\tMiddleWare = append(MiddleWare, DefaultChain...)\n\t\tMiddleWare = append(MiddleWare, t.Middleware...)\n\n\t\tfmt.Printf(\"%v\\n\", len(MiddleWare))\n\t\trouter.Add(t.Method, t.Path, t.Handler, MiddleWare...)\n\t}\n\n\treturn router\n}", "func (agr *apiGatewayResource) GetCustomRoutes() ([]restful.CustomRoute, error) {\n\n\t// since delete and update by default assume /resource/{id} and we want to get the id/namespace from the body\n\t// we need to register custom routes\n\treturn []restful.CustomRoute{\n\t\t{\n\n\t\t\t// TODO: deprecate this custom route\n\t\t\tPattern: \"/\",\n\t\t\tMethod: http.MethodPut,\n\t\t\tRouteFunc: agr.updateAPIGateway,\n\t\t},\n\t\t{\n\t\t\tPattern: \"/\",\n\t\t\tMethod: http.MethodDelete,\n\t\t\tRouteFunc: agr.deleteAPIGateway,\n\t\t},\n\t}, nil\n}", "func MapDefaultRoutes() {\n\thttp.HandleFunc(\"/\", DefaultRoute)\n}", "func (s *server) routes() {\n\ts.router.Handle(\"/api/convert\", s.convert())\n}", "func InitRoutes() *mux.Router {\n\trouter := mux.NewRouter()\n\trouter = SetFinancialTransationsRoutes(router)\n\trouter = SetLastPurchasesRoutes(router)\n\trouter = SetConsultedCPFRoutes(router)\n\treturn router\n}", "func SetupRoutes(app *fiber.App) {\n\tapi := app.Group(\"api/v1/\")\n\tusers := app.Group(\"/auth/v1\")\n}", "func (projectController *ProjectController) Routes(base *gin.RouterGroup, authNormal *jwt.GinJWTMiddleware) *gin.RouterGroup {\n\n\t// Projects - Rutas\n\tprojectRouter := base.Group(\"/projects\") //, middleware.SetRoles(RolAdmin, RolUser), authNormal.MiddlewareFunc())\n\t{\n\t\tprojectRouter.GET(\"\", projectController.GetAll())\n\t\t// Al agregar asociar con usuario\n\t\tprojectRouter.POST(\"\", authNormal.MiddlewareFunc(), projectController.Create())\n\t\tprojectRouter.GET(\"/:id\", projectController.One())\n\t\t// Verificar en handler que el perro sea dueño de usuario\n\t\tprojectRouter.PUT(\"/:id\", authNormal.MiddlewareFunc(), projectController.Update())\n\t\t// Solo admin puede eliminar\n\t\tprojectRouter.DELETE(\"/:id\", middleware.SetRoles(RolAdmin), authNormal.MiddlewareFunc(), projectController.Delete())\n\t}\n\treturn projectRouter\n}", "func (s *ServerT) Routes() []RouteInfoT {\n\troutes := s.Router.Routes()\n\n\tif s.Config.HTTPHealthCheckURL != \"\" {\n\t\troutes = append(routes, RouteInfoT{\n\t\t\tMethod: \"GET\",\n\t\t\tPath: s.Config.HTTPHealthCheckURL,\n\t\t\tHandler: \"\",\n\t\t\tHandlerFunc: nil,\n\t\t})\n\t}\n\n\treturn routes\n}", "func (c *SubscriptionsCollectionApiController) Routes() Routes {\n\treturn Routes{ \n\t\t{\n\t\t\t\"CreateSubscription\",\n\t\t\tstrings.ToUpper(\"Post\"),\n\t\t\t\"/nnrf-nfm/v1/subscriptions\",\n\t\t\tc.CreateSubscription,\n\t\t},\n\t}\n}", "func SetupDefaultRoutes(r *mux.Router, namespaceHeaderName, namespaceHeaderPattern string, burst int, qps float32, clustersConfig kube.ClustersConfig) error {\n\tbackendHandler, err := kube.NewHandler(os.Getenv(\"POD_NAMESPACE\"), namespaceHeaderName, namespaceHeaderPattern, burst, qps, clustersConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/can-i\").Handler(http.HandlerFunc(CanI(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/namespaces\").Handler(http.HandlerFunc(GetNamespaces(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/apprepositories\").Handler(http.HandlerFunc(ListAppRepositories(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories\").Handler(http.HandlerFunc(ListAppRepositories(backendHandler)))\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories\").Handler(http.HandlerFunc(CreateAppRepository(backendHandler)))\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/validate\").Handler(http.HandlerFunc(ValidateAppRepository(backendHandler)))\n\tr.Methods(\"PUT\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/{name}\").Handler(http.HandlerFunc(UpdateAppRepository(backendHandler)))\n\tr.Methods(\"POST\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/{name}/refresh\").Handler(http.HandlerFunc(RefreshAppRepository(backendHandler)))\n\tr.Methods(\"DELETE\").Path(\"/clusters/{cluster}/namespaces/{namespace}/apprepositories/{name}\").Handler(http.HandlerFunc(DeleteAppRepository(backendHandler)))\n\tr.Methods(\"GET\").Path(\"/clusters/{cluster}/namespaces/{namespace}/operator/{name}/logo\").Handler(http.HandlerFunc(GetOperatorLogo(backendHandler)))\n\treturn nil\n}", "func (s *Service) Routes() *mux.Router {\n\ts.Logger.Debug(\"setting up routes\")\n\tr := mux.NewRouter()\n\tr.HandleFunc(\"/\", s.logHandler(s.rootRequest))\n\tr.HandleFunc(\"/query\", s.logHandler(s.queryRequest))\n\tif s.EnableDebug {\n\t\tr.HandleFunc(\"/debug/pprof/\", pprof.Index)\n\t\tr.HandleFunc(\"/debug/pprof/{action}\", pprof.Index)\n\t\tr.HandleFunc(\"/debug/pprof/symbol\", pprof.Symbol)\n\t\tr.HandleFunc(\"/debug/vars\", expvar.Handler().ServeHTTP)\n\t}\n\treturn r\n}", "func InitAPI() {\n\tBaseRoutes = &Routes{}\n\tBaseRoutes.Root = mux.NewRouter()\n\tBaseRoutes.Root.Handle(\"/\", http.HandlerFunc(indexHandler))\n\tBaseRoutes.Recipe = BaseRoutes.Root.PathPrefix(\"/recipe\").Subrouter()\n\tBaseRoutes.NeedRecipe = BaseRoutes.Recipe.PathPrefix(\"/{recipe-id:[0-9]+}\").Subrouter()\n\tBaseRoutes.Recipes = BaseRoutes.Root.PathPrefix(\"/recipes\").Subrouter()\n\tInitRecipe()\n}" ]
[ "0.7880956", "0.7545313", "0.7503585", "0.749873", "0.74294", "0.7349533", "0.73050517", "0.7297267", "0.7239463", "0.7185087", "0.7149267", "0.70478773", "0.70125264", "0.6981117", "0.697953", "0.69765663", "0.6949959", "0.6927297", "0.68335825", "0.6802384", "0.68009883", "0.67976475", "0.6761029", "0.6754431", "0.6751271", "0.6681064", "0.66712356", "0.6669", "0.6645808", "0.66361374", "0.6613008", "0.6610078", "0.65987074", "0.6575674", "0.65497273", "0.65383744", "0.6527628", "0.6525233", "0.651355", "0.6498272", "0.6495349", "0.64788884", "0.6466807", "0.64590997", "0.6406846", "0.6401145", "0.6369914", "0.6361724", "0.635979", "0.63502705", "0.6345749", "0.63382286", "0.6337258", "0.6333935", "0.6325865", "0.63116384", "0.62744397", "0.62724257", "0.61922854", "0.6180124", "0.61728734", "0.61703813", "0.6170207", "0.61679566", "0.6162224", "0.6160408", "0.6158211", "0.6157058", "0.6146527", "0.61458254", "0.6135199", "0.6131307", "0.612692", "0.6121132", "0.6117867", "0.61135155", "0.6102729", "0.6101267", "0.6094376", "0.60893226", "0.6088604", "0.6080898", "0.60791016", "0.6074787", "0.60694027", "0.6055513", "0.6055106", "0.60507166", "0.6050633", "0.6050107", "0.60435045", "0.604232", "0.60231805", "0.602231", "0.6017905", "0.59894246", "0.5987819", "0.5982818", "0.59826916", "0.5980237" ]
0.7773238
1
NewCmdSnapshot adds command for operating on snapshot
func NewCmdSnapshot() *cobra.Command { cmd := &cobra.Command{ Use: "snapshot", Short: "Provides operations related to a Volume snapshot", Long: snapshotCommandHelpText, } cmd.AddCommand( NewCmdSnapshotCreate(), NewCmdSnapshotList(), NewCmdSnapshotRevert(), ) cmd.PersistentFlags().StringVarP(&options.namespace, "namespace", "n", options.namespace, "namespace name, required if volume is not in the default namespace") return cmd }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Snapshot() *Command {\n\tcmd := &Command{\n\t\tCommand: &cobra.Command{\n\t\t\tUse: \"snapshot\",\n\t\t\tAliases: []string{\"s\"},\n\t\t\tShort: \"Access and manage snapshots\",\n\t\t\tLong: \"The subcommands of `doctl compute snapshot` allow you to manage and retrieve information about Droplet and block storage volume snapshots.\",\n\t\t},\n\t}\n\n\tsnapshotDetail := `\n\n - The snapshot's ID\n - The snapshot's name\n - The date and time when the snapshot was created\n - The slugs of the datacenter regions in which the snapshot is available\n - The type of resource the snapshot was made from, Droplet or volume, and its ID\n - The minimum size in GB required for a Droplet or volume to use this snapshot\n - The compressed, billable size of the snapshot\n`\n\n\tcmdRunSnapshotList := CmdBuilder(cmd, RunSnapshotList, \"list [glob]\",\n\t\t\"List Droplet and volume snapshots\", \"List information about Droplet and block storage volume snapshots, including:\"+snapshotDetail,\n\t\tWriter, aliasOpt(\"ls\"), displayerType(&displayers.Snapshot{}))\n\tAddStringFlag(cmdRunSnapshotList, doctl.ArgResourceType, \"\", \"\", \"Filter by resource type (`droplet` or `volume`)\")\n\tAddStringFlag(cmdRunSnapshotList, doctl.ArgRegionSlug, \"\", \"\", \"Filter by regional availability\")\n\n\tCmdBuilder(cmd, RunSnapshotGet, \"get <snapshot-id>...\",\n\t\t\"Retrieve a Droplet or volume snapshot\", \"Retrieve information about a Droplet or block storage volume snapshot, including:\"+snapshotDetail,\n\t\tWriter, aliasOpt(\"g\"), displayerType(&displayers.Snapshot{}))\n\n\tcmdRunSnapshotDelete := CmdBuilder(cmd, RunSnapshotDelete, \"delete <snapshot-id>...\",\n\t\t\"Delete a snapshot of a Droplet or volume\", \"Delete a snapshot of a Droplet or volume by specifying its ID.\",\n\t\tWriter, aliasOpt(\"d\", \"rm\"), displayerType(&displayers.Snapshot{}))\n\tAddBoolFlag(cmdRunSnapshotDelete, doctl.ArgForce, doctl.ArgShortForce, false, \"Delete the snapshot without confirmation\")\n\n\treturn cmd\n}", "func Snapshot() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"snapshot\",\n\t\tAliases: []string{\"sn\"},\n\t\tShort: \"snapshot commands\",\n\t\tLong: `snapshot is used to access snapshot commands`,\n\t}\n\n\tcmd.AddCommand(snapshotCreate)\n\tcmd.AddCommand(snapshotCreateFromURL)\n\tcmd.AddCommand(snapshotDelete)\n\tcmd.AddCommand(snapshotList)\n\n\tsnapshotCreate.Flags().StringP(\"id\", \"i\", \"\", \"ID of the virtual machine to create a snapshot from.\")\n\tsnapshotCreate.Flags().StringP(\"description\", \"d\", \"\", \"(optional) Description of snapshot contents\")\n\tsnapshotCreate.MarkFlagRequired(\"id\")\n\n\tsnapshotCreateFromURL.Flags().StringP(\"url\", \"u\", \"\", \"Remote URL from where the snapshot will be downloaded.\")\n\tsnapshotCreateFromURL.MarkFlagRequired(\"url\")\n\n\treturn cmd\n}", "func (z *zfsctl) Snapshot(ctx context.Context, name string, properties map[string]string) *execute {\n\targs := []string{\"snapshot\", \"-r\"}\n\tif properties != nil {\n\t\tkv := \"-o \"\n\t\tfor k, v := range properties {\n\t\t\tkv += fmt.Sprintf(\"%s=%s \", k, v)\n\t\t}\n\t\targs = append(args, kv)\n\t}\n\targs = append(args, name)\n\treturn &execute{ctx: ctx, name: z.cmd, args: args}\n}", "func (mdb *memdbSlice) NewSnapshot(ts *common.TsVbuuid, commit bool) (SnapshotInfo, error) {\n\n\tmdb.waitPersist()\n\n\tqc := atomic.LoadInt64(&mdb.qCount)\n\tif qc > 0 {\n\t\tcommon.CrashOnError(errors.New(\"Slice Invariant Violation - commit with pending mutations\"))\n\t}\n\n\tmdb.isDirty = false\n\n\t// Coming here means that cmdCh is empty and flush has finished for this index\n\tatomic.StoreUint32(&mdb.flushActive, 0)\n\n\tsnap, err := mdb.mainstore.NewSnapshot()\n\tif err == memdb.ErrMaxSnapshotsLimitReached {\n\t\tlogging.Warnf(\"Maximum snapshots limit reached for indexer. Restarting indexer...\")\n\t\tos.Exit(0)\n\t}\n\n\tnewSnapshotInfo := &memdbSnapshotInfo{\n\t\tTs: ts,\n\t\tMainSnap: snap,\n\t\tCommitted: commit,\n\t}\n\tmdb.setCommittedCount()\n\n\treturn newSnapshotInfo, err\n}", "func GetSnapshotCommand(repoIdentifier, passwordFile string, tags map[string]string) *Command {\n\treturn &Command{\n\t\tCommand: \"snapshots\",\n\t\tRepoIdentifier: repoIdentifier,\n\t\tPasswordFile: passwordFile,\n\t\t// \"--last\" is replaced by \"--latest=1\" in restic v0.12.1\n\t\tExtraFlags: []string{\"--json\", \"--latest=1\", getSnapshotTagFlag(tags)},\n\t}\n}", "func TestCmdSnapshot(t *testing.T) {\n\tassert := asrt.New(t)\n\n\ttestDir, _ := os.Getwd()\n\tfmt.Println(testDir)\n\tsite := TestSites[0]\n\tcleanup := site.Chdir()\n\tapp, err := ddevapp.NewApp(site.Dir, false, \"\")\n\tassert.NoError(err)\n\tdefer func() {\n\t\t// Make sure all databases are back to default empty\n\t\t_ = app.Stop(true, false)\n\t\t_ = app.Start()\n\t\tcleanup()\n\t}()\n\n\t// Ensure that a snapshot can be created\n\targs := []string{\"snapshot\", \"--name\", \"test-snapshot\"}\n\tout, err := exec.RunCommand(DdevBin, args)\n\tassert.NoError(err)\n\tassert.Contains(string(out), \"Created snapshot test-snapshot\")\n\n\t// Try to delete a not existing snapshot\n\targs = []string{\"snapshot\", \"--name\", \"not-existing-snapshot\", \"--cleanup\", \"--yes\"}\n\tout, err = exec.RunCommand(DdevBin, args)\n\tassert.Error(err)\n\tassert.Contains(string(out), \"Failed to delete snapshot\")\n\n\t// Ensure that an existing snapshot can be deleted\n\targs = []string{\"snapshot\", \"--name\", \"test-snapshot\", \"--cleanup\"}\n\tout, err = exec.RunCommand(DdevBin, args)\n\tassert.NoError(err)\n\tassert.Contains(string(out), \"Deleted database snapshot test-snapshot\")\n}", "func NewSnapshot(ctx *pulumi.Context,\n\tname string, args *SnapshotArgs, opts ...pulumi.ResourceOption) (*Snapshot, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.InstanceId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'InstanceId'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Snapshot\n\terr := ctx.RegisterResource(\"alicloud:databasefilesystem/snapshot:Snapshot\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (s *SnapshotHandler) generateNewSnapshot() {\n\t// Generate new snapshot version.\n\tsnapshotVersion := s.newSnapshotVersion()\n\n\t// Create an snapshot with all xDS resources.\n\tsnapshot := cache.NewSnapshot(snapshotVersion,\n\t\tasResources(s.resources[envoy_xds.Endpoint].Contents()),\n\t\tasResources(s.resources[envoy_xds.Cluster].Contents()),\n\t\tasResources(s.resources[envoy_xds.Route].Contents()),\n\t\tasResources(s.resources[envoy_xds.Listener].Contents()),\n\t\tnil)\n\n\t// Update the Secrets xDS resource manually until a new version of go-control-plane is released.\n\t// ref: https://github.com/envoyproxy/go-control-plane/pull/314\n\tsnapshot.Resources[envoy_xds.Secret] = cache.NewResources(snapshotVersion, asResources(s.resources[envoy_xds.Secret].Contents()))\n\n\tif err := s.snapshotCache.SetSnapshot(xds.DefaultHash.String(), snapshot); err != nil {\n\t\ts.Errorf(\"OnChange: Error setting snapshot: %q\", err)\n\t}\n}", "func createSnapshot(sg *snapshotgroup.SnapshotGroup, annotations map[string]string) error {\n\ttimestamp := strconv.Itoa(int(time.Now().Unix()))\n\tannotations[TimestampAnnotation] = timestamp\n\tannotations[managedByAnnotation] = managerName\n\tannotations[GroupNameAnnotation] = sg.ObjectMeta.Name\n\n\tsnapshot := snapshotsv1.VolumeSnapshot{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tNamespace: sg.ObjectMeta.Namespace,\n\t\t\tName: sg.ObjectMeta.Name + \"-\" + timestamp,\n\t\t\tAnnotations: annotations,\n\t\t},\n\t\tSpec: sg.Spec.Template.Spec,\n\t}\n\tname := getPVCName(sg)\n\tklog.Infof(\"%s/%s: creating snapshot for PVC %s\", sg.ObjectMeta.Namespace, sg.ObjectMeta.Name, name)\n\tsnapshot.Spec.Source.PersistentVolumeClaimName = &name\n\n\tmarshaled, err := json.Marshal(snapshot)\n\tif err != nil {\n\t\treturn err\n\t}\n\tunst := unstructured.Unstructured{\n\t\tObject: map[string]interface{}{},\n\t}\n\terr = json.Unmarshal(marshaled, &unst.Object)\n\tif err != nil {\n\t\treturn err\n\t}\n\tclient := kube.GetClient()\n\tunst.Object[\"kind\"] = \"VolumeSnapshot\"\n\tunst.Object[\"apiVersion\"] = client.VolumeSnapshotVersion\n\n\tif strings.HasSuffix(client.VolumeSnapshotVersion, \"v1alpha1\") {\n\t\t// There is a slight change in `source` from alpha to beta\n\t\tspec := unst.Object[\"spec\"].(map[string]interface{})\n\t\tsource := spec[\"source\"].(map[string]interface{})\n\t\tdelete(source, \"persistentVolumeClaimName\")\n\t\tsource[\"name\"] = name\n\t\tsource[\"kind\"] = \"PersistentVolumeClaim\"\n\t\tspec[\"source\"] = source\n\t\tunst.Object[\"spec\"] = spec\n\t}\n\n\tsnapClient := client.SnapshotClient.Namespace(snapshot.ObjectMeta.Namespace)\n\t_, err = snapClient.Create(&unst, metav1.CreateOptions{})\n\treturn err\n}", "func NewSnapshot(ctx *pulumi.Context,\n\tname string, args *SnapshotArgs, opts ...pulumi.ResourceOption) (*Snapshot, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.DiskId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'DiskId'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Snapshot\n\terr := ctx.RegisterResource(\"alicloud:ecs/snapshot:Snapshot\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewSnapshot(kind string, startRevision, lastRevision int64, compressionSuffix string, isFinal bool) *brtypes.Snapshot {\n\tsnap := &brtypes.Snapshot{\n\t\tKind: kind,\n\t\tStartRevision: startRevision,\n\t\tLastRevision: lastRevision,\n\t\tCreatedOn: time.Now().UTC(),\n\t\tCompressionSuffix: compressionSuffix,\n\t\tIsFinal: isFinal,\n\t}\n\tsnap.GenerateSnapshotName()\n\treturn snap\n}", "func NewSnapshot(ctx *pulumi.Context,\n\tname string, args *SnapshotArgs, opts ...pulumi.ResourceOption) (*Snapshot, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.NamespaceName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'NamespaceName'\")\n\t}\n\tif args.SnapshotName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'SnapshotName'\")\n\t}\n\tvar resource Snapshot\n\terr := ctx.RegisterResource(\"aws:redshiftserverless/snapshot:Snapshot\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewSnapshot(ctx *pulumi.Context,\n\tname string, args *SnapshotArgs, opts ...pulumi.ResourceOption) (*Snapshot, error) {\n\tif args == nil || args.SourceDisk == nil {\n\t\treturn nil, errors.New(\"missing required argument 'SourceDisk'\")\n\t}\n\tif args == nil {\n\t\targs = &SnapshotArgs{}\n\t}\n\tvar resource Snapshot\n\terr := ctx.RegisterResource(\"gcp:compute/snapshot:Snapshot\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewSnapshot(ctx *pulumi.Context,\n\tname string, args *SnapshotArgs, opts ...pulumi.ResourceOption) (*Snapshot, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.VolumeId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'VolumeId'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Snapshot\n\terr := ctx.RegisterResource(\"aws-native:fsx:Snapshot\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (p *AuroraAdminClient) Snapshot(ctx context.Context) (r *Response, err error) {\n var _args345 AuroraAdminSnapshotArgs\n var _result346 AuroraAdminSnapshotResult\n if err = p.Client_().Call(ctx, \"snapshot\", &_args345, &_result346); err != nil {\n return\n }\n return _result346.GetSuccess(), nil\n}", "func MakeInstanceSnapshot(svc rdsiface.RDSAPI, instance *string) error {\n // snippet-start:[rds.go.create_instance_snapshot.call]\n // Get the current date and time to uniquely identify snapshot\n currentTime := time.Now()\n t := currentTime.Format(\"2006-01-02 15:04:05\")\n // Replace space with underscore for snapshot ID\n t = strings.Replace(t, \" \", \"_\", -1)\n\n _, err := svc.CreateDBSnapshot(&rds.CreateDBSnapshotInput{\n DBInstanceIdentifier: instance,\n DBSnapshotIdentifier: aws.String(*instance + t),\n })\n // snippet-end:[rds.go.create_instance_snapshot.call]\n if err != nil {\n return err\n }\n\n return nil\n}", "func (a Agent) SnapshotCreate(sid int, password string) (*RawSnapshot, error) {\n\treq := libts.Request{\n\t\tCommand: \"serversnapshotcreate\",\n\t\tServerID: sid,\n\t\tArgs: map[string]interface{}{\n\t\t\t\"password\": password,\n\t\t},\n\t}\n\tsnapshot := &RawSnapshot{}\n\terr := a.Query.Do(req, snapshot)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn snapshot, nil\n}", "func (c *VolumeController) createSnapshot(snapshotName string, labels map[string]string, volume *longhorn.Volume, e *longhorn.Engine) (*longhorn.SnapshotInfo, error) {\n\tif volume.Name == \"\" {\n\t\treturn nil, fmt.Errorf(\"volume name required\")\n\t}\n\n\tif err := util.VerifySnapshotLabels(labels); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := c.checkVolumeNotInMigration(volume); err != nil {\n\t\treturn nil, err\n\t}\n\n\tengineCliClient, err := engineapi.GetEngineBinaryClient(c.ds, volume.Name, c.controllerID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tengineClientProxy, err := engineapi.GetCompatibleClient(e, engineCliClient, c.ds, c.logger, c.proxyConnCounter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer engineClientProxy.Close()\n\n\t// Check if we have already created a snapshot with this name.\n\t// TODO: Update longhorn-engine and longhorn-instance-manager so that SnapshotCreate returns an identifiable\n\t// error/code when a snapshot exists so that this check isn't necessary.\n\tif snapshotName != \"\" {\n\t\tsnap, err := engineClientProxy.SnapshotGet(e, snapshotName)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif snap != nil {\n\t\t\treturn snap, nil\n\t\t}\n\t}\n\n\tsnapshotName, err = engineClientProxy.SnapshotCreate(e, snapshotName, labels)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsnap, err := engineClientProxy.SnapshotGet(e, snapshotName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif snap == nil {\n\t\treturn nil, fmt.Errorf(\"failed to found just created snapshot '%s', for volume '%s'\", snapshotName, volume.Name)\n\t}\n\n\tlogrus.Infof(\"Created snapshot %v with labels %+v for volume %v\", snapshotName, labels, volume.Name)\n\treturn snap, nil\n}", "func (z *zfsctl) SendSnapshot(ctx context.Context, name, options string, i string) *execute {\n\targs := []string{\"send\"}\n\tif len(options) > 0 {\n\t\targs = append(args, options)\n\t}\n\tif len(i) > 0 {\n\t\targs = append(args, \"-i \"+i)\n\t}\n\targs = append(args, name)\n\treturn &execute{ctx: ctx, name: z.cmd, args: args}\n}", "func (kvm *Clone) Snapshot(wr io.Writer) error {\n\tkvm.mu.RLock()\n\tdefer kvm.mu.RUnlock()\n\tdata, err := json.Marshal(kvm.keys)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif _, err := wr.Write(data); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func NewSnapshot(options etcd.Options) (store.Snapshot, error) {\n\tcli, err := etcd.NewClient(options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &snapshot{\n\t\tclient: cli,\n\t\tkey: DefaultKey,\n\t}, nil\n}", "func NewCmd(cxt *command.Context) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"touch\",\n\t\tShort: \"Make the service catalog attempt to re-provision an instance\",\n\t\tExample: \"svcat touch instance wordpress-mysql-instance\",\n\t}\n\tcmd.AddCommand(newTouchInstanceCmd(cxt))\n\treturn cmd\n}", "func NewSnapshot(version string,\n\tendpoints []types.Resource,\n\tclusters []types.Resource,\n\troutes []types.Resource,\n\tlisteners []types.Resource,\n\truntimes []types.Resource) Snapshot {\n\tout := Snapshot{}\n\tout.Resources[types.Endpoint] = NewResources(version, endpoints)\n\tout.Resources[types.Cluster] = NewResources(version, clusters)\n\tout.Resources[types.Route] = NewResources(version, routes)\n\tout.Resources[types.Listener] = NewResources(version, listeners)\n\tout.Resources[types.Runtime] = NewResources(version, runtimes)\n\treturn out\n}", "func Snapshot(scope *Scope, input tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Snapshot\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (s *SnapshotHandler) newSnapshotVersion() string {\n\n\t// Reset the snapshotVersion if it ever hits max size.\n\tif s.snapshotVersion == math.MaxInt64 {\n\t\ts.snapshotVersion = 0\n\t}\n\n\t// Increment the snapshot version & return as string.\n\ts.snapshotVersion++\n\treturn strconv.FormatInt(s.snapshotVersion, 10)\n}", "func (p *AuroraAdminClient) Snapshot(ctx context.Context) (r *Response, err error) {\n var _args395 AuroraAdminSnapshotArgs\n var _result396 AuroraAdminSnapshotResult\n var meta thrift.ResponseMeta\n meta, err = p.Client_().Call(ctx, \"snapshot\", &_args395, &_result396)\n p.SetLastResponseMeta_(meta)\n if err != nil {\n return\n }\n return _result396.GetSuccess(), nil\n}", "func (c *Client) SnapshotCreate(vm *VirtualMachine, name string) (*types.ManagedObjectReference, error) {\n\tif c.Verbose {\n\t\tfmt.Printf(\"Creating a VM snapshot...\\n\")\n\t}\n\n\tvar res types.ManagedObjectReference\n\n\terr := func() error {\n\t\tctx, cancelFn := context.WithTimeout(context.Background(), c.timeout)\n\t\tdefer cancelFn()\n\n\t\ttask, err := vm.VM.CreateSnapshot(ctx, name, \"\", false, false)\n\t\tany, err := c.finishTask(ctx, task, err)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"While snapshotting VM\")\n\t\t}\n\n\t\tres = any.(types.ManagedObjectReference)\n\n\t\treturn nil\n\t}()\n\n\tif err != nil {\n\t\tswitch err := errors.Cause(err).(type) {\n\t\tcase *TimeoutExceededError:\n\t\t\t// handle specifically\n\t\t\treturn nil, fmt.Errorf(\"Timeout while attempting to snapshot VM\")\n\t\tdefault:\n\t\t\t// unknown error\n\t\t\treturn nil, errors.Wrap(err, \"Got error while snapshotting a VM\")\n\t\t}\n\t}\n\n\treturn &res, nil\n}", "func SubvolumeClone(src, dst string) {\n\tout, err := exec.Command(\"btrfs\", \"subvolume\", \"snapshot\", src, dst).CombinedOutput()\n\tlog.Check(log.FatalLevel, \"Creating snapshot: \"+string(out), err)\n}", "func WithNewSnapshot(id string, i containerd.Image) containerd.NewContainerOpts {\n\tf := containerd.WithNewSnapshot(id, i)\n\treturn func(ctx context.Context, client *containerd.Client, c *containers.Container) error {\n\t\tif err := f(ctx, client, c); err != nil {\n\t\t\tif !errdefs.IsNotFound(err) {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err := i.Unpack(ctx, c.Snapshotter); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"error unpacking image\")\n\t\t\t}\n\t\t\treturn f(ctx, client, c)\n\t\t}\n\t\treturn nil\n\t}\n}", "func Snapshot(names []string, pool string, props *DatasetProps) error {\n\tvar snapReq struct {\n\t\tSnaps map[string]bool `nvlist:\"snaps\"`\n\t\tProps *DatasetProps `nvlist:\"props\"`\n\t}\n\tsnapReq.Snaps = make(map[string]bool)\n\tfor _, name := range names {\n\t\tif _, ok := snapReq.Snaps[name]; ok {\n\t\t\treturn errors.New(\"duplicate snapshot name\")\n\t\t}\n\t\tsnapReq.Snaps[name] = true\n\t}\n\tsnapReq.Props = props\n\tcmd := &Cmd{}\n\tsnapRes := make(map[string]int32)\n\treturn NvlistIoctl(zfsHandle.Fd(), ZFS_IOC_SNAPSHOT, pool, cmd, snapReq, snapRes, nil)\n\t// TODO: Maybe there is an error in snapRes\n}", "func (i *Instance) AnnotateSnapshot() error {\n\tjsonBytes, err := json.Marshal(i.Spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif i.Annotations == nil {\n\t\ti.Annotations = make(map[string]string)\n\t}\n\ti.Annotations[snapshotAnnotation] = string(jsonBytes)\n\treturn nil\n}", "func (ks *KopiaSnapshotter) CreateSnapshot(sourceDir string, opts map[string]string) (snapID string, err error) {\n\treturn ks.snap.CreateSnapshot(sourceDir)\n}", "func (c *SSCommand) Run(args []string) int {\n\n\tcmdFlags := flag.NewFlagSet(\"snapshot\", flag.ContinueOnError)\n\tcmdFlags.Usage = func() { c.Ui.Output(c.Help()) }\n\n\tcmdFlags.BoolVar(&c.verbose, \"v\", false, \"Produce verbose output\")\n\tcmdFlags.BoolVar(&c.dryrun, \"n\", false, \"Dry Run\")\n\tcmdFlags.BoolVar(&c.reboot, \"f\", false, \"Reboot instance wehn making snapshot. default: false\")\n\tcmdFlags.BoolVar(&c.automode, \"a\", false, \"auto mode to snapshot any instance with a tag key of autobkup\")\n\tcmdFlags.StringVar(&c.instanceId, \"i\", \"\", \"instance to be backed up\")\n\tif err := cmdFlags.Parse(args); err != nil {\n\t\treturn 1\n\t}\n\n\t// make sure we are in auto mode or an ami id has been provided\n\tif !c.automode && len(c.instanceId) == 0 {\n\t\tfmt.Printf(\"No instance details provided. Please provide an instance id to snapshot\\nor enable auto mode to snapshot all tagged instances.\\n\\n\")\n\t\treturn RCERR\n\t}\n\n\t// Create an EC2 service object\n\t// config values keys, sercet key & region read from environment\n\tsvc := ec2.New(session.New(), &aws.Config{MaxRetries: aws.Int(10)})\n\n\t// load the struct that has details on all instances to be snapshotted\n\tbkupInstances, err := getBkupInstances(svc, c.instanceId, c.reboot)\n\n\tif err != nil {\n\t\t// AWS DescribeInstances failed\n\t\tfmt.Printf(\"Fatal error: %s\\n\", err)\n\t\treturn RCERR\n\t}\n\n\t// amis contains the list of AMI's that have been created and need tagged\n\tvar amis []string\n\n\t// now we have the slice of instanceIds to be backed up we can create the AMI then tag them\n\tfor _, abkupInstance := range bkupInstances {\n\n\t\tif c.dryrun == false {\n\t\t\t// snapshot the instance.\n\t\t\tcreateImageResp, err := svc.CreateImage(abkupInstance)\n\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Error creating AWS AMI for instance %s\\n\", *abkupInstance.InstanceId)\n\t\t\t\tfmt.Printf(\"Error details - %s\\n\", err)\n\t\t\t} else {\n\t\t\t\tif c.verbose {\n\t\t\t\t\tfmt.Printf(\"Info - Started creating AMI: %s\\n\", *createImageResp.ImageId)\n\t\t\t\t}\n\t\t\t\t// add the amiid to the list of ami's to tag\n\t\t\t\tamis = append(amis, *createImageResp.ImageId)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Printf(\"Dry Run - Would have created AMI for instance %s\\n\", *abkupInstance.InstanceId)\n\t\t}\n\t}\n\n\t// if no AMI's created then lets leave\n\tif len(amis) == 0 {\n\t\treturn RCOK\n\t}\n\n\tif c.verbose {\n\t\tfmt.Printf(\"AMI's creation has started. Now waiting for AWS to make AMI's available to tag...\\n\")\n\t}\n\ttime.Sleep(47 * time.Second)\n\n\ttheTags := []*ec2.Tag{\n\t\t&ec2.Tag{\n\t\t\tKey: aws.String(\"autocleanup\"),\n\t\t\tValue: aws.String(strconv.FormatInt(time.Now().Unix(), 10))}}\n\n\tfor _, ami := range amis {\n\n\t\tec2cti := ec2.CreateTagsInput{\n\t\t\tResources: []*string{aws.String(ami)},\n\t\t\tTags: theTags}\n\n\t\t// call the create tag func\n\t\t_, err = svc.CreateTags(&ec2cti)\n\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Warning - problem adding tags to AMI: %s. Error was %s\\n\", ami, err)\n\t\t}\n\t\tif c.verbose {\n\t\t\tfmt.Printf(\"Info - Tagged AMI: %s\\n\", ami)\n\t\t}\n\t}\n\n\tif c.verbose {\n\t\tfmt.Printf(\"All done.\\n\")\n\t}\n\treturn RCOK\n}", "func newCmd(cmd string, arg ...string) *exec.Cmd {\n\tc := exec.Command(cmd, arg...)\n\tc.Stdout = os.Stdout\n\tc.Stderr = os.Stderr\n\treturn c\n}", "func (db *DB) NewSnapshot() *Snapshot {\n\tif db.closed {\n\t\tpanic(ErrDBClosed)\n\t}\n\n\treturn &Snapshot{C.leveldb_create_snapshot(db.Ldb)}\n}", "func createSnapshot(nodeID int, term int, index int, suffix string) (file string, writer io.WriteCloser, err error) {\n\tif term < 0 || index < 0 || suffix == \"\" {\n\t\treturn \"\", nil, errorInvalidSnapshotInfo\n\t}\n\n\tfileName := fmt.Sprintf(\"Node%d_T%dL%d_%s.rkvsnapshot\", nodeID, term, index, suffix)\n\tfullpath := filepath.Join(snapshotPath, fileName)\n\tf, err := os.Create(fullpath)\n\treturn fullpath, f, err\n}", "func (s *OsdCsiServer) CreateSnapshot(\n\tctx context.Context,\n\treq *csi.CreateSnapshotRequest,\n) (*csi.CreateSnapshotResponse, error) {\n\n\tif len(req.GetSourceVolumeId()) == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"Volume id must be provided\")\n\t} else if len(req.GetName()) == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"Name must be provided\")\n\t}\n\n\t// Check if the snapshot with this name already exists\n\tv, err := util.VolumeFromName(s.driver, req.GetName())\n\tif err == nil {\n\t\t// Verify the parent is the same\n\t\tif req.GetSourceVolumeId() != v.GetSource().GetParent() {\n\t\t\treturn nil, status.Error(codes.AlreadyExists, \"Requested snapshot already exists for another source volume id\")\n\t\t}\n\n\t\t// Return current snapshot info\n\t\tcreatedAt, err := ptypes.Timestamp(v.GetCtime())\n\t\tif err != nil {\n\t\t\treturn nil, status.Errorf(codes.Internal, \"Failed to get time snapshot was created: %v\", err)\n\t\t}\n\t\treturn &csi.CreateSnapshotResponse{\n\t\t\tSnapshot: &csi.Snapshot{\n\t\t\t\tId: v.GetId(),\n\t\t\t\tSourceVolumeId: v.GetSource().GetParent(),\n\t\t\t\tCreatedAt: createdAt.Unix(),\n\t\t\t\tStatus: &csi.SnapshotStatus{\n\t\t\t\t\t// This means that we are not uploading our snapshot\n\t\t\t\t\t// We may add support for cloud snaps in future patches\n\t\t\t\t\tType: csi.SnapshotStatus_READY,\n\t\t\t\t},\n\t\t\t},\n\t\t}, nil\n\t}\n\n\t// Get any labels passed in by the CO\n\t_, locator, _, err := s.specHandler.SpecFromOpts(req.GetParameters())\n\tif err != nil {\n\t\treturn nil, status.Errorf(codes.InvalidArgument, \"Unable to get parameters: %v\", err)\n\t}\n\n\t// Create snapshot\n\treadonly := true\n\tsnapshotID, err := s.driver.Snapshot(req.GetSourceVolumeId(), readonly, &api.VolumeLocator{\n\t\tName: req.GetName(),\n\t\tVolumeLabels: locator.GetVolumeLabels(),\n\t}, false)\n\tif err != nil {\n\t\tif err == kvdb.ErrNotFound {\n\t\t\treturn nil, status.Errorf(codes.NotFound, \"Volume id %s not found\", req.GetSourceVolumeId())\n\t\t}\n\t\treturn nil, status.Errorf(codes.Internal, \"Failed to create snapshot: %v\", err)\n\t}\n\n\tsnapInfo, err := util.VolumeFromName(s.driver, snapshotID)\n\tif err != nil {\n\t\treturn nil, status.Errorf(codes.Internal, \"Failed to get information about the snapshot: %v\", err)\n\t}\n\tcreatedAt, err := ptypes.Timestamp(snapInfo.GetCtime())\n\tif err != nil {\n\t\treturn nil, status.Errorf(codes.Internal, \"Failed to get time snapshot was created: %v\", err)\n\t}\n\n\treturn &csi.CreateSnapshotResponse{\n\t\tSnapshot: &csi.Snapshot{\n\t\t\tId: snapshotID,\n\t\t\tSourceVolumeId: req.GetSourceVolumeId(),\n\t\t\tCreatedAt: createdAt.Unix(),\n\t\t\tStatus: &csi.SnapshotStatus{\n\t\t\t\t// This means that we are not uploading our snapshot\n\t\t\t\t// We may add support flow cloud snaps in future patches\n\t\t\t\tType: csi.SnapshotStatus_READY,\n\t\t\t},\n\t\t},\n\t}, nil\n}", "func (m *Nitro) NewSnapshot() (*Snapshot, error) {\n\tbuf := m.snapshots.MakeBuf()\n\tdefer m.snapshots.FreeBuf(buf)\n\n\t// Stitch all local gclists from all writers to create snapshot gclist\n\tvar head, tail *skiplist.Node\n\n\tfor w := m.wlist; w != nil; w = w.next {\n\t\tif tail == nil {\n\t\t\thead = w.gchead\n\t\t\ttail = w.gctail\n\t\t} else if w.gchead != nil {\n\t\t\ttail.SetLink(w.gchead)\n\t\t\ttail = w.gctail\n\t\t}\n\n\t\tw.gchead = nil\n\t\tw.gctail = nil\n\n\t\t// Update global stats\n\t\tm.store.Stats.Merge(&w.slSts1)\n\t\tatomic.AddInt64(&m.itemsCount, w.count)\n\t\tw.count = 0\n\t}\n\n\tsnap := &Snapshot{db: m, sn: m.GetCurrSn(), refCount: 1, count: m.ItemsCount()}\n\tm.snapshots.Insert(unsafe.Pointer(snap), CompareSnapshot, buf, &m.snapshots.Stats)\n\tsnap.gclist = head\n\tnewSn := atomic.AddUint32(&m.currSn, 1)\n\tif newSn == math.MaxUint32 {\n\t\treturn nil, ErrMaxSnapshotsLimitReached\n\t}\n\n\treturn snap, nil\n}", "func newDumper() *cobra.Command {\n\tvar cluster []string\n\tvar dbName string\n\tvar timeout time.Duration\n\n\tcmd := &cobra.Command{\n\t\tUse: \"dump database\",\n\t\tShort: \"dump the database (and its associated WAL file).\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\t\t\tdefer cancel()\n\t\t\treturn dbDump(ctx, &globalKeys, dbName, cluster)\n\t\t},\n\t}\n\tflags := cmd.Flags()\n\tflags.StringSliceVarP(&cluster, \"cluster\", \"c\", clusterList(), \"addresses of existing cluster nodes\")\n\tflags.StringVarP(&dbName, \"database\", \"d\", envy.StringDefault(\"DQLITED_DB\", defaultDatabase), \"name of database to use\")\n\tflags.DurationVarP(&timeout, \"timeout\", \"t\", time.Second*60, \"time to wait for connection to complete\")\n\n\treturn cmd\n}", "func (cli *Client) SnapshotCreate(options types.SnapshotCreateRequest) (types.Snapshot, error) {\n\tvar snapshot types.Snapshot\n\tv := url.Values{}\n\tv.Set(\"volume\", options.Volume)\n\tv.Set(\"name\", options.Name)\n\tif options.Force {\n\t\tv.Set(\"force\", \"true\")\n\t}\n\tresp, err := cli.post(\"/snapshots/create?\"+v.Encode(), nil, options, nil)\n\tif err != nil {\n\t\treturn snapshot, err\n\t}\n\terr = json.NewDecoder(resp.body).Decode(&snapshot)\n\tensureReaderClosed(resp)\n\treturn snapshot, err\n}", "func (gm *gmap) triggerSnapshot(gmp *gmapProgress) {\n\tif gmp.appliedi-gmp.snapi <= defaultSnapshotCount {\n\t\treturn\n\t}\n\tlogger.Infof(\"steart to snapshot (applied: %d, lastsnap: %d)\", gmp.appliedi, gmp.snapi)\n\tgm.snapshot(gmp.appliedi, gmp.confState)\n\tgmp.snapi = gmp.appliedi\n}", "func CreateSnapshot(storageID string) error {\n\tclient, err := NewExtPacketClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trequest := &extpackngo.CreateSnapShotRequest{}\n\n\t_, e := client.Storages.CreateSnapshot(storageID, request)\n\treturn e\n}", "func newStorageMigrateCmd() (cmd *cobra.Command) {\n\tcmd = &cobra.Command{\n\t\tUse: \"migrate\",\n\t\tShort: cmdAutheliaStorageMigrateShort,\n\t\tLong: cmdAutheliaStorageMigrateLong,\n\t\tExample: cmdAutheliaStorageMigrateExample,\n\t\tArgs: cobra.NoArgs,\n\n\t\tDisableAutoGenTag: true,\n\t}\n\n\tcmd.AddCommand(\n\t\tnewStorageMigrateUpCmd(), newStorageMigrateDownCmd(),\n\t\tnewStorageMigrateListUpCmd(), newStorageMigrateListDownCmd(),\n\t\tnewStorageMigrateHistoryCmd(),\n\t)\n\n\treturn cmd\n}", "func (f *fragment) snapshot() error {\n\tf.totalOpN += int64(f.opN)\n\tf.totalOps += int64(f.ops)\n\tf.snapshotsTaken++\n\t_, err := unprotectedWriteToFragment(f, f.storage)\n\treturn err\n}", "func NewMockSnapshot(ctrl *gomock.Controller) *MockSnapshot {\n\tmock := &MockSnapshot{ctrl: ctrl}\n\tmock.recorder = &MockSnapshotMockRecorder{mock}\n\treturn mock\n}", "func (c *RabbitEventStoreClient) CreateSnapshot(opts *framework.CreateSnapshotOption) (success bool, err error) {\n\terr = c.client.Send(Request{\n\t\tAction: \"CreateSnapshot\",\n\t\tData: *opts,\n\t}, &success)\n\n\treturn success, err\n}", "func Command(app *kingpin.Application) {\n\tc := new(command)\n\n\tcmd := app.Command(\"run\", \"Takes a snapshot of the existing Docker Compose stack.\").Action(c.run)\n\n\tcmd.Flag(\"master\", \"Tag to apply to all images when performing a snapshot.\").StringVar(&c.Master)\n\tcmd.Flag(\"kubecfg\", \"Tag to apply to all images when performing a snapshot.\").Envar(\"KUBECONFIG\").StringVar(&c.Kubecfg)\n\n\tcmd.Flag(\"username\", \"Username used to authenticate with the Kubernetes cluster.\").Required().Envar(\"RIG_USERNAME\").StringVar(&c.Username)\n\tcmd.Flag(\"password\", \"Password used to authenticate with the Kubernetes cluster.\").Required().Envar(\"RIG_PASSWORD\").StringVar(&c.Password)\n\n\tcmd.Flag(\"config\", \"Config file to load.\").Default(\".rig.yml\").Envar(\"RIG_CONFIG\").StringVar(&c.Config)\n\n\t// Metadata applied to Kubernetes objects.\n\tcmd.Flag(\"namespace\", \"Tag to apply to all images when performing a snapshot.\").Required().Envar(\"RIG_NAMESPACE\").StringVar(&c.Namespace)\n\tcmd.Arg(\"name\", \"Name of the Kubernetes objects which will be provisioned.\").Required().StringVar(&c.Name)\n\n\t// Information used to run the correct images.\n\tcmd.Flag(\"repository\", \"Tag to apply to all images when performing a snapshot.\").Required().Envar(\"RIG_REPOSITORY\").StringVar(&c.Repository)\n\tcmd.Arg(\"tag\", \"Tag to apply to all images when performing a snapshot.\").Required().StringVar(&c.Tag)\n\n\t// Domains which the environment will be accessible from.\n\tcmd.Arg(\"domain\", \"Domain which this environment will be exposed.\").Required().StringsVar(&c.Domains)\n}", "func (c *Client) CreateSnapshot(ctx context.Context, id, ref string) error {\n\twrapperCli, err := c.Get(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get a containerd grpc client: %v\", err)\n\t}\n\n\toriginalCtx := ctx\n\tctx = leases.WithLease(ctx, wrapperCli.lease.ID)\n\n\tvar (\n\t\tsnName = CurrentSnapshotterName(ctx)\n\t\tsnSrv = wrapperCli.client.SnapshotService(snName)\n\t)\n\n\timage, err := wrapperCli.client.GetImage(ctx, ref)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdiffIDs, err := image.RootFS(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tparent := identity.ChainID(diffIDs).String()\n\n\t// NOTE: PouchContainer always unpacks image during pulling. But there\n\t// maybe crash or terminated by some reason. The image have been stored\n\t// in containerd without unpacking. And the following creating container\n\t// request will fail on preparing snapshot because there is no such\n\t// parent snapshotter. Based on this case, we should skip the not\n\t// found error and try to unpack it again.\n\t_, err = snSrv.Prepare(ctx, id, parent)\n\tif err == nil || !errdefs.IsNotFound(err) {\n\t\treturn err\n\t}\n\tlog.With(ctx).Warnf(\"checking unpack status for image %s on %s snapshotter...\", image.Name(), snName)\n\n\t// check unpacked status\n\tunpacked, werr := image.IsUnpacked(ctx, snName)\n\tif werr != nil {\n\t\tlog.With(ctx).Warnf(\"failed to check unpack status for image %s on %s snapshotter: %v\", image.Name(), snName, werr)\n\t\treturn err\n\t}\n\n\t// if it is not unpacked, try to unpack it.\n\tif !unpacked {\n\t\tlog.With(ctx).Warnf(\"the image %s doesn't unpack for %s snapshotter, try to unpack it...\", image.Name(), snName)\n\t\t// NOTE: don't use pouchd lease id here because pouchd lease id\n\t\t// will hold the snapshotter forever, which means that the\n\t\t// snapshotter will not removed if we remove image.\n\t\tif werr = image.Unpack(originalCtx, snName); werr != nil {\n\t\t\tlog.With(ctx).Warnf(\"failed to unpack for image %s on %s snapshotter: %v\", image.Name(), snName, werr)\n\t\t\treturn err\n\t\t}\n\n\t\t// do it again.\n\t\t_, err = snSrv.Prepare(ctx, id, parent)\n\t}\n\treturn err\n}", "func (z *zfsctl) RenameSnapshot(ctx context.Context, name, newName string) *execute {\n\targs := []string{\"rename\", \"-r\"}\n\targs = append(args, name, newName)\n\treturn &execute{ctx: ctx, name: z.cmd, args: args}\n}", "func (s *OsdCsiServer) CreateSnapshot(\n\tctx context.Context,\n\treq *csi.CreateSnapshotRequest,\n) (*csi.CreateSnapshotResponse, error) {\n\n\tif len(req.GetSourceVolumeId()) == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"Volume id must be provided\")\n\t} else if len(req.GetName()) == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"Name must be provided\")\n\t}\n\n\t// Get secret if any was passed\n\tctx = s.setupContext(ctx, req.GetSecrets())\n\tctx, cancel := grpcutil.WithDefaultTimeout(ctx)\n\tdefer cancel()\n\n\t// Get any labels passed in by the CO\n\t_, locator, _, err := s.specHandler.SpecFromOpts(req.GetParameters())\n\tif err != nil {\n\t\treturn nil, status.Errorf(codes.InvalidArgument, \"Unable to get parameters: %v\", err)\n\t}\n\t// Check ID is valid with the specified volume capabilities\n\tsnapshotType, ok := locator.VolumeLabels[osdSnapshotLabelsTypeKey]\n\tif !ok {\n\t\tsnapshotType = DriverTypeLocal\n\t}\n\tswitch snapshotType {\n\tcase DriverTypeCloud:\n\t\treturn s.createCloudBackup(ctx, req)\n\tcase DriverTypeLocal:\n\t\tfallthrough\n\tdefault:\n\t\treturn s.createLocalSnapshot(ctx, req)\n\t}\n}", "func (rf *Raft) StartSnapshot(snapshotInBytes []byte) {\n rf.mu.Lock()\n defer rf.mu.Unlock()\n\n var snapshot Snapshot\n r := bytes.NewBuffer(snapshotInBytes)\n d := labgob.NewDecoder(r)\n if d.Decode(&snapshot.ServerMap) != nil {\n return\n }\n if d.Decode(&snapshot.LastApplyIdMap) != nil {\n return\n }\n if d.Decode(&snapshot.LastLogIndex) != nil {\n return\n }\n\n lastLogIndexInLogView := rf.convertToRaftLogViewIndex(snapshot.LastLogIndex)\n if lastLogIndexInLogView > 0 && lastLogIndexInLogView < len(rf.log) {\n lastIncludedTerm := rf.log[lastLogIndexInLogView].Term\n rf.cutoffLogBeforeIndex(lastLogIndexInLogView, lastIncludedTerm)\n rf.snapshottedIndex = snapshot.LastLogIndex\n\n rf.persistWithSnapshotInBytes(snapshotInBytes)\n\n if rf.state == \"Leader\" {\n go rf.sendInstallSnapshotToMultipleFollowers(snapshot.LastLogIndex, lastIncludedTerm)\n }\n\n }\n return\n}", "func (c *restClient) CreateSnapshot(ctx context.Context, req *netapppb.CreateSnapshotRequest, opts ...gax.CallOption) (*CreateSnapshotOperation, error) {\n\tm := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}\n\tbody := req.GetSnapshot()\n\tjsonReq, err := m.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbaseUrl, err := url.Parse(c.endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbaseUrl.Path += fmt.Sprintf(\"/v1/%v/snapshots\", req.GetParent())\n\n\tparams := url.Values{}\n\tparams.Add(\"$alt\", \"json;enum-encoding=int\")\n\tparams.Add(\"snapshotId\", fmt.Sprintf(\"%v\", req.GetSnapshotId()))\n\n\tbaseUrl.RawQuery = params.Encode()\n\n\t// Build HTTP headers from client and context metadata.\n\thds := []string{\"x-goog-request-params\", fmt.Sprintf(\"%s=%v\", \"parent\", url.QueryEscape(req.GetParent()))}\n\n\thds = append(c.xGoogHeaders, hds...)\n\thds = append(hds, \"Content-Type\", \"application/json\")\n\theaders := gax.BuildHeaders(ctx, hds...)\n\tunm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}\n\tresp := &longrunningpb.Operation{}\n\te := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {\n\t\tif settings.Path != \"\" {\n\t\t\tbaseUrl.Path = settings.Path\n\t\t}\n\t\thttpReq, err := http.NewRequest(\"POST\", baseUrl.String(), bytes.NewReader(jsonReq))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\thttpReq = httpReq.WithContext(ctx)\n\t\thttpReq.Header = headers\n\n\t\thttpRsp, err := c.httpClient.Do(httpReq)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer httpRsp.Body.Close()\n\n\t\tif err = googleapi.CheckResponse(httpRsp); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tbuf, err := io.ReadAll(httpRsp.Body)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := unm.Unmarshal(buf, resp); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t}, opts...)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\n\toverride := fmt.Sprintf(\"/v1/%s\", resp.GetName())\n\treturn &CreateSnapshotOperation{\n\t\tlro: longrunning.InternalNewOperation(*c.LROClient, resp),\n\t\tpollPath: override,\n\t}, nil\n}", "func addSnapshot(w http.ResponseWriter, r *http.Request) (apiErr *ApiError) {\n\t// Turn the JSON request into a Snapshot object\n\tvar snapshot Snapshot\n\terr := json.NewDecoder(r.Body).Decode(&snapshot)\n\tif err != nil {\n\t\treturn &ApiError{JSON_PARSE_ERROR, http.StatusBadRequest}\n\t}\n\n\t// Validate the snapshot object. All fields are mandatory.\n\terr = snapshot.validate()\n\tif err != nil {\n\t\treturn &ApiError{\"Market snapshot failed to validate.\\n\" + err.Error(), http.StatusBadRequest}\n\t}\n\n\t// Get database session.\n\tdb := dbMaster.spawnDb()\n\tdefer db.stop()\n\n\t// Insert the snapshot into the database.\n\terr = db.addSnapshot(&snapshot)\n\tif err != nil {\n\t\treturn &ApiError{DB_ERROR, http.StatusInternalServerError}\n\t}\n\n\t// Return nil if no errours encountered until now.\n\treturn nil\n}", "func NewGenerateCmd() (*cobra.Command, error) {\n\tgenerateCmd := &cobra.Command{\n\t\tUse: \"generate\",\n\t\tShort: \"Generate a Lockfile to track image digests\",\n\t\tPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn bindPFlags(cmd, []string{\n\t\t\t\t\"base-dir\",\n\t\t\t\t\"dockerfiles\",\n\t\t\t\t\"composefiles\",\n\t\t\t\t\"kubernetesfiles\",\n\t\t\t\t\"lockfile-name\",\n\t\t\t\t\"dockerfile-globs\",\n\t\t\t\t\"composefile-globs\",\n\t\t\t\t\"kubernetesfile-globs\",\n\t\t\t\t\"dockerfile-recursive\",\n\t\t\t\t\"composefile-recursive\",\n\t\t\t\t\"kubernetesfile-recursive\",\n\t\t\t\t\"exclude-all-dockerfiles\",\n\t\t\t\t\"exclude-all-composefiles\",\n\t\t\t\t\"exclude-all-kubernetesfiles\",\n\t\t\t\t\"ignore-missing-digests\",\n\t\t\t\t\"update-existing-digests\",\n\t\t\t})\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tflags, err := parseFlags()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tgenerator, err := SetupGenerator(flags)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar lockfileByt bytes.Buffer\n\n\t\t\terr = generator.GenerateLockfile(&lockfileByt)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tlockfileContents := lockfileByt.Bytes()\n\n\t\t\tif len(lockfileContents) == 0 {\n\t\t\t\treturn errors.New(\"no images found\")\n\t\t\t}\n\n\t\t\twriter, err := os.Create(\n\t\t\t\tflags.FlagsWithSharedValues.LockfileName,\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer writer.Close()\n\n\t\t\t_, err = writer.Write(lockfileContents)\n\t\t\tif err == nil {\n\t\t\t\tfmt.Println(\"successfully generated lockfile!\")\n\t\t\t}\n\n\t\t\treturn err\n\t\t},\n\t}\n\tgenerateCmd.Flags().String(\n\t\t\"base-dir\", \".\", \"Top level directory to collect files from\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"dockerfiles\", []string{}, \"Paths to Dockerfiles\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"composefiles\", []string{}, \"Paths to docker-compose files\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"kubernetesfiles\", []string{}, \"Paths to kubernetes files\",\n\t)\n\tgenerateCmd.Flags().String(\n\t\t\"lockfile-name\", \"docker-lock.json\",\n\t\t\"Lockfile name to be output in the current working directory\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"dockerfile-globs\", []string{}, \"Glob pattern to select Dockerfiles\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"composefile-globs\", []string{},\n\t\t\"Glob pattern to select docker-compose files\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"kubernetesfile-globs\", []string{},\n\t\t\"Glob pattern to select kubernetes files\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"dockerfile-recursive\", false, \"Recursively collect Dockerfiles\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"composefile-recursive\", false,\n\t\t\"Recursively collect docker-compose files\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"kubernetesfile-recursive\", false,\n\t\t\"Recursively collect kubernetes files\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"exclude-all-dockerfiles\", false,\n\t\t\"Do not collect Dockerfiles unless referenced by docker-compose files\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"exclude-all-composefiles\", false,\n\t\t\"Do not collect docker-compose files\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"exclude-all-kubernetesfiles\", false,\n\t\t\"Do not collect kubernetes files\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"ignore-missing-digests\", false,\n\t\t\"Do not fail if unable to find digests\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"update-existing-digests\", false,\n\t\t\"Query registries for new digests even if they are hardcoded in files\",\n\t)\n\n\treturn generateCmd, nil\n}", "func (vm *VM) CreateSnapshot(prefix string, description string) (Snapshot,\n\terror) {\n\tvar descriptor libvirtxml.DomainSnapshot\n\n\tfor true {\n\t\tdescriptor = libvirtxml.DomainSnapshot{\n\t\t\tName: prefix + namesgenerator.GetRandomName(0),\n\t\t\tDescription: description,\n\t\t}\n\n\t\t// check if name is already given\n\t\tregex := []string{\"^\" + descriptor.Name + \"$\"}\n\t\tsnapshots, err := vm.ListMatchingSnapshots(regex)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"unable to retrieve existing snapshot for VM '%s': %s\",\n\t\t\t\tvm.Descriptor.Name,\n\t\t\t\terr,\n\t\t\t)\n\t\t\treturn Snapshot{}, err\n\t\t}\n\n\t\tif len(snapshots) == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// create snapshot with the given name\n\txml, err := descriptor.Marshal()\n\tif err != nil {\n\t\terr = fmt.Errorf(\"unable to marshal snapshot XML for VM '%s': %s\",\n\t\t\tvm.Descriptor.Name,\n\t\t\terr,\n\t\t)\n\t\treturn Snapshot{}, err\n\t}\n\n\tsnapshot, err := vm.Instance.CreateSnapshotXML(xml, 0)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"unable to create snapshot for VM '%s': %s\",\n\t\t\tvm.Descriptor.Name,\n\t\t\terr,\n\t\t)\n\t\treturn Snapshot{}, err\n\t}\n\n\treturn Snapshot{\n\t\tInstance: *snapshot,\n\t\tDescriptor: descriptor,\n\t}, nil\n}", "func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {\n\tlog.Debugf(\"Starting Create Snapshot %s with response: %v\", req.Name, req)\n\t// Step 1: check request\n\tsnapshotName := req.GetName()\n\tif len(snapshotName) == 0 {\n\t\tlog.Error(\"CreateSnapshot: snapshot name not provided\")\n\t\treturn nil, status.Error(codes.InvalidArgument, \"CreateSnapshot: snapshot name not provided\")\n\t}\n\tvolumeID := req.GetSourceVolumeId()\n\tif len(volumeID) == 0 {\n\t\tlog.Error(\"CreateSnapshot: snapshot volume source ID not provided\")\n\t\treturn nil, status.Error(codes.InvalidArgument, \"CreateSnapshot: snapshot volume source ID not provided\")\n\t}\n\n\t// Step 2: get snapshot initial size from parameter\n\tinitialSize, _, _, err := getSnapshotInitialInfo(req.Parameters)\n\tif err != nil {\n\t\tlog.Errorf(\"CreateSnapshot: get snapshot %s initial info error: %s\", req.Name, err.Error())\n\t\treturn nil, status.Errorf(codes.Internal, \"CreateSnapshot: get snapshot %s initial info error: %s\", req.Name, err.Error())\n\t}\n\n\t// Step 3: get nodeName and vgName\n\tnodeName, vgName, pv, err := getPvSpec(cs.client, volumeID, cs.driverName)\n\tif err != nil {\n\t\tlog.Errorf(\"CreateSnapshot: get pv %s error: %s\", volumeID, err.Error())\n\t\treturn nil, status.Errorf(codes.Internal, \"CreateSnapshot: get pv %s error: %s\", volumeID, err.Error())\n\t}\n\tlog.Infof(\"CreateSnapshot: snapshot %s is in %s, whose vg is %s\", snapshotName, nodeName, vgName)\n\n\t// Step 4: update initialSize if initialSize is bigger than pv request size\n\tpvSize, _ := pv.Spec.Capacity.Storage().AsInt64()\n\tif pvSize < int64(initialSize) {\n\t\tinitialSize = uint64(pvSize)\n\t}\n\n\t// Step 5: get grpc client\n\tconn, err := cs.getNodeConn(nodeName)\n\tif err != nil {\n\t\tlog.Errorf(\"CreateSnapshot: get grpc client at node %s error: %s\", nodeName, err.Error())\n\t\treturn nil, status.Errorf(codes.Internal, \"CreateSnapshot: get grpc client at node %s error: %s\", nodeName, err.Error())\n\t}\n\tdefer conn.Close()\n\n\t// Step 6: create lvm snapshot\n\tvar lvmName string\n\tif lvmName, err = conn.GetLvm(ctx, vgName, snapshotName); err != nil {\n\t\tlog.Errorf(\"CreateSnapshot: get lvm snapshot %s failed: %s\", snapshotName, err.Error())\n\t\treturn nil, status.Errorf(codes.Internal, \"CreateSnapshot: get lvm snapshot %s failed: %s\", snapshotName, err.Error())\n\t}\n\tif lvmName == \"\" {\n\t\t_, err := conn.CreateSnapshot(ctx, vgName, snapshotName, volumeID, initialSize)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"CreateSnapshot: create lvm snapshot %s failed: %s\", snapshotName, err.Error())\n\t\t\treturn nil, status.Errorf(codes.Internal, \"CreateSnapshot: create lvm snapshot %s failed: %s\", snapshotName, err.Error())\n\t\t}\n\t\tlog.Infof(\"CreateSnapshot: create snapshot %s successfully\", snapshotName)\n\t} else {\n\t\tlog.Infof(\"CreateSnapshot: lvm snapshot %s in node %s already exists\", snapshotName, nodeName)\n\t}\n\treturn cs.newCreateSnapshotResponse(req)\n}", "func (f *IBMPIInstanceClient) CreatePvmSnapShot(snapshotdef *p_cloud_p_vm_instances.PcloudPvminstancesSnapshotsPostParams, pvminstanceid, powerinstanceid string, timeout time.Duration) (*models.SnapshotCreateResponse, error) {\n\n\tparams := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsPostParamsWithTimeout(helpers.PICreateTimeOut).WithPvmInstanceID(pvminstanceid).WithCloudInstanceID(powerinstanceid).WithBody(snapshotdef.Body)\n\tsnapshotpostaccepted, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesSnapshotsPost(params, ibmpisession.NewAuth(f.session, powerinstanceid))\n\tif err != nil || snapshotpostaccepted == nil {\n\t\treturn nil, fmt.Errorf(\"Failed to Create the snapshot %s for the pvminstance : %s\", pvminstanceid, err)\n\t}\n\treturn snapshotpostaccepted.Payload, nil\n}", "func (_this *RaftNode) GenerateSnapshot(data interface{}) ([]byte, error) {\n\t_this.dataRWLock.Lock()\n\tdefer _this.dataRWLock.Unlock()\n\treturn json.Marshal(data)\n}", "func NewGenerateCmd(client *registry.HTTPClient) *cobra.Command {\n\tgenerateCmd := &cobra.Command{\n\t\tUse: \"generate\",\n\t\tShort: \"Generate a Lockfile to track image digests\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif err := validateGenerateCmdFlags(cmd); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tenvPath, err := cmd.Flags().GetString(\"env-file\")\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tenvPath = filepath.ToSlash(envPath)\n\t\t\t_ = godotenv.Load(envPath)\n\t\t\twm, err := getDefaultWrapperManager(cmd, client)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tgenerator, err := generate.NewGenerator(cmd)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tlFile, err := os.Create(generator.LockfileName)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer lFile.Close()\n\t\t\tif err := generator.GenerateLockfile(wm, lFile); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\tgenerateCmd.Flags().String(\n\t\t\"base-dir\", \".\", \"Top level directory to collect files from\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"dockerfiles\", []string{}, \"Path to Dockerfiles\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"compose-files\", []string{}, \"Path to docker-compose files\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"dockerfile-globs\", []string{}, \"Glob pattern to select Dockerfiles\",\n\t)\n\tgenerateCmd.Flags().StringSlice(\n\t\t\"compose-file-globs\", []string{},\n\t\t\"Glob pattern to select docker-compose files\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"dockerfile-recursive\", false, \"Recursively collect Dockerfiles\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"compose-file-recursive\", false,\n\t\t\"Recursively collect docker-compose files\",\n\t)\n\tgenerateCmd.Flags().String(\n\t\t\"lockfile-name\", \"docker-lock.json\",\n\t\t\"Lockfile name to be output in the current working directory\",\n\t)\n\tgenerateCmd.Flags().String(\n\t\t\"config-file\", getDefaultConfigPath(),\n\t\t\"Path to config file for auth credentials\",\n\t)\n\tgenerateCmd.Flags().String(\n\t\t\"env-file\", \".env\", \"Path to .env file\",\n\t)\n\tgenerateCmd.Flags().Bool(\n\t\t\"dockerfile-env-build-args\", false,\n\t\t\"Use environment vars as build args for Dockerfiles\",\n\t)\n\treturn generateCmd\n}", "func New(notifier MountNotifier, statePath string) *Snapshot {\n\t// Initialize default library driver\n\ts := &Snapshot{\n\t\tnotifier: newLocalStateNotifier(statePath, notifier),\n\t}\n\ts.driver = csicommon.NewCSIDriver(\"container-snapshot.openshift.io\", \"0.0.1\", uuid.New())\n\tif s.driver == nil {\n\t\tpanic(\"unable to initialize driver\")\n\t}\n\ts.driver.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{\n\t\tcsi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,\n\t})\n\ts.driver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{\n\t\tcsi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,\n\t\tcsi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,\n\t})\n\n\t// Create GRPC servers\n\ts.identity = &identityServer{\n\t\tDefaultIdentityServer: csicommon.NewDefaultIdentityServer(s.driver),\n\t}\n\ts.node = &nodeServer{\n\t\tDefaultNodeServer: csicommon.NewDefaultNodeServer(s.driver),\n\t\tnotifier: s.notifier,\n\t}\n\ts.controller = &controllerServer{\n\t\tDefaultControllerServer: csicommon.NewDefaultControllerServer(s.driver),\n\t}\n\treturn s\n}", "func (snapshotter *Snapshotter) CreateSnapshot(endpoint *portainer.Endpoint) (*portainer.DockerSnapshot, error) {\n\tcli, err := snapshotter.clientFactory.CreateClient(endpoint, \"\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer cli.Close()\n\n\treturn snapshot(cli, endpoint)\n}", "func newSnapshotCache() cache.SnapshotCache {\n\treturn cache.NewSnapshotCache(false, tbnProxyNodeHash{}, consoleLogger{})\n}", "func (client *Client) Snapshot(expression string) error {\n\trequest, err := client.buildRequest(expression)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thttpClient := &http.Client{}\n\tresponse, err := httpClient.Do(request)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif response.StatusCode != 200 {\n\t\tbody, err := ioutil.ReadAll(response.Body)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error parsing body of non 200 response on snapshot create: %v, %v\", response.StatusCode, err.Error())\n\t\t}\n\n\t\treturn fmt.Errorf(\"Received non 200 status code creating snapshot: %v\\n%v\", response.StatusCode, string(body))\n\t}\n\n\treturn nil\n}", "func Snapshot(d Ploop) (string, error) {\n\tvar p C.struct_ploop_snapshot_param\n\tvar uuid, err = Uuid()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tp.guid = C.CString(uuid)\n\tdefer cfree(p.guid)\n\n\tret := C.ploop_create_snapshot(d.d, &p)\n\tif ret == 0 {\n\t\tuuid = C.GoString(p.guid)\n\t}\n\n\treturn uuid, mkerr(ret)\n}", "func (rf *Raft) Snapshot(index int, snapshot []byte) {\n\t// Your code here (2D).\n\n}", "func (rf *Raft) Snapshot(index int, snapshot []byte) {\n\t// Your code here (2D).\n\n}", "func (rf *Raft) Snapshot(index int, snapshot []byte) {\n\t// Your code here (2D).\n\n}", "func (rf *Raft) Snapshot(index int, snapshot []byte) {\n\t// Your code here (2D).\n\n}", "func (rf *Raft) Snapshot(index int, snapshot []byte) {\n\t// Your code here (2D).\n\n}", "func (rf *Raft) Snapshot(index int, snapshot []byte) {\n\t// Your code here (2D).\n\n}", "func (rf *Raft) Snapshot(index int, snapshot []byte) {\n\t// Your code here (2D).\n\n}", "func (f *Function) CreateInstanceSnapshot() {\n\tlogger := log.WithFields(log.Fields{\"fID\": f.fID})\n\n\tlogger.Debug(\"Creating instance snapshot\")\n\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second*5)\n\tdefer cancel()\n\n\terr := orch.PauseVM(ctx, f.vmID)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\terr = orch.CreateSnapshot(ctx, f.vmID)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\t_, err = orch.ResumeVM(ctx, f.vmID)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n}", "func (in *ActionExportCreateInput) SetSnapshot(value int64) *ActionExportCreateInput {\n\tin.Snapshot = value\n\n\tif in._selectedParameters == nil {\n\t\tin._selectedParameters = make(map[string]interface{})\n\t}\n\n\tin.SetSnapshotNil(false)\n\tin._selectedParameters[\"Snapshot\"] = nil\n\treturn in\n}", "func (d *lvm) MountVolumeSnapshot(snapVol Volume, op *operations.Operation) error {\n\tunlock := snapVol.MountLock()\n\tdefer unlock()\n\n\trevert := revert.New()\n\tdefer revert.Fail()\n\n\tvar err error\n\tmountPath := snapVol.MountPath()\n\n\t// Check if already mounted.\n\tif snapVol.contentType == ContentTypeFS && !filesystem.IsMountPoint(mountPath) {\n\t\terr = snapVol.EnsureMountPath()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Default to mounting the original snapshot directly. This may be changed below if a temporary\n\t\t// snapshot needs to be taken.\n\t\tmountVol := snapVol\n\t\tmountFlags, mountOptions := filesystem.ResolveMountOptions(strings.Split(mountVol.ConfigBlockMountOptions(), \",\"))\n\n\t\t// Regenerate filesystem UUID if needed. This is because some filesystems do not allow mounting\n\t\t// multiple volumes that share the same UUID. As snapshotting a volume will copy its UUID we need\n\t\t// to potentially regenerate the UUID of the snapshot now that we are trying to mount it.\n\t\t// This is done at mount time rather than snapshot time for 2 reasons; firstly snapshots need to be\n\t\t// as fast as possible, and on some filesystems regenerating the UUID is a slow process, secondly\n\t\t// we do not want to modify a snapshot in case it is corrupted for some reason, so at mount time\n\t\t// we take another snapshot of the snapshot, regenerate the temporary snapshot's UUID and then\n\t\t// mount that.\n\t\tregenerateFSUUID := renegerateFilesystemUUIDNeeded(snapVol.ConfigBlockFilesystem())\n\t\tif regenerateFSUUID {\n\t\t\t// Instantiate a new volume to be the temporary writable snapshot.\n\t\t\ttmpVolName := fmt.Sprintf(\"%s%s\", snapVol.name, tmpVolSuffix)\n\t\t\ttmpVol := NewVolume(d, d.name, snapVol.volType, snapVol.contentType, tmpVolName, snapVol.config, snapVol.poolConfig)\n\n\t\t\t// Create writable snapshot from source snapshot named with a tmpVolSuffix suffix.\n\t\t\t_, err = d.createLogicalVolumeSnapshot(d.config[\"lvm.vg_name\"], snapVol, tmpVol, false, d.usesThinpool())\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Error creating temporary LVM logical volume snapshot: %w\", err)\n\t\t\t}\n\n\t\t\trevert.Add(func() {\n\t\t\t\t_ = d.removeLogicalVolume(d.lvmDevPath(d.config[\"lvm.vg_name\"], tmpVol.volType, tmpVol.contentType, tmpVol.name))\n\t\t\t})\n\n\t\t\t// We are going to mount the temporary volume instead.\n\t\t\tmountVol = tmpVol\n\t\t}\n\n\t\tvolDevPath := d.lvmDevPath(d.config[\"lvm.vg_name\"], mountVol.volType, mountVol.contentType, mountVol.name)\n\n\t\t// Activate volume if needed.\n\t\t_, err = d.activateVolume(mountVol)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif regenerateFSUUID {\n\t\t\ttmpVolFsType := mountVol.ConfigBlockFilesystem()\n\n\t\t\t// When mounting XFS filesystems temporarily we can use the nouuid option rather than fully\n\t\t\t// regenerating the filesystem UUID.\n\t\t\tif tmpVolFsType == \"xfs\" {\n\t\t\t\tidx := strings.Index(mountOptions, \"nouuid\")\n\t\t\t\tif idx < 0 {\n\t\t\t\t\tmountOptions += \",nouuid\"\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\td.logger.Debug(\"Regenerating filesystem UUID\", logger.Ctx{\"dev\": volDevPath, \"fs\": tmpVolFsType})\n\t\t\t\terr = regenerateFilesystemUUID(mountVol.ConfigBlockFilesystem(), volDevPath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Finally attempt to mount the volume that needs mounting.\n\t\terr = TryMount(volDevPath, mountPath, mountVol.ConfigBlockFilesystem(), mountFlags|unix.MS_RDONLY, mountOptions)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to mount LVM snapshot volume: %w\", err)\n\t\t}\n\n\t\td.logger.Debug(\"Mounted logical volume snapshot\", logger.Ctx{\"dev\": volDevPath, \"path\": mountPath, \"options\": mountOptions})\n\t} else if snapVol.contentType == ContentTypeBlock {\n\t\t// Activate volume if needed.\n\t\t_, err = d.activateVolume(snapVol)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// For VMs, mount the filesystem volume.\n\t\tif snapVol.IsVMBlock() {\n\t\t\tfsVol := snapVol.NewVMBlockFilesystemVolume()\n\t\t\terr = d.MountVolumeSnapshot(fsVol, op)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tsnapVol.MountRefCountIncrement() // From here on it is up to caller to call UnmountVolumeSnapshot() when done.\n\trevert.Success()\n\treturn nil\n}", "func newVersion() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"version\",\n\t\tShort: \"show build version\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tfmt.Println(version)\n\t\t\treturn nil\n\t\t},\n\t}\n\n\treturn cmd\n}", "func (cs *DefaultControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {\n\treturn nil, status.Error(codes.Unimplemented, \"\")\n}", "func (s *Server) Snapshot(w http.ResponseWriter, r *http.Request) {\n\t_ = json.NewEncoder(w).Encode(s.Regenbox.Snapshot())\n}", "func cephRBDSnapshotCreate(clusterName string, poolName string,\n\tvolumeName string, volumeType string, snapshotName string,\n\tuserName string) error {\n\t_, err := shared.RunCommand(\n\t\t\"rbd\",\n\t\t\"--id\", userName,\n\t\t\"--cluster\", clusterName,\n\t\t\"--pool\", poolName,\n\t\t\"snap\",\n\t\t\"create\",\n\t\t\"--snap\", snapshotName,\n\t\tfmt.Sprintf(\"%s_%s\", volumeType, volumeName))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func NewCmd(name, fullName string) *cobra.Command {\n\treturn &cobra.Command{\n\t\tUse: name,\n\t\tShort: \"Print the version information\",\n\t\tLong: \"Print the version information\",\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tfmt.Printf(\"kam version %s\\n\", Version)\n\t\t},\n\t}\n}", "func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer,\n\treplyFn structs.SnapshotReplyFn) error {\n\treturn a.delegate.SnapshotRPC(args, in, out, replyFn)\n}", "func BdevLvolSnapshot(ctx context.Context, client *Client, args BdevLvolSnapshotArgs) (string, error) {\n\tvar response string\n\terr := client.Invoke(ctx, \"bdev_lvol_snapshot\", args, &response)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn response, err\n}", "func ExampleRDS_CreateDBSnapshot_shared00() {\n\tsvc := rds.New(session.New())\n\tinput := &rds.CreateDBSnapshotInput{\n\t\tDBInstanceIdentifier: aws.String(\"mydbsnapshot\"),\n\t\tDBSnapshotIdentifier: aws.String(\"database-mysql\"),\n\t}\n\n\tresult, err := svc.CreateDBSnapshot(input)\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tcase rds.ErrCodeDBSnapshotAlreadyExistsFault:\n\t\t\t\tfmt.Println(rds.ErrCodeDBSnapshotAlreadyExistsFault, aerr.Error())\n\t\t\tcase rds.ErrCodeInvalidDBInstanceStateFault:\n\t\t\t\tfmt.Println(rds.ErrCodeInvalidDBInstanceStateFault, aerr.Error())\n\t\t\tcase rds.ErrCodeDBInstanceNotFoundFault:\n\t\t\t\tfmt.Println(rds.ErrCodeDBInstanceNotFoundFault, aerr.Error())\n\t\t\tcase rds.ErrCodeSnapshotQuotaExceededFault:\n\t\t\t\tfmt.Println(rds.ErrCodeSnapshotQuotaExceededFault, aerr.Error())\n\t\t\tdefault:\n\t\t\t\tfmt.Println(aerr.Error())\n\t\t\t}\n\t\t} else {\n\t\t\t// Print the error, cast err to awserr.Error to get the Code and\n\t\t\t// Message from an error.\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(result)\n}", "func (c *cstorSnapshotCreate) Run() (r RunCommandResult) {\n\terr := c.validateOptions()\n\tif err != nil {\n\t\treturn c.AddError(errors.Errorf(\"failed to create cstor snapshot: %s\", err)).Result(nil)\n\t}\n\tip, _ := c.Data[\"ip\"].(string)\n\n\t// get snapshot operation struct\n\tsnapOps := cstor.Cstor()\n\tsnapOps.IP = ip\n\tsnapOps.Snap = c.casSnapshot()\n\n\t// use the struct to call the Create method\n\tresponse, err := snapOps.Create()\n\tif err != nil {\n\t\treturn c.AddError(err).Result(nil)\n\t}\n\treturn c.Result(response)\n}", "func newNativeSnapshot(c *C.rocksdb_snapshot_t) *Snapshot {\n\treturn &Snapshot{c: c}\n}", "func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) {\n\tvar err error\n\n\tif req.Region == \"\" {\n\t\tdefaultRegion, _ := s.client.GetDefaultRegion()\n\t\treq.Region = defaultRegion\n\t}\n\n\tif req.Name == \"\" {\n\t\treq.Name = namegenerator.GetRandomName(\"snp\")\n\t}\n\n\tif fmt.Sprint(req.Region) == \"\" {\n\t\treturn nil, errors.New(\"field Region cannot be empty in request\")\n\t}\n\n\tif fmt.Sprint(req.InstanceID) == \"\" {\n\t\treturn nil, errors.New(\"field InstanceID cannot be empty in request\")\n\t}\n\n\tscwReq := &scw.ScalewayRequest{\n\t\tMethod: \"POST\",\n\t\tPath: \"/rdb/v1/regions/\" + fmt.Sprint(req.Region) + \"/instances/\" + fmt.Sprint(req.InstanceID) + \"/snapshots\",\n\t\tHeaders: http.Header{},\n\t}\n\n\terr = scwReq.SetBody(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resp Snapshot\n\n\terr = s.client.Do(scwReq, &resp, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {\n\treturn nil, status.Error(codes.Unimplemented, \"\")\n}", "func (img *Image) CreateSnapshot(name string) (*Snapshot, error) {\n\targs := img.cmdArgs(\"snap\", \"create\", \"--snap\", name)\n\terr := cmdRun(createErrs, args...)\n\tif err != nil && !errors.Is(err, ErrAlreadyExists) {\n\t\treturn nil, err\n\t}\n\treturn img.getSnapshot(name), err\n}", "func (a Agent) SnapshotDeploy(sid int, keepFiles bool, password string, snapshot RawSnapshot) error {\n\treq := libts.Request{\n\t\tCommand: \"serversnapshotdeploy\",\n\t\tServerID: sid,\n\t\tArgs: map[string]interface{}{\n\t\t\t\"password\": password,\n\t\t},\n\t}\n\tif keepFiles {\n\t\treq.Args[\"-keepfiles\"] = \"\"\n\t}\n\treq.Args[\"version\"] = snapshot.Version\n\treq.Args[\"salt\"] = snapshot.Salt\n\treq.Args[\"data\"] = snapshot.Data\n\treturn a.Query.Do(req, nil)\n}", "func (d CephDriver) CreateBlockDeviceSnapshot(volumeUUID string, snapshotID string) error {\n\tvar cmd *exec.Cmd\n\tcmd = exec.Command(\"rbd\", \"--id\", d.ID, \"snap\", \"create\", volumeUUID+\"@\"+snapshotID)\n\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error when running: %v: %v: %s\", cmd.Args, err, out)\n\t}\n\n\tcmd = exec.Command(\"rbd\", \"--id\", d.ID, \"snap\", \"protect\", volumeUUID+\"@\"+snapshotID)\n\n\tout, err = cmd.CombinedOutput()\n\tif err != nil {\n\t\td.DeleteBlockDevice(volumeUUID)\n\t\treturn fmt.Errorf(\"Error when running: %v: %v: %s\", cmd.Args, err, out)\n\t}\n\treturn nil\n}", "func AddNewProvisionerCmd(newCmd *cobra.Command) {\n\tprovisionersNewCmd.AddCommand(newCmd)\n}", "func NewCmd(args ...interface{}) *redis.Cmd {\n\treturn redis.NewCmd(args...)\n}", "func (driver *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {\n\treturn nil, status.Error(codes.Unimplemented, \"\")\n}", "func ProvisionSnapshot(\n\tsnap *apis.ZFSSnapshot,\n) error {\n\n\t_, err := snapbuilder.NewKubeclient().WithNamespace(OpenEBSNamespace).Create(snap)\n\tif err == nil {\n\t\tklog.Infof(\"provisioned snapshot %s\", snap.Name)\n\t}\n\n\treturn err\n}", "func (d *lvm) CreateVolumeSnapshot(snapVol Volume, op *operations.Operation) error {\n\tparentName, _, _ := api.GetParentAndSnapshotName(snapVol.name)\n\tparentVol := NewVolume(d, d.name, snapVol.volType, snapVol.contentType, parentName, snapVol.config, snapVol.poolConfig)\n\tsnapPath := snapVol.MountPath()\n\n\t// Create the parent directory.\n\terr := createParentSnapshotDirIfMissing(d.name, snapVol.volType, parentName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trevert := revert.New()\n\tdefer revert.Fail()\n\n\t// Create snapshot directory.\n\terr = snapVol.EnsureMountPath()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trevert.Add(func() { _ = os.RemoveAll(snapPath) })\n\n\t_, err = d.createLogicalVolumeSnapshot(d.config[\"lvm.vg_name\"], parentVol, snapVol, true, d.usesThinpool())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error creating LVM logical volume snapshot: %w\", err)\n\t}\n\n\tvolDevPath := d.lvmDevPath(d.config[\"lvm.vg_name\"], snapVol.volType, snapVol.contentType, snapVol.name)\n\n\trevert.Add(func() {\n\t\t_ = d.removeLogicalVolume(volDevPath)\n\t})\n\n\t// For VMs, also snapshot the filesystem.\n\tif snapVol.IsVMBlock() {\n\t\tparentFSVol := parentVol.NewVMBlockFilesystemVolume()\n\t\tfsVol := snapVol.NewVMBlockFilesystemVolume()\n\t\t_, err = d.createLogicalVolumeSnapshot(d.config[\"lvm.vg_name\"], parentFSVol, fsVol, true, d.usesThinpool())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error creating LVM logical volume snapshot: %w\", err)\n\t\t}\n\t}\n\n\trevert.Success()\n\treturn nil\n}", "func newFileCmd() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"file\",\n\t\tShort: \"run File gNOI RPCs\",\n\n\t\tSilenceUsage: true,\n\t}\n\tgApp.InitFileFlags(cmd)\n\treturn cmd\n}", "func newSyncCommand() cli.Command {\n\treturn new(syncCommand).getCommand()\n}", "func (c *SSCommand) Help() string {\n\treturn `\n\tDescription:\n\tSnapshot an instance (no reboot) and create an AMI\n\n\tUsage:\n\t\tawsgo-tools snapshot [flags]\n\n\tFlags:\n\t-a to use auto mode to snapshot all instances with tag key of autobkup\n\t-i <instanceid> to snapshot one EC2 instance\n\t-n - Dry run. Report what would have happened but make no changes\n\t-f force an instance reboot when making the snapshot\n\t-v to produce verbose output\n\t`\n}", "func NewCmdVolumeExporter() *cobra.Command {\n\t// create an instance of VolumeExporterOptions to initialize with default\n\t// values for the flags.\n\toptions := VolumeExporterOptions{}\n\toptions.ControllerAddress = \"http://localhost:9501\"\n\toptions.ListenAddress = \":9500\"\n\toptions.MetricsPath = \"/metrics\"\n\tcmd := &cobra.Command{\n\t\tUse: \"monitor\",\n\t\tShort: \"Collect metrics from OpenEBS volumes\",\n\t\tLong: ` monitor command is used to start monitoring openebs volumes. It\n start collecting metrics from the jiva controller at the endpoint\n \"/v1/stats\" and push it to Prometheus Server`,\n\t\tExample: ` maya-agent monitor -a=http://localhost:8001 -c=:9500 -m=/metrics`,\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tutil.CheckErr(Run(cmd, &options), util.Fatal)\n\t\t},\n\t}\n\n\tAddControllerAddressFlag(cmd, &options.ControllerAddress)\n\tAddListenAddressFlag(cmd, &options.ListenAddress)\n\tAddMetricsPathFlag(cmd, &options.MetricsPath)\n\n\treturn cmd\n}", "func (c *PostgresConnection) DumpSnapshot(\n\tctx context.Context, snapshotName string,\n) (dump db.DatabaseData, err error) {\n\tif err = c.DoInTransactionSnapshot(ctx, snapshotName, func(ctx context.Context) error {\n\t\tdump, err = c.db.Dump(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn dump, nil\n}", "func (c *restClient) CreateSnapshotOperation(name string) *CreateSnapshotOperation {\n\toverride := fmt.Sprintf(\"/v1/%s\", name)\n\treturn &CreateSnapshotOperation{\n\t\tlro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),\n\t\tpollPath: override,\n\t}\n}" ]
[ "0.7127528", "0.6976639", "0.6315205", "0.6281483", "0.6244356", "0.6174659", "0.59622616", "0.57991153", "0.5735832", "0.5718462", "0.56993085", "0.5630121", "0.5628828", "0.561144", "0.5593766", "0.5501497", "0.549639", "0.5496263", "0.54405695", "0.54318595", "0.5427724", "0.5415986", "0.5385018", "0.537261", "0.53536755", "0.53116554", "0.5304438", "0.52929324", "0.52606773", "0.5256073", "0.52462214", "0.5225523", "0.5220606", "0.5218504", "0.52008975", "0.5165884", "0.5149008", "0.513264", "0.51323825", "0.5125834", "0.5115147", "0.5102285", "0.50991946", "0.50957584", "0.50919956", "0.50909394", "0.5086863", "0.50747895", "0.50537944", "0.5053172", "0.5041106", "0.5027091", "0.5023336", "0.50222874", "0.5020378", "0.5004026", "0.50020874", "0.5001553", "0.49837378", "0.4977091", "0.49680397", "0.49585742", "0.49539757", "0.494789", "0.49460524", "0.49460524", "0.49460524", "0.49460524", "0.49460524", "0.49460524", "0.49460524", "0.4928824", "0.49259818", "0.49165165", "0.4898622", "0.4895408", "0.48820433", "0.48749095", "0.4873544", "0.4850818", "0.4848865", "0.48483607", "0.4844366", "0.48413724", "0.4838188", "0.48342982", "0.48315263", "0.48251203", "0.48246697", "0.4823866", "0.48222187", "0.48208028", "0.4814477", "0.48133337", "0.48117605", "0.48073643", "0.48053885", "0.48052296", "0.48026013", "0.48019904" ]
0.7492406
0
IsDNS1123Label tests for a string that conforms to the definition of a label in DNS (RFC 1123).
func IsDNS1123Label(value string) bool { if len(value) > dns1123LabelMaxLength { return false } if !dns1123LabelRegexp.MatchString(value) { return false } return true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NameIsDNSLabel(name string, prefix bool) []string {\n\tif prefix {\n\t\tname = maskTrailingDash(name)\n\t}\n\treturn validation.IsDNS1123Label(name)\n}", "func validDNSLabel(s string) bool {\n\tif len(s) > 63 {\n\t\treturn false\n\t}\n\n\tfor i, r := range s {\n\t\tif i == 0 || i == len(s)-1 {\n\t\t\tif (r < 'a' || r > 'z') && (r < '0' || r > '9') {\n\t\t\t\treturn false\n\t\t\t}\n\t\t} else {\n\t\t\tif (r < 'a' || r > 'z') && (r < '0' || r > '9') && (r != '-') {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true\n}", "func NameIsDNS1035Label(name string, prefix bool) []string {\n\tif prefix {\n\t\tname = maskTrailingDash(name)\n\t}\n\treturn validation.IsDNS1035Label(name)\n}", "func isDnsRFC1035LabelFormat(fl FieldLevel) bool {\n\tval := fl.Field().String()\n\treturn dnsRegexRFC1035Label.MatchString(val)\n}", "func IsValidLabel(label string) []string {\n\tvar labelerrs []string\n\n\texpectLabelName := false\n\texpectLabelPrefix := false\n\n\t// split label up into prefix, name and value\n\t// format: prefix/name=value\n\tvar labelprefix, labelname, labelvalue string\n\n\tkv := strings.SplitN(label, \"=\", 2)\n\tif len(kv) == 1 {\n\t\tlabelprefix = \"\"\n\t\tlabelname = \"\"\n\t\tlabelvalue = kv[0]\n\t} else {\n\t\tpn := strings.SplitN(kv[0], \"/\", 2)\n\t\tif len(pn) == 1 {\n\t\t\tlabelprefix = \"\"\n\t\t\tlabelname = pn[0]\n\t\t} else {\n\t\t\tlabelprefix = pn[0]\n\t\t\tlabelname = pn[1]\n\t\t\texpectLabelPrefix = true\n\t\t}\n\t\tlabelvalue = kv[1]\n\t\t// if \"=\" was in the label input, then expect a non-zero length name\n\t\texpectLabelName = true\n\t}\n\n\t// check label prefix validity - prefix is optional\n\tif len(labelprefix) > 0 {\n\t\terrs := validation.IsDNS1123Subdomain(labelprefix)\n\t\tif len(errs) > 0 {\n\t\t\tlabelerrs = append(labelerrs, \"Invalid label prefix - label=[\"+label+\"%], labelprefix=[\"+labelprefix+\"], errors: \")\n\t\t\tfor _, err := range errs {\n\t\t\t\tlabelerrs = append(labelerrs, err)\n\t\t\t}\n\t\t}\n\t} else if expectLabelPrefix {\n\t\tlabelerrs = append(labelerrs, \"Invalid label prefix - label=[\"+label+\"%], labelprefix=[\"+labelprefix+\"]\")\n\t}\n\tif expectLabelName {\n\t\terrs := validation.IsDNS1123Label(labelname)\n\t\tif len(errs) > 0 {\n\t\t\tlabelerrs = append(labelerrs, \"Invalid label name - label=[\"+label+\"%], labelname=[\"+labelname+\"], errors: \")\n\t\t\tfor _, err := range errs {\n\t\t\t\tlabelerrs = append(labelerrs, err)\n\t\t\t}\n\t\t}\n\t}\n\tif len(labelvalue) > 0 {\n\t\terrs := validation.IsValidLabelValue(labelvalue)\n\t\tif len(errs) > 0 {\n\t\t\tlabelerrs = append(labelerrs, \"Invalid label value - label=[\"+label+\"%], labelvalue=[\"+labelvalue+\"], errors: \")\n\t\t\tfor _, err := range errs {\n\t\t\t\tlabelerrs = append(labelerrs, err)\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// expect a non-zero value\n\t\tlabelerrs = append(labelerrs, \"Invalid label value - label=[\"+label+\"%], labelvalue=[\"+labelvalue+\"]\")\n\t}\n\n\treturn labelerrs\n}", "func DNSLabel(value string) error {\n\tre := `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{0,62}){1}(\\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*?$`\n\tif !regexp.MustCompile(re).MatchString(value) {\n\t\treturn fmt.Errorf(\"value '%s' must match '%s' regexp (DNS label, RFC 1123)\", value, re)\n\t}\n\n\treturn nil\n}", "func DNSLabel(label string) error {\n\tDNSlenLimits := intranger.IntRanger(1, 63)\n\tif !DNSlenLimits.Containing(len(label)) {\n\t\treturn ErrInvalidDNSLabel.CommentF(\"DNS label length can be in range %v\", DNSlenLimits)\n\t}\n\tif !dnsLabelRe.MatchString(label) {\n\t\treturn ErrInvalidDNSLabel.Comment(\n\t\t\t\"must consist of a-Z 1-9 and '-'(dash) letters\",\n\t\t\t\"must start and end with a-Z 1-9 letters\",\n\t\t)\n\t}\n\tif numericRe.MatchString(label) {\n\t\treturn ErrInvalidLabel.CommentF(\"must not consist of all numeric values\")\n\t}\n\treturn nil\n}", "func FormatToDNS1123(name string) string {\n\treturn strings.ToLower(strings.ReplaceAll(name, \"_\", \"-\"))\n}", "func IsDNS(str string) bool {\n\tif str == \"\" || len(strings.Replace(str, \".\", \"\", -1)) > 255 {\n\t\t// constraints already violated\n\t\treturn false\n\t}\n\treturn !IsIP(str) && rxDNSName.MatchString(str)\n}", "func IsDNSName(str string) bool {\n\tif str == \"\" || len(strings.Replace(str, \".\", \"\", -1)) > 255 {\n\t\t// constraints already violated\n\t\treturn false\n\t}\n\treturn !IsIP(str) && rxDNSName.MatchString(str)\n}", "func ValidLabel(label string) bool {\n\treturn len(label) <= maxLabel && labelRegex.Match([]byte(label))\n}", "func RFC1123(name string) string {\n\treturn string(label([]byte(name), 63, \"-\", \"-\"))\n}", "func IsHostname(str string) bool {\n\tif !rxHostname.MatchString(str) {\n\t\treturn false\n\t}\n\n\t// the sum of all label octets and label lengths is limited to 255.\n\tif len(str) > 255 {\n\t\treturn false\n\t}\n\n\t// Each node has a label, which is zero to 63 octets in length\n\tparts := strings.Split(str, \".\")\n\tvalid := true\n\tfor _, p := range parts {\n\t\tif len(p) > 63 {\n\t\t\tvalid = false\n\t\t}\n\t}\n\treturn valid\n}", "func DNSName(str string) bool {\n\tif str == \"\" || len(strings.Replace(str, \".\", \"\", -1)) > 255 {\n\t\t// constraints already violated\n\t\treturn false\n\t}\n\treturn rxDNSName.MatchString(str)\n}", "func validateDockerLabel(dockerLabel string) (string, error) {\n\tdockerLabel = sanitize(dockerLabel)\n\tif dockerLabel == \"\" {\n\t\treturn \"dd-dns.hostname\", nil\n\t}\n\treturn dockerLabel, nil\n}", "func LabelIsValid(label string) bool {\n\tcLabel := C.CString(label)\n\tdefer C.free(unsafe.Pointer(cLabel))\n\n\treturn bool(C.daos_label_is_valid(cLabel))\n}", "func IsMSSQLLabel(s string) bool {\n\tif len(s) < 2 {\n\t\treturn false\n\t}\n\tif string(s[len(s)]) == \":\" && IsMSSQLIdentifier(s[0:len(s)-1]) {\n\t\treturn true\n\t}\n\treturn false\n}", "func toDNS1123Subdomain(name string) string {\n\t// If it is not a valid DNS1123 subdomain, make it a valid one.\n\tif msgs := validation.IsDNS1123Subdomain(name); len(msgs) != 0 {\n\t\t// If the length exceeds the max, cut it and leave some room for a potential generated UUID.\n\t\tif len(name) > validation.DNS1123SubdomainMaxLength {\n\t\t\tname = name[:validation.DNS1123SubdomainMaxLength-generateNameSafety]\n\t\t}\n\t\tname = strings.ToLower(name)\n\t\tname = validChars.ReplaceAllString(name, \"\")\n\t\t// Only start/end with alphanumeric.\n\t\tname = strings.Trim(name, \"-.\")\n\t}\n\treturn name\n}", "func Validate(label string) error {\n\tif len(label) > MaxLength {\n\t\treturn ErrLabelTooLong\n\t}\n\n\t// If the label is shorter than our reserved prefix, it cannot contain\n\t// it.\n\tif len(label) < len(Reserved) {\n\t\treturn nil\n\t}\n\n\t// Check if our label begins with our reserved prefix. We don't mind if\n\t// it has our reserved prefix in another case, we just need to be able\n\t// to reserve a subset of labels with this prefix.\n\tif label[0:len(Reserved)] == Reserved {\n\t\treturn ErrReservedPrefix\n\t}\n\n\treturn nil\n}", "func isLabel(input string) bool {\n\tif len(input) > 0 {\n\t\tfor _, t := range labelList {\n\t\t\tif t == input {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "func isDomainName(s string) bool {\n\t// See RFC 1035, RFC 3696.\n\t// Presentation format has dots before every label except the first, and the\n\t// terminal empty label is optional here because we assume fully-qualified\n\t// (absolute) input. We must therefore reserve space for the first and last\n\t// labels' length octets in wire format, where they are necessary and the\n\t// maximum total length is 255.\n\t// So our _effective_ maximum is 253, but 254 is not rejected if the last\n\t// character is a dot.\n\tl := len(s)\n\tif l == 0 || l > 254 || l == 254 && s[l-1] != '.' {\n\t\treturn false\n\t}\n\n\tlast := byte('.')\n\tnonNumeric := false // true once we've seen a letter or hyphen\n\tpartlen := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tc := s[i]\n\t\tswitch {\n\t\tdefault:\n\t\t\treturn false\n\t\tcase 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_':\n\t\t\tnonNumeric = true\n\t\t\tpartlen++\n\t\tcase '0' <= c && c <= '9':\n\t\t\t// fine\n\t\t\tpartlen++\n\t\tcase c == '-':\n\t\t\t// Byte before dash cannot be dot.\n\t\t\tif last == '.' {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tpartlen++\n\t\t\tnonNumeric = true\n\t\tcase c == '.':\n\t\t\t// Byte before dot cannot be dot, dash.\n\t\t\tif last == '.' || last == '-' {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif partlen > 63 || partlen == 0 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tpartlen = 0\n\t\t}\n\t\tlast = c\n\t}\n\tif last == '-' || partlen > 63 {\n\t\treturn false\n\t}\n\n\treturn nonNumeric\n}", "func RFC1123(inputStr string) string {\n\t// Map to lowercase\n\ttmpStr := strings.ToLower(inputStr)\n\n\t// only allow rfc compliant characters to lowercase\n\tdash := rune('-')\n\tvar na rune\n\trfc := func(r rune) rune {\n\t\tswitch {\n\t\tcase r >= '0' && r <= '9':\n\t\t\treturn r\n\t\tcase r >= 'a' && r <= 'z':\n\t\t\treturn r\n\t\tcase r == dash:\n\t\t\treturn r\n\t\t}\n\t\treturn na\n\t}\n\ttmpStr = strings.Map(rfc, tmpStr)\n\tif len(tmpStr) > 63 {\n\t\tfmt.Println(\"first 63 chars:\", tmpStr)\n\t\treturn tmpStr[0:62]\n\t} else {\n\t\treturn tmpStr\n\t}\n}", "func validateNamespace(ns string) error {\n\terrs := validation.IsDNS1123Label(ns)\n\tif len(errs) == 0 {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"invalid namespace %q, %v\", ns, errs)\n}", "func hasNFDLabels(labels map[string]string) bool {\n\tfor key := range labels {\n\t\tif strings.HasPrefix(key, nfdLabelPrefix) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func IsValidHostname(hostname string) bool {\n\tfor _, label := range strings.Split(hostname, \".\") {\n\t\tif len(validation.IsDNS1035Label(label)) > 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func IsDomainName(s string) bool {\n\t// The root domain name is valid. See golang.org/issue/45715.\n\tif s == \".\" {\n\t\treturn true\n\t}\n\n\t// See RFC 1035, RFC 3696.\n\t// Presentation format has dots before every label except the first, and the\n\t// terminal empty label is optional here because we assume fully-qualified\n\t// (absolute) input. We must therefore reserve space for the first and last\n\t// labels' length octets in wire format, where they are necessary and the\n\t// maximum total length is 255.\n\t// So our _effective_ maximum is 253, but 254 is not rejected if the last\n\t// character is a dot.\n\tl := len(s)\n\tif l == 0 || l > 254 || l == 254 && s[l-1] != '.' {\n\t\treturn false\n\t}\n\n\tlast := byte('.')\n\tnonNumeric := false // true once we've seen a letter or hyphen\n\tpartlen := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tc := s[i]\n\t\tswitch {\n\t\tdefault:\n\t\t\treturn false\n\t\tcase 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_':\n\t\t\tnonNumeric = true\n\t\t\tpartlen++\n\t\tcase '0' <= c && c <= '9':\n\t\t\t// fine\n\t\t\tpartlen++\n\t\tcase c == '-':\n\t\t\t// Byte before dash cannot be dot.\n\t\t\tif last == '.' {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tpartlen++\n\t\t\tnonNumeric = true\n\t\tcase c == '.':\n\t\t\t// Byte before dot cannot be dot, dash.\n\t\t\tif last == '.' || last == '-' {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif partlen > 63 || partlen == 0 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tpartlen = 0\n\t\t}\n\t\tlast = c\n\t}\n\tif last == '-' || partlen > 63 {\n\t\treturn false\n\t}\n\n\treturn nonNumeric\n}", "func IsValidLabelKey(s string) bool {\n\treturn validLabelKey.MatchString(s)\n}", "func ValidK8sValue(inputStr string) string {\n\treturn RFC1123(inputStr)\n}", "func HasReservedLabelPrefix(s string) bool {\n\treturn reservedLabelPrefix.MatchString(s)\n}", "func ValidateLabel(text string) error {\n\ttext = strings.TrimSpace(text)\n\tif text == \"\" {\n\t\treturn fmt.Errorf(\"label cannot be empty\")\n\t} else if strings.Contains(text, \"/\") {\n\t\treturn fmt.Errorf(\"label cannot contain `/`\")\n\t} else if strings.Contains(text, \"|\") {\n\t\treturn fmt.Errorf(\"label cannot contain `|`\")\n\t}\n\treturn nil\n}", "func (ln LabelName) IsValid() bool {\n\tif len(ln) == 0 {\n\t\treturn false\n\t}\n\tfor i, b := range ln {\n\t\tif !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || (b >= '0' && b <= '9' && i > 0)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func ValidateLabel(l RextLabelDef) (hasError bool) {\n\tif len(l.GetName()) == 0 {\n\t\thasError = true\n\t\tlog.Errorln(\"name is required in label config\")\n\t}\n\tif l.GetNodeSolver() == nil {\n\t\thasError = true\n\t\tlog.Errorln(\"node solver is required in label config\")\n\t} else if l.GetNodeSolver().Validate() {\n\t\thasError = true\n\t}\n\treturn hasError\n}", "func LabelWithString(s string) (*Label, error) {\n\t// intern case preserved\n\tvalue, ok := labelNames.Load(s)\n\tif ok {\n\t\treturn value.(*Label), nil\n\t}\n\n\tn := len(s)\n\tif n > 63 {\n\t\treturn nil, ErrLabel\n\t}\n\tl := &Label{}\n\tl.data = make([]byte, n+1)\n\tl.data[0] = byte(n)\n\tfor i := 0; i < n; i++ {\n\t\tb := s[i]\n\t\tif b == 0 {\n\t\t\tl.data[i+1] = '.'\n\t\t} else {\n\t\t\tl.data[i+1] = byte(b)\n\t\t}\n\t}\n\tl.key = strings.ToLower(string(l.data[1:]))\n\n\t// if we race, faster to throw away our new one than to replace the old one\n\tvalue, _ = labelNames.LoadOrStore(s, l)\n\treturn value.(*Label), nil\n}", "func isLabelUnique(ctx context.Context, ss do.ServerlessService, label string) (bool, error) {\n\tresp, err := ss.ListNamespaces(ctx)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tfor _, ns := range resp.Namespaces {\n\t\tif label == ns.Label {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\treturn true, nil\n}", "func IsKubernetesLabel(key string) bool {\n\tnamespace := getLabelNamespace(key)\n\tif namespace == \"kubernetes.io\" || strings.HasSuffix(namespace, \".kubernetes.io\") {\n\t\treturn true\n\t}\n\tif namespace == \"k8s.io\" || strings.HasSuffix(namespace, \".k8s.io\") {\n\t\treturn true\n\t}\n\treturn false\n}", "func HasLabel(label string, issueLabels []*github.Label) bool {\n\tfor _, l := range issueLabels {\n\t\tif strings.ToLower(l.GetName()) == strings.ToLower(label) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidateLabelName(identifier, label string) error {\n\tif strings.HasPrefix(label, \"!\") {\n\t\treturn fmt.Errorf(\"%s : Invalid label: name must not contain '!'\", identifier)\n\t}\n\treturn nil\n}", "func labelExactMatch(pr *gogithub.PullRequest, labelToFind string) bool {\n\tfor _, label := range pr.Labels {\n\t\tif *label.Name == labelToFind {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (v *testVolume) isLabel(label uint64, body *testBody) bool {\n\tnx := v.size[0]\n\tnxy := nx * v.size[1]\n\tfor _, span := range body.voxelSpans {\n\t\tz, y, x0, x1 := span.Unpack()\n\t\tp := (z*nxy + y*nx) * 8\n\t\tfor i := p + x0*8; i <= p+x1*8; i += 8 {\n\t\t\tcurLabel := binary.LittleEndian.Uint64(v.data[i : i+8])\n\t\t\tif curLabel != label {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}", "func validChallengeAddr(a string) bool {\n\t// TODO: flesh this out. parse a, make configurable, support\n\t// IPv6. Good enough for now.\n\treturn strings.HasPrefix(a, \"10.\") || strings.HasPrefix(a, \"192.168.\")\n}", "func HasXNLabelPrefix(s string) bool {\n\treturn xnLabelPrefix.MatchString(s)\n}", "func validDelegateServerName(n string) bool {\n\tif n == \"\" {\n\t\treturn false\n\t}\n\tif !strings.Contains(n, \".\") {\n\t\treturn false\n\t}\n\tif strings.Contains(n, \":\") {\n\t\t// Contains port or is IPv6 literal.\n\t\treturn false\n\t}\n\tif net.ParseIP(n) != nil {\n\t\t// No IPs.\n\t\treturn false\n\t}\n\tif \"x://\"+n != (&url.URL{Scheme: \"x\", Host: n}).String() {\n\t\t// name must have contained invalid characters and caused escaping.\n\t\treturn false\n\t}\n\treturn true\n}", "func K8sName(userInput string) error {\n\terrStrings := validation.IsDNS1123Subdomain(userInput)\n\tif len(errStrings) > 0 {\n\t\treturn eris.New(strings.Join(errStrings, \". \"))\n\t}\n\treturn nil\n}", "func SafeLabel(s string) (string, error) {\n\tmaxlen := 61\n\t// Replace common invalid chars\n\ts = strings.Replace(s, \"/\", \"-\", -1)\n\ts = strings.Replace(s, \"_\", \"-\", -1)\n\ts = strings.Replace(s, \":\", \"-\", -1)\n\n\t// Trim to max length\n\tif len(s) > maxlen {\n\t\ts = s[0:maxlen]\n\t}\n\n\t// Ensure the string doesn't begin or end in -\n\ts = strings.TrimSuffix(s, \"-\")\n\ts = strings.TrimPrefix(s, \"-\")\n\n\t// Ensure the string doesn't begin with a number\n\tif numFirstRe.MatchString(s) {\n\t\ts = \"n\" + s\n\t}\n\n\t// The sanitized value should pass the GCE regex\n\tif mustMatchRe.MatchString(s) {\n\t\treturn s, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"Label value %q did not satisfy the GCE label regexp\", s)\n}", "func validateBrokerName(name string) error {\n\terrs := validation.IsDNS1123Label(name)\n\tif len(errs) == 0 {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"invalid name %q, %v\", name, errs)\n}", "func isNulName(name string) bool {\n\tif len(name) != 3 {\n\t\treturn false\n\t}\n\tif name[0] != 'n' && name[0] != 'N' {\n\t\treturn false\n\t}\n\tif name[1] != 'u' && name[1] != 'U' {\n\t\treturn false\n\t}\n\tif name[2] != 'l' && name[2] != 'L' {\n\t\treturn false\n\t}\n\treturn true\n}", "func IsFQDN(fqdn, hostname string) bool {\n\treturn len(fqdn) > len(hostname) && strings.HasPrefix(fqdn, hostname)\n}", "func hostnameInSNI(name string) string {\n\thost := name\n\tif len(host) > 0 && host[0] == '[' && host[len(host)-1] == ']' {\n\t\thost = host[1 : len(host)-1]\n\t}\n\tif i := strings.LastIndex(host, \"%\"); i > 0 {\n\t\thost = host[:i]\n\t}\n\tif net.ParseIP(host) != nil {\n\t\treturn \"\"\n\t}\n\tfor len(name) > 0 && name[len(name)-1] == '.' {\n\t\tname = name[:len(name)-1]\n\t}\n\treturn name\n}", "func (v *testVolume) hasLabel(label uint64, body *testBody) bool {\n\tnx := v.size[0]\n\tnxy := nx * v.size[1]\n\tfor _, span := range body.voxelSpans {\n\t\tz, y, x0, x1 := span.Unpack()\n\t\tp := (z*nxy + y*nx) * 8\n\t\tfor i := p + x0*8; i <= p+x1*8; i += 8 {\n\t\t\tcurLabel := binary.LittleEndian.Uint64(v.data[i : i+8])\n\t\t\tif curLabel == label {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "func IsIP(s string) bool { return s != \"\" && net.ParseIP(s) != nil }", "func FQDN(s string) bool {\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] >= utf8.RuneSelf {\n\t\t\treturn false\n\t\t}\n\t}\n\t_, err := idnaProfile.ToASCII(s)\n\treturn err == nil\n}", "func IsSSN(str string) bool {\n\tif str == \"\" || len(str) != 11 {\n\t\treturn false\n\t}\n\treturn rxSSN.MatchString(str)\n}", "func ValidateDNSPrefix(dnsName string) error {\n\tdnsNameRegex := `^([A-Za-z][A-Za-z0-9-]{1,43}[A-Za-z0-9])$`\n\tre, err := regexp.Compile(dnsNameRegex)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !re.MatchString(dnsName) {\n\t\treturn errors.Errorf(\"DNSPrefix '%s' is invalid. The DNSPrefix must contain between 3 and 45 characters and can contain only letters, numbers, and hyphens. It must start with a letter and must end with a letter or a number. (length was %d)\", dnsName, len(dnsName))\n\t}\n\treturn nil\n}", "func (suite *PouchDaemonSuite) TestDaemonLabel(c *check.C) {\n\tdcfg, err := StartDefaultDaemon(map[string]interface{}{\n\t\t\"label\": []string{\"a=b\"},\n\t})\n\tc.Assert(err, check.IsNil)\n\t// Must kill it, as we may loose the pid in next call.\n\tdefer dcfg.KillDaemon()\n\n\tresult := RunWithSpecifiedDaemon(dcfg, \"info\")\n\terr = util.PartialEqual(result.Stdout(), \"a=b\")\n\tc.Assert(err, check.IsNil)\n}", "func (p *Prefix) Validate(addr string) (ret bool) {\n\tip := net.ParseIP(addr)\n\tif ip == nil {\n\t\treturn false\n\t}\n\treturn p.net.Contains(ip)\n}", "func NameIsDNSSubdomain(name string, prefix bool) []string {\n\tif prefix {\n\t\tname = maskTrailingDash(name)\n\t}\n\treturn validation.IsDNS1123Subdomain(name)\n}", "func (q *QuestionnaireT) LabelIsOutline(s string) bool {\n\treturn outlineNumbering1.MatchString(s) || outlineNumbering2.MatchString(s)\n}", "func isKnownSingleAddress(address string) bool {\n\tknownIps := []string{\n\t\t\"54.149.21.90\",\n\t\t\"54.69.114.54\",\n\t\t\"52.25.122.31\",\n\t\t\"52.25.145.215\",\n\t\t\"52.26.192.160\",\n\t\t\"52.24.91.157\",\n\t\t\"52.27.126.9\",\n\t\t\"52.11.152.229\",\n\t}\n\n\tfor _, ip := range knownIps {\n\t\tif address == ip {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (obj *instruction) IsLabel() bool {\n\treturn obj.label != nil\n}", "func validContainer(name string, label string) bool {\n\tinfo, err := client.ContainerInspect(context.Background(), name)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false\n\t}\n\tkv := strings.SplitN(label, \"=\", 2)\n\tif len(kv) != 2 {\n\t\treturn false\n\t}\n\tv, ok := info.Config.Labels[kv[0]]\n\treturn ok && v == kv[1]\n}", "func (z *Zone) IsIDN() bool {\n\tfor i := 0; i < len(z.Domain); i++ {\n\t\tif z.Domain[i] >= utf8.RuneSelf {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func isValidDomainLite(domain string) error {\n\tfor i := 0; i < len(domain); i++ {\n\t\tc := domain[i]\n\t\tif 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_' || '0' <= c && c <= '9' ||\n\t\t\tc == '-' || c == '.' {\n\t\t\tcontinue\n\t\t}\n\t\treturn errors.New(\"character \" + string(c) + \" is not allowed\")\n\t}\n\tsections := strings.Split(domain, \".\")\n\tfor _, s := range sections {\n\t\tif len(s) == 0 {\n\t\t\treturn errors.New(\"empty section between dots in domain name or trailing dot\")\n\t\t}\n\t\tif len(s) > 63 {\n\t\t\treturn errors.New(\"domain name section is too long\")\n\t\t}\n\t}\n\treturn nil\n}", "func IsClusterLocal(domain string) bool {\n\treturn strings.HasSuffix(domain, pkgnet.GetClusterDomainName())\n}", "func LenLabels(s string) (labels int) {\n\tif s == \".\" {\n\t\treturn\n\t}\n\tlast := byte('.')\n\tlastlast := byte('.')\n\ts = Fqdn(s) // Make fully qualified\n\tfor i := 0; i < len(s); i++ {\n\t\tif s[i] == '.' {\n\t\t\tif last == '\\\\' {\n\t\t\t\tif lastlast != '\\\\' {\n\t\t\t\t\t// do nothing\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tlabels++\n\t\t}\n\t\tlastlast = last\n\t\tlast = s[i]\n\t}\n\treturn\n}", "func (addressBook *AddressHelper) CheckAddressHelperString(req string) (string, bool) {\n\tif req != \"\" {\n\t\tif strings.HasSuffix(strings.Split(req, \".b32.i2p\")[0], \".b32.i2p\") {\n\t\t\treturn req, false\n\t\t}\n\t\tb, e := addressBook.jumpClient.Check(req)\n\t\tif e != nil {\n\t\t\tdii2perrs.Warn(e, \"addresshelper.go Address Lookup Error\", \"addresshelper.go this should never be reached\")\n\t\t\treturn \"\", false\n\t\t}\n\t\tif !b {\n\t\t\ts, c := addressBook.jumpClient.Request(req)\n\t\t\tif c == nil {\n\t\t\t\tdii2perrs.Warn(nil, \"addresshelper.go !b \"+s+\".b32.i2p\", \"addresshelper.go !b \"+s+\".b32.i2p\")\n\t\t\t\treq = s + \".b32.i2p\"\n\t\t\t\treturn req, true\n\t\t\t}\n\t\t}\n\t\tdii2perrs.Warn(nil, \"addresshelper.go b \"+req, \"addresshelper.go b \"+req)\n\t\treturn req, false\n\t}\n\treturn req, false\n}", "func HasLabel(key, value string) Predicate {\n\treturn func(c *CSP) bool {\n\t\tval, ok := c.Object.GetLabels()[key]\n\t\tif ok {\n\t\t\treturn val == value\n\t\t}\n\t\treturn false\n\t}\n}", "func IsPkcs11PublicKey(yamlstr []byte) bool {\n\t_, err := ParsePkcs11KeyFile(yamlstr)\n\treturn err == nil\n}", "func ValidateLabels(limits *Limits, userID string, ls []cortexpb.LabelAdapter, skipLabelNameValidation bool) ValidationError {\n\tif limits.EnforceMetricName {\n\t\tunsafeMetricName, err := extract.UnsafeMetricNameFromLabelAdapters(ls)\n\t\tif err != nil {\n\t\t\tDiscardedSamples.WithLabelValues(missingMetricName, userID).Inc()\n\t\t\treturn newNoMetricNameError()\n\t\t}\n\n\t\tif !model.IsValidMetricName(model.LabelValue(unsafeMetricName)) {\n\t\t\tDiscardedSamples.WithLabelValues(invalidMetricName, userID).Inc()\n\t\t\treturn newInvalidMetricNameError(unsafeMetricName)\n\t\t}\n\t}\n\n\tnumLabelNames := len(ls)\n\tif numLabelNames > limits.MaxLabelNamesPerSeries {\n\t\tDiscardedSamples.WithLabelValues(maxLabelNamesPerSeries, userID).Inc()\n\t\treturn newTooManyLabelsError(ls, limits.MaxLabelNamesPerSeries)\n\t}\n\n\tmaxLabelNameLength := limits.MaxLabelNameLength\n\tmaxLabelValueLength := limits.MaxLabelValueLength\n\tlastLabelName := \"\"\n\tmaxLabelsSizeBytes := limits.MaxLabelsSizeBytes\n\tlabelsSizeBytes := 0\n\n\tfor _, l := range ls {\n\t\tif !skipLabelNameValidation && !model.LabelName(l.Name).IsValid() {\n\t\t\tDiscardedSamples.WithLabelValues(invalidLabel, userID).Inc()\n\t\t\treturn newInvalidLabelError(ls, l.Name)\n\t\t} else if len(l.Name) > maxLabelNameLength {\n\t\t\tDiscardedSamples.WithLabelValues(labelNameTooLong, userID).Inc()\n\t\t\treturn newLabelNameTooLongError(ls, l.Name, maxLabelNameLength)\n\t\t} else if len(l.Value) > maxLabelValueLength {\n\t\t\tDiscardedSamples.WithLabelValues(labelValueTooLong, userID).Inc()\n\t\t\treturn newLabelValueTooLongError(ls, l.Name, l.Value, maxLabelValueLength)\n\t\t} else if cmp := strings.Compare(lastLabelName, l.Name); cmp >= 0 {\n\t\t\tif cmp == 0 {\n\t\t\t\tDiscardedSamples.WithLabelValues(duplicateLabelNames, userID).Inc()\n\t\t\t\treturn newDuplicatedLabelError(ls, l.Name)\n\t\t\t}\n\n\t\t\tDiscardedSamples.WithLabelValues(labelsNotSorted, userID).Inc()\n\t\t\treturn newLabelsNotSortedError(ls, l.Name)\n\t\t}\n\n\t\tlastLabelName = l.Name\n\t\tlabelsSizeBytes += l.Size()\n\t}\n\tif maxLabelsSizeBytes > 0 && labelsSizeBytes > maxLabelsSizeBytes {\n\t\tDiscardedSamples.WithLabelValues(labelsSizeBytesExceeded, userID).Inc()\n\t\treturn labelSizeBytesExceededError(ls, labelsSizeBytes, maxLabelsSizeBytes)\n\t}\n\treturn nil\n}", "func supportedLabel(key rune) bool {\n\tif key == 'a' || key == 'd' || key == 'e' ||\n\t\tkey == 'q' || key == 's' || key == 'w' {\n\t\treturn true\n\t}\n\treturn false\n}", "func IsIPAddr(s string) bool {\n\treturn net.ParseIP(s) != nil\n}", "func isValidDomainName(d string) bool {\n\t// Reject localhost.localdomain\n\tif d == \"localhost.localdomain\" {\n\t\treturn false\n\t}\n\n\t// Run the dns package's check (extremely liberal)\n\tif _, ok := dns.IsDomainName(d); !ok {\n\t\treturn false\n\t}\n\n\t// Check for a valid length\n\tif len(d) < 4 || len(d) > 255 {\n\t\treturn false\n\t}\n\n\t// Check that it has a dot, and the dot is reasonably positioned\n\tif i := strings.IndexByte(d, '.'); i < 1 || i >= len(d)-2 {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (p IPPrefix) IsSingleIP() bool { return p.Bits != 0 && p.Bits == p.IP.BitLen() }", "func IsIPHostname(input string) bool {\n\tvalidIP := net.ParseIP(input)\n\tif validIP == nil {\n\t\tmatched, err := regexp.MatchString(HostnameRegex, input)\n\t\tif err != nil {\n\t\t\treturn false\n\t\t}\n\n\t\treturn matched\n\t}\n\n\treturn true\n}", "func isPureIPv4Address(ipString string) bool {\n\tfor i := 0; i < len(ipString); i++ {\n\t\tswitch ipString[i] {\n\t\tcase '.':\n\t\t\treturn true\n\t\tcase ':':\n\t\t\treturn false\n\t\t}\n\t}\n\treturn false\n}", "func StrIsASNStr(asn string) bool {\n\t// check length.\n\tif len(asn) < 3 {\n\t\treturn false\n\t}\n\n\t// ensure \"AS\" or \"as\" prefix.\n\tif !strings.HasPrefix(asn, \"AS\") && !strings.HasPrefix(asn, \"as\") {\n\t\treturn false\n\t}\n\n\t// ensure number suffix.\n\tasnNumStr := asn[2:]\n\tif _, err := strconv.Atoi(asnNumStr); err != nil {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (fxt *TestFixture) LabelByName(name string, spaceID ...uuid.UUID) *label.Label {\n\tfor _, l := range fxt.Labels {\n\t\tif l.Name == name && len(spaceID) > 0 && l.SpaceID == spaceID[0] {\n\t\t\treturn l\n\t\t} else if l.Name == name && len(spaceID) == 0 {\n\t\t\treturn l\n\t\t}\n\t}\n\treturn nil\n}", "func formattingRuleHasFirstGroupOnly(nationalPrefixFormattingRule string) bool {\n\treturn len(nationalPrefixFormattingRule) == 0 ||\n\t\tFIRST_GROUP_ONLY_PREFIX_PATTERN.MatchString(nationalPrefixFormattingRule)\n}", "func (l LabelDef) Validate() bool {\n\treturn config.ValidateLabel(&l)\n}", "func IsHostname(toCheckHostname string) bool {\n\treturn RegexDomain.MatchString(toCheckHostname)\n}", "func (me TdtypeType) IsIpv4Packet() bool { return me.String() == \"ipv4-packet\" }", "func isSharedPortLabel(port string) bool {\n\t// XXX - I think we can get rid of these built-in labels (uplink/freeuplink).\n\t//\tThis will be cleaned up as part of support for deviceConfig\n\t//\tfrom cloud.\n\tif strings.EqualFold(port, \"uplink\") {\n\t\treturn true\n\t}\n\tif strings.EqualFold(port, \"freeuplink\") {\n\t\treturn true\n\t}\n\treturn false\n}", "func (k *Deployment) LabelFound(label string) bool {\n\tfor _, l := range k.Labels {\n\t\tif l.Match(label) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func IsAddress(a string) bool {\n\tif len(a) > 0 && a[:3] == string(binary.PrefixAccountPubkey) {\n\t\treturn true\n\t}\n\treturn false\n}", "func isValidPrefixLength(pLen *uint8, isIpv4 bool) bool {\n // maxPrfxLen corresponds to Maximum prefix length for all interface types other than loopback\n var maxPrfxLen uint8 = 31\n if !isIpv4 {\n maxPrfxLen = 127\n }\n return *pLen <= maxPrfxLen\n}", "func (lv LabelValue) IsValid() bool {\n\treturn utf8.ValidString(string(lv))\n}", "func (sc *spfChecker) Validate(ip, domain string) (bool, error) {\n\tspfRecordList, err := sc.LookupSPFRecords(domain)\n\tif err != nil {\n\t\tif err == ErrNoSPFRecords {\n\t\t\treturn true, nil\n\t\t}\n\t\treturn false, err\n\t}\n\tspfRecord := spfRecordList[0]\n\tsplitSPFRecord := strings.Split(spfRecord, \" \")\n\tallRecord := splitSPFRecord[len(splitSPFRecord)-1]\n\tallRecordSplit := strings.Split(allRecord, \"a\")\n\tallRecord = allRecordSplit[0]\n\n\tips, err := getIPsForRecord(domain, spfRecord)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n // TODO Does this need IPv6 modernisation? Not clear what's happening with the\n\t// mask suffixing.\n\tfor _, element := range ips {\n\t\telementWithCidr := element\n\t\tif !strings.Contains(elementWithCidr, \"/\") {\n\t\t\tif !strings.Contains(elementWithCidr, \":\") {\n\t\t\t\telementWithCidr = elementWithCidr + \"/32\" // fmt.Sprintf(\"%s/32\", elementWithCidr)\n\t\t\t} else {\n\t\t\t\telementWithCidr = elementWithCidr + \"/128\" // fmt.Sprintf(\"%s/128\", elementWithCidr)\n\t\t\t}\n\t\t}\n\t\t_, cidrnet, err := net.ParseCIDR(elementWithCidr)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tipAddress := net.ParseIP(ip)\n\t\tif cidrnet.Contains(ipAddress) {\n\t\t\treturn true, nil\n\t\t}\n\t}\n\treturn false, nil\n}", "func (k *Pod) LabelFound(label string) bool {\n\tfor _, l := range k.Labels {\n\t\tif l.Match(label) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidateName(identifier, name string) error {\n\tif strings.Contains(name, \".\") {\n\t\treturn fmt.Errorf(\"Invalid TestDefinition (%s): metadata.name : Invalid value: name must not contain '.'\", identifier)\n\t}\n\n\t// IsDNS1123Subdomain: lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character\n\t// used for e.g. statefulset names\n\terrMsgs := []string{}\n\tfor _, msg := range apimachineryvalidation.IsDNS1123Subdomain(name) {\n\t\terrMsgs = append(errMsgs, msg)\n\t}\n\n\tif len(errMsgs) != 0 {\n\t\treturn fmt.Errorf(\"Invalid TestDefinition (%s): metadata.name : Invalid value: %s\", identifier, strings.Join(errMsgs, \";\"))\n\t}\n\n\treturn nil\n}", "func convertNillableType(str string) (string, error) {\n\tdataType, err := convertType(str)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tnillableDataType, exists := nillableDataTypes[dataType]\n\tif exists {\n\t\treturn nillableDataType, nil \n\t}\n\n\treturn str, fmt.Errorf(\"convertingNillableType '%s'\", dataType)\n}", "func Parse(s string) (Name, error) {\n\tformattedName := strings.Trim(strings.ToLower(s), \".\")\n\n\tif strings.HasPrefix(formattedName, \"*.\") {\n\t\tformattedName = strings.Replace(formattedName, \"*.\", \"\", 1)\n\t}\n\tif strings.HasPrefix(formattedName, \"@.\") {\n\t\tformattedName = strings.Replace(formattedName, \"@.\", \"\", 1)\n\t}\n\n\tif len(formattedName) == 0 {\n\t\treturn Name{}, fmt.Errorf(\"domain name is empty\")\n\t}\n\n\tvar err error\n\tformattedName, err = idna.ToASCII(formattedName)\n\tif err != nil {\n\t\treturn Name{}, fmt.Errorf(\"domain name %s is invalid: %w\", s, err)\n\t}\n\n\tif err = Validate(formattedName); err != nil {\n\t\treturn Name{}, fmt.Errorf(\"domain name %s is invalid: %w\", s, err)\n\t}\n\n\trule := publicsuffix.DefaultList.Find(formattedName, publicsuffix.DefaultFindOptions)\n\tif rule == nil {\n\t\treturn Name{}, fmt.Errorf(\"domain name %s is invalid: no rule found\", s)\n\t}\n\n\tcategory := eTLDUndefined\n\tif rule.Private {\n\t\tcategory = eTLDPrivate\n\t} else if len(rule.Value) > 0 {\n\t\t// empty value indicates the default rule\n\t\tcategory = eTLDICANN\n\t}\n\n\tdecomposedName := rule.Decompose(formattedName)\n\tif decomposedName[1] == \"\" {\n\t\t// no TLD found, which means it's already a TLD\n\t\treturn Name{\n\t\t\tlabels: []string{formattedName},\n\t\t\tcategory: category,\n\t\t}, nil\n\t}\n\n\tlabelsNoTDL := strings.TrimSuffix(formattedName, decomposedName[1])\n\tlabelsNoTDL = strings.TrimSuffix(labelsNoTDL, \".\")\n\n\tif len(labelsNoTDL) == 0 {\n\t\treturn Name{\n\t\t\tlabels: []string{decomposedName[1]},\n\t\t\tcategory: category,\n\t\t}, nil\n\t}\n\n\treturn Name{\n\t\tlabels: append(strings.Split(labelsNoTDL, \".\"), decomposedName[1]),\n\t\tcategory: category,\n\t}, nil\n}", "func (p *ZFSVolume) HasLabel(key, value string) bool {\n\tval, ok := p.Object.GetLabels()[key]\n\tif ok {\n\t\treturn val == value\n\t}\n\treturn false\n}", "func (p PRMirror) CreateLabel(labelText string, labelColour string) bool {\n\tlabel := github.Label{\n\t\tName: &labelText,\n\t\tColor: &labelColour,\n\t}\n\n\t_, _, err := p.GitHubClient.Issues.CreateLabel(*p.Context, p.Configuration.DownstreamOwner, p.Configuration.DownstreamRepo, &label)\n\tif err != nil {\n\t\tlog.Errorf(\"Error while creating a label - %s\", err.Error())\n\t\treturn false\n\t}\n\n\treturn true\n}", "func HasHumanName(addr string) bool {\n\t_, ok := humanNames[strings.ToLower(addr)]\n\treturn ok\n}", "func IsPlainHostName(host string) bool {\n\treturn strings.Index(host, \".\") == -1\n}", "func HasLabel(i *github.Issue, label string) bool {\n\tfor _, l := range i.Labels {\n\t\tif *l.Name == label {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (d *DNS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {\n\td.buffer = d.buffer[:0]\n\n\tif len(data) < 12 {\n\t\tdf.SetTruncated()\n\t\treturn errDNSPacketTooShort\n\t}\n\n\t// since there are no further layers, the baselayer's content is\n\t// pointing to this layer\n\td.BaseLayer = BaseLayer{Contents: data[:len(data)]}\n\td.ID = binary.BigEndian.Uint16(data[:2])\n\td.QR = data[2]&0x80 != 0\n\td.OpCode = DNSOpCode(data[2]>>3) & 0x0F\n\td.AA = data[2]&0x04 != 0\n\td.TC = data[2]&0x02 != 0\n\td.RD = data[2]&0x01 != 0\n\td.RA = data[3]&0x80 != 0\n\td.Z = uint8(data[3]>>4) & 0x7\n\td.ResponseCode = DNSResponseCode(data[3] & 0xF)\n\td.QDCount = binary.BigEndian.Uint16(data[4:6])\n\td.ANCount = binary.BigEndian.Uint16(data[6:8])\n\td.NSCount = binary.BigEndian.Uint16(data[8:10])\n\td.ARCount = binary.BigEndian.Uint16(data[10:12])\n\n\td.Questions = d.Questions[:0]\n\td.Answers = d.Answers[:0]\n\td.Authorities = d.Authorities[:0]\n\td.Additionals = d.Additionals[:0]\n\n\toffset := 12\n\tvar err error\n\tfor i := 0; i < int(d.QDCount); i++ {\n\t\tvar q DNSQuestion\n\t\tif offset, err = q.decode(data, offset, df, &d.buffer); err != nil {\n\t\t\treturn err\n\t\t}\n\t\td.Questions = append(d.Questions, q)\n\t}\n\n\t// For some horrible reason, if we do the obvious thing in this loop:\n\t// var r DNSResourceRecord\n\t// if blah := r.decode(blah); err != nil {\n\t// return err\n\t// }\n\t// d.Foo = append(d.Foo, r)\n\t// the Go compiler thinks that 'r' escapes to the heap, causing a malloc for\n\t// every Answer, Authority, and Additional. To get around this, we do\n\t// something really silly: we append an empty resource record to our slice,\n\t// then use the last value in the slice to call decode. Since the value is\n\t// already in the slice, there's no WAY it can escape... on the other hand our\n\t// code is MUCH uglier :(\n\tfor i := 0; i < int(d.ANCount); i++ {\n\t\td.Answers = append(d.Answers, DNSResourceRecord{})\n\t\tif offset, err = d.Answers[i].decode(data, offset, df, &d.buffer); err != nil {\n\t\t\td.Answers = d.Answers[:i] // strip off erroneous value\n\t\t\treturn err\n\t\t}\n\t}\n\tfor i := 0; i < int(d.NSCount); i++ {\n\t\td.Authorities = append(d.Authorities, DNSResourceRecord{})\n\t\tif offset, err = d.Authorities[i].decode(data, offset, df, &d.buffer); err != nil {\n\t\t\td.Authorities = d.Authorities[:i] // strip off erroneous value\n\t\t\treturn err\n\t\t}\n\t}\n\tfor i := 0; i < int(d.ARCount); i++ {\n\t\td.Additionals = append(d.Additionals, DNSResourceRecord{})\n\t\tif offset, err = d.Additionals[i].decode(data, offset, df, &d.buffer); err != nil {\n\t\t\td.Additionals = d.Additionals[:i] // strip off erroneous value\n\t\t\treturn err\n\t\t}\n\t\t// extract extended RCODE from OPT RRs, RFC 6891 section 6.1.3\n\t\tif d.Additionals[i].Type == DNSTypeOPT {\n\t\t\td.ResponseCode = DNSResponseCode(uint8(d.ResponseCode) | uint8(d.Additionals[i].TTL>>20&0xF0))\n\t\t}\n\t}\n\n\tif uint16(len(d.Questions)) != d.QDCount {\n\t\treturn errDecodeQueryBadQDCount\n\t} else if uint16(len(d.Answers)) != d.ANCount {\n\t\treturn errDecodeQueryBadANCount\n\t} else if uint16(len(d.Authorities)) != d.NSCount {\n\t\treturn errDecodeQueryBadNSCount\n\t} else if uint16(len(d.Additionals)) != d.ARCount {\n\t\treturn errDecodeQueryBadARCount\n\t}\n\treturn nil\n}", "func validateShortName(name string) error {\n\trepo, err := reference.Parse(name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot parse short name: %q: %w\", name, err)\n\t}\n\n\tif _, ok := repo.(reference.Digested); ok {\n\t\treturn fmt.Errorf(\"invalid short name %q: must not contain digest\", name)\n\t}\n\n\tif _, ok := repo.(reference.Tagged); ok {\n\t\treturn fmt.Errorf(\"invalid short name %q: must not contain tag\", name)\n\t}\n\n\tnamed, ok := repo.(reference.Named)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid short name %q: no name\", name)\n\t}\n\n\tregistry := reference.Domain(named)\n\tif strings.ContainsAny(registry, \".:\") || registry == \"localhost\" {\n\t\treturn fmt.Errorf(\"invalid short name %q: must not contain registry\", name)\n\t}\n\treturn nil\n}", "func (l *LabelAcceptanceCriterion) acceptsLabel(pair LabelPair) (result bool, labelMismatch bool, err error) {\n\tif l.LabelPair.Name != pair.Name {\n\t\treturn false, true, nil\n\t}\n\n\tswitch pair.Value.(type) {\n\tcase float64: /* since json does not differentiate between int or float, the marshaller will encode numbers as float64 */\n\t\tswitch l.Operator {\n\t\tcase \"==\":\n\t\t\treturn pair.Value.(float64) == l.LabelPair.Value.(float64), false, nil\n\t\tcase \">\":\n\t\t\treturn pair.Value.(float64) > l.LabelPair.Value.(float64), false, nil\n\t\tcase \"<\":\n\t\t\treturn pair.Value.(float64) < l.LabelPair.Value.(float64), false, nil\n\t\tcase \">=\":\n\t\t\treturn pair.Value.(float64) >= l.LabelPair.Value.(float64), false, nil\n\t\tcase \"<=\":\n\t\t\treturn pair.Value.(float64) <= l.LabelPair.Value.(float64), false, nil\n\t\tdefault:\n\t\t\treturn false, false, OperatorNotFound\n\t\t}\n\tcase string:\n\t\tswitch l.Operator {\n\t\tcase \"==\":\n\t\t\treturn pair.Value.(string) == l.LabelPair.Value.(string), false, nil\n\t\tdefault:\n\t\t\treturn false, false, OperatorNotFound\n\t\t}\n\tcase bool:\n\t\tswitch l.Operator {\n\t\tcase \"==\":\n\t\t\treturn pair.Value.(bool) == l.LabelPair.Value.(bool), false, nil\n\t\tdefault:\n\t\t\treturn false, false, OperatorNotFound\n\t\t}\n\t}\n\n\treturn false, false, nil\n}", "func isIPv4(s string) bool {\n\tip := netutils.ParseIPSloppy(s)\n\treturn ip != nil && strings.Contains(s, \".\")\n}", "func DomainIn(addr string, locals *set.String) bool {\n\tdomain := DomainOf(addr)\n\tif domain == \"\" {\n\t\treturn true\n\t}\n\n\treturn locals.Has(domain)\n}" ]
[ "0.7073981", "0.6784894", "0.6662813", "0.6645072", "0.6610259", "0.65547305", "0.6539056", "0.61992234", "0.590272", "0.5892211", "0.57716644", "0.568415", "0.56640834", "0.56540054", "0.5626012", "0.55819505", "0.55145305", "0.5475766", "0.5388402", "0.5378654", "0.53565663", "0.53268105", "0.53141844", "0.52859217", "0.5215048", "0.51935256", "0.51362985", "0.5129192", "0.50837576", "0.50821066", "0.50220454", "0.5017787", "0.50014424", "0.499683", "0.49732348", "0.49035373", "0.4890716", "0.48663446", "0.48594865", "0.48335874", "0.48066035", "0.47509807", "0.4749952", "0.46953434", "0.46774408", "0.46687493", "0.4668742", "0.46682453", "0.46585825", "0.46559602", "0.46247113", "0.46191785", "0.46131027", "0.45970792", "0.4594514", "0.45896024", "0.45573667", "0.452191", "0.4517373", "0.45055217", "0.44936746", "0.4475451", "0.44699398", "0.44503397", "0.44485673", "0.4443249", "0.44420174", "0.442022", "0.44054335", "0.43997815", "0.43975526", "0.4383945", "0.43796822", "0.43787393", "0.43714014", "0.43626162", "0.4345351", "0.4343728", "0.43218276", "0.43200576", "0.4313494", "0.43064404", "0.4304344", "0.4303479", "0.43005404", "0.42934993", "0.42934284", "0.42928985", "0.4289529", "0.42885104", "0.4287943", "0.4284626", "0.4284387", "0.42770875", "0.427531", "0.42741936", "0.42710635", "0.42697102", "0.42636615", "0.42522755" ]
0.8913801
0
SetJSON store json data
func (h *API) SetJSON(key string, value interface{}, expiration time.Duration) (*redis.StatusCmd, error) { value, err := json.Marshal(value) if err != nil { return nil, err } ret := h.Client.Set(key, value, expiration) return ret, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func SetJSON(s KVStore, key string, v interface{}) (returnErr error) {\n\tdata, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error while storing json\")\n\t}\n\treturn s.Store(key, data)\n}", "func (s *DiffStore) SetJSON(key []byte, value interface{}) {\n\tvalueBytes, err := json.Marshal(value)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"failed to JSON marshal value: %w\", err))\n\t}\n\n\th := xxhash.Sum64(valueBytes)\n\ts.Set(key, h, value)\n}", "func (r *Client) JSONSet(key, path, json string) error {\n\t_, err := r.Conn.JSONSet(r.ctx, key, path, json).Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tr.log.Debug().Msgf(\"JsonSet key %s in cache, path %s, json %s\", key, path, json)\n\n\treturn nil\n}", "func (instance *Instance) SetJSON(blob []byte) error {\n\tjsonCStr := C.CString(string(blob))\n\tdefer C.free(unsafe.Pointer(jsonCStr))\n\n\tretcode := int(C.RTI_Connector_set_json_instance(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, jsonCStr))\n\treturn checkRetcode(retcode)\n}", "func (o *ParamsReg) SetJSON(jsonString string) {\n\n\t// variable to hold input\n\ttype jsonType struct {\n\t\tTheta la.Vector\n\t\tBias float64\n\t\tLambda float64\n\t\tDegree int\n\t}\n\tinput := &jsonType{}\n\n\t// decode\n\terr := json.Unmarshal([]byte(jsonString), input)\n\tif err != nil {\n\t\tchk.Panic(\"cannot unmarshal json string\\n\")\n\t}\n\n\t// set data\n\to.theta = input.Theta\n\to.bias = input.Bias\n\to.lambda = input.Lambda\n\to.degree = input.Degree\n\n\t// notifications\n\to.NotifyUpdate()\n}", "func (c *FileSystemCache) SetJSON(o interface{}, expire time.Duration, key ...string) error {\n\tb, err := json.Marshal(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.Set(b, expire, key...)\n}", "func JSONSet(conn redis.Conn, key string, path string, obj interface{}, NX bool, XX bool) (res interface{}, err error) {\n\tname, args, err := CommandBuilder(\"JSON.SET\", key, path, obj, NX, XX)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn conn.Do(name, args...)\n}", "func setJSONData(req *http.Request, data interface{}) error {\n\tif data == nil {\n\t\treturn nil\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tbody, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Body = ioutil.NopCloser(bytes.NewReader(body))\n\treturn nil\n}", "func (self *Response) SetJson(js *simplejson.Json) *Response {\n\tself.jsonMap = js\n\treturn self\n}", "func (m *Setting) SetJsonValue(value *string)() {\n err := m.GetBackingStore().Set(\"jsonValue\", value)\n if err != nil {\n panic(err)\n }\n}", "func (bu *Builder) JSONStorage(store storage.Storage) *Builder {\n\tbu.srv.jsonStore = store\n\treturn bu\n}", "func setJSONValue(genericData map[string]interface{}, path []string, value interface{}) error {\n\tcurrentData := genericData\n\tfor index, key := range path {\n\t\tif index == len(path)-1 {\n\t\t\tcurrentData[key] = value\n\t\t} else {\n\t\t\tif currentData[key] == nil {\n\t\t\t\tcurrentData[key] = make(map[string]interface{})\n\t\t\t}\n\t\t\tvar isMap bool\n\t\t\tcurrentData, isMap = currentData[key].(map[string]interface{})\n\t\t\tif !isMap {\n\t\t\t\treturn fmt.Errorf(\"Invalid type for %v\", path[0:index+1])\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (j *JSON) Set(data map[string]interface{}) {\n\tj.Valid = true\n\tj.Map = data\n}", "func (j Json) Set(path string, value interface{}) (string, error) {\n\treturn sjson.Set(string(j), path, value)\n}", "func (d *JSON) SetData(data interface{}) error {\n\t// cast back to a string\n\tline, ok := data.(string)\n\tif !ok {\n\t\treturn fmt.Errorf(\"Could not cast `%v` into type string\", data)\n\t}\n\t// unmarshal\n\tvar m map[string]interface{}\n\terr := json.Unmarshal([]byte(line), &m)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Could not unmarshal `%v` into type map[string]interface{}\", data)\n\t}\n\td.Data = m\n\treturn nil\n}", "func SetJSONMiddleware(next gin.HandlerFunc) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tc.Header(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\tnext(c)\n\t}\n}", "func (v *JSONValue) Set() {\n\tswitch {\n\tcase v.IsNull():\n\t\tv.SetNull()\n\tcase v.IsObject():\n\t\tv.SetObject(v.valObject)\n\tcase v.IsArray():\n\t\tv.SetArray(v.valArray)\n\tcase v.IsString():\n\t\tv.SetString(v.valString)\n\tcase v.IsNumber():\n\t\tv.SetNumber(v.valNumber)\n\tcase v.IsBoolean():\n\t\tv.SetBoolean(v.valBoolean)\n\t}\n}", "func SetSettingsFromTheJSON(settingsJSON []byte) (msg string, err error) {\n\treturn\n}", "func SetContentTypeJSON(handler http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\thandler.ServeHTTP(w, r)\n\t})\n}", "func SetSyncByJSON(d dvid.Data, uuid dvid.UUID, replace bool, in io.ReadCloser) error {\n\tif manager == nil {\n\t\treturn ErrManagerNotInitialized\n\t}\n\tjsonData := make(map[string]string)\n\tdecoder := json.NewDecoder(in)\n\tif err := decoder.Decode(&jsonData); err != nil && err != io.EOF {\n\t\treturn fmt.Errorf(\"Malformed JSON request in sync request: %v\", err)\n\t}\n\tsyncedCSV, ok := jsonData[\"sync\"]\n\tif !ok {\n\t\treturn fmt.Errorf(\"Could not find 'sync' value in POSTed JSON to sync request.\")\n\t}\n\n\tsyncedNames := strings.Split(syncedCSV, \",\")\n\tif len(syncedNames) == 0 || (len(syncedNames) == 1 && syncedNames[0] == \"\") {\n\t\tsyncedNames = []string{}\n\t}\n\n\tif len(syncedNames) == 0 && !replace {\n\t\tdvid.Infof(\"Ignored attempt to append no syncs to instance %q.\\n\", d.DataName())\n\t\treturn nil\n\t}\n\n\t// Make sure all synced names currently exist under this UUID, then transform to data UUIDs.\n\tsyncs := make(dvid.UUIDSet)\n\tfor _, name := range syncedNames {\n\t\tdata, err := GetDataByUUIDName(uuid, dvid.InstanceName(name))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsyncs[data.DataUUID()] = struct{}{}\n\t}\n\n\tif err := SetSyncData(d, syncs, replace); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func SetMiddlewareJSON(next http.HandlerFunc) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tnext(w, r)\n\t}\n}", "func SetMiddlewareJSON(next http.HandlerFunc) http.HandlerFunc {\r\n\treturn func(w http.ResponseWriter, r *http.Request) {\r\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\r\n\t\tnext(w, r)\r\n\t}\r\n}", "func SetJSONLog() *pkg.Logger {\r\n\treturn defaultLogger.SetJSONLog()\r\n}", "func (r *Client) JSONSetNX(key, path, json string) error {\n\t_, err := r.Conn.JSONSet(r.ctx, key, path, json, \"NX\").Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tr.log.Debug().Msgf(\"JsonSetNX key %s in cache, path %s, json %s\", key, path, json)\n\n\treturn nil\n}", "func (l Util) SaveJson(p string, value interface{}) error {\n\tbts, err := json.Marshal(value)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(l.path(p), bts, os.ModePerm)\n}", "func (glogger *GLogger) SetJSONLog(set bool) {\n\tglogger.logJSONFormat = set\n}", "func Json(data string) *Js {\n\tj := new(Js)\n\tvar f interface{}\n\terr := json.Unmarshal([]byte(data), &f)\n\tif err != nil {\n\t\treturn j\n\t}\n\tj.data = f\n\treturn j\n}", "func (s *Store) Set(ctx context.Context, key interface{}, v json.Marshaler) error {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\tb, err := v.MarshalJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\ts.m[key] = entry{data: b}\n\treturn nil\n}", "func (p *Parser) Set(pattern string, value interface{}) error {\n return p.json.Set(pattern, value)\n}", "func writeJSON(w http.ResponseWriter, data JSON) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(data)\n}", "func (j Json) Sets(path string, value interface{}) Json {\n\tif s, err := j.Set(path, value); err == nil {\n\t\treturn Json(s)\n\t}\n\treturn j\n}", "func SetMiddleWareJSON(next http.HandlerFunc) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tnext(w, r)\n\t}\n}", "func (t *testRequest) SetData(url url.URL, res interface{}) {\n\tt.url = url\n\tbytes, _ := json.Marshal(res)\n\tt.res = bytes\n}", "func SetHandler(s *store.Store) JSONHandler {\n\treturn func(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\t\tdefer r.Body.Close()\n\n\t\tkey := chi.URLParam(r, \"key\")\n\t\tvalue, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\treturn nil, NewAPIError(int(store.NoError), errors.New(\"failed to retrieve request body\"))\n\t\t}\n\n\t\twriteErr := s.Set(key, value)\n\t\tif writeErr != store.NoError {\n\t\t\treturn nil, NewAPIError(int(writeErr), nil)\n\t\t}\n\t\treturn Acknowledged{Acknowledged: true}, nil\n\t}\n}", "func (m *TemplateParameter) SetJsonDefaultValue(value *string)() {\n err := m.GetBackingStore().Set(\"jsonDefaultValue\", value)\n if err != nil {\n panic(err)\n }\n}", "func (this *JSONObject) Set(key string, value interface{}) bool {\n\tunmarshalled, ok := interfaceToJsonCompatible(value)\n\tif !ok {\n\t\treturn ok\n\t}\n\tthis.innerMap[key] = unmarshalled\n\treturn true\n}", "func SetJSONRaw(data, out []byte, path string) ([]byte, error) {\n\treturn setJSONRaw(data, out, path)\n}", "func setJsObject(key string, v interface{}) {\n\tmodule.Set(key, v)\n}", "func (r *Request) SetJSONBody(val interface{}) error {\n\tbuf := bytes.NewBuffer(nil)\n\tenc := json.NewEncoder(buf)\n\tif err := enc.Encode(val); err != nil {\n\t\treturn err\n\t}\n\n\tr.Obj = val\n\tr.Body = buf\n\tr.BodySize = int64(buf.Len())\n\treturn nil\n}", "func (c *EzClient) JSON(j interface{}) *EzClient {\n\tb, err := json.Marshal(j)\n\tif err == nil {\n\t\tc.body = bytes.NewReader(b)\n\t}\n\n\treturn c\n}", "func (app *application) writeJSON(w http.ResponseWriter, status int, data interface{}) error {\n\tjs, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\tjs = append(js, '\\n')\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(js)\n\n\treturn nil\n}", "func writeJSON(w http.ResponseWriter, status int, data mapStringInterface) error {\n\tjs, err := json.Marshal(data)\n\t//js, err := json.MarshalIndent(data, \"\", \"\\t\")\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tjs = append(js, '\\n')\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\tw.Write(js)\n\treturn nil\n}", "func (v SetJSON) Run(t *Txn) (resp *api.Assigned, err error) {\n\treturn t.Setb([]byte(v))\n}", "func (db *Database) Set(v interface{}, fps ...string) error {\n\t// TODO: check if v is of a type that can be stored in json file (struct{})\n\n\tf, err := db.fs.Open(path.Join(fps...))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tfw, ok := f.(io.Writer)\n\tif !ok {\n\t\treturn fmt.Errorf(\"file doesn't implement io.Writer\")\n\t}\n\tobj, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = fw.Write(obj)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (vc *VehicleContainer) SaveJSON(target string) (err error) {\n\tbuff, err := vc.MarshalJSON()\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = os.WriteFile(target, buff, 0o666)\n\treturn\n}", "func JSON(JSONh JSONHandler) *EJ {\n\treturn &EJ{\n\t\tjsonHandler: JSONh,\n\t}\n}", "func (jf *JFile) AddJSON(JSONpath string, JSONdata []byte) error {\n\tif err := jf.rootnode.AddJSON(JSONpath, JSONdata); err != nil {\n\t\treturn err\n\t}\n\t// Use the correct JSON function, depending on the pretty parameter\n\tJSON := jf.rootnode.JSON\n\tif jf.pretty {\n\t\tJSON = jf.rootnode.PrettyJSON\n\t}\n\tdata, err := JSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn jf.Write(data)\n}", "func (l *List) AppendJSON(json interface{}) (err error) {\n\titem := MakeZeroValue(l.valType)\n\n\tif err := item.Set(json); err != nil {\n\t\treturn err\n\t}\n\n\treturn l.Append(item)\n}", "func writeByJSON(path string, data interface{}) error {\n\tos.MkdirAll(dname, os.ModeDir|os.ModePerm)\n\tfile, err := os.OpenFile(dname+path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\tif err := json.NewEncoder(file).Encode(data); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (g *gsutilUploader) UploadJSON(data interface{}, tempFileName, gcsObjPath string) error {\n\tjsonBytes, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := ioutil.WriteFile(tempFileName, jsonBytes, 0644); err != nil {\n\t\treturn err\n\t}\n\n\t// Upload the written file.\n\treturn g.UploadBytes(nil, tempFileName, prefixGCS(gcsObjPath))\n}", "func (m *WorkbookNamedItem) SetValue(value Jsonable)() {\n err := m.GetBackingStore().Set(\"value\", value)\n if err != nil {\n panic(err)\n }\n}", "func PutJSON(s Secret, v interface{}) error {\n\tb, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn s.Put(b)\n}", "func (s *Server) writeJSON(w http.ResponseWriter, data []byte) {\n\tw.Header().Set(contentType, jsonContentType)\n\t_, err := w.Write(data)\n\tif err != nil {\n\t\ts.logger.Errorf(\"error writing to response: %v\", err)\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t}\n}", "func JSONEncoder() Encoder { return jsonEncoder }", "func SaveJSON(filename string, thing interface{}, mode os.FileMode) error {\n\tdata, err := json.MarshalIndent(thing, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn SaveBinary(filename, data, mode)\n}", "func (l *Logerr) SetFormatJSON() {\n\t//l.SetFormatter(&log.TextFormatter)\n}", "func (l *List) PrependJSON(json interface{}) (err error) {\n\titem := MakeZeroValue(l.valType)\n\n\tif err := item.Set(json); err != nil {\n\t\treturn err\n\t}\n\n\treturn l.Prepend(item)\n}", "func (F *Frisby) SetJson(json interface{}) *Frisby {\n\tF.Req.Json = json\n\treturn F\n}", "func (ao *Client) SetJSONToken(token string) {\n\tao.jsonToken = token\n}", "func (m *TemplateParameter) SetJsonAllowedValues(value *string)() {\n err := m.GetBackingStore().Set(\"jsonAllowedValues\", value)\n if err != nil {\n panic(err)\n }\n}", "func (p *prop) set(injson string) (string, error) {\n\tvar x interface{}\n\terr := json.Unmarshal([]byte(injson), &x)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\txv := reflect.ValueOf(x)\n\txv, err = cast(xv, p.t)\n\tif !p.v.CanSet() {\n\t\treturn \"\", fmt.Errorf(\"property %s is not settable\", p.name)\n\t}\n\tp.v.Set(xv)\n\treturn p.get()\n}", "func (e *HueEmulator) sendJSON(w http.ResponseWriter, val interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tvar buf bytes.Buffer\n\tif err := json.NewEncoder(&buf).Encode(val); err != nil {\n\t\te.logger.Error(\"Failed to respond\", err)\n\t\treturn\n\t}\n\tw.Write(buf.Bytes()) // nolint: gosec, errcheck\n}", "func Set() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tbody, err := ioutil.ReadAll(r.Body)\n\n\t\t// Default to NOT OK response\n\t\tresponse := core.JSONResponse{OK: false}\n\n\t\tif err != nil {\n\t\t\tlog.Error().Msgf(\"Error reading body: %v\", err)\n\t\t\thttp.Error(w, \"can't read body\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\t// Put body back\n\t\tr.Body.Close() // must close\n\t\tr.Body = ioutil.NopCloser(bytes.NewBuffer(body))\n\n\t\tif len(body) == 0 {\n\t\t\tresponse.Output = \"Error: Empty body\"\n\t\t\tresponse.Write(&w, r)\n\t\t\treturn\n\t\t}\n\n\t\tparams := mux.Vars(r)\n\t\tvar newdata Package\n\n\t\tif err = json.NewDecoder(r.Body).Decode(&newdata); err != nil {\n\t\t\tlog.Error().Err(err).Msg(\"Error decoding incoming JSON\")\n\t\t\tresponse.Output = err.Error()\n\t\t\tresponse.Write(&w, r)\n\t\t\treturn\n\t\t}\n\n\t\t// Call the setter\n\t\tnewdata.Name = params[\"name\"]\n\t\tcore.Session.Publish(params[\"name\"], newdata.Value)\n\n\t\t// Craft OK response\n\t\tresponse.OK = true\n\t\tresponse.Output = newdata\n\n\t\tresponse.Write(&w, r)\n\t}\n}", "func (c *Controller) SetData(data interface{}) {\n\taccept := c.Ctx.Input.Header(\"Accept\")\n\tswitch accept {\n\tcase context.ApplicationYAML:\n\t\tc.Data[\"yaml\"] = data\n\tcase context.ApplicationXML, context.TextXML:\n\t\tc.Data[\"xml\"] = data\n\tdefault:\n\t\tc.Data[\"json\"] = data\n\t}\n}", "func SetProducts(v interface{}) {\n\n\tf, _ := ioutil.ReadFile(\"db/products.json\")\n\n\tpjson, _ := simplejson.NewJson(f)\n\n\tpjson.Set(\"products\", v)\n\n\tSave(\"db/products.json\", pjson)\n\n}", "func (e *EJ) Write(data interface{}) error {\n\n\tvalue, err := json.Marshal(data)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"json marshal: %s\", err.Error())\n\t}\n\n\tif err := e.jsonHandler.Write(value); err != nil {\n\t\treturn fmt.Errorf(\"write: %s\", err.Error())\n\t}\n\n\treturn nil\n}", "func (i *Index) SaveJSON() ([]byte, error) {\n\treturn json.Marshal(i.Objects)\n}", "func doSetAccessJSON(targetURL string, targetPERMS accessPerms) *probe.Error {\n\tclnt, err := newClient(targetURL)\n\tif err != nil {\n\t\treturn err.Trace(targetURL)\n\t}\n\tfileReader, e := os.Open(string(targetPERMS))\n\tif e != nil {\n\t\tfatalIf(probe.NewError(e).Trace(), \"Unable to set policy for `\"+targetURL+\"`.\")\n\t}\n\tdefer fileReader.Close()\n\n\tconst maxJSONSize = 120 * 1024 // 120KiB\n\tconfigBuf := make([]byte, maxJSONSize+1)\n\n\tn, e := io.ReadFull(fileReader, configBuf)\n\tif e == nil {\n\t\treturn probe.NewError(bytes.ErrTooLarge).Trace(targetURL)\n\t}\n\tif e != io.ErrUnexpectedEOF {\n\t\treturn probe.NewError(e).Trace(targetURL)\n\t}\n\n\tconfigBytes := configBuf[:n]\n\tif err = clnt.SetAccess(string(configBytes), true); err != nil {\n\t\treturn err.Trace(targetURL, string(targetPERMS))\n\t}\n\treturn nil\n}", "func RenderJSON(w http.ResponseWriter, dataJSON []byte, cacheMaxAge time.Duration) {\n\tw.Header().Set(\"Cache-Control\", BuildCacheControlHeader(cacheMaxAge))\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t_, _ = w.Write(dataJSON)\n}", "func saveJSONToCloudStorage(w http.ResponseWriter, data map[string]string) {\n\tbucket := \"my-test-appsero-storage\"\n\tt := time.Now()\n\tobject := \"track/\" + t.Format(\"2006/01/02/15\") + \"/\" + strconv.FormatInt(time.Now().UnixNano(), 10) + \".json\"\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\tfmt.Fprint(w, \"storage.NewClient: %v\", err)\n\t}\n\tdefer client.Close()\n\n\tctx, cancel := context.WithTimeout(ctx, time.Second*50)\n\tdefer cancel()\n\n\tbkt := client.Bucket(bucket)\n\tobj := bkt.Object(object)\n\twc := obj.NewWriter(ctx)\n\n\twc.ContentType = \"text/josn\"\n\tmapData, err := json.Marshal(data)\n\tif err != nil {\n\t\tfmt.Fprintf(w, \"Error %v\\n\", err.Error())\n\t}\n\n\tif _, err := wc.Write(mapData); err != nil {\n\t\tfmt.Fprintf(w, \"Failed to write json file %v\\n\", err)\n\t}\n\n\tif err := wc.Close(); err != nil {\n\t\tfmt.Fprintf(w, \"Failed to close file %v\\n\", err)\n\t}\n}", "func (us *UserStorage) ImportJSON(data []byte) error {\n\treturn nil\n}", "func (s *SubmissionHandler) writeJSON(i interface{}) error {\n\tif e := util.WriteJSON(s.conn, i); e != nil {\n\t\treturn e\n\t}\n\t_, e := s.conn.Write([]byte(util.EOT))\n\treturn e\n}", "func (a *API) Set(w http.ResponseWriter, r *http.Request) {\n\t// Get Request Vars\n\tvars := mux.Vars(r)\n\trealm, ok := vars[\"realm\"]\n\tif !ok {\n\t\tRaiseError(w, \"Realm is missing\", http.StatusBadRequest, ErrorCodeRealmMissing)\n\t\treturn\n\t}\n\n\tkey, ok := vars[\"key\"]\n\tif !ok {\n\t\tRaiseError(w, \"Key is missing\", http.StatusBadRequest, ErrorCodeKeyMissing)\n\t\treturn\n\t}\n\n\tvalue, err := ValueFromValueMessageType(r.Body)\n\tif err != nil {\n\t\tRaiseError(w, \"Invalid request body\", http.StatusBadRequest, ErrorCodeInvalidRequestBody)\n\t\treturn\n\t}\n\n\ta.Storage.Set(realm, key, value)\n\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(w).Encode(value.ToValueMessageType())\n}", "func (r *Reflector) SetJSONResponse(o *Operation, output interface{}, httpStatus int) error {\n\treturn r.SetupResponse(OperationContext{\n\t\tOperation: o,\n\t\tOutput: output,\n\t\tHTTPStatus: httpStatus,\n\t})\n}", "func (c *Ctx) JSON(data interface{}) error {\n\traw, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.Response.SetBodyRaw(raw)\n\tc.Response.Header.SetContentType(MIMEApplicationJSON)\n\treturn nil\n}", "func getJSONData() []byte {\n\t// if the json file is not existed, create a new file\n\tif _, err := os.Stat(savedJSONFile); os.IsNotExist(err) {\n\t\tos.Create(savedJSONFile)\n\t\t// it is necessary to have a object in json file or it will raise error\n\t\twtiteBrackets := []byte(\"[]\")\n\t\twriteErr := ioutil.WriteFile(savedJSONFile, wtiteBrackets, 0644)\n\t\tif writeErr != nil {\n\t\t\tpc, _, _, _ := runtime.Caller(0)\n\t\t\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \"Write to json file error.\", writeErr)\n\t\t}\n\t}\n\n\tjsonData, err := ioutil.ReadFile(savedJSONFile)\n\tif err != nil {\n\t\tpc, _, _, _ := runtime.Caller(0)\n\t\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \"Write to json file error.\", err)\n\t}\n\treturn jsonData\n}", "func writeJSON(buf *bytes.Buffer, v interface{}, keyName string) error {\n\tenc, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, `failed to encode '%s'`, keyName)\n\t}\n\tbuf.Write(enc)\n\n\treturn nil\n}", "func setGeneration(genericData map[string]interface{}, generation float64) error {\n\treturn setJSONValue(genericData, []string{\"metadata\", \"generation\"}, generation)\n}", "func (e *Exporter) HandleJSON(w http.ResponseWriter, r *http.Request) {\n\tb, err := json.MarshalIndent(e.store, \"\", \" \")\n\tif err != nil {\n\t\texportJSONErrors.Add(1)\n\t\tglog.Info(\"error marshalling metrics into json:\", err.Error())\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tif _, err := w.Write(b); err != nil {\n\t\tglog.Error(err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func (c *RCache) PutJson(key string, val interface{}, timeout time.Duration) error {\n\tbuf, err := json.Marshal(val)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.Put(key, string(buf), timeout)\n}", "func writeJSON(w http.ResponseWriter, data interface{}) {\n\tb, err := json.Marshal(data)\n\tif err != nil {\n\t\twriteErr(w, 500, err)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(b)\n}", "func writeJSON(w http.ResponseWriter, code int, value interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tjson.NewEncoder(w).Encode(value)\n}", "func setUID(genericData map[string]interface{}) error {\n\treturn setJSONValue(genericData, []string{\"metadata\", \"uid\"}, uuid.NewUUID())\n}", "func (jf *JFile) SetString(JSONpath, value string) error {\n\t_, parentNode, err := jf.rootnode.GetNodes(JSONpath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tm, ok := parentNode.CheckMap()\n\tif !ok {\n\t\treturn errors.New(\"Parent is not a map: \" + JSONpath)\n\t}\n\n\t// Set the string\n\tm[lastpart(JSONpath)] = value\n\n\tnewdata, err := jf.rootnode.PrettyJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn jf.Write(newdata)\n}", "func SettingEnCodeJSON(configPath string, pa *Setting) error {\n\tfile, err := os.Create(configPath + \"/SsrMicroConfig.json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tenc := json.NewEncoder(file)\n\tenc.SetIndent(\"\", \" \")\n\tif err := enc.Encode(&pa); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func SetJSONResp(res http.ResponseWriter, httpCode int, resMessage []byte) {\n\tres.Header().Set(\"Content-type\", \"application/json\")\n\tres.WriteHeader(httpCode)\n\tres.Write(resMessage)\n}", "func (t *Task) SetData(d interface{}) *Task {\n\tencoded, err := json.Marshal(d)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tt.Data = encoded\n\treturn t\n}", "func (s *Set) UnmarshalJSON(text []byte) error {\n\tvar items []string\n\tif err := json.Unmarshal(text, &items); err != nil {\n\t\treturn err\n\t}\n\ts.AppendSlice(items)\n\treturn nil\n}", "func (as *AppStorage) ImportJSON(data []byte) error {\n\tapd := []appData{}\n\tif err := json.Unmarshal(data, &apd); err != nil {\n\t\tlog.Println(\"Error unmarshalling app data:\", err)\n\t\treturn err\n\t}\n\tfor _, a := range apd {\n\t\tif _, err := as.addNewApp(&AppData{appData: a}); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func writeJSON(w http.ResponseWriter, v interface{}) error {\n\t// Indent the JSON so it's easier to read for hackers.\n\tdata, err := json.MarshalIndent(v, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"content-type\", \"application/json; charset=utf-8\")\n\t_, err = w.Write(data)\n\treturn err\n}", "func (response *HTTPResponseVM) JSON(w http.ResponseWriter) {\n\tif response.Data == nil {\n\t\tresponse.Data = map[string]interface{}{}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(response.Status)\n\t_ = json.NewEncoder(w).Encode(response)\n}", "func setUp() {\n\tdefaultData := map[string]string{\n\t\t\"key1\": \"value1\",\n\t\t\"key2\": \"value2\",\n\t\t\"key3\": \"value3\",\n\t}\n\tjsonData, _ := json.Marshal(defaultData)\n\terr := ioutil.WriteFile(JsonTestPath, jsonData, 0644)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n}", "func SetString(filename, JSONpath, value string) error {\n\tjf, err := NewFile(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn jf.SetString(JSONpath, value)\n}", "func (m *PolicySetsItemUpdatePostRequestBody) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func TestJSON() {\n\tvoucher1 := Vocuher{\n\t\tID: \"5fcfb3393f2e48e107adc0a7\",\n\t\tHerbivoreSpecies: \"Zaretis crawfordhilli\",\n\t\tCollectionDate: \"10/22/2004\",\n\t\tHerbivoreFamily: \"Nymphalidae\",\n\t\tLatitude: \"10.98680\",\n\t\tLocality: \"Sendero Evangelista\",\n\t\tLongitude: \"-85.42083\",\n\t\tVoucher: \"04-SRNP-55848\",\n\t}\n\n\tvoucher2 := Vocuher{\n\t\tID: \"5f3333393f2e48e107adc0a7\",\n\t\tHerbivoreSpecies: \"Zaretis crawfordhilli\",\n\t\tCollectionDate: \"10/22/2004\",\n\t\tHerbivoreFamily: \"Nymphalidae\",\n\t\tLatitude: \"10.98680\",\n\t\tLocality: \"Sendero Evangelista\",\n\t\tLongitude: \"-85.42083\",\n\t\tVoucher: \"05-SRNP-55848\",\n\t}\n\n\tlocals := []Vocuher{}\n\tlocals = append(locals, voucher1, voucher2)\n\t//decare and initialize the map with data, to initialize it empty:\n\t//localities := make(map[string][]vocuher)\n\tlocalities := map[string][]Vocuher{\n\t\t\"Sendero Evangelista\": locals,\n\t}\n\n\tresponseB := []SpPoints{} ///\n\tspPoint := SpPoints{\n\t\tID: \"ZC\",\n\t\tCount: 180.0,\n\t\tData: localities,\n\t}\n\n\tresponseB = append(responseB, spPoint)\n\n\tfmt.Println(spPoint)\n\tos.Exit(0)\n}", "func SetBytes(json []byte, path string, value interface{}) ([]byte, error) {\n\tjstr := *(*string)(unsafe.Pointer(&json))\n\tvar res []byte\n\tvar err error\n\tswitch v := value.(type) {\n\tdefault:\n\t\tb, err := jsongo.Marshal(value)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\traw := *(*string)(unsafe.Pointer(&b))\n\t\tres, err = set(jstr, path, raw, false)\n\tcase string:\n\t\tres, err = set(jstr, path, v, true)\n\tcase []byte:\n\t\traw := *(*string)(unsafe.Pointer(&v))\n\t\tres, err = set(jstr, path, raw, true)\n\tcase bool:\n\t\tif v {\n\t\t\tres, err = set(jstr, path, \"true\", false)\n\t\t} else {\n\t\t\tres, err = set(jstr, path, \"false\", false)\n\t\t}\n\tcase int8:\n\t\tres, err = set(jstr, path, strconv.FormatInt(int64(v), 10), false)\n\tcase int16:\n\t\tres, err = set(jstr, path, strconv.FormatInt(int64(v), 10), false)\n\tcase int32:\n\t\tres, err = set(jstr, path, strconv.FormatInt(int64(v), 10), false)\n\tcase int64:\n\t\tres, err = set(jstr, path, strconv.FormatInt(int64(v), 10), false)\n\tcase uint8:\n\t\tres, err = set(jstr, path, strconv.FormatUint(uint64(v), 10), false)\n\tcase uint16:\n\t\tres, err = set(jstr, path, strconv.FormatUint(uint64(v), 10), false)\n\tcase uint32:\n\t\tres, err = set(jstr, path, strconv.FormatUint(uint64(v), 10), false)\n\tcase uint64:\n\t\tres, err = set(jstr, path, strconv.FormatUint(uint64(v), 10), false)\n\tcase float32:\n\t\tres, err = set(jstr, path, strconv.FormatFloat(float64(v), 'f', -1, 64), false)\n\tcase float64:\n\t\tres, err = set(jstr, path, strconv.FormatFloat(float64(v), 'f', -1, 64), false)\n\t}\n\treturn res, err\n}", "func (m *Mouse) WriteJSON() {\n\tvar flags int\n\tif FileExists() {\n\t\tos.Truncate(\"mouse.json\", 0)\n\t\tflags = os.O_WRONLY\n\t} else {\n\t\tflags = os.O_WRONLY | os.O_CREATE\n\t}\n\tfile, _ := os.OpenFile(\"mouse.json\", flags, 0755)\n\tdefer file.Close()\n\tjson.NewEncoder(file).Encode(m)\n}", "func (ctx *Context) Json(data interface{}) {\n\tdata, err := json.Marshal(data)\n\tif err != nil {\n\t\tfmt.Println(\"[ERROR] \" + err.Error())\n\t}\n\tctx.writer.Header().Set(\"Content-Type\", \"application/json\")\n\tfmt.Fprintf(ctx.writer, \"%s\", data)\n}", "func AsJSON(jsonString string) JSON {\n\tvar j JSON\n\tj.BindStr(jsonString)\n\n\treturn j\n}", "func (c *Column) AppendJSON(j json.BinaryJSON) {\n\tc.data = append(c.data, j.TypeCode)\n\tc.data = append(c.data, j.Value...)\n\tc.finishAppendVar()\n}" ]
[ "0.7538773", "0.7155119", "0.70645815", "0.6895792", "0.6857484", "0.6847259", "0.67868143", "0.6607495", "0.6364926", "0.62667775", "0.6214888", "0.6126578", "0.60069203", "0.59185195", "0.5913743", "0.59000033", "0.5890777", "0.58237827", "0.57883984", "0.56852114", "0.56774884", "0.56756735", "0.5648878", "0.5645887", "0.56203276", "0.5618452", "0.55766964", "0.5568942", "0.5566457", "0.5551541", "0.5528906", "0.5518316", "0.5507022", "0.5499368", "0.5445845", "0.5434315", "0.543411", "0.5414677", "0.5411694", "0.5398995", "0.5369596", "0.5360643", "0.5339617", "0.5337313", "0.5332266", "0.53029996", "0.53001064", "0.5262071", "0.52560854", "0.52356154", "0.5232862", "0.5221016", "0.5216931", "0.5212902", "0.52013713", "0.5196766", "0.51937646", "0.51925135", "0.5178899", "0.51762104", "0.5170196", "0.51583433", "0.5152863", "0.5152159", "0.5148795", "0.51360995", "0.5129802", "0.5127114", "0.5127056", "0.5118189", "0.511377", "0.5096404", "0.50882494", "0.5081142", "0.5078162", "0.5068673", "0.50420314", "0.5040331", "0.50336635", "0.503099", "0.5027347", "0.5026417", "0.502514", "0.5024961", "0.5024819", "0.50220174", "0.50177836", "0.5016404", "0.5014606", "0.5001965", "0.49982494", "0.49963906", "0.4993715", "0.496725", "0.49600708", "0.4958765", "0.49487153", "0.49468818", "0.49450567", "0.49440774" ]
0.6524781
8
GetJSON get json data
func (h *API) GetJSON(key string) (map[string]interface{}, error) { var imapGet map[string]interface{} value, err := h.Client.Get(key).Result() if err != nil { return nil, err } json.Unmarshal([]byte(value), &imapGet) return imapGet, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getJson(url string, target interface{}) error {\n\tr, err := sendClient.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer r.Body.Close()\n\treturn json.NewDecoder(r.Body).Decode(target)\n}", "func getJson(url string, target interface{}) error {\n\tr, err := http.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer r.Body.Close()\n\n\treturn json.NewDecoder(r.Body).Decode(target)\n}", "func (handler Handler) GetJSON(r *http.Request) (*jsonq.JsonQuery, error) {\n\n\tcontent, err := ioutil.ReadAll(r.Body)\n\tr.Body.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(content) == 0 {\n\t\treturn nil, errors.NewWithCode(err, errors.JSONIsEmpty, r.URL.String())\n\t}\n\n\tdata := map[string]interface{}{}\n\tdec := json.NewDecoder(strings.NewReader(string(content)))\n\tdec.Decode(&data)\n\tjq := jsonq.NewQuery(data)\n\n\treturn jq, nil\n}", "func getJSON(url string, obj interface{}) (err error) {\n\tresp, err := http.Get(url)\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(b, obj)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\t// Success!\n\treturn\n}", "func getJSON(url string, target interface{}) error {\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\treturn json.NewDecoder(resp.Body).Decode(target)\n}", "func GetJSON(url string, v interface{}) error {\n\tcli := &http.Client{\n\t\tTimeout: RequestTimeout * time.Second,\n\t}\n\tresp, err := cli.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\treply, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = json.Unmarshal(reply, v)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func GetJSON(url string, v interface{}) error {\n\treturn doJSONReq(\"GET\", url, nil, v)\n}", "func (c *EzClient) JSONGet(url string, out interface{}) (int, error) {\n\tresp, err := c.Client.Get(url)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn decodeJSONResponse(resp, out)\n}", "func (client *Instance) GetJSON(v interface{}) (statusCode int, err error) {\n\tstatusCode, body, err := client.GET()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn statusCode, json.NewDecoder(bytes.NewReader(body)).Decode(&v)\n}", "func getJson(url string) (resp Resp, err error) {\n\tr, err := http.Get(url)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif len(body) > 0 {\n\t\terr = json.Unmarshal(body, &resp)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif resp.Error.ErrorMsg != \"\" {\n\t\t\tlog.Fatal(resp.Error.ErrorMsg)\n\t\t}\n\t}\n\treturn\n}", "func (c *HTTPClient) GetJSON(url string, headers map[string]string, out interface{}) error {\n\treturn c.doRequest(url, http.MethodGet, headers, nil, out)\n}", "func (client *Client) GetJSON(\n\turl string,\n\tparams url.Values,\n\tresult interface{},\n\toptions ...interface{},\n) (json.RawMessage, int, error) {\n\treturn client.requestJSON(\"GET\", url, params, nil, result, options...)\n}", "func (c *Client) getJSON(route string, request interface{}, response interface{}) error {\n\turl := c.endpoint(route)\n\n\tvalues, err := query.Values(request)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tqueryString := values.Encode()\n\tif queryString != \"\" {\n\t\turl = url + \"?\" + queryString\n\t}\n\n\tresp, err := c.client.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := ioutil.ReadAll(resp.Body)\n\t\treturn fmt.Errorf(\"%v: %v\", resp.Status, string(body))\n\t}\n\n\tdec := json.NewDecoder(resp.Body)\n\treturn dec.Decode(response)\n}", "func (s *Client) GetJSON(url string, target interface{}) error {\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tres, err := s.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer res.Body.Close()\n\n\treturn json.NewDecoder(res.Body).Decode(target)\n}", "func GetJSON(httpClient http.Client, path string, response proto.Message) error {\n\treq, err := http.NewRequest(\"GET\", path, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn doJSONRequest(httpClient, req, response)\n}", "func getJSON(url string, target interface{}) error {\n\tmyClient := &http.Client{Timeout: defaultHTTPTimeout}\n\treq, err := http.NewRequestWithContext(context.Background(), \"GET\", url, http.NoBody)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create http req for %s: %w\", url, err)\n\t}\n\tr, err := myClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer r.Body.Close()\n\n\treturn json.NewDecoder(r.Body).Decode(target)\n}", "func JSONGet(conn redis.Conn, key string, path string, opts ...JSONGetOption) (res interface{}, err error) {\n\targs := make([]interface{}, 0)\n\targs = append(args, key)\n\n\tfor _, op := range opts {\n\t\tty, va := op.optionTypeValue()\n\n\t\targs = append(args, ty)\n\t\tif ty != \"NOESCAPE\" {\n\t\t\targs = append(args, va)\n\t\t}\n\t}\n\targs = append(args, path)\n\n\tname, args, _ := CommandBuilder(\"JSON.GET\", args...)\n\treturn conn.Do(name, args...)\n}", "func GetJSON(url string, token string, client http.Client, val interface{}) (err error) {\n\treq, err := createJSONGetRequest(url, token)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = executeRequestCheckStatusDecodeJSONResponse(client, req, val)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (g *Github) GetJSON(url string, v interface{}) error {\n\tbytes, err := g.getBytes(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := json.Unmarshal(bytes, v); err != nil {\n\t\treturn fmt.Errorf(\"could not parse json for url %s: %v\", url, err)\n\t}\n\treturn nil\n}", "func (api *API) GetJSON(path string, v interface{}) (body []byte, status int, err error) {\n\tbody, status, err = api.Get(path)\n\tif err != nil {\n\t\treturn body, status, err\n\t}\n\n\terr = json.Unmarshal(body, v)\n\tif err != nil {\n\t\treturn body, status, err\n\t}\n\n\treturn body, status, nil\n}", "func GetJSON(url string, target interface{}) error {\n\treturn NewClient(nil).GetJSON(url, target)\n}", "func HttpGetJson(requestUrl, user, pass string) (interface{}, error) {\n\tbody, err := httpGet(requestUrl, user, pass)\n\tif err != nil {\n\t\tfmt.Println(\"httpGetJson: fetching data failed!\")\n\t\t//TODO: PANIC\n\t}\n\n\t//NOTE debug\n\t//err = ioutil.WriteFile(\"response.json\", body, 0644)\n\t//errorHandler(err, \"\")\n\n\tdata, err := jsonToMap(body)\n\tif err != nil {\n\t\t//\n\t}\n\n\treturn data, nil\n}", "func (c *FileSystemCache) GetJSON(o interface{}, key ...string) error {\n\tb, err := c.Get(key...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn json.Unmarshal(b, o)\n}", "func (c *Client) GetJSON(endpoint string, v interface{}) error {\n\taddress, err := c.addToken(endpoint)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresp, err := http.Get(address)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\treturn json.NewDecoder(resp.Body).Decode(v)\n}", "func httpGetJSON(url string, data interface{}) (interface{}, error) {\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\tlog.Errorf(\"Error during http get. Err: %v\", err)\n\t\treturn nil, err\n\t}\n\tbody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\tlog.Errorf(\"Error during ioutil readall. Err: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tif err := json.Unmarshal(body, data); err != nil {\n\t\tlog.Errorf(\"Error during json unmarshall. Err: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tlog.Debugf(\"Results for (%s): %+v\\n\", url, data)\n\n\treturn data, nil\n}", "func DownloadJSON(ctx context.Context) ([]byte, error) {\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, dataURI.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tdata, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn data, nil\n}", "func (r *Request) GetJSON(path string, params ...url.Values) {\n\tcontentType := \"application/json\"\n\n\tif len(params) == 0 {\n\t\tr.Send(\"GET\", path, contentType)\n\t} else {\n\t\tr.Send(\"GET\", path, contentType, params[0])\n\t}\n}", "func getJSONData() []byte {\n\t// if the json file is not existed, create a new file\n\tif _, err := os.Stat(savedJSONFile); os.IsNotExist(err) {\n\t\tos.Create(savedJSONFile)\n\t\t// it is necessary to have a object in json file or it will raise error\n\t\twtiteBrackets := []byte(\"[]\")\n\t\twriteErr := ioutil.WriteFile(savedJSONFile, wtiteBrackets, 0644)\n\t\tif writeErr != nil {\n\t\t\tpc, _, _, _ := runtime.Caller(0)\n\t\t\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \"Write to json file error.\", writeErr)\n\t\t}\n\t}\n\n\tjsonData, err := ioutil.ReadFile(savedJSONFile)\n\tif err != nil {\n\t\tpc, _, _, _ := runtime.Caller(0)\n\t\terrorWebLogger.FatalPrintln(getCurrentRPCmethod(pc), \"Write to json file error.\", err)\n\t}\n\treturn jsonData\n}", "func GetJSON(url string, response interface{}) error {\n\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\treturn json.NewDecoder(resp.Body).Decode(response)\n}", "func getJsonByte (url string) []byte {\n\tjsonClient := http.Client{\n\t\tTimeout: time.Second * 2, // Maximum of 2 secs\n\t}\n\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treq.Header.Set(\"User-Agent\", \"umbrella client\")\n\n\tres, getErr := jsonClient.Do(req)\n\tif getErr != nil {\n\t\tlog.Fatal(getErr)\n\t}\n\n\tbody, readErr := ioutil.ReadAll(res.Body)\n\tif readErr != nil {\n\t\tlog.Fatal(readErr)\n\t}\n\n\treturn body\n\t//jsonErr := json.Unmarshal(body, jsonBody)\n//\n//\tif jsonErr != nil {\n//\t\tlog.Fatal(jsonErr)\n//\t}\n}", "func GetQuestionJSON(nquestion int,qt string) string{\n\tresp,err:=http.Get(fmt.Sprintf(urlfmt,nquestion,qt))\n\tif err!=nil {\n\t\tfmt.Fprintf(os.Stderr,\"Error: %s\\n\",err.Error())\n\t\treturn \"\"\n\t}\n\tdefer resp.Body.Close()\n\tvar bytebuf bytes.Buffer\n\tn,err:=bytebuf.ReadFrom(resp.Body)\n\tif n==0 {\n\t\tfmt.Fprintf(os.Stderr,\"Error: cannot retrieve JSON data\\n\")\n\t}\n\tif (err!=nil){\n\t\tfmt.Fprintf(os.Stderr,\"Error: %s\\n\",err.Error())\n\t\treturn \"\"\n\t}\n\n\treturn bytebuf.String()\n\n\n\n\n\n}", "func (r *Client) JSONGet(key, path string, value interface{}) error {\n\tcmdString := r.Conn.JSONGet(r.ctx, key, path)\n\t_, err := cmdString.Result()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = cmdString.Scan(value)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tr.log.Debug().Msgf(\"JSONGet value by key %s from cache, path %s\", key, path)\n\n\treturn nil\n}", "func GetJSON(URL string, headers map[string]string, v interface{}) error {\n\tspaceClient := http.Client{}\n\n\treq, err := http.NewRequest(http.MethodGet, URL, nil)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor key, value := range headers {\n\t\treq.Header.Set(key, value)\n\t}\n\n\tres, err := spaceClient.Do(req)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.Body != nil {\n\t\tdefer res.Body.Close()\n\t}\n\n\tbody, err := ioutil.ReadAll(res.Body)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn json.Unmarshal(body, v)\n}", "func GetWithJSONQuery(path string, data string) {\n\tres, err := getThisWithReqBody(path, data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tfmt.Printf(sep)\n\tfmt.Printf(\"GET+ result: %s\\n\", res)\n}", "func (p *provider) getJSON(url string, token string, data interface{}) (map[string]string, error) {\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", token))\n\treq.Header.Set(\"Accept\", githubAccept)\n\n\tres, err := p.transport.RoundTrip(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"Non-200 response from GitHub API call %s: %d\", url, res.StatusCode)\n\t}\n\n\tif err := json.NewDecoder(res.Body).Decode(&data); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn links.ParseLinks(res.Header.Get(\"Link\")), nil\n}", "func JsonGet(keyS string) string {\n\n\tdb := Connect()\n\n\t//defer db.Close()\n\n\tkey := []byte(keyS)\n\n\tvar valbyte []byte\n\n\terr = db.View(func(tx *bolt.Tx) error {\n\n\t\tbucket := tx.Bucket(Database)\n\t\tif bucket == nil {\n\t\t\treturn fmt.Errorf(\"Bucket %q not found!\", Database)\n\t\t}\n\n\t\tvalbyte = bucket.Get(key)\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tbyt := []byte(string(valbyte))\n\n\t///interface\n\n\terrjs := json.Unmarshal(byt, &djson)\n\n\tfmt.Println(\"here: \", djson)\n\n\tif errjs != nil {\n\n\t\tlog.Fatal(fmt.Println(\"Error Json: \", errjs))\n\t}\n\n\treturn string(valbyte)\n}", "func getRawJSON(t *testing.T, ts *httptest.Server, path string) []byte {\n\tres, body := checkGet(t, ts, path)\n\n\t_, file, line, _ := runtime.Caller(1)\n\tfile = filepath.Base(file)\n\tif res.StatusCode != 200 {\n\t\tt.Fatalf(\"%s:%d: Expected status %d, got %d. Path: %s\", file, line, 200, res.StatusCode, path)\n\t}\n\n\tfoundCtype := res.Header.Get(\"content-type\")\n\tif foundCtype != \"application/json\" {\n\t\tt.Errorf(\"%s:%d: Wrong Content-type for JSON: %s\", file, line, foundCtype)\n\t}\n\n\tif len(body) == 0 {\n\t\tt.Errorf(\"%s:%d: No response body\", file, line)\n\t}\n\t// fmt.Printf(\"Body: %s\", body)\n\n\treturn body\n}", "func GetJSONBody(client *http.Client, url string) (map[string]interface{}, error) {\n\tresp, err := client.Get(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tdecoder := json.NewDecoder(resp.Body)\n\tvar data map[string]interface{}\n\tif err = decoder.Decode(&data); err != nil {\n\t\treturn nil, err\n\t}\n\treturn data, nil\n}", "func getJSON(url string) ([]byte, error) {\n\n\t// switch to return hardcoded results during testing. Copy-and-pasted\n\t//\tin for simplicity\n\n\t/*\n\t\t// TODO DEBUG\n\t\tif url == \"https://api.github.com/repos/tholok97/the-t-files/languages\" {\n\t\t\treturn []byte(`{ \"C++\": 85890, \"Vim script\": 15368 }`), nil\n\t\t}\n\n\t\tswitch url {\n\t\tcase \"https://api.github.com/repos/tholok97/the-t-files\":\n\t\t\treturn []byte(`{\n\t\t\t\t\t\t\t\t\"id\": 71177175,\n\t\t\t\t\t\t\t\t\"name\": \"the-t-files\",\n\t\t\t\t\t\t\t\t\"full_name\": \"tholok97/the-t-files\",\n\t\t\t\t\t\t\t\t\"owner\": {\n\t\t\t\t\t\t\t\t\t\"login\": \"tholok97\",\n\t\t\t\t\t\t\t\t\t\"id\": 22896227,\n\t\t\t\t\t\t\t\t\t\"avatar_url\": \"https://avatars0.githubusercontent.com/u/22896227?v=4\",\n\t\t\t\t\t\t\t\t\t\"gravatar_id\": \"\",\n\t\t\t\t\t\t\t\t\t\"url\": \"https://api.github.com/users/tholok97\",\n\t\t\t\t\t\t\t\t\t\"html_url\": \"https://github.com/tholok97\",\n\t\t\t\t\t\t\t\t\t\"followers_url\": \"https://api.github.com/users/tholok97/followers\",\n\t\t\t\t\t\t\t\t\t\"following_url\": \"https://api.github.com/users/tholok97/following{/other_user}\",\n\t\t\t\t\t\t\t\t\t\"gists_url\": \"https://api.github.com/users/tholok97/gists{/gist_id}\",\n\t\t\t\t\t\t\t\t\t\"starred_url\": \"https://api.github.com/users/tholok97/starred{/owner}{/repo}\",\n\t\t\t\t\t\t\t\t\t\"subscriptions_url\": \"https://api.github.com/users/tholok97/subscriptions\",\n\t\t\t\t\t\t\t\t\t\"organizations_url\": \"https://api.github.com/users/tholok97/orgs\",\n\t\t\t\t\t\t\t\t\t\"repos_url\": \"https://api.github.com/users/tholok97/repos\",\n\t\t\t\t\t\t\t\t\t\"events_url\": \"https://api.github.com/users/tholok97/events{/privacy}\",\n\t\t\t\t\t\t\t\t\t\"received_events_url\": \"https://api.github.com/users/tholok97/received_events\",\n\t\t\t\t\t\t\t\t\t\"type\": \"User\",\n\t\t\t\t\t\t\t\t\t\"site_admin\": false\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"private\": false,\n\t\t\t\t\t\t\t\t\"html_url\": \"https://github.com/tholok97/the-t-files\",\n\t\t\t\t\t\t\t\t\"description\": \"Div. C++ prosjekter\",\n\t\t\t\t\t\t\t\t\"fork\": false,\n\t\t\t\t\t\t\t\t\"url\": \"https://api.github.com/repos/tholok97/the-t-files\",\n\t\t\t\t\t\t\t\t\"forks_url\": \"https://api.github.com/repos/tholok97/the-t-files/forks\",\n\t\t\t\t\t\t\t\t\"keys_url\": \"https://api.github.com/repos/tholok97/the-t-files/keys{/key_id}\",\n\t\t\t\t\t\t\t\t\"collaborators_url\": \"https://api.github.com/repos/tholok97/the-t-files/collaborators{/collaborator}\",\n\t\t\t\t\t\t\t\t\"teams_url\": \"https://api.github.com/repos/tholok97/the-t-files/teams\",\n\t\t\t\t\t\t\t\t\"hooks_url\": \"https://api.github.com/repos/tholok97/the-t-files/hooks\",\n\t\t\t\t\t\t\t\t\"issue_events_url\": \"https://api.github.com/repos/tholok97/the-t-files/issues/events{/number}\",\n\t\t\t\t\t\t\t\t\"events_url\": \"https://api.github.com/repos/tholok97/the-t-files/events\",\n\t\t\t\t\t\t\t\t\"assignees_url\": \"https://api.github.com/repos/tholok97/the-t-files/assignees{/user}\",\n\t\t\t\t\t\t\t\t\"branches_url\": \"https://api.github.com/repos/tholok97/the-t-files/branches{/branch}\",\n\t\t\t\t\t\t\t\t\"tags_url\": \"https://api.github.com/repos/tholok97/the-t-files/tags\",\n\t\t\t\t\t\t\t\t\"blobs_url\": \"https://api.github.com/repos/tholok97/the-t-files/git/blobs{/sha}\",\n\t\t\t\t\t\t\t\t\"git_tags_url\": \"https://api.github.com/repos/tholok97/the-t-files/git/tags{/sha}\",\n\t\t\t\t\t\t\t\t\"git_refs_url\": \"https://api.github.com/repos/tholok97/the-t-files/git/refs{/sha}\",\n\t\t\t\t\t\t\t\t\"trees_url\": \"https://api.github.com/repos/tholok97/the-t-files/git/trees{/sha}\",\n\t\t\t\t\t\t\t\t\"statuses_url\": \"https://api.github.com/repos/tholok97/the-t-files/statuses/{sha}\",\n\t\t\t\t\t\t\t\t\"languages_url\": \"https://api.github.com/repos/tholok97/the-t-files/languages\",\n\t\t\t\t\t\t\t\t\"stargazers_url\": \"https://api.github.com/repos/tholok97/the-t-files/stargazers\",\n\t\t\t\t\t\t\t\t\"contributors_url\": \"https://api.github.com/repos/tholok97/the-t-files/contributors\",\n\t\t\t\t\t\t\t\t\"subscribers_url\": \"https://api.github.com/repos/tholok97/the-t-files/subscribers\",\n\t\t\t\t\t\t\t\t\"subscription_url\": \"https://api.github.com/repos/tholok97/the-t-files/subscription\",\n\t\t\t\t\t\t\t\t\"commits_url\": \"https://api.github.com/repos/tholok97/the-t-files/commits{/sha}\",\n\t\t\t\t\t\t\t\t\"git_commits_url\": \"https://api.github.com/repos/tholok97/the-t-files/git/commits{/sha}\",\n\t\t\t\t\t\t\t\t\"comments_url\": \"https://api.github.com/repos/tholok97/the-t-files/comments{/number}\",\n\t\t\t\t\t\t\t\t\"issue_comment_url\": \"https://api.github.com/repos/tholok97/the-t-files/issues/comments{/number}\",\n\t\t\t\t\t\t\t\t\"contents_url\": \"https://api.github.com/repos/tholok97/the-t-files/contents/{+path}\",\n\t\t\t\t\t\t\t\t\"compare_url\": \"https://api.github.com/repos/tholok97/the-t-files/compare/{base}...{head}\",\n\t\t\t\t\t\t\t\t\"merges_url\": \"https://api.github.com/repos/tholok97/the-t-files/merges\",\n\t\t\t\t\t\t\t\t\"archive_url\": \"https://api.github.com/repos/tholok97/the-t-files/{archive_format}{/ref}\",\n\t\t\t\t\t\t\t\t\"downloads_url\": \"https://api.github.com/repos/tholok97/the-t-files/downloads\",\n\t\t\t\t\t\t\t\t\"issues_url\": \"https://api.github.com/repos/tholok97/the-t-files/issues{/number}\",\n\t\t\t\t\t\t\t\t\"pulls_url\": \"https://api.github.com/repos/tholok97/the-t-files/pulls{/number}\",\n\t\t\t\t\t\t\t\t\"milestones_url\": \"https://api.github.com/repos/tholok97/the-t-files/milestones{/number}\",\n\t\t\t\t\t\t\t\t\"notifications_url\": \"https://api.github.com/repos/tholok97/the-t-files/notifications{?since,all,participating}\",\n\t\t\t\t\t\t\t\t\"labels_url\": \"https://api.github.com/repos/tholok97/the-t-files/labels{/name}\",\n\t\t\t\t\t\t\t\t\"releases_url\": \"https://api.github.com/repos/tholok97/the-t-files/releases{/id}\",\n\t\t\t\t\t\t\t\t\"deployments_url\": \"https://api.github.com/repos/tholok97/the-t-files/deployments\",\n\t\t\t\t\t\t\t\t\"created_at\": \"2016-10-17T20:13:35Z\",\n\t\t\t\t\t\t\t\t\"updated_at\": \"2016-11-03T16:35:36Z\",\n\t\t\t\t\t\t\t\t\"pushed_at\": \"2017-04-24T21:50:48Z\",\n\t\t\t\t\t\t\t\t\"git_url\": \"git://github.com/tholok97/the-t-files.git\",\n\t\t\t\t\t\t\t\t\"ssh_url\": \"[email protected]:tholok97/the-t-files.git\",\n\t\t\t\t\t\t\t\t\"clone_url\": \"https://github.com/tholok97/the-t-files.git\",\n\t\t\t\t\t\t\t\t\"svn_url\": \"https://github.com/tholok97/the-t-files\",\n\t\t\t\t\t\t\t\t\"homepage\": \"\",\n\t\t\t\t\t\t\t\t\"size\": 3511,\n\t\t\t\t\t\t\t\t\"stargazers_count\": 0,\n\t\t\t\t\t\t\t\t\"watchers_count\": 0,\n\t\t\t\t\t\t\t\t\"language\": \"C++\",\n\t\t\t\t\t\t\t\t\"has_issues\": true,\n\t\t\t\t\t\t\t\t\"has_projects\": true,\n\t\t\t\t\t\t\t\t\"has_downloads\": true,\n\t\t\t\t\t\t\t\t\"has_wiki\": true,\n\t\t\t\t\t\t\t\t\"has_pages\": false,\n\t\t\t\t\t\t\t\t\"forks_count\": 0,\n\t\t\t\t\t\t\t\t\"mirror_url\": null,\n\t\t\t\t\t\t\t\t\"open_issues_count\": 0,\n\t\t\t\t\t\t\t\t\"forks\": 0,\n\t\t\t\t\t\t\t\t\"open_issues\": 0,\n\t\t\t\t\t\t\t\t\"watchers\": 0,\n\t\t\t\t\t\t\t\t\"default_branch\": \"master\",\n\t\t\t\t\t\t\t\t\"network_count\": 0,\n\t\t\t\t\t\t\t\t\"subscribers_count\": 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t`), nil\n\t\tcase \"https://api.github.com/repos/tholok97/the-t-files/languages\":\n\t\t\treturn []byte(`{ \"C++\": 85890, \"Vim script\": 15368 }`), nil\n\t\tcase \"https://api.github.com/repos/tholok97/the-t-files/stats/contributors\":\n\t\t\treturn []byte(`[\n\t\t\t {\n\t\t\t\t \"total\": 117,\n\t\t\t\t \"weeks\": [\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1476576000,\n\t\t\t\t\t \"a\": 698,\n\t\t\t\t\t \"d\": 42,\n\t\t\t\t\t \"c\": 8\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1477180800,\n\t\t\t\t\t \"a\": 163,\n\t\t\t\t\t \"d\": 25,\n\t\t\t\t\t \"c\": 3\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1477785600,\n\t\t\t\t\t \"a\": 601,\n\t\t\t\t\t \"d\": 268,\n\t\t\t\t\t \"c\": 31\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1478390400,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1478995200,\n\t\t\t\t\t \"a\": 96,\n\t\t\t\t\t \"d\": 41,\n\t\t\t\t\t \"c\": 9\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1479600000,\n\t\t\t\t\t \"a\": 334,\n\t\t\t\t\t \"d\": 335,\n\t\t\t\t\t \"c\": 12\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1480204800,\n\t\t\t\t\t \"a\": 14,\n\t\t\t\t\t \"d\": 9,\n\t\t\t\t\t \"c\": 4\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1480809600,\n\t\t\t\t\t \"a\": 234,\n\t\t\t\t\t \"d\": 19,\n\t\t\t\t\t \"c\": 8\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1481414400,\n\t\t\t\t\t \"a\": 35,\n\t\t\t\t\t \"d\": 33,\n\t\t\t\t\t \"c\": 2\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1482019200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1482624000,\n\t\t\t\t\t \"a\": 196,\n\t\t\t\t\t \"d\": 11,\n\t\t\t\t\t \"c\": 8\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1483228800,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1483833600,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1484438400,\n\t\t\t\t\t \"a\": 369,\n\t\t\t\t\t \"d\": 82,\n\t\t\t\t\t \"c\": 7\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1485043200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1485648000,\n\t\t\t\t\t \"a\": 284,\n\t\t\t\t\t \"d\": 135,\n\t\t\t\t\t \"c\": 14\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1486252800,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1486857600,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1487462400,\n\t\t\t\t\t \"a\": 274,\n\t\t\t\t\t \"d\": 23,\n\t\t\t\t\t \"c\": 5\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1488067200,\n\t\t\t\t\t \"a\": 85,\n\t\t\t\t\t \"d\": 28,\n\t\t\t\t\t \"c\": 1\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1488672000,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1489276800,\n\t\t\t\t\t \"a\": 166,\n\t\t\t\t\t \"d\": 120,\n\t\t\t\t\t \"c\": 2\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1489881600,\n\t\t\t\t\t \"a\": 109,\n\t\t\t\t\t \"d\": 50,\n\t\t\t\t\t \"c\": 1\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1490486400,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1491091200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1491696000,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1492300800,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1492905600,\n\t\t\t\t\t \"a\": 784,\n\t\t\t\t\t \"d\": 162,\n\t\t\t\t\t \"c\": 2\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1493510400,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1494115200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1494720000,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1495324800,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1495929600,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1496534400,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1497139200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1497744000,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1498348800,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1498953600,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1499558400,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1500163200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1500768000,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1501372800,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1501977600,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1502582400,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1503187200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1503792000,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1504396800,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1505001600,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1505606400,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t },\n\t\t\t\t {\n\t\t\t\t\t \"w\": 1506211200,\n\t\t\t\t\t \"a\": 0,\n\t\t\t\t\t \"d\": 0,\n\t\t\t\t\t \"c\": 0\n\t\t\t\t }\n\t\t\t\t ],\n\t\t\t\t \"author\": {\n\t\t\t\t\t \"login\": \"tholok97\",\n\t\t\t\t\t \"id\": 22896227,\n\t\t\t\t\t \"avatar_url\": \"https://avatars0.githubusercontent.com/u/22896227?v=4\",\n\t\t\t\t\t \"gravatar_id\": \"\",\n\t\t\t\t\t \"url\": \"https://api.github.com/users/tholok97\",\n\t\t\t\t\t \"html_url\": \"https://github.com/tholok97\",\n\t\t\t\t\t \"followers_url\": \"https://api.github.com/users/tholok97/followers\",\n\t\t\t\t\t \"following_url\": \"https://api.github.com/users/tholok97/following{/other_user}\",\n\t\t\t\t\t \"gists_url\": \"https://api.github.com/users/tholok97/gists{/gist_id}\",\n\t\t\t\t\t \"starred_url\": \"https://api.github.com/users/tholok97/starred{/owner}{/repo}\",\n\t\t\t\t\t \"subscriptions_url\": \"https://api.github.com/users/tholok97/subscriptions\",\n\t\t\t\t\t \"organizations_url\": \"https://api.github.com/users/tholok97/orgs\",\n\t\t\t\t\t \"repos_url\": \"https://api.github.com/users/tholok97/repos\",\n\t\t\t\t\t \"events_url\": \"https://api.github.com/users/tholok97/events{/privacy}\",\n\t\t\t\t\t \"received_events_url\": \"https://api.github.com/users/tholok97/received_events\",\n\t\t\t\t\t \"type\": \"User\",\n\t\t\t\t\t \"site_admin\": false\n\t\t\t\t }\n\t\t\t }\n\t\t\t ] `), nil\n\t\tdefault:\n\t\t\treturn []byte(\"\"), nil\n\t\t}\n\n\t\tfmt.Println(\"requesting github.... (bad?)\")\n\t*/\n\n\t// (try to) get response from url\n\tresp, getErr := http.Get(url)\n\tif getErr != nil || resp.StatusCode != http.StatusOK {\n\t\treturn nil, getErr\n\t}\n\n\t// we need to close the body when we're done. defer it\n\tdefer resp.Body.Close()\n\n\t// (try to) read []byte from response\n\tbodyBytes, readErr := ioutil.ReadAll(resp.Body)\n\tif readErr != nil {\n\t\treturn nil, readErr\n\t}\n\n\treturn bodyBytes, nil\n}", "func TestGetJSON(t *testing.T) {\n\tassert := audit.NewTestingAssertion(t, true)\n\t// Setup the test server.\n\tmux := newMultiplexer(assert)\n\tts := restaudit.StartServer(mux, assert)\n\tdefer ts.Close()\n\terr := mux.Register(\"test\", \"json\", NewTestHandler(\"json\", assert))\n\tassert.Nil(err)\n\t// Perform test requests.\n\treq := restaudit.NewRequest(\"GET\", \"/base/test/json/4711?foo=0815\")\n\treq.AddHeader(restaudit.HeaderAccept, restaudit.ApplicationJSON)\n\tresp := ts.DoRequest(req)\n\tresp.AssertStatusEquals(200)\n\tresp.AssertBodyContains(`\"ResourceID\":\"4711\"`)\n\tresp.AssertBodyContains(`\"Query\":\"0815\"`)\n\tresp.AssertBodyContains(`\"Context\":\"foo\"`)\n}", "func (client *HTTPClient) GetAsJSON(url string, dest interface{}, opts *RequestOptions) error {\n\tresp, err := client.Get(url, opts)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\treturn json.NewDecoder(resp.Body).Decode(dest)\n}", "func FetchJSON(urlPath string) map[string]any {\n\tout := map[string]any{}\n\tresponse, err := http.Get(fmt.Sprintf(\"%s%s\", ServerAddress, urlPath))\n\tif err != nil {\n\t\treturn out\n\t}\n\tdefer response.Body.Close()\n\t_ = json.NewDecoder(response.Body).Decode(&out)\n\treturn out\n}", "func BindGetJSONData(url string, param req.Param, body interface{}) error {\n\tr, err := req.Get(url, param)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = r.ToJSON(body)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *ManagerMock) GetByUserJSON(ctx context.Context) ([]byte, error) {\n\targs := m.Called(ctx)\n\tdata, _ := args.Get(0).([]byte)\n\treturn data, args.Error(1)\n}", "func (m *Manager) GetJson(name string, target interface{}) (err error) {\n\tfile, ok := m.json[name]\n\tif !ok {\n\t\tfile, err = os.Open(name + \".json\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tm.json[name] = file\n\t}\n\tdecoder := json.NewDecoder(file)\n\terr = decoder.Decode(target)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (u *EtcdUtil) GetJSON(key string, dst interface{}) (uint64, error) {\n\ts, i, err := u.Get(key, \"\")\n\tif err != nil {\n\t\treturn i, err\n\t}\n\tif err := json.Unmarshal([]byte(s), dst); err != nil {\n\t\treturn i, err\n\t}\n\treturn i, nil\n}", "func GetJSON(m Model) ([]byte, error) {\n\tdata, err := json.MarshalIndent(m, \"\", \" \")\n\trtx.Must(err, \"ERROR: failed to marshal archive.Model to JSON. This should never happen\")\n\treturn data, err\n}", "func TestGetJson(t *testing.T) {\n\taURL := \"http://localhost:8000/tree?depth=2&path=/lustre\"\n\tres, err := http.Get(aURL)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\t//fmt.Println(res.Status)\n\tj, err := ioutil.ReadAll(res.Body)\n\tres.Body.Close()\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\n\tfmt.Println(jsonPrettyPrint(string(j)))\n\twriteFile([]string{jsonPrettyPrint(string(j))}, \"/tmp/out.json\", false)\n\n}", "func (vd ViewData) GetJsonString() (j []byte, err error) {\n\tj, err = json.Marshal(vd.JsonData)\n\treturn\n}", "func getJSON(found, child, original *unstructured.Unstructured) ([]byte, []byte, []byte, error) {\n\tfoundJSON, err := found.MarshalJSON()\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"unable to marshal found JSON: %v\", err)\n\t}\n\tchildJSON, err := child.MarshalJSON()\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"unable to marshal child JSON: %v\", err)\n\t}\n\toriginalJSON, err := original.MarshalJSON()\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"unable to marshal original JSON: %v\", err)\n\t}\n\treturn foundJSON, childJSON, originalJSON, nil\n}", "func JsonGet(uri string, self Contact) (string, interface{}, Contact) {\n dstContact := Contact{}\n\n // Make the http request\n client := &http.Client{}\n req, _ := http.NewRequest(\"GET\", uri, nil)\n\n nullID := NodeID{}\n if self.ID != nullID {\n req.Header.Set(\"Modata-NodeID\", HexNodeID(self.ID))\n req.Header.Set(\"Modata-Address\", self.Addr)\n req.Header.Set(\"Modata-Port\", fmt.Sprintf(\"%v\", self.Port))\n }\n resp, err := client.Do(req)\n if (err != nil) { return ERROR, err, dstContact}\n\n // Decode the headers into a contact\n dstContact, err = DecodeModataHeaders(resp.Header)\n if (err != nil) {\n dstContact = Contact{}\n }\n\n // Decode the body of the response into a []byte\n response := make(map[string]interface{})\n raw, err := ioutil.ReadAll(resp.Body)\n resp.Body.Close()\n if (err != nil) { return ERROR, err, dstContact}\n\n // Decode the []byte into the standard mapping\n err = json.Unmarshal(raw, &response)\n if (err != nil) { return ERROR, err, dstContact}\n\n // Return the values TODO: check for existence of correct keys\n return response[\"status\"].(string), response[\"data\"], dstContact\n}", "func GetJSON(s Secret, v interface{}) error {\n\tb, err := s.Get()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn json.Unmarshal(b, v)\n}", "func getJSONDataFromAPI(path string) []byte {\n\n\tu, err := url.Parse(\"https://api.datadoghq.com/api/v1/\" + path)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tq := u.Query()\n\tq.Set(\"api_key\", viper.GetString(\"api_key\"))\n\tq.Set(\"application_key\", viper.GetString(\"app_key\"))\n\tu.RawQuery = q.Encode()\n\n\tvar netClient = &http.Client{\n\t\tTimeout: time.Second * 10,\n\t}\n\tresp, err := netClient.Get(u.String())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer resp.Body.Close()\n\n\tjd, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn jd\n}", "func GetJSON(u string) UserResponse {\n\turl := fmt.Sprintf(\"%s/%s\", GITHUB_ENDPOINT, u)\n\tresp, _ := http.Get(url)\n\n\tdefer resp.Body.Close()\n\n\tb, e := ioutil.ReadAll(resp.Body)\n\n\tif e != nil {\n\t\tfmt.Println(\"Error2\", resp.Body)\n\t}\n\ti := &UserResponse{}\n\te = json.Unmarshal(b, i)\n\treturn *i\n\n}", "func (h *HTTP) FetchJSON() (map[string]interface{}, error) {\n\tbody, err := h.FetchContent()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar data map[string]interface{}\n\n\terr = json.Unmarshal(body, &data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn data, nil\n}", "func (t *DelayRecent) GetJson() ([]byte, error) {\n\td := t.Get()\n\treturn d.GetJson()\n}", "func (c *Config) GetJson(pattern string, def ...interface{}) *gjson.Json {\n\tif j := c.getJson(); j != nil {\n\t\treturn j.GetJson(pattern, def...)\n\t}\n\treturn nil\n}", "func (r *Records) GetJSON() string {\n\tbuf := bytes.NewBufferString(\"\")\n\terr := r.WriteJSON(buf)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\treturn buf.String()\n}", "func fetchJSON(url string, resp interface{}) error {\n\tr, err := http.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer r.Body.Close()\n\treturn json.NewDecoder(r.Body).Decode(&resp)\n}", "func (c *Client) GetJSON(\n\tctx context.Context,\n\tendpoint string,\n) (ClientResponse, error) {\n\tres, err := c.GetEndpoint(ctx, endpoint)\n\tif err != nil {\n\t\treturn ClientResponse{}, err\n\t}\n\n\t// Read body\n\tdefer res.Body.Close()\n\tpayload, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn ClientResponse{}, err\n\t}\n\n\t// Decode json payload\n\tresult := make(ClientResponse)\n\terr = json.Unmarshal(payload, &result)\n\tif err != nil {\n\t\treturn ClientResponse{}, err\n\t}\n\treturn result, nil\n}", "func (m *ManagerMock) GetByPackageJSON(ctx context.Context, packageID string) ([]byte, error) {\n\targs := m.Called(ctx, packageID)\n\tdata, _ := args.Get(0).([]byte)\n\treturn data, args.Error(1)\n}", "func GetJSONContent(v interface{}, r *http.Request) error {\n\tdefer r.Body.Close()\n\treturn json.NewDecoder(r.Body).Decode(v)\n}", "func GetJSONContent(v interface{}, r *http.Request) error {\n\tdefer r.Body.Close()\n\treturn json.NewDecoder(r.Body).Decode(v)\n}", "func GetjsonData(url string) (HttpStatusCode int, res []byte, er error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlog.Println(\"[E]\", r.(error))\n\t\t}\n\t}()\n\thttpOrhttps := strings.Split(url, \":\")\n\tswitch httpOrhttps[0] {\n\tcase \"https\":\n\t\ttr := &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t\t}\n\t\tclient := &http.Client{Transport: tr}\n\t\tresp, err := client.Get(url)\n\t\tif err != nil {\n\t\t\ter = err\n\t\t\treturn 500, []byte(\"\"), er\n\t\t}\n\n\t\tWritelog(\"D\", \"get url\"+url)\n\t\tHttpStatusCode = resp.StatusCode\n\t\tdefer resp.Body.Close()\n\t\tif HttpStatusCode == 200 {\n\t\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\ter = err\n\t\t\t\treturn 500, []byte(\"\"), er\n\t\t\t}\n\t\t\tres = body\n\t\t}\n\t\treturn HttpStatusCode, res, nil\n\n\tcase \"http\":\n\t\tresp, err := http.Get(url)\n\t\tif err != nil {\n\t\t\treturn 500, []byte(\"\"), err\n\t\t}\n\t\tWritelog(\"D\", \"get url\"+url)\n\n\t\tHttpStatusCode = resp.StatusCode\n\t\tdefer resp.Body.Close()\n\t\tif HttpStatusCode == 200 {\n\t\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\treturn 500, []byte(\"\"), err\n\t\t\t}\n\t\t\tres = body\n\t\t}\n\t}\n\treturn HttpStatusCode, res, nil\n\n}", "func JSONForget(conn redis.Conn, key string, path string) (res interface{}, err error) {\n\tname, args, _ := CommandBuilder(\"JSON.FORGET\", key, path)\n\treturn conn.Do(name, args...)\n}", "func JSONGet(filename string) []JSONData {\n\tfile, err := os.Open(filename)\n\n\tif err != nil {\n\t\tlog.Printf(\"[!] Couldn't open the file for reading. Cause %s\",\n\t\t\terr.Error())\n\t}\n\n\tdefer file.Close()\n\tscanner := bufio.NewScanner(file)\n\n\tvar rows []JSONData = make([]JSONData, 0)\n\n\tfor scanner.Scan() {\n\n\t\tvar row JSONData\n\t\tvar data []byte = scanner.Bytes()\n\n\t\tif len(data) != 0 {\n\t\t\terr = json.Unmarshal(data, &row)\n\n\t\t\trows = append(rows, row)\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"[!] Couldn't unmarshal data of file. Got %s Cause %s\",\n\t\t\t\t\tscanner.Text(), err.Error())\n\t\t\t}\n\t\t}\n\t}\n\n\treturn rows\n}", "func getJsonObject(fileName string) *Data {\n\tjsonFile, err := os.Open(fileName)\n\t// check if error occured\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\t// close the json connection after program executation\n\tdefer jsonFile.Close()\n\n\t// convert the json file in memory to byte array\n\tbyteValue, _ := ioutil.ReadAll(jsonFile)\n\n\tvar data Data\n\tjson.Unmarshal(byteValue, &data)\n\n\treturn &data\n}", "func HttpGetJsonThink(requestUrl string) (interface{}, error) {\n\treturn HttpGetJson(Config.BaseUrl+requestUrl, Config.User, Config.Password)\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 (td TupleDesc) GetJSON(i int, tup Tuple) (v []byte, ok bool) {\n\ttd.expectEncoding(i, JSONEnc)\n\tb := td.GetField(i, tup)\n\tif b != nil {\n\t\tv = readByteString(b)\n\t\tok = true\n\t}\n\treturn\n}", "func GetJson(w http.ResponseWriter, Status string, Msg string, httpStatus int) string {\n\tmsgJsonStruct := &JsonMsg{Status, Msg}\n\tmsgJson, errj := json.Marshal(msgJsonStruct)\n\tif errj != nil {\n\t\tmsg := `{\"status\":\"error\",\"message\":\"We could not generate the json error!\"}`\n\t\treturn msg\n\t}\n\treturn string(msgJson)\n}", "func (j *JSONData) get(path ...interface{}) (*sj.Json, error) {\n\tjson, err := sj.NewJson(j.data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, p := range path {\n\t\tswitch p.(type) {\n\t\tcase string:\n\t\t\tdt, err := strconv.Atoi(p.(string))\n\t\t\tif err == nil {\n\t\t\t\tjson = json.GetIndex(dt)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tjson = json.Get(p.(string))\n\t\tcase int:\n\t\t\tjson = json.GetIndex(p.(int))\n\t\tcase []string:\n\t\t\tdata := p.([]string)\n\t\t\tfor _, p2 := range data {\n\t\t\t\tdt, err := strconv.Atoi(p2)\n\t\t\t\tif err == nil {\n\t\t\t\t\tjson = json.GetIndex(dt)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tjson = json.Get(p2)\n\t\t\t}\n\t\tcase []int:\n\t\t\tdata := p.([]int)\n\t\t\tfor _, p2 := range data {\n\t\t\t\tjson = json.GetIndex(p2)\n\t\t\t}\n\t\tcase []interface{}:\n\t\t\tdata := p.([]interface{})\n\t\t\tfor _, p2 := range data {\n\t\t\t\tswitch p2.(type) {\n\t\t\t\tcase string:\n\t\t\t\t\tdt, err := strconv.Atoi(p2.(string))\n\t\t\t\t\tif err == nil {\n\t\t\t\t\t\tjson = json.GetIndex(dt)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tjson = json.Get(p2.(string))\n\t\t\t\tcase int:\n\t\t\t\t\tjson = json.GetIndex(p2.(int))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn json, err\n}", "func (self *Response) GetJson() *simplejson.Json {\n\treturn self.jsonMap\n}", "func (r *Summary) GetJSON() (string, error) {\n\tjsonBytes, err := json.Marshal(*r)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn prettyPrintJSON(jsonBytes)\n}", "func VariationJSONGet(c *gin.Context) {\n\tasin := c.Param(\"asin\")\n\n\tvariation := models.Variation{}\n\tmodels.DB.Preload(\"ItemAttributes\").Where(\"asin = ?\", asin).First(&variation)\n\tif variation.ID == 0 {\n\t\tc.JSON(404, nil)\n\t}\n\tvar images, description, offer bytes.Buffer\n\tif err := tmpl.ExecuteTemplate(&images, \"products/product_images\", variation); err != nil {\n\t\tlog.Println(err)\n\t\tc.JSON(500, nil)\n\t\treturn\n\t}\n\tif err := tmpl.ExecuteTemplate(&description, \"products/short_description\", variation); err != nil {\n\t\tlog.Println(err)\n\t\tc.JSON(500, nil)\n\t\treturn\n\t}\n\tif err := tmpl.ExecuteTemplate(&offer, \"products/offer_details\", variation); err != nil {\n\t\tlog.Println(err)\n\t\tc.JSON(500, nil)\n\t\treturn\n\t}\n\tc.JSON(200, gin.H{\n\t\t\"Images\": images.String(),\n\t\t\"Description\": description.String(),\n\t\t\"Offer\": offer.String(),\n\t})\n}", "func (ctx *httpCtx) readJSONEx() (interface{}, bool, bool) {\n\tdata, ok := ctx.readBody()\n\tif !ok {\n\t\treturn nil, false, false\n\t}\n\tif len(data) == 0 {\n\t\treturn nil, true, true\n\t}\n\tv, ok := ctx.parseJSON(data)\n\tif !ok {\n\t\treturn nil, false, false\n\t}\n\treturn v, false, true\n}", "func (sr *statusResponse) getJson(s string) []byte {\n\tsr.Status = s\n\tjsr, _ := json.Marshal(sr)\n\treturn jsr\n}", "func (req *Request) GetJson() ([]byte, error) {\n\treturn json.MarshalIndent(req, \"\", \"\\t\")\n}", "func (c *FileConfig) GetJSON(v interface{}) error {\n\tr, err := c.Get()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn r.JSON(v)\n}", "func FetchJson(url string, v interface{}) error {\r\n\tresp, err := http.Get(url)\r\n\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\tdata, err := ioutil.ReadAll(resp.Body)\r\n\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\tif err = json.Unmarshal(data, v); err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\treturn nil\r\n}", "func getGraphData(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r)\n\tresult := get.GetGraphData(params[\"id\"])\n\tjson.NewEncoder(w).Encode(result)\n}", "func JSONMGet(conn redis.Conn, path string, keys ...string) (res interface{}, err error) {\n\tif len(keys) == 0 {\n\t\terr = fmt.Errorf(\"need atlesat one key as an argument\")\n\t\treturn nil, err\n\t}\n\n\targs := make([]interface{}, 0)\n\tfor _, key := range keys {\n\t\targs = append(args, key)\n\t}\n\targs = append(args, path)\n\tname, args, _ := CommandBuilder(\"JSON.MGET\", args...)\n\treturn conn.Do(name, args...)\n}", "func loadData() jsonObj {\n\t/*\n\t\tAPI: https://opentdb.com/api_config.php\n\t*/\n\turl := \"https://opentdb.com/api.php?amount=10&type=multiple\"\n\tclient := http.Client{\n\t\tTimeout: time.Second * 2,\n\t}\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tres, getErr := client.Do(req)\n\tif(getErr != nil) {\n\t\tlog.Fatal(getErr)\n\t}\n\tif(res.Body != nil) {\n\t\tdefer res.Body.Close()\n\t}\n\n\tbody, readErr := ioutil.ReadAll(res.Body)\n\tif(readErr != nil) {\n\t\tlog.Fatal(readErr)\n\t}\n\tbyteBody := []byte(body)\n\tvar questions jsonObj\n\terr = json.Unmarshal(byteBody, &questions)\n\n\tif err == nil {\n\t\tfmt.Printf(\"Data loaded successfully!\")\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", err)\n\t}\n\n\treturn questions\n}", "func GetAsJson(pIFC interface{}) string {\n\tvar labJSON []byte\n\tvar lsText string\n\t// var lErr error\n\n\tlabJSON, _ = json.Marshal(pIFC)\n\n\tlsText = bytes.NewBuffer(labJSON).String()\n\t// log.Println(lsText)\n\treturn lsText\n}", "func JSONGetOne(table database.Table, w http.ResponseWriter, r *http.Request, sb *sqrl.SelectBuilder) {\n\ttable.Clear()\n\n\texSb := *sb\n\n\tvars := mux.Vars(r)\n\tfmt.Println(\"query\")\n\n\tvar val string\n\n\tif value, ok := vars[\"id\"]; ok {\n\t\tval = value\n\t} else if value, ok := vars[\"login\"]; ok {\n\t\tval = value\n\t}\n\n\ttype Item struct {\n\t\tData interface{} `json:\"data\"`\n\t}\n\n\tfmt.Println(val)\n\t//fmt.Println(table.GetPrimaryKey())\n\n\tquery, params, _ := exSb.Where(sqrl.Eq{table.GetPrimaryKey(): val}).ToSql()\n\tfmt.Println(query)\n\n\tif params != nil {\n\t\terrs := db.DB.Select(table.GetItems(), query, params[0])\n\t\tfmt.Println(errs)\n\t} else {\n\t\terrs := db.DB.Select(table.GetItems(), query)\n\t\tfmt.Println(errs)\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(Item{Data: table.GetItem()})\n}", "func (fhp *FastHTTPProvider) JSON(ctx context.Context, request *fasthttp.Request, response interface{}, duration *time.Duration) (*fasthttp.Response, error) {\n\tresult, err := fhp.request(ctx, request, duration)\n\n\tif err == nil {\n\t\t_ = json.Unmarshal(result.Body(), &response)\n\t}\n\n\treturn result, err\n}", "func getdata(fpath string) map[string]interface{} {\n\t// read file data (json []byte) into b\n\tb, err := ioutil.ReadFile(fpath)\n\t// err check\n\tif err != nil {\n\t\t// if err; print timestamp and err, then panic\n\t\tlog.Panic(err)\n\t}\n\t// no err; create empty map as placeholder\n\tvar m map[string]interface{}\n\t// unmarshal (convert) b (json []byte) into map\n\terr = json.Unmarshal(b, &m)\n\t// err check\n\tif err != nil {\n\t\t// if err; print timestamp and err, then panic\n\t\tlog.Panic(err)\n\t}\n\t// no err; return map \n\treturn m\n}", "func Get(url string, key string) (Response, error) {\n\n\tres, err := http.Get(url + \"/jsonResult.php?test=\" + key)\n\n\tif err != nil {\n\t\treturn Response{}, err\n\t}\n\n\tdefer res.Body.Close()\n\treturn process(ioutil.ReadAll(res.Body))\n}", "func (info *Info) GetJSON() JSONInfo {\n\treturn JSONInfo{\n\t\tServerUpTime: info.serverUpTime,\n\t}\n}", "func httpGetJSON(clt *http.Client, URL string, request interface{}, response interface{}) error {\n\n\tparams := make(map[string]string)\n\tif err := struct2Map(request, params); err != nil {\n\t\treturn errors.Wrap(err, \"params error\")\n\t}\n\n\tu, err := encodeURL(URL, params)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"url encode error\")\n\t}\n\n\thttpResp, err := clt.Get(u)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer httpResp.Body.Close()\n\n\tif httpResp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"http.Status: %s\", httpResp.Status)\n\t}\n\treturn decodeJSONResponse(httpResp.Body, response)\n}", "func (h *handler) readJSON() (db.Body, error) {\n\tvar body db.Body\n\treturn body, h.readJSONInto(&body)\n}", "func JsonMGets(keys []string, path string) map[uint16]Completed {\n\tret := slotMCMDs(\"JSON.MGET\", keys, mtGetTag)\n\tfor _, jsonmget := range ret {\n\t\tjsonmget.cs.s = append(jsonmget.cs.s, path)\n\t\tjsonmget.cs.l++\n\t}\n\treturn ret\n}", "func getData() []Data {\n raw, err := ioutil.ReadFile(\"data/responses.json\")\t// read json file\n\n\tif err != nil {\t// error checking\n fmt.Println(err.Error())\n os.Exit(1)\n }\n\n var data []Data\t// create array variable of struct Data to store multiple values\n\n json.Unmarshal(raw, &data)\t//put data into the variable\n\n return data\t// return the data\n}", "func readJSON(path string) gjson.Result {\n\tjsonFile, err := os.Open(path)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tdefer jsonFile.Close()\n\n\tbyteValue, _ := ioutil.ReadAll(jsonFile)\n\n\treturn gjson.ParseBytes(byteValue)\n}", "func HTTPServiceGetJSON(urlPath, jsonPayload string) ([]byte, error) {\n\treturn CheckHTTPResponse(HTTPQuery(CreateServiceHTTPJSONRequest(\"GET\", urlPath, jsonPayload)))\n}", "func (c *RCache) GetJson(key string, val interface{}) error {\n\tv, err := redis.String(c.Get(key))\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn json.Unmarshal([]byte(v), val)\n}", "func (downloader *HTTPDownloader) downloadJSON(pageItem *page.Page, req *request.Request) *page.Page {\r\n\tvar err error\r\n\tpage, destbody := downloader.downloadFile(pageItem, req)\r\n\tif !page.IsSucc() {\r\n\t\treturn page\r\n\t}\r\n\r\n\tvar body []byte\r\n\tbody = []byte(destbody)\r\n\tmtype := req.GetResponceType()\r\n\tif mtype == \"jsonp\" {\r\n\t\ttmpstr := util.JsonpToJson(destbody)\r\n\t\tbody = []byte(tmpstr)\r\n\t}\r\n\r\n\tvar r *simplejson.Json\r\n\tif r, err = simplejson.NewJson(body); err != nil {\r\n\t\tmlog.LogInst().LogError(string(body) + \"\\t\" + err.Error())\r\n\t\tpage.SetStatus(true, err.Error())\r\n\t\treturn page\r\n\t}\r\n\r\n\t// json result\r\n\tpage.SetBodyStr(string(body)).SetJSON(r).SetStatus(false, \"\")\r\n\r\n\treturn page\r\n}", "func (g *Game) getGameJson() []byte {\n\tb, err := json.Marshal(g)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn b\n}", "func (u *EtcdUtil) MustGetJSON(key string, dst interface{}) uint64 {\n\ti, err := u.GetJSON(key, dst)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"MustGetJSON(%v): %v\\n\", key, err))\n\t}\n\treturn i\n}", "func (d *Data) GetTagJSON(ctx *datastore.VersionedCtx, tag Tag, addRels bool) (jsonBytes []byte, err error) {\n\td.RLock()\n\tdefer d.RUnlock()\n\n\tvar tk storage.TKey\n\tvar elems interface{}\n\ttk, err = NewTagTKey(tag)\n\tif err != nil {\n\t\treturn\n\t}\n\tif addRels {\n\t\telems, err = d.getExpandedElements(ctx, tk)\n\t} else {\n\t\telems, err = getElementsNR(ctx, tk)\n\t}\n\tif err == nil {\n\t\tjsonBytes, err = json.Marshal(elems)\n\t}\n\treturn\n}" ]
[ "0.70674294", "0.70100605", "0.6993362", "0.6975635", "0.695702", "0.69370836", "0.6917192", "0.69113797", "0.6858359", "0.6826451", "0.68240994", "0.6764532", "0.67441463", "0.6697951", "0.6689485", "0.6645399", "0.6592032", "0.65773845", "0.65652645", "0.6562084", "0.65135026", "0.64893335", "0.64746356", "0.6467812", "0.6451442", "0.6445096", "0.64318794", "0.6418252", "0.6408226", "0.63655436", "0.6360812", "0.6349918", "0.63207734", "0.6246844", "0.62275755", "0.62026364", "0.6193263", "0.61679626", "0.6161193", "0.6149999", "0.61471164", "0.6130997", "0.61298895", "0.61266655", "0.6124673", "0.6089935", "0.6088688", "0.607651", "0.60717326", "0.6068594", "0.6029504", "0.60241663", "0.6022715", "0.6021141", "0.60191315", "0.6015204", "0.6003393", "0.59935653", "0.5992041", "0.59894717", "0.59703684", "0.5964489", "0.5964489", "0.59521484", "0.59136444", "0.59130365", "0.5904958", "0.5882641", "0.58458024", "0.5826835", "0.58204293", "0.5818525", "0.5812847", "0.57919884", "0.57837236", "0.5778442", "0.5776028", "0.5767648", "0.5735147", "0.5730598", "0.57283235", "0.57136875", "0.5713104", "0.5680007", "0.5677026", "0.5659363", "0.565788", "0.564436", "0.5643663", "0.56292796", "0.56174797", "0.5581106", "0.5559299", "0.55565846", "0.5529659", "0.5514363", "0.54991484", "0.54969573", "0.5489343", "0.548893" ]
0.6406143
29
getTemplatingSource fetches template source files and adds them to a data set to be used when running the template function
func getTemplatingSource(spec *opsv1alpha1.GitOps) (map[string]interface{}, error) { if spec.Spec.Templating != nil { sourceDir := spec.Status.RootFolder + "/" + spec.Spec.RootFolder + "/" + spec.Spec.Templating.SourceFolder if spec.Spec.Templating.SourceFolder != "" { sourceDir += "/" } t := spec.Spec.Templating if t.Enabled { if t.Source != nil { data := make(map[string]interface{}) for _, f := range t.Source.TemplateDataFile { temp := make(map[string]interface{}) fData, err := ioutil.ReadFile(sourceDir + f) if err != nil { log.Error(err, "Failed to read file") return nil, err } yaml.Unmarshal(fData, temp) for k, v := range temp { data[k] = v } } return data, nil } } return nil, nil } return nil, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getTemplateSource() templateSource {\n\t// do lazy init to avoid zip decompression unless absolutely necessary\n\ttemplatesOnce.Do(func() {\n\t\ttemplates = &fsTemplateSource{\n\t\t\tfs: http.FS(templatesFs),\n\t\t\tnamingScheme: func(language extension.Language, category extension.Category, template string) string {\n\t\t\t\treturn \"/\" + path.Join(language.String(), category.String(), template)\n\t\t\t},\n\t\t}\n\t})\n\treturn templates\n}", "func getTemplate(tmpls []string) *template.Template {\n\treturn template.Must(template.ParseFiles(tmpls...))\n}", "func getTemplate(filenames ...string) *template.Template {\n\treturn template.Must(template.Must(getBaseTemplate().Clone()).ParseFiles(filenames...))\n}", "func addSourceFile(t *Template, typ sourceType, file string) {}", "func loadTemplate(source string, sourceData interface{}) []byte {\n\tvar byteBuff = new(bytes.Buffer)\n\tdefer byteBuff.Reset()\n\n\ttmpl, err := tpl.Funcs(formatTemplate()).Parse(source)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := tmpl.Execute(byteBuff, sourceData); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn byteBuff.Bytes()\n}", "func genSource(dir, filename, templateSource string, args map[string]interface{}) {\n\tsourceCode := revel.ExecuteTemplate(\n\t\ttemplate.Must(template.New(\"\").Parse(templateSource)),\n\t\targs)\n\n\t// Create a fresh dir.\n\ttmpPath := path.Join(revel.AppPath, dir)\n\terr := os.RemoveAll(tmpPath)\n\tif err != nil {\n\t\trevel.ERROR.Println(\"Failed to remove dir:\", err)\n\t}\n\terr = os.Mkdir(tmpPath, 0777)\n\tif err != nil {\n\t\trevel.ERROR.Fatalf(\"Failed to make tmp directory: %v\", err)\n\t}\n\n\t// Create the file\n\tfile, err := os.Create(path.Join(tmpPath, filename))\n\tdefer file.Close()\n\tif err != nil {\n\t\trevel.ERROR.Fatalf(\"Failed to create file: %v\", err)\n\t}\n\t_, err = file.WriteString(sourceCode)\n\tif err != nil {\n\t\trevel.ERROR.Fatalf(\"Failed to write to file: %v\", err)\n\t}\n}", "func (a *templateLoader) Get(tmpl string) (io.Reader, error) {\n\tvar b []byte\n\tvar e error\n\ttmpl += a.ext\n\tif a.mgr != nil && a.mgr.Caches != nil {\n\t\tk := strings.TrimPrefix(tmpl, a.templateDir)\n\t\tb, e = a.mgr.GetTemplate(k)\n\t}\n\tif b == nil || e != nil {\n\t\tif e != nil {\n\t\t\ta.logger.Error(e)\n\t\t}\n\t\tb, e = ioutil.ReadFile(tmpl)\n\t}\n\tbuf := new(bytes.Buffer)\n\tbuf.WriteString(string(b))\n\treturn buf, e\n}", "func (g *Generator) prepare(gen *FileMapGenerate) (*template.Template, error) {\n\t// Preload the function map (or else the functions will fail when\n\t// called due to a lack of valid context).\n\tvar (\n\t\tt = template.New(\"\").Funcs(Preload)\n\t\terr error\n\t)\n\n\t// Parse the included template files.\n\tfor _, inc := range gen.Include {\n\t\t_, err := g.loadTemplate(t, inc)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Parse the template file to execute.\n\ttmpl, err := g.loadTemplate(t, gen.Template)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t_, name := path.Split(gen.Template)\n\ttmpl = tmpl.Lookup(name)\n\treturn tmpl, nil\n}", "func (self templateEngine) getTemplate(name string) (t string) {\n if ! self.templateCached(name) {\n self.templates[name] = self.loadTemplate(name) \n }\n t, _ = self.templates[name]\n return\n}", "func GetTemplate(r *registry.Registry) *template.Template {\n\tt := template.New(\"file\")\n\tt = t.Funcs(sprig.TxtFuncMap())\n\n\tt = t.Funcs(template.FuncMap{\n\t\t\"include\": include(t),\n\t\t\"tsType\": func(fieldType data.Type) string {\n\t\t\treturn tsType(r, fieldType)\n\t\t},\n\t\t\"renderURL\": renderURL(r),\n\t\t\"buildInitReq\": buildInitReq,\n\t\t\"fieldName\": fieldName(r),\n\t})\n\n\tt = template.Must(t.Parse(tmpl))\n\treturn t\n}", "func gatherTemplates(cfg *config.Config, outFileNamer func(string) (string, error)) (templates []*tplate, err error) {\n\tmode, modeOverride, err := cfg.GetMode()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch {\n\t// the arg-provided input string gets a special name\n\tcase cfg.Input != \"\":\n\t\ttemplates = []*tplate{{\n\t\t\tname: \"<arg>\",\n\t\t\tcontents: cfg.Input,\n\t\t\tmode: mode,\n\t\t\tmodeOverride: modeOverride,\n\t\t\ttargetPath: cfg.OutputFiles[0],\n\t\t}}\n\tcase cfg.InputDir != \"\":\n\t\t// input dirs presume output dirs are set too\n\t\ttemplates, err = walkDir(cfg.InputDir, outFileNamer, cfg.ExcludeGlob, mode, modeOverride)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase cfg.Input == \"\":\n\t\ttemplates = make([]*tplate, len(cfg.InputFiles))\n\t\tfor i := range cfg.InputFiles {\n\t\t\ttemplates[i], err = fileToTemplates(cfg.InputFiles[i], cfg.OutputFiles[i], mode, modeOverride)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn processTemplates(cfg, templates)\n}", "func genSource(dir, filename, templateSource string, args map[string]interface{}) {\n\tsourceCode := revel.ExecuteTemplate(\n\t\ttemplate.Must(template.New(\"\").Parse(templateSource)),\n\t\targs)\n\n\t// Create a fresh dir.\n\t// tmpPath := path.Join(revel.AppPath, dir)\n\n\t// Create the file\n\tfile, err := os.Create(path.Join(dir, filename))\n\tdefer file.Close()\n\tif err != nil {\n\t\trevel.ERROR.Fatalf(\"Failed to create file: %v\", err)\n\t}\n\t_, err = file.WriteString(sourceCode)\n\tif err != nil {\n\t\trevel.ERROR.Fatalf(\"Failed to write to file: %v\", err)\n\t}\n}", "func GetTemplate(templateName string, templateLocation string, funcs map[string]interface{}, dev bool) *text.Template {\n\tif dev {\n\t\tt, err := text.New(templateName).Funcs(funcs).ParseFiles(templateLocation)\n\t\tcheckErr(err, funcName(), \"Load template console\", templateLocation)\n\t\treturn t\n\t}\n\n\tassetBloomsky, err := assembly.Asset(templateLocation)\n\tcheckErr(err, funcName(), \"Load template console\", templateLocation)\n\tt, err := text.New(templateName).Funcs(funcs).Parse(string(assetBloomsky[:]))\n\tcheckErr(err, funcName(), \"Load template parse\")\n\treturn t\n}", "func (self templateEngine) loadTemplate(name string) (t string) {\n b, err := ioutil.ReadFile(self.templateFilepath(name))\n if err == nil {\n t = string(b)\n } else {\n log.Println(\"error loading template\", err)\n t = err.Error()\n }\n return\n}", "func (i *ImageTemplateSource) GetImageTemplateSource() *ImageTemplateSource { return i }", "func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl interface{}, err error) {\n\tvar (\n\t\tmapKey = fmt.Sprintf(\"%s_%v\", filePath, view.config.Delimiters)\n\t\tmapFunc = func() interface{} {\n\t\t\ttplName := filePath\n\t\t\tif view.config.AutoEncode {\n\t\t\t\ttpl = htmltpl.New(tplName).Delims(\n\t\t\t\t\tview.config.Delimiters[0],\n\t\t\t\t\tview.config.Delimiters[1],\n\t\t\t\t).Funcs(view.funcMap)\n\t\t\t} else {\n\t\t\t\ttpl = texttpl.New(tplName).Delims(\n\t\t\t\t\tview.config.Delimiters[0],\n\t\t\t\t\tview.config.Delimiters[1],\n\t\t\t\t).Funcs(view.funcMap)\n\t\t\t}\n\t\t\t// Firstly checking the resource manager.\n\t\t\tif !gres.IsEmpty() {\n\t\t\t\tif files := gres.ScanDirFile(folderPath, pattern, true); len(files) > 0 {\n\t\t\t\t\tif view.config.AutoEncode {\n\t\t\t\t\t\tvar t = tpl.(*htmltpl.Template)\n\t\t\t\t\t\tfor _, v := range files {\n\t\t\t\t\t\t\t_, err = t.New(v.FileInfo().Name()).Parse(string(v.Content()))\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(v.Name(), tplName, err)\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar t = tpl.(*texttpl.Template)\n\t\t\t\t\t\tfor _, v := range files {\n\t\t\t\t\t\t\t_, err = t.New(v.FileInfo().Name()).Parse(string(v.Content()))\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(v.Name(), tplName, err)\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn tpl\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Secondly checking the file system,\n\t\t\t// and then automatically parsing all its sub-files recursively.\n\t\t\tvar files []string\n\t\t\tfiles, err = gfile.ScanDir(folderPath, pattern, true)\n\t\t\tif err != nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif view.config.AutoEncode {\n\t\t\t\tt := tpl.(*htmltpl.Template)\n\t\t\t\tfor _, file := range files {\n\t\t\t\t\tif _, err = t.Parse(gfile.GetContents(file)); err != nil {\n\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(file, tplName, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tt := tpl.(*texttpl.Template)\n\t\t\t\tfor _, file := range files {\n\t\t\t\t\tif _, err = t.Parse(gfile.GetContents(file)); err != nil {\n\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(file, tplName, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tpl\n\t\t}\n\t)\n\tresult := templates.GetOrSetFuncLock(mapKey, mapFunc)\n\tif result != nil {\n\t\treturn result, nil\n\t}\n\treturn\n}", "func GetTemplate(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tw.Header().Set(\"Content-Type\", \"application/javascript; charset=utf-8\")\n\tfile, _ := ResourceFile(\"templates.tpl.js\")\n\tfmt.Fprint(w, string(file))\n}", "func addSourceFile(t *Template, typ sourceType, file string) {\n\tt.parseFilesSources = append(t.parseFilesSources, parseFileSources{\n\t\tType: typ,\n\t\tFile: file,\n\t})\n}", "func prepareTemplate(templateName string) (*template.Template, error) {\n\t// stat for .gotmpl file size\n\tfi, err := pkger.Stat(templateName)\n\tif err != nil {\n\t\tlog.Printf(\"Stat: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\n\ttf, err := pkger.Open(templateName)\n\tif err != nil {\n\t\tlog.Printf(\"Open: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\tdefer tf.Close()\n\n\t// read the template source from pkger\n\tbuf := make([]byte, fi.Size())\n\t_, err = tf.Read(buf)\n\tif err != nil {\n\t\tlog.Printf(\"Unable to read template %s\\n\", templateName)\n\t\treturn nil, err\n\t}\n\n\t// create the template\n\tt := template.Must(template.New(\"Entity model template\").Parse(string(buf)))\n\tif t == nil {\n\t\tlog.Printf(\"Parse: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\treturn t, nil\n}", "func GetSource(c *gin.Context) {\n\tresp, err := http.Get(SOURCE_URL)\n\tif err != nil {\n\t\tc.AbortWithError(500, err)\n\t\treturn\n\t}\n\n\tdefer resp.Body.Close()\n\n\tvar data []Source\n\terr = json.NewDecoder(resp.Body).Decode(&data)\n\tif err != nil {\n\t\tc.AbortWithError(500, err)\n\t\treturn\n\t}\n\n\tvar result = make(map[string][]string)\n\n\tfor index := 0; index < len(data); index++ {\n\t\tresult[\"latest\"] = append(result[\"latest\"], data[index].Endpoints.Latest)\n\t\tresult[\"popular\"] = append(result[\"popular\"], data[index].Endpoints.Popular)\n\t}\n\n\tc.JSON(200, result)\n}", "func getTemplateList(tname string) []string {\n\tbase := TemplateBase + \"html/templates/base.html\"\n\tthisOne := TemplateBase + \"html/templates/\" + tname + \".html\"\n\ttmpl_list := []string{base, thisOne}\n\treturn tmpl_list\n}", "func (g project) GetTemplates(serviceName string) {\n\tcontents := `#!/usr/bin/env bash\n\tservicename=$1;\n\tcd $servicename;\n\tgit init;\n\tgit remote add origin [email protected]:yowez/skeleton-service.git;\n\tgit remote -v;\n\tgit fetch;\t\n\tgit pull origin master;\n\trm -rf .git;\n\tcd ..;\n`\n\tbt := []byte(contents)\n\terr := ioutil.WriteFile(template, bt, 0644)\n\tif err != nil {\n\t\tg.rollbackWhenError(\"fail when create scaffold script\")\n\t}\n\tdefer func() {\n\t\t_ = os.Remove(template)\n\t}()\n\tcmd := exec.Command(bash, template, serviceName)\n\terr = g.runCmd(cmd)\n\tif err != nil {\n\t\tlog.Fatal(\"fail run scaffold script\")\n\t}\n\n}", "func (st *Stemplate) loadTemplate(tname string) *template.Template {\n\n\ttemplates, terr := filepath.Glob(st.templatesDir + \"*.tmpl\")\n\tif terr != nil {\n\t\tfmt.Println(\"[JIT template]: ERROR ~ \" + terr.Error())\n\t\treturn nil\n\t}\n\n\ttemplates = append(templates, st.templatesDir+tname)\n\n\treturn template.Must(template.ParseFiles(templates...))\n}", "func (h *createWantsHandler) getSource(ctx context.Context, edp muxrpc.Endpoint) (luigi.Source, error) {\n\tref := edp.Remote().String()\n\n\th.l.Lock()\n\tdefer h.l.Unlock()\n\n\tsrc, ok := h.sources[ref]\n\tif ok {\n\t\tif src != nil {\n\t\t\treturn src, nil\n\t\t}\n\t\th.log.Log(\"msg\", \"got a nil source from the map, ignoring and making new\")\n\t}\n\n\tsrc, err := edp.Source(ctx, &blobstore.WantMsg{}, muxrpc.Method{\"blobs\", \"createWants\"})\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error making source call\")\n\t}\n\tif src == nil {\n\t\treturn nil, errors.New(\"failed to get createWants source from remote\")\n\t}\n\th.sources[ref] = src\n\treturn src, nil\n}", "func getTemplate(w http.ResponseWriter, tmpl string) *template.Template {\n\ttemplates := template.New(\"template\")\n\t_, err := templates.ParseFiles(\"templates/base.html\", \"templates/nav.html\", \"templates/\"+tmpl+\".html\", \"templates/flashes.html\")\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\treturn template.Must(templates, err)\n}", "func (t *Template) Source() string {\n\tif t.source == \"\" {\n\t\treturn \"(dynamic)\"\n\t}\n\treturn t.source\n}", "func (g *Generator) loadTemplate(t *template.Template, tmplPath string) (*template.Template, error) {\n\t// Make the filepath relative to the filemap.\n\ttmplPath = g.FileMap.relative(tmplPath)[0]\n\n\t// Determine the open function.\n\treadFile := g.ReadFile\n\tif readFile == nil {\n\t\treadFile = ioutil.ReadFile\n\t}\n\n\t// Read the file.\n\tdata, err := readFile(tmplPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create a new template and parse.\n\t_, name := path.Split(tmplPath)\n\treturn t.New(name).Parse(string(data))\n}", "func getTemplate(templateType string) string {\n\tconf := config.GetConfig()\n\n\trequestedTemplate := conf[\"user_\"+templateType+\"_template\"]\n\n\tif requestedTemplate == \"\" {\n\t\ttemp, _ := Asset(\"templates/\" + templateType + \".html\")\n\n\t\tif len(temp) > 0 {\n\t\t\trequestedTemplate = string(temp[:])\n\t\t}\n\t}\n\n\treturn requestedTemplate\n}", "func getTemplate(filepath string) *template.Template {\n if templates[filepath] == nil {\n file, err := os.Open(template_dir+filepath, os.O_RDONLY, 0666)\n if err != nil { log.Exit(\"not exist: %s\", filepath) }\n reader := bufio.NewReader(file)\n body, _ := reader.ReadString('~')\n tmpl := template.MustParse(body, nil)\n templates[filepath] = tmpl\n }\n return templates[filepath]\n}", "func (s *Static) GenerateStaticTemplates() (fNames []string, err error) {\n\n\t// begin of new part\n\ttmlFiles, err := glob(s.SrcDir, \"*\"+\".gotmpl\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// end of new part\n\n\tfor _, f := range tmlFiles {\n\n\t\t// start of new part\n\t\tfi, err := pkger.Stat(f)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Stat: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttf, err := pkger.Open(f)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Open: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer tf.Close()\n\n\t\t// read the template source from pkger\n\t\tbuf := make([]byte, fi.Size())\n\t\t_, err = tf.Read(buf)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Unable to read template: %s %v\\n\", f, err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tst := template.Must(template.New(\"Static template\").Parse(string(buf)))\n\t\tif st == nil {\n\t\t\tlog.Printf(\"Parse error: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\t// end of new part\n\n\t\t// create the file-path if required\n\t\t_, err = os.Stat(s.DstDir)\n\t\tif err != nil {\n\t\t\tos.Mkdir(s.DstDir, 0755)\n\t\t}\n\n\t\t// create the static source file\n\t\tfileName := filepath.Base(f)\n\t\tfileName = strings.TrimSuffix(fileName, \"tmpl\")\n\t\tf, err := os.Create(s.DstDir + \"/\" + fileName)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"generateStaticTemplates: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer f.Close()\n\n\t\t// set permissions\n\t\terr = f.Chmod(0755)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"generateStaticTemplates: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// execute the template using the new controller file as a target\n\t\terr = st.Execute(f, s)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"generateStaticTemplates: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tfName := s.DstDir + \"/\" + fileName\n\t\tfNames = append(fNames, fName)\n\t\tlog.Println(\"generated:\", fName)\n\t\tf.Close()\n\t}\n\treturn fNames, nil\n}", "func RenderTemplate(tmpfile string, pairs map[string]interface{}) (string, error) {\n\n\tfile, err := os.Open(tmpfile)\n\tif err != nil {\n\t\tLogWarning.Println(err)\n\t}\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\t//var srcContent string\n\tvar srcContent bytes.Buffer\n\tfor scanner.Scan() {\n\t\tt := fmt.Sprintln(scanner.Text())\n\t\tif strings.Index(t, \"<%file:\") > -1 {\n\t\t\tLogDebug.Println(\"Including file external file\")\n\t\t\tif strings.Index(t, \"%>\") > -1 {\n\t\t\t\tre := regexp.MustCompile(\"\\\\<\\\\%file:(.*?)\\\\%\\\\>\")\n\t\t\t\tmatch := re.FindStringSubmatch(t)\n\t\t\t\tif len(match) == 0 {\n\t\t\t\t\tLogError.Println(\"invalid file: syntax \", t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tincludeFileName := fmt.Sprintf(\"%s/%s\", path.Dir(tmpfile), match[1])\n\t\t\t\tincludeContent, err := ioutil.ReadFile(includeFileName)\n\t\t\t\tif err != nil {\n\t\t\t\t\tLogWarning.Println(err)\n\t\t\t\t}\n\t\t\t\tLogInfo.Println(\"including file :\", includeFileName)\n\t\t\t\tLogDebug.Println(\"includeContent\", string(includeContent))\n\t\t\t\tsrcContent.WriteString(string(includeContent))\n\t\t\t} else {\n\t\t\t\tLogWarning.Println(\"Found incomplete tag in include from file \", tmpfile)\n\t\t\t}\n\t\t} else if strings.Index(t, \"<%LookupFile:\") > -1 {\n\t\t\tLogDebug.Println(\"Rendering LookupFile\")\n\t\t\tvar lookup LookupList\n\t\t\tre := regexp.MustCompile(\"\\\\<\\\\%LookupFile:(.*?),(.*?),(.*?),(.*?)\\\\%\\\\>\")\n\n\t\t\t/*\n\t\t\t\t//\n\t\t\t\t// Fist we need to find if there is a template within the lookup definition\n\t\t\t\tt := fasttemplate.New(t, \"{{\", \"}}\")\n\t\t\t\ts := t.ExecuteString(pairs)\n\t\t\t*/\n\t\t\t//var tmpl = template.Must(template.ParseFiles(t))\n\t\t\t// Create a new template and parse the letter into it.\n\t\t\t// Get the Sprig function map.\n\t\t\tfmap := sprig.TxtFuncMap()\n\t\t\tvar tmpl = template.Must(template.New(\"LookupFile\").Funcs(fmap).Parse(t))\n\n\t\t\tvar bytes bytes.Buffer\n\t\t\twriter := bufio.NewWriter(&bytes)\n\n\t\t\terr = tmpl.Execute(writer, pairs)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = writer.Flush()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tLogDebug.Println(bytes.String())\n\n\t\t\tmatch := re.FindStringSubmatch(bytes.String())\n\n\t\t\tif len(match) == 0 {\n\t\t\t\tLogError.Println(\"invalid LookupFile: syntax \", t)\n\t\t\t\t//BUG/FIX: Should push up a error to rest calling function\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tLogDebug.Println(\"LookupFile: \", match[LookupFile])\n\t\t\tLogDebug.Println(\"LookupKey: \", match[LookupKey])\n\t\t\tLogDebug.Println(\"LookupSubkey: \", match[LookupSubkey])\n\t\t\tLogDebug.Println(\"LookupDefaultValue: \", match[LookupDefaultValue])\n\n\t\t\tyamlFile, err := ioutil.ReadFile(fmt.Sprintf(match[LookupFile]))\n\t\t\tif err != nil {\n\t\t\t\tLogError.Println(\"reading LookupFile \", match[LookupFile])\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = yaml.Unmarshal(yamlFile, &lookup)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tvar lookupvalue string\n\t\t\tvar ok bool\n\t\t\tLogDebug.Println(lookup.Lookup)\n\t\t\tif lookupvalue, ok = lookup.Lookup[match[LookupKey]][match[LookupSubkey]]; ok {\n\t\t\t\tLogDebug.Println(\"Found lookup value in file :\", lookupvalue)\n\t\t\t} else {\n\t\t\t\tlookupvalue = match[LookupDefaultValue]\n\t\t\t\tLogDebug.Println(\"Using default lookup Value :\", lookupvalue)\n\t\t\t}\n\n\t\t\tsrcContent.WriteString(re.ReplaceAllString(bytes.String(), lookupvalue))\n\n\t\t} else {\n\t\t\tsrcContent.WriteString(t)\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tLogWarning.Println(err)\n\t}\n\n\t//var tmpl = template.Must(template.ParseFiles(tmpl_file))\n\t// Get the Sprig function map.\n\tfmap := sprig.TxtFuncMap()\n\tvar tmpl = template.Must(template.New(\"rendered_template\").Funcs(fmap).Parse(srcContent.String()))\n\n\tvar bytes bytes.Buffer\n\twriter := bufio.NewWriter(&bytes)\n\n\terr = tmpl.Execute(writer, pairs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\terr = writer.Flush()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tLogDebug.Println(bytes.String())\n\n\treturn bytes.String(), nil\n\n}", "func (t *Table) Source() (string, error) {\n\tb, err := render(t.SourceTemplate, t.parent.SourceTemplate, sourceTemplate, t)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tb2, err := imports.Process(\"\", b, nil)\n\tif err != nil {\n\t\tlog.Println(\"WARN:\", err)\n\t\treturn string(b), nil\n\t}\n\n\treturn string(b2), nil\n}", "func generateFileFromTemplate(t template.Template, data interface{}) (string, error) {\n\t// generate temporary file\n\ttmpfile, err := ioutil.TempFile(\"\", \"lift-*\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer tmpfile.Close()\n\n\t// execute the template, saving the result in the tempfile\n\tif err := t.Execute(tmpfile, data); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tlog.WithFields(log.Fields{\n\t\t\"template\": t.Name(),\n\t\t\"file\": tmpfile.Name(),\n\t}).Debug(\"parsed template to file\")\n\n\t// return handle to the temp file\n\treturn tmpfile.Name(), nil\n}", "func GetStringFromTemplate(tpl string, config interface{}) (string, error) {\n\tvar tplbuffer bytes.Buffer\n\tvar packageTemplate = template.Must(template.New(\"\").Parse(tpl))\n\terr := packageTemplate.Execute(&tplbuffer, config)\n\tif err != nil {\n\t\tlog.Warnf(\"Unable to translate template %q to string using the data %v\", tpl, config)\n\t\treturn \"\", err\n\t}\n\treturn tplbuffer.String(), nil\n}", "func (s *server) loadTemplates() error {\n includePath := \"templates/\"\n layoutPath := \"templates/layout/\"\n\n if s.templates == nil {\n s.templates = make(map[string]*template.Template)\n }\n\n layoutFiles, err := filepath.Glob(layoutPath + \"*.tmpl\")\n if err != nil {\n log.Println(\"failed to get included templates\")\n return err\n }\n\n includeFiles, err := filepath.Glob(includePath + \"*.tmpl\")\n if err != nil {\n log.Println(\"failed to get layout templates\")\n return err\n }\n\n mainTemplate := template.New(\"main\")\n mainTemplate, err = mainTemplate.Parse(mainTmpl)\n if err != nil {\n log.Println(\"failed to parse main template\")\n return err\n }\n\n for _, file := range includeFiles {\n fileName := filepath.Base(file)\n files := append(layoutFiles, file)\n s.templates[fileName], err = mainTemplate.Clone()\n if err != nil {\n return err\n }\n s.templates[fileName] = template.Must(\n s.templates[fileName].ParseFiles(files...))\n }\n\n s.bufpool = bpool.NewBufferPool(64)\n return nil\n}", "func processTemplates(cfg *config.Config, templates []*tplate) ([]*tplate, error) {\n\tfor _, t := range templates {\n\t\tif t.contents == \"\" {\n\t\t\tvar in io.Reader\n\t\t\tif t.name == \"-\" {\n\t\t\t\tin = cfg.Stdin\n\t\t\t}\n\n\t\t\tb, err := t.loadContents(in)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tt.contents = string(b)\n\t\t}\n\n\t\tif t.target == nil {\n\t\t\tout, err := openOutFile(cfg, t.targetPath, 0755, t.mode, t.modeOverride)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tt.target = out\n\t\t}\n\t}\n\n\treturn templates, nil\n}", "func templatesPartialsGtmDataLayerTmpl() (*asset, error) {\n\tpath := \"/Users/ravipradhan/Documents/personal-projects/test-modules/render/assets/templates/partials/gtm-data-layer.tmpl\"\n\tname := \"templates/partials/gtm-data-layer.tmpl\"\n\tbytes, err := bindataRead(path, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Error reading asset info %s at %s: %w\", name, path, err)\n\t}\n\n\ta := &asset{bytes: bytes, info: fi}\n\treturn a, err\n}", "func PopulateTemplate(config *OperatorConfig, path string) ([]byte, error) {\n\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tglog.Fatalf(\"Error reading %#v\", err)\n\t}\n\n\tpopulatedData, err := Manifests(config, data)\n\tif err != nil {\n\t\tglog.Fatalf(\"Unable to render manifests %q: %v\", data, err)\n\t}\n\treturn populatedData, nil\n}", "func parseTemplates() (){\n templates = make(map[string]*template.Template)\n if files, err := ioutil.ReadDir(CONFIG.TemplatesDir) ; err != nil {\n msg := \"Error reading templates directory: \" + err.Error()\n log.Fatal(msg)\n } else {\n for _, f := range files {\n fmt.Println(f.Name())\n err = nil\n\n tpl, tplErr := template.New(f.Name()).Funcs(template.FuncMap{\n \"humanDate\": humanDate,\n \"humanSize\": humanSize,}).ParseFiles(CONFIG.TemplatesDir + \"/\" + f.Name())\n if tplErr != nil {\n log.Fatal(\"Error parsing template: \" + tplErr.Error())\n } else {\n templates[f.Name()] = tpl\n }\n }\n }\n return\n}", "func InitTemplating(path ...string) error {\n\ttpls, err = template.ParseGlob(path[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(path) > 1 {\n\t\tfor _, p := range path {\n\t\t\ttpls, err = tpls.ParseGlob(p)\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 TemplateFile(src string, outBuf *bytes.Buffer, vars map[string]interface{}) error {\n\n\t// verify that the input template exists\n\tif _, err := os.Stat(src); err != nil {\n\t\treturn errors.Wrapf(err, \"Source template '%s' doesn't exist\", src)\n\t}\n\n\tsrcTemplate, err := ioutil.ReadFile(src)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"Error reading source template file %s\", src)\n\t}\n\n\treturn TemplateString(string(srcTemplate[:]), outBuf, vars)\n}", "func getSrc(params *input.Params) string {\n\treturn fmt.Sprintf(SRC_PATH, params.ProjectName)\n}", "func fetchTemplates(names ...string) error {\n\tfor _, name := range names {\n\t\tt, err := template.ParseFiles(fmt.Sprintf(\"%s/frontend/templates/%s.html\", *srcPath, name))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpageTemplates[name] = t\n\t}\n\treturn nil\n}", "func GetTemplates(path string) *template.Template {\n\n\t// Crawl via relative path, since our current work dir is in cmd/ticketsystem\n\tt, errTemplates := template.ParseGlob(path + \"/templates/*.html\")\n\n\tif errTemplates != nil {\n\t\tlog.Fatal(\"Unable to load the templates: \", errTemplates)\n\t}\n\n\treturn t\n}", "func getTemplates() *template.Template {\n\treturn template.Must(template.ParseGlob(\"form/*\"))\n}", "func applyTemplateFromPath(templFP string, data *gengokit.Data) (io.Reader, error) {\n\ttemplBytes, err := templFiles.Asset(templFP)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to find template file: %v\", templFP)\n\t}\n\n\treturn data.ApplyTemplate(string(templBytes), templFP)\n}", "func (loader riceTemplateLoader) Get(path string) (io.Reader, error) {\n\treturn loader.templateBox.Open(path)\n}", "func loadTemplate() (*template.Template, error) {\n\tt := template.New(\"\")\n\tfor name, file := range Assets.Files {\n\t\tif file.IsDir() || !strings.HasSuffix(name, \".gohtml\") {\n\t\t\tcontinue\n\t\t}\n\t\th, err := ioutil.ReadAll(file)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tt, err = t.New(name).Parse(string(h))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn t, nil\n}", "func (s *Store) GetTemplate(ctx context.Context, name string, langTag language.Tag) (String, error) {\n\tre := regexp.MustCompile(`^\\w+\\.\\w+$`)\n\tif !re.Match([]byte(name)) {\n\t\treturn String{}, errors.New(\"illegal name\", \"\")\n\t}\n\n\ttemplate, err := s.FindTemplateByTypeAndLocale(ctx, name, langTag)\n\tif err == nil {\n\t\treturn String{\n\t\t\tTemplate: template.Template,\n\t\t\tUpdatedAt: template.UpdatedAt,\n\t\t}, nil\n\t}\n\tif !errors.IsKind(err, errors.ErrorNotFound) {\n\t\treturn String{}, err\n\t}\n\tbasePath := viper.GetString(\"base_path\")\n\tfilePath := fmt.Sprintf(\"%s/templates/%v/%v\", basePath, langTag, name)\n\tvar bytes []byte\n\tbytes, err = ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn String{}, errors.Wrap(err, errors.ErrorUnknown, \"\")\n\t}\n\treturn ToTemplateString(string(bytes)), nil\n}", "func PopulateTemplates() *template.Template {\n\ttemplates, err := template.ParseGlob(\"*.html\")\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tos.Exit(1) // no point in our webapp if templates aren't read\n\t}\n\n\treturn templates\n}", "func Template(templatePath string) Result {\n\tconfig := config.GetLoadedConfig()\n\tfullPath := filepath.Join(config.GetTemplatePath(), templatePath)\n\n\tif f, err := os.Open(fullPath); err != nil {\n\t\tlog.Printf(\"could not open template file %s\\n\", fullPath)\n\t} else {\n\t\tif bytes, err := io.ReadAll(f); err != nil {\n\t\t\tlog.Printf(\"could not read template file %s\\n\", fullPath)\n\t\t} else {\n\t\t\treturn StringResult(bytes)\n\t\t}\n\t}\n\n\treturn StringResult(\"\")\n}", "func templatesPartialsJsonLdDatasetTimeseriesTmpl() (*asset, error) {\n\tpath := \"/Users/ravipradhan/Documents/personal-projects/test-modules/render/assets/templates/partials/json-ld/dataset/timeseries.tmpl\"\n\tname := \"templates/partials/json-ld/dataset/timeseries.tmpl\"\n\tbytes, err := bindataRead(path, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Error reading asset info %s at %s: %w\", name, path, err)\n\t}\n\n\ta := &asset{bytes: bytes, info: fi}\n\treturn a, err\n}", "func t(base, name string) *template.Template {\n\t// First, read from the global cache if available:\n\tcachedMutex.RLock()\n\tif t, ok := cachedTemplates[name]; ok {\n\t\tdefer cachedMutex.RUnlock()\n\t\treturn t\n\t}\n\n\t// There is no cached version available. Remove the read lock and get a full RW lock,\n\t// compile the template, and return it\n\tcachedMutex.RUnlock()\n\tcachedMutex.Lock()\n\tdefer cachedMutex.Unlock()\n\n\t// Create a template with the given basename and custom functions.\n\t// Panic if there is any error\n\tn := template.New(base).Funcs(funcs)\n\tt := template.Must(gotogether.LoadTemplates(n, filepath.Join(\"templates\", base), filepath.Join(\"templates\", name)))\n\n\t// Add the newly compiled template to our global cache\n\tcachedTemplates[name] = t\n\n\treturn t\n}", "func TemplateFromFiles(paths ...string) (*template.Template, error) {\n\tvar ps []string\n\tfor _, p := range paths {\n\t\tps = append(ps, srcutil.Path(p))\n\t}\n\n\tt, err := template.ParseFiles(ps...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"template.ParseFiles() failed: %v\", err)\n\t}\n\n\treturn t, nil\n}", "func GetTemplateData(config *vsphere.Platform) *TemplateData {\n\tvar templateData TemplateData\n\n\ttemplateData.UserProvidedVIPs = len(config.APIVIPs) > 0\n\n\treturn &templateData\n}", "func LoadTemplates(dir string, basefile string) (*Templates, error) {\n\tt := &Templates{BaseDir: dir, BaseFile: basefile}\n\treturn t, t.Scan()\n}", "func GetSource(rawSource map[string]interface{}) (Source, error) {\n\tsourceType, found := configMappings[rawSource[\"type\"].(string)]\n\tif !found {\n\t\treturn nil, fmt.Errorf(\"Failed to find source type: %s\", rawSource[\"type\"])\n\t}\n\tdelete(rawSource, \"type\")\n\n\tvar metadata mapstructure.Metadata\n\tloader := reflect.New(sourceType).Interface().(Source)\n\n\tdecoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{\n\t\tMetadata: &metadata,\n\t\tResult: loader,\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := decoder.Decode(rawSource); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(metadata.Unused) > 0 {\n\t\treturn nil, fmt.Errorf(\"unknown configuration keys: %v\", metadata.Unused)\n\t}\n\n\treturn loader, nil\n}", "func prepareTemplates(templatedir string, fn ...string) (t *template.Template) {\n\tvar files []string\n\tfor _, file := range fn {\n\t\tfiles = append(files, fmt.Sprintf(\"%s/%s.html\", templatedir, file))\n\t}\n\tt = template.Must(template.ParseFiles(files...))\n\treturn\n}", "func (t Template) ProcessTemplate(template, sourceFolder, targetFolder string) (resultFile string, err error) {\n\tisCode := t.IsCode(template)\n\tvar content string\n\n\tif isCode {\n\t\tcontent = template\n\t\ttemplate = \".\"\n\t} else if fileContent, err := ioutil.ReadFile(template); err == nil {\n\t\tcontent = string(fileContent)\n\t} else {\n\t\treturn \"\", err\n\t}\n\n\tresult, err := t.ProcessContent(content, template)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif isCode {\n\t\tfmt.Println(result)\n\t\treturn \"\", nil\n\t}\n\tresultFile = template\n\tfor i := range templateExt {\n\t\tresultFile = strings.TrimSuffix(resultFile, templateExt[i])\n\t}\n\tresultFile = getTargetFile(resultFile, sourceFolder, targetFolder)\n\tisTemplate := t.isTemplate(template)\n\tif isTemplate {\n\t\text := path.Ext(resultFile)\n\t\tif strings.TrimSpace(result)+ext == \"\" {\n\t\t\t// We do not save anything for an empty resulting template that has no extension\n\t\t\treturn \"\", nil\n\t\t}\n\t\tif !t.options[Overwrite] {\n\t\t\tresultFile = fmt.Sprint(strings.TrimSuffix(resultFile, ext), \".generated\", ext)\n\t\t}\n\t}\n\n\tif t.options[OutputStdout] {\n\t\terr = t.printResult(template, resultFile, result)\n\t\tif err != nil {\n\t\t\terrors.Print(err)\n\t\t}\n\t\treturn \"\", nil\n\t}\n\n\tif sourceFolder == targetFolder && result == content {\n\t\treturn \"\", nil\n\t}\n\n\tmode := must(os.Stat(template)).(os.FileInfo).Mode()\n\tif !isTemplate && !t.options[Overwrite] {\n\t\tnewName := template + \".originalSourceLines\"\n\t\tlog.Noticef(\"%s => %s\", utils.Relative(t.folder, template), utils.Relative(t.folder, newName))\n\t\tmust(os.Rename(template, template+\".originalSourceLines\"))\n\t}\n\n\tif sourceFolder != targetFolder {\n\t\tmust(os.MkdirAll(filepath.Dir(resultFile), 0777))\n\t}\n\tlog.Notice(\"Writing file\", utils.Relative(t.folder, resultFile))\n\n\tif utils.IsShebangScript(result) {\n\t\tmode = 0755\n\t}\n\n\tif err = ioutil.WriteFile(resultFile, []byte(result), mode); err != nil {\n\t\treturn\n\t}\n\n\tif isTemplate && t.options[Overwrite] && sourceFolder == targetFolder {\n\t\tos.Remove(template)\n\t}\n\treturn\n}", "func GetTemplate(name string) (map[string]string, error) {\n\tresp, err := http.Get(fmt.Sprintf(\"https://api.github.com/gitignore/templates/%s\", name))\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tvar data map[string]string\n\n\tjson.NewDecoder(resp.Body).Decode(&data)\n\n\treturn data, nil\n}", "func (d *Data) readSource(ctx context.Context, source *Source, args ...string) ([]byte, error) {\n\tif d.cache == nil {\n\t\td.cache = make(map[string][]byte)\n\t}\n\tcacheKey := source.Alias\n\tfor _, v := range args {\n\t\tcacheKey += v\n\t}\n\tcached, ok := d.cache[cacheKey]\n\tif ok {\n\t\treturn cached, nil\n\t}\n\tr, err := d.lookupReader(source.URL.Scheme)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Datasource not yet supported\")\n\t}\n\tdata, err := r(ctx, source, args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\td.cache[cacheKey] = data\n\treturn data, nil\n}", "func loadTemplate(filePath string) (string, error) {\n\tcontent, err := ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn \"\", errors.New(fmt.Sprintf(\"failed to read file %s: %v\", filePath, err))\n\t}\n\ttemplateStr := string(content)\n\treturn templateStr, nil\n}", "func (tpl Template) GetData() (Template, error) {\n\tvar template Template\n\terr := DB.QueryRow(\"SELECT id, name, remark, script, package_id_str, create_time, update_time FROM template WHERE id = ?\", tpl.ID).Scan(&template.ID, &template.Name, &template.Remark, &template.Script, &template.PackageIDStr, &template.CreateTime, &template.UpdateTime)\n\tif err != nil {\n\t\treturn template, err\n\t}\n\treturn template, nil\n}", "func filesetForSource(gc GenerationContext, source vts.Target) (fileset, error) {\n\tswitch src := source.(type) {\n\tcase *vts.Puesdo:\n\t\tswitch src.Kind {\n\t\tcase vts.FileRef:\n\t\t\treturn filesetForFileSource(src)\n\t\tcase vts.DebRef:\n\t\t\treturn filesetForDebSource(gc, src)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"cannot generate using puesdo source %v\", src.Kind)\n\n\tcase *vts.Generator:\n\t\treturn nil, errors.New(\"not implemented\")\n\n\tcase *vts.Build:\n\t\th, err := src.RollupHash(gc.RunnerEnv, proc.EvalComputedAttribute)\n\t\tif err != nil {\n\t\t\treturn nil, vts.WrapWithTarget(err, src)\n\t\t}\n\t\treturn gc.Cache.FilesetReader(h)\n\n\tcase *vts.Sieve:\n\t\treturn filesetForSieve(gc, src)\n\t}\n\treturn nil, fmt.Errorf(\"cannot obtain fileset for source %T\", source)\n}", "func (h *GiteaTemplateHelper) loadTemplate(name string) ([]byte, error) {\n\tpath := fmt.Sprintf(\"%s/%s.yaml\", h.TemplatePath, name)\n\ttpl, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tparsed, err := template.New(\"gitea\").Parse(string(tpl))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar buffer bytes.Buffer\n\terr = parsed.Execute(&buffer, h.Parameters)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "func init(){\n\ttemp, _ := ioutil.ReadFile(\"templates/file2.htemplate\")\n\tfile1 = string(temp)\n}", "func (p *JenkinsPlugin) generate_source_files(instance_name string, ret *goforjj.PluginData) (status bool) {\n\tfor file, desc := range p.templates {\n\t\tif err := desc.Generate(p.yaml, p.template_dir, p.source_path, desc.Template); err != nil {\n\t\t\tlog.Printf(ret.Errorf(\"%s\", err))\n\t\t\treturn\n\t\t}\n\n\t\tret.AddFile(path.Join(instance_name, desc.Template))\n\t\tlog.Printf(ret.StatusAdd(\"%s (%s) generated\", file, desc.Template))\n\t}\n\tstatus = true\n\treturn\n}", "func templatesMainTmpl() (*asset, error) {\n\tpath := \"/Users/ravipradhan/Documents/personal-projects/test-modules/render/assets/templates/main.tmpl\"\n\tname := \"templates/main.tmpl\"\n\tbytes, err := bindataRead(path, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Error reading asset info %s at %s: %w\", name, path, err)\n\t}\n\n\ta := &asset{bytes: bytes, info: fi}\n\treturn a, err\n}", "func (a *SourcesApiService) GetSourceExecute(r ApiGetSourceRequest) (*GetSourceResponse, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t\tlocalVarReturnValue *GetSourceResponse\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"SourcesApiService.GetSource\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/v1/orgs/self/ws/{workspace}/collections/{collection}/sources/{source}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"workspace\"+\"}\", url.PathEscape(parameterValueToString(r.workspace, \"workspace\")), -1)\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"collection\"+\"}\", url.PathEscape(parameterValueToString(r.collection, \"collection\")), -1)\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"source\"+\"}\", url.PathEscape(parameterValueToString(r.source, \"source\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\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 Templatize(filename string) (tpl *raymond.Template, myerr error) {\n\tcontents, myerr := ioutil.ReadFile(filename)\n\tif myerr != nil {\n\t\treturn\n\t}\n\n\tt, myerr := raymond.Parse(string(contents))\n\tif myerr != nil {\n\t\treturn\n\t}\n\n\ttpl = t\n\n\treturn\n}", "func (i *ImageTemplateManagedImageSource) GetImageTemplateSource() *ImageTemplateSource {\n\treturn &ImageTemplateSource{\n\t\tType: i.Type,\n\t}\n}", "func loadTemplates(path string) (*pongo2.TemplateSet, error) {\n\tloader, err := pongo2.NewLocalFileSystemLoader(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Could not load templates: %s\", err.Error())\n\t}\n\n\ttset := pongo2.NewSet(\"web\", loader)\n\n\treturn tset, nil\n}", "func getHTMLFromTemplate(path string, data HelloMessage) string {\n\ttmpl := template.Must(template.ParseFiles(path))\n\tvar templateString bytes.Buffer\n\ttmpl.Execute(&templateString, data)\n\treturn templateString.String()\n}", "func (t *Repository) Get(name string) (*template.Template, error) {\n\ttempl, found := t.templates[name]\n\n\tif !found {\n\t\treturn templ, fmt.Errorf(\"template doesn't exist %s\", name)\n\t}\n\n\treturn t.addDependencies(templ)\n}", "func GetTemplates(r *templates.TemplateRenderer) ([]*resource.Resource, error) {\n\n\t// resourceList contains all kustomize resources\n\tresourceList := []*resource.Resource{}\n\n\t// add prometheus template\n\tif err := r.AddTemplateFromPath(r.GetTemplatesPath()+\"/prometheus\", &resourceList); err != nil {\n\t\treturn resourceList, err\n\t}\n\n\treturn resourceList, nil\n}", "func (g *Generator) GetTypeSource(tp *fdep.DepType) TypeNamer {\n\tif tp.IsScalar() {\n\t\treturn &TypeNamer_Scalar{tp: tp}\n\t} else {\n\t\treturn &TypeNamer_Source{tp: tp}\n\t}\n}", "func populateTemplateValues(data map[string]runtimeInterfaces.DataSource) (templateValuesType, error) {\n\ttemplateValues := make(templateValuesType, len(data))\n\tcollectedErrs := make([]error, 0)\n\tfor templateVar, dataSource := range data {\n\t\tif templateVar == namespaceVariable {\n\t\t\t// The namespace variable is specifically reserved for system use only.\n\t\t\tcollectedErrs = append(collectedErrs, errors.NewFlyteAdminErrorf(codes.InvalidArgument,\n\t\t\t\t\"Cannot assign namespace template value in user data\"))\n\t\t\tcontinue\n\t\t}\n\t\tvar dataValue string\n\t\tif len(dataSource.Value) > 0 {\n\t\t\tdataValue = dataSource.Value\n\t\t} else if len(dataSource.ValueFrom.EnvVar) > 0 {\n\t\t\tdataValue = os.Getenv(dataSource.ValueFrom.EnvVar)\n\t\t} else if len(dataSource.ValueFrom.FilePath) > 0 {\n\t\t\ttemplateFile, err := ioutil.ReadFile(dataSource.ValueFrom.FilePath)\n\t\t\tif err != nil {\n\t\t\t\tcollectedErrs = append(collectedErrs, errors.NewFlyteAdminErrorf(codes.InvalidArgument,\n\t\t\t\t\t\"failed to substitute parameterized value for %s: unable to read value from: [%+v] with err: %v\",\n\t\t\t\t\ttemplateVar, dataSource.ValueFrom.FilePath, err))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdataValue = string(templateFile)\n\t\t} else {\n\t\t\tcollectedErrs = append(collectedErrs, errors.NewFlyteAdminErrorf(codes.InvalidArgument,\n\t\t\t\t\"failed to substitute parameterized value for %s: unset or unrecognized ValueFrom: [%+v]\", templateVar, dataSource.ValueFrom))\n\t\t\tcontinue\n\t\t}\n\t\tif len(dataValue) == 0 {\n\t\t\tcollectedErrs = append(collectedErrs, errors.NewFlyteAdminErrorf(codes.InvalidArgument,\n\t\t\t\t\"failed to substitute parameterized value for %s: unset. ValueFrom: [%+v]\", templateVar, dataSource.ValueFrom))\n\t\t\tcontinue\n\t\t}\n\t\ttemplateValues[fmt.Sprintf(templateVariableFormat, templateVar)] = dataValue\n\t}\n\tif len(collectedErrs) > 0 {\n\t\treturn nil, errors.NewCollectedFlyteAdminError(codes.InvalidArgument, collectedErrs)\n\t}\n\treturn templateValues, nil\n}", "func parseTemplate() {\n\tif *inputFile == \"\" {\n\t\t// no input file given\n\t\tfmt.Println(\"No input file provided!\")\n\t\tos.Exit(1)\n\t}\n\ttmpl, err := template.ParseFiles(*inputFile)\n\tif err != nil {\n\t\t// parsing error\n\t\tfmt.Printf(\"Error parsing the input file: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tinputTemplate = tmpl\n}", "func Template(templateFileName string, data interface{}) (templateByte []byte, err error) {\n\ttemplatePath, err := filepath.Abs(templateFileName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid template name\")\n\t}\n\n\tt, err := template.ParseFiles(templatePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := new(bytes.Buffer)\n\tif err = t.Execute(buf, data); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buf.Bytes(), nil\n}", "func (ev *Evaler) Source(fname string) error {\n\tsrc, err := readFileUTF8(fname)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ev.SourceText(src)\n}", "func (ev *Evaler) Source(fname string) error {\n\tsrc, err := readFileUTF8(fname)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ev.SourceText(src)\n}", "func GetStickerTemplates(path, ext string) ([]string, error) {\n\tfiles := make([]string, 0)\n\terr := filepath.Walk(filepath.Join(path), func(path string, info os.FileInfo, err error) error {\n\t\tif (!info.IsDir()) && filepath.Ext(info.Name()) == ext {\n\t\t\tfiles = append(files, info.Name())\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\n\t}\n\treturn files, nil\n}", "func GetTpls() *template.Template {\n\treturn tpls\n}", "func templatesPartialsFilterSelectionTmpl() (*asset, error) {\n\tpath := \"/Users/ravipradhan/Documents/personal-projects/test-modules/render/assets/templates/partials/filter-selection.tmpl\"\n\tname := \"templates/partials/filter-selection.tmpl\"\n\tbytes, err := bindataRead(path, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Error reading asset info %s at %s: %w\", name, path, err)\n\t}\n\n\ta := &asset{bytes: bytes, info: fi}\n\treturn a, err\n}", "func (f *FileStore) GetTemplate(theme *models.Theme, templateName string) (*models.ThemeTemplate, error) {\n\tif theme == nil || theme.GetName() == \"\" {\n\t\treturn nil, nil\n\t}\n\tthemeDir := theme.GetName()\n\tif altDir := f.themeDirMap[theme.GetName()]; altDir != \"\" {\n\t\tthemeDir = altDir\n\t}\n\tp := path.Join(f.baseDir, themeDir, fileStoreTemplateDir, templateName)\n\tb, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err)\n\t}\n\tdata := string(b)\n\text := strings.TrimLeft(path.Ext(templateName), \".\")\n\tt := proto.Clone(theme.GetTemplates()[templateName]).(*models.ThemeTemplate)\n\tt.Theme = theme.Name\n\tt.Data = &data\n\tt.Name = &templateName\n\tt.Engine = &ext\n\treturn t, nil\n}", "func (ft *FileTuple) GetSource() string {\n\treturn ft.source\n}", "func (c *Client) Template(sourceFilePath, destinationFilePath string, perms os.FileMode, appendMap, envMap map[string]string) error {\n\ttemplateText, err := readTemplate(sourceFilePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttemplateResultBuffer, err := c.renderTemplate(templateText, appendMap, envMap)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn writeTemplateResults(destinationFilePath, templateResultBuffer, perms)\n}", "func getSourceTgz(sl spanLogger, repo, rev string, isTry bool) (tgz io.Reader, err error) {\n\tsp := sl.createSpan(\"get_source\")\n\tdefer func() { sp.done(err) }()\n\n\tfromCache := false\n\tkey := fmt.Sprintf(\"%v-%v\", repo, rev)\n\tvi, err, _ := sourceGroup.Do(key, func() (interface{}, error) {\n\t\tif tgzBytes, ok := sourceCache.Get(key); ok {\n\t\t\tfromCache = true\n\t\t\treturn tgzBytes, nil\n\t\t}\n\n\t\tif useWatcher() && !isTry {\n\t\t\tsp := sl.createSpan(\"get_source_from_watcher\")\n\t\t\tfor i := 0; i < 10; i++ {\n\t\t\t\tif i > 0 {\n\t\t\t\t\t// Wait for watcher to start up. Give it a minute until\n\t\t\t\t\t// we try Gerrit.\n\t\t\t\t\ttime.Sleep(6 * time.Second)\n\t\t\t\t}\n\t\t\t\ttgzBytes, err := getSourceTgzFromWatcher(repo, rev)\n\t\t\t\tif err == nil {\n\t\t\t\t\tsourceCache.Add(key, tgzBytes)\n\t\t\t\t\tsp.done(nil)\n\t\t\t\t\treturn tgzBytes, nil\n\t\t\t\t}\n\t\t\t\tlog.Printf(\"Error fetching source %s/%s from watcher (after %v uptime): %v\",\n\t\t\t\t\trepo, rev, time.Since(processStartTime), err)\n\t\t\t}\n\t\t\tsp.done(errors.New(\"timeout\"))\n\t\t}\n\n\t\tsp := sl.createSpan(\"get_source_from_gerrit\", fmt.Sprintf(\"%v from gerrit\", key))\n\t\ttgzBytes, err := getSourceTgzFromGerrit(repo, rev)\n\t\tsp.done(err)\n\t\tif err == nil {\n\t\t\tsourceCache.Add(key, tgzBytes)\n\t\t}\n\t\treturn tgzBytes, err\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bytes.NewReader(vi.([]byte)), nil\n}", "func SourceFile(filenames ...string) SqlSource {\n\treturn func(tx *sql.Tx) ([]string, error) {\n\t\tvar retStmts []string\n\t\tfor _, filename := range filenames {\n\t\t\tf, err := os.Open(filename)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t// parse source file\n\t\t\tstmts, err := ParseSQLStatements(f)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tretStmts = append(retStmts, stmts...)\n\t\t}\n\t\treturn retStmts, nil\n\t}\n}", "func (f *File) getSources() (*Entry, *Entry, error) {\n\te, err := getEntry(f.source, false)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tee, err := getEntry(f.msource, false)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn e, ee, nil\n}", "func execTemplate(c *Config, mdata metadata.Metadata, meta map[string]string, files []FileInfo, ctx httpserver.Context) ([]byte, error) {\n\tmdData := Data{\n\t\tContext: ctx,\n\t\tDoc: mdata.Variables,\n\t\tStyles: c.Styles,\n\t\tScripts: c.Scripts,\n\t\tMeta: meta,\n\t\tFiles: files,\n\t}\n\n\ttemplateName := mdata.Template\n\t// reload template on every request for now\n\t// TODO: cache templates by a general plugin\n\tif templateFile, ok := c.TemplateFiles[templateName]; ok {\n\t\terr := SetTemplate(c.Template, templateName, templateFile)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tb := new(bytes.Buffer)\n\tif err := c.Template.ExecuteTemplate(b, templateName, mdData); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b.Bytes(), nil\n}", "func loadSources(files ...string) (string, []byte, error) {\n\tvar sources []string\n\tbuf := new(bytes.Buffer)\n\n\treadFile := func(path string) error {\n\t\tif common.IsStrictPerms() {\n\t\t\tif err := common.OwnerHasExclusiveWritePerms(path); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tf, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to open file %v\", path)\n\t\t}\n\t\tdefer f.Close()\n\n\t\tif _, err = io.Copy(buf, f); err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to read file %v\", path)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfor _, filePath := range files {\n\t\tfilePath = paths.Resolve(paths.Config, filePath)\n\n\t\tif hasMeta(filePath) {\n\t\t\tmatches, err := filepath.Glob(filePath)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\t\tsources = append(sources, matches...)\n\t\t} else {\n\t\t\tsources = append(sources, filePath)\n\t\t}\n\t}\n\n\tif len(sources) == 0 {\n\t\treturn \"\", nil, errors.Errorf(\"no sources were found in %v\",\n\t\t\tstrings.Join(files, \", \"))\n\t}\n\n\tfor _, name := range sources {\n\t\tif err := readFile(name); err != nil {\n\t\t\treturn \"\", nil, err\n\t\t}\n\t}\n\n\treturn strings.Join(sources, \";\"), buf.Bytes(), nil\n}", "func (h *GrafanaTemplateHelper) loadTemplate(name string) ([]byte, error) {\n\tpath := fmt.Sprintf(\"%s/%s.yaml\", h.TemplatePath, name)\n\ttpl, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tparsed, err := template.New(\"grafana\").Parse(string(tpl))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar buffer bytes.Buffer\n\terr = parsed.Execute(&buffer, h.Parameters)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "func (s *baseNode) GetSource() []byte {\n\tif s.nodeType == NodeTypePackage {\n\t\tvar sources [][]byte\n\t\tfor _, rawFile := range s.realMe.(*Package).rawFiles {\n\t\t\tsources = append(sources, rawFile.source)\n\t\t}\n\t\treturn bytes.Join(sources, []byte{'\\n'})\n\t} else if s.nodeType == NodeTypeFile {\n\t\treturn s.rawFile.source\n\t}\n\n\tbase := token.Pos(s.rawFile.Base())\n\treturn s.rawFile.source[s.node.Pos()-base : s.node.End()-base]\n}", "func (i *ImageTemplateSharedImageVersionSource) GetImageTemplateSource() *ImageTemplateSource {\n\treturn &ImageTemplateSource{\n\t\tType: i.Type,\n\t}\n}", "func GetTemplates() packr.Box {\n\tbox := packr.NewBox(\"../../templates\")\n\treturn box\n}", "func WriteSource(w io.Writer, pkg, varName string, files []*File) error {\n\n\treturn tmpl.Execute(w, struct {\n\t\tPackage string\n\t\tVar string\n\t\tFiles []*File\n\t}{pkg, varName, files})\n}", "func (f FilePP) GetSource() []byte {\n\treturn f.pp\n}", "func templateInit(w http.ResponseWriter, templateFile string, templateData page) {\n\tif err := tmpls.ExecuteTemplate(w, templateFile, templateData); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func (*SpxTemplates) GetPath() string { return \"/api/objects/spx/template/\" }" ]
[ "0.7741914", "0.6508751", "0.6408694", "0.62078", "0.6203542", "0.61677474", "0.6116086", "0.61155236", "0.60829556", "0.60757655", "0.60627323", "0.6052237", "0.6047212", "0.59024334", "0.58020484", "0.5796863", "0.57956225", "0.5792862", "0.57480186", "0.5741771", "0.57385665", "0.5731672", "0.5715425", "0.5696822", "0.56929725", "0.5681116", "0.56737363", "0.5613588", "0.5612127", "0.55616695", "0.5547711", "0.5536072", "0.5532206", "0.55224985", "0.5515419", "0.54953307", "0.5467564", "0.54615855", "0.5450893", "0.54302967", "0.54192615", "0.53770185", "0.53707", "0.5368496", "0.53538114", "0.53402954", "0.5317249", "0.5300865", "0.52981085", "0.528284", "0.52778524", "0.52759206", "0.5257087", "0.52562755", "0.5250193", "0.524856", "0.52345246", "0.5224987", "0.52249265", "0.52241266", "0.5222223", "0.5220043", "0.52142626", "0.5212185", "0.51975524", "0.5193252", "0.5187544", "0.518465", "0.51677716", "0.51646876", "0.515852", "0.5151771", "0.5147926", "0.5145476", "0.5138182", "0.51272976", "0.51272136", "0.51092696", "0.51003474", "0.5096131", "0.5096131", "0.5070696", "0.50675386", "0.50660795", "0.5064142", "0.50606555", "0.5059156", "0.5058276", "0.5058275", "0.5036163", "0.5035528", "0.5027001", "0.50266045", "0.5022927", "0.50188327", "0.5011015", "0.5009479", "0.50091577", "0.49923018", "0.49904287" ]
0.76934034
1
templateFile takes one yaml file as input and runs Go template engine on the file. Output is written to output directory
func (t *templater) templateFile(workDir string, outDir string, file os.FileInfo, d map[string]interface{}) { if strings.Contains(file.Name(), "yaml") { filePath := workDir + "/" + file.Name() tEx := templ.New(file.Name()) tEx.Funcs(templateFuncs(workDir)) tEx.ParseFiles(filePath) b := bytes.NewBuffer([]byte{}) err := tEx.Execute(b, d) if err != nil { log.Error(err, "Failed to execute template") } newF, err := os.Create(outDir + "/" + file.Name()) if err != nil { log.Error(err, "Failed to create file", "file", file.Name()) return } newF.Write(b.Bytes()) newF.Close() } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TemplateFile(src string, outBuf *bytes.Buffer, vars map[string]interface{}) error {\n\n\t// verify that the input template exists\n\tif _, err := os.Stat(src); err != nil {\n\t\treturn errors.Wrapf(err, \"Source template '%s' doesn't exist\", src)\n\t}\n\n\tsrcTemplate, err := ioutil.ReadFile(src)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"Error reading source template file %s\", src)\n\t}\n\n\treturn TemplateString(string(srcTemplate[:]), outBuf, vars)\n}", "func (c *Client) Template(sourceFilePath, destinationFilePath string, perms os.FileMode, appendMap, envMap map[string]string) error {\n\ttemplateText, err := readTemplate(sourceFilePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttemplateResultBuffer, err := c.renderTemplate(templateText, appendMap, envMap)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn writeTemplateResults(destinationFilePath, templateResultBuffer, perms)\n}", "func ExecuteTemplateFromFile(boxed, to string, templateData interface{}) {\n\ttemplateString, err := ioutil.ReadFile(boxed)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to find template file: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\texecuteTemplateFromString(string(templateString), to, templateData)\n}", "func Template(tempName string, templatePath string, replacings ...Replacement) *os.File {\n\treplacedFile, err := ioutil.TempFile(\"/tmp\", tempName+\"-*.yaml\")\n\tExpect(err).ToNot(HaveOccurred())\n\n\ttemplateContent, err := ioutil.ReadFile(templatePath)\n\tExpect(err).ToNot(HaveOccurred())\n\n\treplacedStr := \"\"\n\tfor _, rep := range replacings {\n\t\tcontent := \"\"\n\t\tif replacedStr == \"\" {\n\t\t\tcontent = string(templateContent)\n\t\t} else {\n\t\t\tcontent = replacedStr\n\t\t}\n\t\treplacedStr = strings.ReplaceAll(content, rep.Old, rep.New)\n\t}\n\n\terr = ioutil.WriteFile(replacedFile.Name(), []byte(replacedStr), 0644)\n\tExpect(err).ToNot(HaveOccurred())\n\n\treturn replacedFile\n}", "func Template(templatePath string) Result {\n\tconfig := config.GetLoadedConfig()\n\tfullPath := filepath.Join(config.GetTemplatePath(), templatePath)\n\n\tif f, err := os.Open(fullPath); err != nil {\n\t\tlog.Printf(\"could not open template file %s\\n\", fullPath)\n\t} else {\n\t\tif bytes, err := io.ReadAll(f); err != nil {\n\t\t\tlog.Printf(\"could not read template file %s\\n\", fullPath)\n\t\t} else {\n\t\t\treturn StringResult(bytes)\n\t\t}\n\t}\n\n\treturn StringResult(\"\")\n}", "func createFile(input map[string]*context,\n\ttemplate string, conf string) error {\n\t// read the template\n\tcontents, err := ioutil.ReadFile(template)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t// replace\n\tfor _, ctx := range input {\n\t\tcontents = bytes.Replace(contents, []byte(ctx.templateKeyword),\n\t\t\t[]byte(ctx.cliInput), -1)\n\t}\n\t// write\n\terr = ioutil.WriteFile(conf, contents, 0644)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn nil\n}", "func Template(t, b string, o io.Writer) error {\n\tbf, err := Parse(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttf, err := os.OpenFile(t, os.O_RDONLY, os.ModePerm)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer tf.Close()\n\n\ttext, err := ioutil.ReadAll(tf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttmpl, err := template.New(b).Parse(string(text))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn tmpl.Execute(o, bf)\n}", "func RenderTemplate(tmpfile string, pairs map[string]interface{}) (string, error) {\n\n\tfile, err := os.Open(tmpfile)\n\tif err != nil {\n\t\tLogWarning.Println(err)\n\t}\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\t//var srcContent string\n\tvar srcContent bytes.Buffer\n\tfor scanner.Scan() {\n\t\tt := fmt.Sprintln(scanner.Text())\n\t\tif strings.Index(t, \"<%file:\") > -1 {\n\t\t\tLogDebug.Println(\"Including file external file\")\n\t\t\tif strings.Index(t, \"%>\") > -1 {\n\t\t\t\tre := regexp.MustCompile(\"\\\\<\\\\%file:(.*?)\\\\%\\\\>\")\n\t\t\t\tmatch := re.FindStringSubmatch(t)\n\t\t\t\tif len(match) == 0 {\n\t\t\t\t\tLogError.Println(\"invalid file: syntax \", t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tincludeFileName := fmt.Sprintf(\"%s/%s\", path.Dir(tmpfile), match[1])\n\t\t\t\tincludeContent, err := ioutil.ReadFile(includeFileName)\n\t\t\t\tif err != nil {\n\t\t\t\t\tLogWarning.Println(err)\n\t\t\t\t}\n\t\t\t\tLogInfo.Println(\"including file :\", includeFileName)\n\t\t\t\tLogDebug.Println(\"includeContent\", string(includeContent))\n\t\t\t\tsrcContent.WriteString(string(includeContent))\n\t\t\t} else {\n\t\t\t\tLogWarning.Println(\"Found incomplete tag in include from file \", tmpfile)\n\t\t\t}\n\t\t} else if strings.Index(t, \"<%LookupFile:\") > -1 {\n\t\t\tLogDebug.Println(\"Rendering LookupFile\")\n\t\t\tvar lookup LookupList\n\t\t\tre := regexp.MustCompile(\"\\\\<\\\\%LookupFile:(.*?),(.*?),(.*?),(.*?)\\\\%\\\\>\")\n\n\t\t\t/*\n\t\t\t\t//\n\t\t\t\t// Fist we need to find if there is a template within the lookup definition\n\t\t\t\tt := fasttemplate.New(t, \"{{\", \"}}\")\n\t\t\t\ts := t.ExecuteString(pairs)\n\t\t\t*/\n\t\t\t//var tmpl = template.Must(template.ParseFiles(t))\n\t\t\t// Create a new template and parse the letter into it.\n\t\t\t// Get the Sprig function map.\n\t\t\tfmap := sprig.TxtFuncMap()\n\t\t\tvar tmpl = template.Must(template.New(\"LookupFile\").Funcs(fmap).Parse(t))\n\n\t\t\tvar bytes bytes.Buffer\n\t\t\twriter := bufio.NewWriter(&bytes)\n\n\t\t\terr = tmpl.Execute(writer, pairs)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = writer.Flush()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tLogDebug.Println(bytes.String())\n\n\t\t\tmatch := re.FindStringSubmatch(bytes.String())\n\n\t\t\tif len(match) == 0 {\n\t\t\t\tLogError.Println(\"invalid LookupFile: syntax \", t)\n\t\t\t\t//BUG/FIX: Should push up a error to rest calling function\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tLogDebug.Println(\"LookupFile: \", match[LookupFile])\n\t\t\tLogDebug.Println(\"LookupKey: \", match[LookupKey])\n\t\t\tLogDebug.Println(\"LookupSubkey: \", match[LookupSubkey])\n\t\t\tLogDebug.Println(\"LookupDefaultValue: \", match[LookupDefaultValue])\n\n\t\t\tyamlFile, err := ioutil.ReadFile(fmt.Sprintf(match[LookupFile]))\n\t\t\tif err != nil {\n\t\t\t\tLogError.Println(\"reading LookupFile \", match[LookupFile])\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = yaml.Unmarshal(yamlFile, &lookup)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tvar lookupvalue string\n\t\t\tvar ok bool\n\t\t\tLogDebug.Println(lookup.Lookup)\n\t\t\tif lookupvalue, ok = lookup.Lookup[match[LookupKey]][match[LookupSubkey]]; ok {\n\t\t\t\tLogDebug.Println(\"Found lookup value in file :\", lookupvalue)\n\t\t\t} else {\n\t\t\t\tlookupvalue = match[LookupDefaultValue]\n\t\t\t\tLogDebug.Println(\"Using default lookup Value :\", lookupvalue)\n\t\t\t}\n\n\t\t\tsrcContent.WriteString(re.ReplaceAllString(bytes.String(), lookupvalue))\n\n\t\t} else {\n\t\t\tsrcContent.WriteString(t)\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tLogWarning.Println(err)\n\t}\n\n\t//var tmpl = template.Must(template.ParseFiles(tmpl_file))\n\t// Get the Sprig function map.\n\tfmap := sprig.TxtFuncMap()\n\tvar tmpl = template.Must(template.New(\"rendered_template\").Funcs(fmap).Parse(srcContent.String()))\n\n\tvar bytes bytes.Buffer\n\twriter := bufio.NewWriter(&bytes)\n\n\terr = tmpl.Execute(writer, pairs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\terr = writer.Flush()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tLogDebug.Println(bytes.String())\n\n\treturn bytes.String(), nil\n\n}", "func ExecTemplate(filename string, result io.Writer, data interface{}) error {\n\n\t// Set curent target file name for function fileMD5\n\ttmplTargetFileName = filename\n\t// Read template from file.\n\ttmplData, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Parse template.\n\ttmpl, err := template.New(\"main\").Funcs(TmplFunctionsMap()).Option(\"missingkey=error\").Parse(string(tmplData))\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Apply data to template.\n\terr = tmpl.Execute(result, &data)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (g *Generator) ParseFile(path string) (*template.Template, error) {\n\treturn g.generateTemplate(path, nil)\n}", "func (t Template) ProcessTemplate(template, sourceFolder, targetFolder string) (resultFile string, err error) {\n\tisCode := t.IsCode(template)\n\tvar content string\n\n\tif isCode {\n\t\tcontent = template\n\t\ttemplate = \".\"\n\t} else if fileContent, err := ioutil.ReadFile(template); err == nil {\n\t\tcontent = string(fileContent)\n\t} else {\n\t\treturn \"\", err\n\t}\n\n\tresult, err := t.ProcessContent(content, template)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif isCode {\n\t\tfmt.Println(result)\n\t\treturn \"\", nil\n\t}\n\tresultFile = template\n\tfor i := range templateExt {\n\t\tresultFile = strings.TrimSuffix(resultFile, templateExt[i])\n\t}\n\tresultFile = getTargetFile(resultFile, sourceFolder, targetFolder)\n\tisTemplate := t.isTemplate(template)\n\tif isTemplate {\n\t\text := path.Ext(resultFile)\n\t\tif strings.TrimSpace(result)+ext == \"\" {\n\t\t\t// We do not save anything for an empty resulting template that has no extension\n\t\t\treturn \"\", nil\n\t\t}\n\t\tif !t.options[Overwrite] {\n\t\t\tresultFile = fmt.Sprint(strings.TrimSuffix(resultFile, ext), \".generated\", ext)\n\t\t}\n\t}\n\n\tif t.options[OutputStdout] {\n\t\terr = t.printResult(template, resultFile, result)\n\t\tif err != nil {\n\t\t\terrors.Print(err)\n\t\t}\n\t\treturn \"\", nil\n\t}\n\n\tif sourceFolder == targetFolder && result == content {\n\t\treturn \"\", nil\n\t}\n\n\tmode := must(os.Stat(template)).(os.FileInfo).Mode()\n\tif !isTemplate && !t.options[Overwrite] {\n\t\tnewName := template + \".originalSourceLines\"\n\t\tlog.Noticef(\"%s => %s\", utils.Relative(t.folder, template), utils.Relative(t.folder, newName))\n\t\tmust(os.Rename(template, template+\".originalSourceLines\"))\n\t}\n\n\tif sourceFolder != targetFolder {\n\t\tmust(os.MkdirAll(filepath.Dir(resultFile), 0777))\n\t}\n\tlog.Notice(\"Writing file\", utils.Relative(t.folder, resultFile))\n\n\tif utils.IsShebangScript(result) {\n\t\tmode = 0755\n\t}\n\n\tif err = ioutil.WriteFile(resultFile, []byte(result), mode); err != nil {\n\t\treturn\n\t}\n\n\tif isTemplate && t.options[Overwrite] && sourceFolder == targetFolder {\n\t\tos.Remove(template)\n\t}\n\treturn\n}", "func createFileFromTemplate(input string, output string) {\n\tt := loadTemplateFromFile(input)\n\n\tf, err := os.Create(output)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\terr = t.Execute(f, packageName)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func Templatize(filename string) (tpl *raymond.Template, myerr error) {\n\tcontents, myerr := ioutil.ReadFile(filename)\n\tif myerr != nil {\n\t\treturn\n\t}\n\n\tt, myerr := raymond.Parse(string(contents))\n\tif myerr != nil {\n\t\treturn\n\t}\n\n\ttpl = t\n\n\treturn\n}", "func Execute(template string) (*string, error) {\n\n\t// overrides for never touching the filesystem\n\tcreateDestDirs := false\n\terrMissingKey := true\n\tdestination := \"dummydest\"\n\n\t// feed our template string into a default template config, with above overrides\n\ttemplateConfig := ctconfig.DefaultTemplateConfig()\n\ttemplateConfig.Contents = &template\n\ttemplateConfig.CreateDestDirs = &createDestDirs\n\ttemplateConfig.ErrMissingKey = &errMissingKey\n\ttemplateConfig.Destination = &destination\n\ttemplateConfigs := ctconfig.TemplateConfigs([]*ctconfig.TemplateConfig{templateConfig})\n\n\t// default config, except it runs to completion and has the template argument injected\n\tconf := ctconfig.DefaultConfig()\n\tconf.Once = true\n\tconf.Templates = &templateConfigs\n\n\t// default runner, except it writes output to a byte buffer in memory\n\trunner, err := ctman.NewRunner(conf, true)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar buf bytes.Buffer\n\trunner.SetOutStream(&buf)\n\n\t// start the runner, which closes by itself, and read any errors from its error channel\n\trunner.Start()\n\tclose(runner.ErrCh)\n\terr = <-runner.ErrCh\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// sanitize and return the rendered output string\n\trendered := buf.String()\n\trendered = strings.Replace(rendered, \"> dummydest\\n\", \"\", 1)\n\treturn &rendered, nil\n}", "func generateAndRunFile(projectDir, fileName string, tmpl *template.Template) {\n\tprojectPack, err := build.ImportDir(path.Join(projectDir, \"config\"), 0)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"Error while importing project path: %s\", err))\n\t}\n\n\ttmplData := struct {\n\t\tImports []string\n\t\tConfig string\n\t}{\n\t\tImports: projectPack.Imports,\n\t\tConfig: fmt.Sprintf(\"%#v\", viper.AllSettings()),\n\t}\n\tstartFileName := path.Join(projectDir, fileName)\n\tgenerate.CreateFileFromTemplate(startFileName, tmpl, tmplData)\n\tcmd := exec.Command(\"go\", \"run\", startFileName)\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\tcmd.Run()\n}", "func ProcessTemplate(yamlTemplate string, values interface{}) (yaml []byte, err error) {\n\tt, err := template.New(\"\").Parse(yamlTemplate)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to parse the yaml template\\n%s\", yamlTemplate)\n\t}\n\n\tvar buf bytes.Buffer\n\terr = t.Execute(&buf, values)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to execute the yaml template with the values:\\n%#v\", values)\n\t}\n\n\treturn buf.Bytes(), nil\n}", "func Template(templateFileName string, data interface{}) (templateByte []byte, err error) {\n\ttemplatePath, err := filepath.Abs(templateFileName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid template name\")\n\t}\n\n\tt, err := template.ParseFiles(templatePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := new(bytes.Buffer)\n\tif err = t.Execute(buf, data); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buf.Bytes(), nil\n}", "func main() {\n\tl := []yamlFile{\n\t\t{\"configurations.yml\", false, cfgTemplate},\n\t\t{\"configurationsResponse.yml\", true, responseTemplate},\n\t}\n\tfor _, file := range l {\n\t\tf, err := os.Create(file.Name)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdoc := document{\n\t\t\tItems: userCfgItems(file.IsResponse),\n\t\t}\n\t\ttmpl, err := template.New(\"test\").Parse(file.TempName)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\terr = tmpl.Execute(f, doc)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tf.Close()\n\t}\n}", "func GenerateTemplate(params cloudformation.GenerateParams) {\n\toutput, _ := GenerateYamlTemplate(params)\n\tprepareOutputDir(params.Directory)\n\tif params.WriteParams {\n\t\twriteParamMap(params.Filename, params.Directory, params.ParamMap)\n\t}\n\twriteOutput(params.Filename, params.Directory, output)\n}", "func generateFileFromTemplate(t template.Template, data interface{}) (string, error) {\n\t// generate temporary file\n\ttmpfile, err := ioutil.TempFile(\"\", \"lift-*\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer tmpfile.Close()\n\n\t// execute the template, saving the result in the tempfile\n\tif err := t.Execute(tmpfile, data); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tlog.WithFields(log.Fields{\n\t\t\"template\": t.Name(),\n\t\t\"file\": tmpfile.Name(),\n\t}).Debug(\"parsed template to file\")\n\n\t// return handle to the temp file\n\treturn tmpfile.Name(), nil\n}", "func applyTemplateToFile(fileitem fileitem, changesets []changeset) (string, bool, error) {\n\t// try open file\n\tbuffer, err := os.ReadFile(fileitem.Path)\n\tif err != nil {\n\t\treturn \"\", false, err\n\t}\n\n\tcontent := parseContentAsTemplate(string(buffer), changesets)\n\n\toutput, status := writeContentToFile(fileitem, content)\n\n\treturn output, status, err\n}", "func ProcessFile(tmpPath string, vars interface{}) (string, error) {\n\ttmp, err := newTemplateFile(tmpPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn process(tmp, vars)\n}", "func RenderTemplateToFile(templateFP, destFP string, context ...interface{}) error {\n\t// Render the mustache file.\n\tcontents, err := mustache.RenderFile(templateFP, context...)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Write contents to the destination.\n\terr = os.Remove(destFP)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn err\n\t}\n\tf, err := os.Create(destFP)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating file %s: %w\", destFP, err)\n\t}\n\tdefer f.Close()\n\tf.WriteString(contents)\n\treturn nil\n}", "func renderFileFromTemplate(basePath string, templateInstance *template.Template, renderConfig rt.RenderConfig, config *rt.Config, fromTo rt.FromTo) error {\n\trelativeDestPath := path.Join(basePath, fromTo.To)\n\n\tdestDir := path.Dir(relativeDestPath)\n\terr := os.MkdirAll(destDir, os.ModePerm)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdestFile, err := os.Create(relativeDestPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := addAutogeneratedHeader(destFile); err != nil {\n\t\treturn err\n\t}\n\n\tvalues := map[string]interface{}{\"Values\": renderConfig.Values, \"Global\": config.Global}\n\n\treturn templateInstance.Execute(destFile, values)\n}", "func executeTemplate(nameTemplate, constTemplate string, templateToApply Template) (string, error) {\r\n\tnewTemplate := template.New(nameTemplate)\r\n\t// parses template\r\n\tnewTemplate, err := newTemplate.Parse(constTemplate)\r\n\tif err != nil {\r\n\t\tos.Remove(\"profile.xml\")\r\n\t\treturn \"\", err\r\n\t}\r\n\t// executes the template into the open file\r\n\tvar templateBuffer bytes.Buffer\r\n\terr = newTemplate.Execute(&templateBuffer, templateToApply)\r\n\tif err != nil {\r\n\t\tos.Remove(\"profile.xml\")\r\n\t\treturn templateBuffer.String(), err\r\n\t}\r\n\t// handles error\r\n\tif err != nil {\r\n\t\tos.Remove(\"profile.xml\")\r\n\t\treturn templateBuffer.String(), err\r\n\t}\r\n\treturn templateBuffer.String(), nil\r\n}", "func RenderTemplate(t *testing.T, options *Options, chartDir string, releaseName string, templateFiles []string) string {\n\tout, err := RenderTemplateE(t, options, chartDir, releaseName, templateFiles)\n\trequire.NoError(t, err)\n\treturn out\n}", "func createFile(name string, template interface{}) (interface{}, error) {\n\t// filling the template with a default value\n\tif err := iterateTemplate(template, true); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// casting a template to an array of bytes\n\tjsonBytes, err := json.MarshalIndent(template, \"\", \" \")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// write template to json file\n\tif err = ioutil.WriteFile(fmt.Sprintf(\"%s/%s.json\", configsDir, name), jsonBytes, 0644); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn template, err\n}", "func ApplyTemplate(templateName string, templateDefinition string, context interface{}) string {\n\n\ttemplate := safeParseTemplate(templateName, templateDefinition)\n\n\tvar buf bytes.Buffer\n\ttemplate.Execute(&buf, context)\n\treturn buf.String()\n}", "func (e DefaultEngine) ParseAndExecuteFile(sourcePath string, settings interface{}, wr io.Writer) error {\n\tfileTemplate, err := template.ParseFiles(sourcePath)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"Error Parsing template for file '%v'\", sourcePath)\n\t}\n\n\tif err = fileTemplate.ExecuteTemplate(wr, filepath.Base(sourcePath), settings); err != nil {\n\t\treturn errors.Wrapf(err, \"Error executing template file '%v'\", sourcePath)\n\t}\n\n\treturn nil\n}", "func (u Options) CopyTemplate(rootFs billy.Filesystem, chartsScriptOptions options.ChartsScriptOptions, templateDir string) error {\n\ttemplateFiles, ok := u[chartsScriptOptions.Template]\n\tif !ok {\n\t\treturn fmt.Errorf(\"No templates defined for type %s. Only staging or live are supported\", chartsScriptOptions.Template)\n\t}\n\ttemplateFileMap := make(map[string]bool, len(templateFiles))\n\tfor _, p := range templateFiles {\n\t\ttemplateFileMap[p] = true\n\t}\n\tabsTempDir, err := ioutil.TempDir(filepath.Join(rootFs.Root(), templateDir), \"generated\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Encountered error while trying to create temporary directory: %s\", err)\n\t}\n\tdefer os.RemoveAll(absTempDir)\n\ttempDir, err := filesystem.GetRelativePath(rootFs, absTempDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Encountered error while getting relative path for %s in %s: %s\", absTempDir, rootFs.Root(), err)\n\t}\n\ttempFs := filesystem.GetFilesystem(absTempDir)\n\terr = filesystem.WalkDir(rootFs, templateDir, func(fs billy.Filesystem, path string, isDir bool) error {\n\t\trepoPath, err := filesystem.MovePath(path, templateDir, \"\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to get path of %s within %s: %s\", repoPath, templateDir, err)\n\t\t}\n\t\tif exists, ok := templateFileMap[repoPath]; !ok || !exists {\n\t\t\treturn nil\n\t\t}\n\t\tf, err := filesystem.CreateFileAndDirs(tempFs, repoPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer f.Close()\n\t\tt := template.Must(template.New(filepath.Base(path)).ParseFiles(filesystem.GetAbsPath(rootFs, path)))\n\t\tif err := t.Execute(f, chartsScriptOptions); err != nil {\n\t\t\treturn fmt.Errorf(\"Error while executing Go template for %s: %s\", path, err)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn filesystem.CopyDir(rootFs, tempDir, \".\")\n}", "func parseTemplate(redisConn redis.Conn, templateFile *os.File, outputFile *os.File) (err error) {\n\n\tvar (\n\t\tcountLines int\n\t\tcountReplace int\n\t\tcountKeep int\n\t\tcountRm int\n\t\tcountRmLine int\n\t\tcountCheckTrue int\n\t\tcountCheckFalse int\n\t\tcountDefault int\n\t)\n\n\t// Read template file line by line\n\tscanner := bufio.NewScanner(templateFile)\n\tplaceholderPattern := regexp.MustCompile(\"{{(.+?)}}\")\n\n\tfor scanner.Scan() {\n\t\tvar (\n\t\t\toutputLine string // current line of template file that will be written to outputFile\n\t\t\tplaceholders [][]string // contains placeholders of a single line, each with a key and optionally a fallback part\n\t\t\tprintLine = true // print line if true, set to 'false' when fallback is #rmLine\n\t\t)\n\n\t\toutputLine = scanner.Text()\n\t\tplaceholders = placeholderPattern.FindAllStringSubmatch(outputLine, -1)\n\n\t\t// replace individual placeholder\n\t\tfor i := range placeholders {\n\t\t\tvar (\n\t\t\t\tplaceholder string // current placeholder\n\t\t\t\tplaceholderFields []string // individual fields of placeholder, separated by a space (\" \")\n\t\t\t\tredisKey string // Redis key of a placeholder\n\t\t\t\tredisVal string // value fetched from Redis for a placeholder\n\t\t\t\toption string // option like #rm or #rmLineTrue\n\t\t\t)\n\n\t\t\t// Redis GET\n\t\t\tplaceholder = placeholders[i][0]\n\t\t\tplaceholderFields = strings.Fields(placeholders[i][1])\n\t\t\tredisKey = placeholderFields[0]\n\n\t\t\t// skip line with outputFile specifier\n\t\t\tif strings.ToLower(redisKey) == \"#output:\" {\n\t\t\t\tprintLine = false\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// get placeholder option, if present\n\t\t\tif len(placeholderFields) > 1 {\n\t\t\t\toption = placeholderFields[1]\n\t\t\t}\n\n\t\t\tredisVal, _ = redis.String(redisConn.Do(\"GET\", redisKey))\n\n\t\t\tif option == \"#check\" || option == \"#rmLineFalse\" {\n\t\t\t\t// if key value is 'false' or empty, drop line\n\t\t\t\tif redisVal == \"0\" || strings.EqualFold(redisVal, \"false\") || strings.EqualFold(redisVal, \"no\") || strings.EqualFold(redisVal, \"n\") || len(redisVal) == 0 {\n\t\t\t\t\tprintLine = false\n\t\t\t\t\tcountCheckFalse++\n\t\t\t\t} else {\n\t\t\t\t\toutputLine = strings.Replace(outputLine, placeholder, \"\", -1)\n\t\t\t\t\tcountCheckTrue++\n\t\t\t\t}\n\n\t\t\t} else if option == \"#rmLineTrue\" {\n\t\t\t\t// if key value is 'true', drop line\n\t\t\t\tif redisVal == \"1\" || strings.EqualFold(redisVal, \"true\") || strings.EqualFold(redisVal, \"yes\") || strings.EqualFold(redisVal, \"y\") {\n\t\t\t\t\tprintLine = false\n\t\t\t\t\tcountCheckFalse++\n\t\t\t\t} else {\n\t\t\t\t\toutputLine = strings.Replace(outputLine, placeholder, \"\", -1)\n\t\t\t\t\tcountCheckTrue++\n\t\t\t\t}\n\n\t\t\t} else if len(redisVal) > 0 {\n\t\t\t\t// replace placeholder if Redis key is found\n\t\t\t\toutputLine = strings.Replace(outputLine, placeholder, redisVal, -1)\n\t\t\t\tcountReplace++\n\n\t\t\t} else {\n\t\t\t\t// if specified, use fallback options if Redis key is not found\n\t\t\t\tswitch strings.ToLower(option) {\n\t\t\t\tcase \"#rm\":\n\t\t\t\t\toutputLine = strings.Replace(outputLine, placeholder, \"\", -1)\n\t\t\t\t\tcountRm++\n\t\t\t\tcase \"#rmline\":\n\t\t\t\t\tprintLine = false\n\t\t\t\t\tcountRmLine++\n\t\t\t\tcase \"#default:\":\n\t\t\t\t\tdefaultValue := strings.Join(placeholderFields[2:], \" \")\n\t\t\t\t\toutputLine = strings.Replace(outputLine, placeholder, defaultValue, -1)\n\t\t\t\t\tcountDefault++\n\t\t\t\tdefault:\n\t\t\t\t\tcountKeep++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// write processed line to outputFile\n\t\tif printLine {\n\t\t\tfmt.Fprintln(outputFile, outputLine)\n\t\t\tcountLines++\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn err\n\t}\n\n\tif !*quietArg {\n\t\tlog.Printf(\"written %v lines\\n\", countLines)\n\t\tlog.Printf(\"placeholders: %v replaced, %v kept, %v deleted, %v lines deleted, %v set to default\\n\", countReplace, countKeep, countRm, countRmLine, countDefault)\n\t\tlog.Printf(\"checks: %v lines dropped, %v lines kept\\n\\n\", countCheckFalse, countCheckTrue)\n\t}\n\treturn nil\n\n}", "func main(){\n\tcfg := setup()\n\n\t// Just output the template.\n\ttemplate, _ := ioutil.ReadAll(cfg.Template)\n\tfmt.Println(string(template))\n}", "func (e *Engine) CompileTemplate(src *model.Source) (*model.Template, *Issues) {\n\tast, iss := parser.ParseYaml(src)\n\tif iss.Err() != nil {\n\t\treturn nil, iss\n\t}\n\tc := compiler.NewCompiler(e, e.limits, e.evalOpts...)\n\treturn c.CompileTemplate(src, ast)\n}", "func templateExecute(ctx interface{}, w io.Writer, templateContent string) {\n\ttmpl, err := template.New(\"docker build template\").Parse(templateContent)\n\tif err == nil {\n\t\ttmpl.Execute(w, ctx)\n\t}\n}", "func ExecuteTemplates(valuesIn io.Reader, out io.Writer, tplFiles []string) error {\n\tname := path.Base(tplFiles[0])\n\ttpl, err := template.New(name).Funcs(sprig.TxtFuncMap()).ParseFiles(tplFiles...)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error parsing template(s): %v\", err)\n\t}\n\n\tbuf := bytes.NewBuffer(nil)\n\t_, err = io.Copy(buf, valuesIn)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to parse input template: %v\", err)\n\t}\n\n\tvar values map[string]interface{}\n\terr = yaml.Unmarshal(buf.Bytes(), &values)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to parse input template: %v\", err)\n\t}\n\n\terr = tpl.Execute(out, values)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to parse input template: %v\", err)\n\t}\n\treturn nil\n}", "func WriteTargetFileFromTemplate(targetFile string, tmpl []byte, envs *utils.MainConfig) error {\n\tt, err := template.New(\"\").Parse(string(tmpl))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tf, err := os.Create(targetFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\terr = t.Execute(f, envs.Environments)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func ConvertTemplate(file string) (dashboard Dashboard, err error) {\n\tf, err := os.Open(file)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\tbuf, err := ioutil.ReadAll(f)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdashboard.Editable = true\n\tif tomlErr := toml.Unmarshal(buf, &dashboard); tomlErr != nil {\n\t\t//try to convert a json template\n\t\tif jsonErr := json.Unmarshal(buf, &dashboard); jsonErr != nil {\n\t\t\tfmt.Printf(\"not a JSON template: %s\\n\", err.Error())\n\t\t\terr = fmt.Errorf(\"unable to parse template:\\nTOML error: %s\\nJSON error: %s\", tomlErr.Error(), jsonErr.Error())\n\t\t\treturn dashboard, err\n\t\t}\n\t\t//cleanup existing dashboard ID\n\t\tdashboard.ID = 0\n\t}\n\tdefRow := NewRow()\n\tdefPanel := NewPanel()\n\n\tif len(dashboard.Templating.List) > 0 {\n\t\tdefTemplate := NewTemplate()\n\t\tfor i := range dashboard.Templating.List {\n\t\t\ttemplate := &dashboard.Templating.List[i]\n\t\t\tif err := mergo.Merge(template, defTemplate); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := range dashboard.Rows {\n\t\trow := &dashboard.Rows[i]\n\t\tif err := mergo.Merge(row, defRow); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfor j := range row.Panels {\n\t\t\tpanel := &row.Panels[j]\n\t\t\tif err := mergo.Merge(panel, defPanel); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tfor _, metric := range panel.Metrics {\n\t\t\t\ttarget := NewTarget()\n\t\t\t\tfields := strings.Join(metric.Fields, \"|\")\n\t\t\t\thosts := strings.Join(metric.Hosts, \"|\")\n\n\t\t\t\ttarget.Measurement = metric.Measurement\n\n\t\t\t\t// adding tags\n\t\t\t\thostTag := Tag{Key: \"host\", Value: \"/\" + hosts + \"/\"}\n\t\t\t\ttarget.Tags = append(target.Tags, hostTag)\n\t\t\t\tfieldsTag := Tag{Key: \"name\", Value: \"/\" + fields + \"/\", Condition: \"AND\"}\n\t\t\t\ttarget.Tags = append(target.Tags, fieldsTag)\n\t\t\t\ttarget.GroupBy = NewGroupBy()\n\t\t\t\ttarget.GroupBy = append(target.GroupBy, GroupBy{Type: \"tag\", Params: []string{\"name\"}})\n\t\t\t\ttarget.GroupBy = append(target.GroupBy, GroupBy{Type: \"tag\", Params: []string{\"host\"}})\n\t\t\t\tpanel.Targets = append(panel.Targets, target)\n\t\t\t}\n\t\t}\n\t}\n\n\tif dashboard.GTime == (GTime{}) {\n\t\tdashboard.GTime = NewGTime()\n\t}\n\treturn\n\n}", "func Render(c *Doc) {\n\n\tfmt.Println(c.LatexTemplate)\n\n\tfiles, _ := filepath.Glob(\"templates/*.tex\")\n\tfmt.Println(files)\n\n\tt, err := template.New(c.LatexTemplate).Delims(\"[[\", \"]]\").ParseFiles(\"templates/\" + c.LatexTemplate,\n\t\t\"templates/partials/header.tex\", \"templates/partials/base.tex\", \"sections/main.tex\") //templates/doc\n\tcheckError(err)\n\n\t// get a file handle io.Writer object\n\tfileHandle, _ := os.Create(\"templates/output.tex\")\n\n\t// Template parameters are in doc\n\terr = t.Execute(fileHandle, c)\n\tdefer fileHandle.Close()\n\n\t// write to console also, Writer can do anything\n\t// we can write to an S3 bucket if we want or a socket\n\terr = t.Execute(os.Stdout, c)\n\n\tcheckError(err)\n}", "func outputToFile(data interface{}, outputFilePath string, templateName string) error {\n\tfile, err := os.Create(outputFilePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\tstatikFs, err := fs.New()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// ----- コンテンツテンプレート\n\ttemplateFile, err := statikFs.Open(\"/\" + templateName)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttemplateBytes, err := ioutil.ReadAll(templateFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// --------------\n\n\tfuncs := template.FuncMap{\n\t\t\"add\": func(x, y int) int {\n\t\t\treturn x + y\n\t\t},\n\t}\n\ttpl := template.Must(template.New(templateName).Funcs(funcs).Parse(string(templateBytes)))\n\n\t// HTML テンプレートを指定された場合\n\tif strings.Index(templateName, \".html\") > -1 {\n\n\t\t// ----- ヘッダーテンプレート\n\t\theaderTemplateFile, err := statikFs.Open(\"/header.tmpl.html\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\theaderTemplateBytes, err := ioutil.ReadAll(headerTemplateFile)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// --------------\n\n\t\t// ----- 共通テンプレート\n\t\tinfoTemplateFile, err := statikFs.Open(\"/information.tmpl.html\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tinfoTemplateBytes, err := ioutil.ReadAll(infoTemplateFile)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// --------------\n\t\ttplInformation := template.Must(template.New(\"information\").Funcs(funcs).Parse(string(infoTemplateBytes)))\n\t\ttplHeader := template.Must(template.New(\"information\").Funcs(funcs).Parse(string(headerTemplateBytes)))\n\t\ttpl.AddParseTree(\"information\", tplInformation.Tree)\n\t\ttpl.AddParseTree(\"header\", tplHeader.Tree)\n\t}\n\n\tinfo := map[string]interface{}{\n\t\t\"createdDate\": time.Now().Format(\"2006-01-02 15:04:05\"),\n\t}\n\td := map[string]interface{}{\n\t\t\"Data\": data,\n\t\t\"Info\": info,\n\t}\n\n\tif err = tpl.ExecuteTemplate(file, templateName, d); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func WriteTemplateToFile(tpl string, config interface{}, writepath string, filemode os.FileMode) error {\n\tvar tplbuffer bytes.Buffer\n\tvar packageTemplate = template.Must(template.New(\"\").Parse(tpl))\n\terr := packageTemplate.Execute(&tplbuffer, config)\n\tif err != nil {\n\t\tlog.Warnf(\"Unable to translate template %q to string using the data %v\", tpl, config)\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(writepath, tplbuffer.Bytes(), filemode)\n\tif err != nil {\n\t\tlog.Warnf(\"Error writing file at %s : %s\", writepath, err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func createNewTemplate(name string, namespace string, expose bool, clusterDomain string, kube kube.KymaKube) error {\n\tparams := TemplateParameters{\n\t\tName: name,\n\t\tExpose: expose,\n\t\tNamespace: namespace,\n\t\tClusterDomain: clusterDomain,\n\t}\n\n\tcurrentDir, err := filepath.Abs(filepath.Dir(os.Args[0]))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// check if folder exists\n\toutputPath := filepath.Join(currentDir, name)\n\terr = dev.EnsureDir(outputPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// iterate through files of template and create files based on parameters\n\tvar files []string\n\terr = filepath.Walk(templateFolder, func(path string, info os.FileInfo, err error) error {\n\t\tfiles = append(files, path)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Could not generate lambda\")\n\t}\n\tfor _, file := range files {\n\t\tif file != templateFolder {\n\t\t\tdev.ProcessTemplateFile(outputPath, templateFolder, file, params)\n\t\t}\n\t}\n\treturn nil\n}", "func ProcessTemplate(templateFile string, values interface{}) (string, []byte, error) {\n\tname := path.Base(templateFile)\n\tt := template.New(name).Funcs(map[string]interface{}{\n\t\t\"addURIAndSha\": func(url, tag string) string {\n\t\t\tt := struct {\n\t\t\t\tTagName string\n\t\t\t}{\n\t\t\t\tTagName: tag,\n\t\t\t}\n\t\t\tbuf := new(bytes.Buffer)\n\t\t\ttemp, err := template.New(\"url\").Parse(url)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\terr = temp.Execute(buf, t)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tlogrus.Infof(\"getting sha256 for %s\", buf.String())\n\t\t\tsha256, err := getSha256ForAsset(buf.String())\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\treturn fmt.Sprintf(`uri: %s\n sha256: %s`, buf.String(), sha256)\n\t\t},\n\t})\n\n\ttemplateObject, err := t.ParseFiles(templateFile)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tbuf := new(bytes.Buffer)\n\terr = templateObject.Execute(buf, values)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tkrewFile, err := ioutil.TempFile(\"\", \"krew-\")\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\terr = ioutil.WriteFile(krewFile.Name(), buf.Bytes(), 0644)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tprocessedTemplate := buf.Bytes()\n\tpluginName, err := krew.GetPluginName(krewFile.Name())\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\treturn pluginName, processedTemplate, nil\n}", "func CreateTemplate(oc *exutil.CLI, baseName string, ns string, configPath string, numObjects int, tuning *TuningSetType) {\n\t// Try to read the file\n\tcontent, err := ioutil.ReadFile(configPath)\n\tif err != nil {\n\t\tframework.Failf(\"Error reading file: %s\", err)\n\t}\n\n\t// ${IDENTIFER} is what we're replacing in the file\n\tregex, err := regexp.Compile(\"\\\\${IDENTIFIER}\")\n\tif err != nil {\n\t\tframework.Failf(\"Error compiling regex: %v\", err)\n\t}\n\n\tfor i := 0; i < numObjects; i++ {\n\t\tresult := regex.ReplaceAll(content, []byte(strconv.Itoa(i)))\n\n\t\ttmpfile, err := ioutil.TempFile(\"\", \"cl\")\n\t\tif err != nil {\n\t\t\te2e.Failf(\"Error creating new tempfile: %v\", err)\n\t\t}\n\t\tdefer os.Remove(tmpfile.Name())\n\n\t\tif _, err := tmpfile.Write(result); err != nil {\n\t\t\te2e.Failf(\"Error writing to tempfile: %v\", err)\n\t\t}\n\t\tif err := tmpfile.Close(); err != nil {\n\t\t\te2e.Failf(\"Error closing tempfile: %v\", err)\n\t\t}\n\n\t\terr = oc.Run(\"new-app\").Args(\"-f\", tmpfile.Name(), getNsCmdFlag(ns)).Execute()\n\t\te2e.Logf(\"%d/%d : Created template %s\", i+1, numObjects, baseName)\n\n\t\t// If there is a tuning set defined for this template\n\t\tif tuning != nil {\n\t\t\tif tuning.Templates.RateLimit.Delay != 0 {\n\t\t\t\te2e.Logf(\"Sleeping %d ms between template creation.\", tuning.Templates.RateLimit.Delay)\n\t\t\t\ttime.Sleep(time.Duration(tuning.Templates.RateLimit.Delay) * time.Millisecond)\n\t\t\t}\n\t\t\tif tuning.Templates.Stepping.StepSize != 0 && (i+1)%tuning.Templates.Stepping.StepSize == 0 {\n\t\t\t\te2e.Logf(\"We have created %d templates and are now sleeping for %d seconds\", i+1, tuning.Templates.Stepping.Pause)\n\t\t\t\ttime.Sleep(time.Duration(tuning.Templates.Stepping.Pause) * time.Second)\n\t\t\t}\n\t\t}\n\t}\n}", "func RenderTemplate(deployment Deployment) {\n\tlog.Info(\"Generating Terraform data\")\n\n\terr := os.MkdirAll(deployment.Name + \".data\", os.ModePerm)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdata, err := Asset(\"templates/\" + deployment.Provider + \".tf\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttmpl, err := template.New(\"terraform\").Parse(string(data))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfile, err := os.Create(deployment.Name + \".data/\" + deployment.Provider + \".tf\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = tmpl.Execute(file, deployment)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdata, err = Asset(\"templates/\" + deployment.Provider + \"_variables.tf\")\n\tif err == nil {\n\t\ttmpl, err = template.New(\"terraform\").Parse(string(data))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tfile, err = os.Create(deployment.Name + \".data/\" + deployment.Provider + \"variables.tf\")\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\terr = tmpl.Execute(file, deployment)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "func renderTemplate(basePath string, templateConfig *rt.TemplateConfig, config *rt.Config) error {\n\tfor _, fromTo := range templateConfig.FromTo {\n\t\tif *showOutputDir {\n\t\t\tlog.Printf(\"Rendering %s\", fromTo)\n\t\t}\n\t\ttemplateInstance, err := loadTemplate(basePath, fromTo.From)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor _, render := range templateConfig.Render {\n\t\t\terr = renderFileFromTemplate(basePath, templateInstance, *render, config, fromTo)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Failed render %s file\", fromTo.To)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (t *Template) Execute(w io.Writer, data interface{}) error {\n\n\tt.fullLock()\n\tt.Template = template.New(t.name)\n\tt.Template.Funcs(t.helpers)\n\tt.fullUnlock()\n\n\tif _, err := t.ParseFiles(); err != nil {\n\t\treturn err\n\t}\n\terr := t.Template.Execute(w, data)\n\n\treturn err\n}", "func (tg *Generate) WriteTmplToFile(filePath string, tmpl string, data interface{}) (err error) {\n\tfile, err := os.Create(filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tt := template.Must(template.New(\"toFile\").Funcs(template.FuncMap{\n\t\t\"ToLower\": func(str string) string {\n\t\t\treturn strings.ToLower(str)\n\t\t},\n\t}).Funcs(\n\t\ttemplate.FuncMap{\n\t\t\t\"Initial\": func(str string) string {\n\t\t\t\tif len(str) > 0 {\n\t\t\t\t\treturn string(strings.ToLower(str)[0])\n\t\t\t\t}\n\t\t\t\treturn \"x\"\n\t\t\t},\n\t\t}).Funcs(template.FuncMap{\n\t\t\"Counter\": func(str string) string {\n\t\t\tif s, err := strconv.Atoi(str); err == nil {\n\t\t\t\tcount := s + 1\n\t\t\t\treturn strconv.Itoa(count)\n\t\t\t}\n\t\t\treturn \"0\"\n\t\t}}).Funcs(template.FuncMap{\n\t\t\"GoType\": func(tpe string) string {\n\t\t\tif scler := tg.Scalars.GetScalar(tpe); scler != nil {\n\t\t\t\treturn scler.GoType\n\t\t\t}\n\t\t\treturn \"\"\n\t\t}}).Funcs(template.FuncMap{\n\t\t\"GrpcType\": func(tpe string) string {\n\t\t\tif scler := tg.Scalars.GetScalar(tpe); scler != nil {\n\t\t\t\treturn scler.GrpcType\n\t\t\t}\n\t\t\treturn \"\"\n\t\t}}).Funcs(template.FuncMap{\n\t\t\"GrpcArrayModel\": func(tpe string) string {\n\t\t\tss := strings.Split(tpe, \"[]\")\n\t\t\tif len(ss) > 1 {\n\t\t\t\treturn ss[1]\n\t\t\t}\n\t\t\treturn \"\"\n\t\t}}).Funcs(template.FuncMap{\n\t\t\"GoRegExFormat\": func(str string) string {\n\t\t\tif str == \"\" {\n\t\t\t\treturn \"\"\n\t\t\t}\n\t\t\tstr = strings.Trim(str, \" \")\n\t\t\t//strbuff := []byte(str)\n\t\t\tif len(str) > 2 {\n\t\t\t\t//\tstrbuff[0] = 96\n\t\t\t\t//\tstrbuff[len(strbuff)-1] = 96\n\t\t\t\tstroriginal := str\n\t\t\t\tstr = strings.Replace(str[1:len(str)-1], \"`\", `\"`+\"`\"+`\"`, -2)\n\t\t\t\treturn string(stroriginal[0]) + str + string(stroriginal[len(stroriginal)-1])\n\t\t\t}\n\t\t\treturn string(str)\n\t\t}}).Parse(tmpl))\n\terr = t.Execute(file, data)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func GeneratePackageFromFile(c *cli.Context) {\n\tfileName := c.Args().First()\n\tif &fileName == nil {\n\t\tfmt.Println(\"please input .toml file name.\")\n\t\tos.Exit(0)\n\t}\n\tuserInput := parser.Parse(fileName)\n\tgeneratePackage(userInput)\n}", "func (p *Plugin) OutputTemplate(dst io.Writer, templatePath string, data interface{}) error {\n\treturn template.Must(\n\t\ttemplate.New(path.Base(templatePath)).ParseFiles(templatePath),\n\t).Execute(dst, data)\n}", "func GenerateTestFile(testFileName string, templateValues *TemplateValues) error {\n\toutFile, err := os.Create(testFileName)\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating test file named: %s\\n\", testFileName)\n\t}\n\ttmpl := template.Must(template.New(\"out\").Parse(outputTemplate))\n\tif err := tmpl.Execute(outFile, templateValues); err != nil {\n\t\treturn err\n\t}\n\tif err := outFile.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {\r\n t, err := template.ParseFiles(tmpl + \".html\")\r\n if err != nil {\r\n http.Error(w, err.Error(), http.StatusInternalServerError)\r\n return\r\n }\r\n err = t.Execute(w, p)\r\n if err != nil {\r\n http.Error(w, err.Error(), http.StatusInternalServerError)\r\n }\r\n}", "func genTemplate(w http.ResponseWriter, tmpt string, p *Page) {\n\tt, _ := template.ParseFiles(\"templates/\" + tmpt + \".html\")\n\tt.Execute(w, p)\n}", "func applyTemplates(files []string, op string, args UserRepoArgs) error {\n\tfor _, f := range files {\n\n\t\treplaced := replaceDir(f, args)\n\n\t\t// fetch the template\n\t\ttb, err := Asset(f)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Remove the .tmpl from the suffix\n\t\tnp := filepath.Join(op, strings.TrimSuffix(replaced, \".tmpl\"))\n\n\t\t// Create the *template.Template with name f\n\t\tt, err := template.New(np).Parse(string(tb))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Create the file at path f\n\t\tf, err := os.Create(np)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Render template and write it to file\n\t\terr = t.Execute(f, args)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Printf(\"Created %s...\\n\", np)\n\t}\n\treturn nil\n}", "func RenderFileTemplate(w http.ResponseWriter, tmpl string) {\n\thead, err := template.ParseFiles(\"header.html\")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tcontent, err := template.ParseFiles(tmpl + \".html\")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tfoot, err := template.ParseFiles(\"footer.html\")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\terr = head.Execute(w, nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n\terr = content.Execute(w, nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n\terr = foot.Execute(w, nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func (templates *Templates) ExecuteTemplate(w io.Writer, name string, data interface{}) error {\n\tt := templates.templateMap[name]\n\tif t == nil {\n\t\treturn errors.New(\"Unknown template name: \" + name)\n\t}\n\n\treturn t.ExecuteTemplate(w, \"_base.template.html\", data)\n}", "func parseTemplate() {\n\tif *inputFile == \"\" {\n\t\t// no input file given\n\t\tfmt.Println(\"No input file provided!\")\n\t\tos.Exit(1)\n\t}\n\ttmpl, err := template.ParseFiles(*inputFile)\n\tif err != nil {\n\t\t// parsing error\n\t\tfmt.Printf(\"Error parsing the input file: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tinputTemplate = tmpl\n}", "func RenderTemplate(w http.ResponseWriter, templateFile string, templateData interface{}) {\n\tt, err := template.ParseFiles(templateFile, \"./templates/header.html\", \"./templates/footer.html\")\n\tif err != nil {\n\t\tlog.Printf(\"Error encountered while parsing the template: \", err)\n\t}\n\tt.Execute(w, templateData)\n}", "func ParseTemplate(filename string, data interface{}) (string, error) {\n\tt, err := template.ParseFiles(filename)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tbuf := new(bytes.Buffer)\n\tif err = t.Execute(buf, data); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn buf.String(), nil\n}", "func (app *App) ExecuteWithFile(yamlFile string, output io.Writer) error {\n\tfile, err := os.Open(yamlFile)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"yaml file\")\n\t}\n\tdefer file.Close()\n\treturn app.Execute(file, output)\n}", "func processTemplates(cfg *config.Config, templates []*tplate) ([]*tplate, error) {\n\tfor _, t := range templates {\n\t\tif t.contents == \"\" {\n\t\t\tvar in io.Reader\n\t\t\tif t.name == \"-\" {\n\t\t\t\tin = cfg.Stdin\n\t\t\t}\n\n\t\t\tb, err := t.loadContents(in)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tt.contents = string(b)\n\t\t}\n\n\t\tif t.target == nil {\n\t\t\tout, err := openOutFile(cfg, t.targetPath, 0755, t.mode, t.modeOverride)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tt.target = out\n\t\t}\n\t}\n\n\treturn templates, nil\n}", "func NewTemplateFromFile(name, file string, config *TemplateConfig) (*Template, error) {\n\tcontents, err := os.ReadFile(file)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read: %w\", err)\n\t}\n\treturn NewTemplate(name, string(contents), config)\n}", "func (util *Utils) CheckTemplateFile(path string) (string, error) {\n\tvar templates string\n\tif path == \"\" {\n\t\ttemplates = util.GetCurrentPath() + \"/guppy.yml\"\n\t} else {\n\t\ttemplates = path\n\t}\n\tif !util.CheckFile(templates) {\n\t\treturn \"\", cli.NewExitError(\"No Templates Parse\", 1)\n\t}\n\treturn templates, nil\n}", "func CreateTemplate(file string, name string) string {\n\ttmplFile := filepath.Join(directory, file)\n\ttmpl := template.Must(template.ParseFiles(tmplFile))\n\n\tvar tmplBytes bytes.Buffer\n\terr := tmpl.Execute(&tmplBytes, name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn tmplBytes.String()\n}", "func UseTemplate() {\n\tcwd, _ := os.Getwd()\n\tfileName := pickFile(TemplatesDir(), \"Choose a template to copy to the current directory\")\n\tsourceFile := filepath.Join(TemplatesDir(), fileName)\n\tdestFile := filepath.Join(cwd, fileName)\n\n\tif _, err := os.Stat(destFile); !os.IsNotExist(err) {\n\t\tshouldReplace := false\n\t\terr := survey.AskOne(\n\t\t\t&survey.Confirm{Message: \"The file already exists, do you want to overwrite it?\"},\n\t\t\t&shouldReplace,\n\t\t\tsurvey.WithValidator(survey.Required),\n\t\t)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tif shouldReplace {\n\t\t\terr = overwriteFile(sourceFile, destFile)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tlog.Printf(\"Template %q copied to current directory\\n\", fileName)\n\t\t}\n\t} else if os.IsNotExist(err) {\n\t\terr = copyFile(sourceFile, destFile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tlog.Printf(\"Template %q copied to current directory\\n\", fileName)\n\t}\n}", "func parseTemplate(filename string) *appTemplate {\n\ttmpl := template.Must(template.ParseFiles(\"templates/base.html\"))\n\n\t// Put the named file into a template called \"body\"\n\tpath := filepath.Join(\"templates\", filename)\n\tb, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tApp.Log.Errorf(\"could not read template: %v\", err)\n\t\tpanic(fmt.Errorf(\"could not read template: %v\", err))\n\t}\n\ttemplate.Must(tmpl.New(\"body\").Parse(string(b)))\n\n\treturn &appTemplate{tmpl.Lookup(\"base.html\")}\n}", "func execTemplate(c *Config, mdata metadata.Metadata, meta map[string]string, files []FileInfo, ctx httpserver.Context) ([]byte, error) {\n\tmdData := Data{\n\t\tContext: ctx,\n\t\tDoc: mdata.Variables,\n\t\tStyles: c.Styles,\n\t\tScripts: c.Scripts,\n\t\tMeta: meta,\n\t\tFiles: files,\n\t}\n\n\ttemplateName := mdata.Template\n\t// reload template on every request for now\n\t// TODO: cache templates by a general plugin\n\tif templateFile, ok := c.TemplateFiles[templateName]; ok {\n\t\terr := SetTemplate(c.Template, templateName, templateFile)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tb := new(bytes.Buffer)\n\tif err := c.Template.ExecuteTemplate(b, templateName, mdData); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b.Bytes(), nil\n}", "func (g *Generator) AddFileTemplate(t string) error {\n\ts, err := ioutil.ReadFile(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// add the template string.\n\tg.AddTemplate(string(s))\n\treturn nil\n}", "func renderTemplate(w http.ResponseWriter, p *models.Page) {\n\tlp := path.Join(\"views\", \"log.html\")\n\ttmpl, err := template.ParseFiles(lp)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\ttmpl.ExecuteTemplate(w, \"log.html\", p)\n}", "func readYamlTemplate(templateFile string, requirements *config.RequirementsConfig, svc *corev1.Service) ([]byte, error) {\n\t_, name := filepath.Split(templateFile)\n\tfuncMap := helm.NewFunctionMap()\n\ttmpl, err := template.New(name).Option(\"missingkey=error\").Funcs(funcMap).ParseFiles(templateFile)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to parse Secrets template: %s\", templateFile)\n\t}\n\n\trequirementsMap, err := requirements.ToMap()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed turn requirements into a map: %v\", requirements)\n\t}\n\n\tsvcMap, err := createServiceMap(svc)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed turn Service into a map: %v\", svc)\n\t}\n\n\ttemplateData := map[string]interface{}{\n\t\t\"Requirements\": chartutil.Values(requirementsMap),\n\t\t\"Environments\": chartutil.Values(requirements.EnvironmentMap()),\n\t\t\"Service\": chartutil.Values(svcMap),\n\t}\n\tvar buf bytes.Buffer\n\terr = tmpl.Execute(&buf, templateData)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to execute Secrets template: %s\", templateFile)\n\t}\n\tdata := buf.Bytes()\n\treturn data, nil\n}", "func (t *TemplateConfig) Write() error {\n\tfp := filepath.Join(t.ProjectPath, \"template.yml\")\n\t// make sure directory exists\n\tif _, err := os.Stat(t.ProjectPath); os.IsNotExist(err) {\n\t\tif err := os.MkdirAll(t.ProjectPath, 0755); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tyml, err := yaml.Marshal(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(fp, yml, 0644)\n}", "func generateFromTemplate(fullpath, templateName, actualTemplate string, data interface{}) {\n\tfullpath = filepath.FromSlash(fullpath)\n\tfile, err := os.Create(fullpath)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error: cannot create component file %s.\\n\"+\n\t\t\t\"The error is: %v\", fullpath, err)\n\t}\n\n\tt := template.Must(template.New(templateName).Parse(actualTemplate))\n\terr = t.Execute(file, data)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error: cannot generate from template %s.\\n\"+\n\t\t\t\"The error is: %v\", fullpath, err)\n\t}\n\n\tlog.Successf(\"Created %v\\n\", fullpath)\n}", "func ApplyTemplating(stackPath string, templateMetadata interface{}) error {\n\n\terr := filepath.Walk(stackPath, func(path string, info os.FileInfo, err error) error {\n\n\t\t//Skip .git folder\n\t\tif info.IsDir() && info.Name() == \".git\" {\n\t\t\treturn filepath.SkipDir\n\t\t} else if !info.IsDir() {\n\n\t\t\t//get file name\n\t\t\tfile := filepath.Base(path)\n\n\t\t\t// get permission of file\n\t\t\tpermission := info.Mode()\n\n\t\t\tbinaryFile, err := ioutil.ReadFile(path)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error reading file for binary test: %v\", err)\n\t\t\t}\n\n\t\t\t// skip binary files\n\t\t\tif isbinary.Test(binaryFile) {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// set file permission to writable to apply templating\n\t\t\terr = os.Chmod(path, 0666)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error changing file permision: %v\", err)\n\t\t\t}\n\n\t\t\t// create new template from parsing file\n\t\t\ttmpl, err := template.New(file).Delims(\"{{.stack\", \"}}\").ParseFiles(path)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error creating new template from file: %v\", err)\n\t\t\t}\n\n\t\t\t// open file at path\n\t\t\tf, err := os.Create(path)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error opening file: %v\", err)\n\t\t\t}\n\n\t\t\t// apply template to file\n\t\t\terr = tmpl.ExecuteTemplate(f, file, templateMetadata)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error executing template: %v\", err)\n\t\t\t}\n\n\t\t\t// set old file permission to new file\n\t\t\terr = os.Chmod(path, permission)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error reverting file permision: %v\", err)\n\t\t\t}\n\t\t\tf.Close()\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn errors.Errorf(\"Error walking through directory: %v\", err)\n\t}\n\n\treturn nil\n\n}", "func (self templateEngine) loadTemplate(name string) (t string) {\n b, err := ioutil.ReadFile(self.templateFilepath(name))\n if err == nil {\n t = string(b)\n } else {\n log.Println(\"error loading template\", err)\n t = err.Error()\n }\n return\n}", "func (app *Application) copyFile (file os.FileInfo, source, destination string) error {\n\n fileData, _ := ioutil.ReadFile (source)\n\n // detecting template and processing it\n if strings.HasSuffix (source, \".go.template\") {\n var buffer bytes.Buffer\n tmpl := template.Must (template.New (\"app\").Parse (string(fileData)))\n tmpl.Execute (&buffer, app)\n\n // overwriting file contents with data from processed template\n fileData = buffer.Bytes ()\n\n // removing tmp suffixes from file names\n destination = strings.Replace(destination, \".template\", \"\", -1)\n }\n\n if err := ioutil.WriteFile (destination, fileData, file.Mode ()); err == nil {\n fmt.Println(green, \" create:\", reset, destination)\n } else {\n return err\n }\n return nil\n}", "func MakeTemplate(tpl string) (*template.Template, error) {\n\treturn template.New(\"file\").Parse(tpl)\n}", "func (t *Template) ExecuteTemplate(w io.Writer, name string, data interface{}) error {\n\t// TODO\n\treturn nil\n}", "func LoadTemplateFile(fileName string) ([]*Label, error) {\n\tdata, err := options.Labels(fileName)\n\tif err != nil {\n\t\treturn nil, ErrTemplateLoad{fileName, fmt.Errorf(\"LoadTemplateFile: %w\", err)}\n\t}\n\n\tif strings.HasSuffix(fileName, \".yaml\") || strings.HasSuffix(fileName, \".yml\") {\n\t\treturn parseYamlFormat(fileName, data)\n\t}\n\treturn parseLegacyFormat(fileName, data)\n}", "func Run(input, output string) error {\n\n\ttmpl, err := template.ParseFiles(input)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tenv := LoadEnv()\n\tif output == \"\" {\n\t\treturn tmpl.Execute(os.Stdout, env)\n\t}\n\tf, err := os.Create(output)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not open outputfile %v\", err)\n\t}\n\tdefer f.Close()\n\n\treturn tmpl.Execute(f, env)\n}", "func ExecuteTemplate(templ string, w http.ResponseWriter, data interface{}) {\n\tt, err := template.ParseFiles(templ)\n\tif err != nil {\n\t\tlog.WithError(err).Warning(\"Could not parse template\")\n\t}\n\n\terr = t.Execute(w, data)\n\tif err != nil {\n\t\tlog.WithError(err).Warning(\"Could not execute template\")\n\t}\n}", "func LoadTemplate(filename string) (*raymond.Template, error) {\n\ttpl, err := raymond.ParseFile(filename)\n\treturn tpl, err\n}", "func BuildTemplate(dir string, files ...string) error {\n\tvar err error\n\tfs := beeTemplateFS()\n\tf, err := fs.Open(dir)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.New(\"dir open err\")\n\t}\n\tdefer f.Close()\n\n\tbeeTemplates, ok := beeViewPathTemplates[dir]\n\tif !ok {\n\t\tpanic(\"Unknown view path: \" + dir)\n\t}\n\tself := &templateFile{\n\t\troot: dir,\n\t\tfiles: make(map[string][]string),\n\t}\n\terr = Walk(fs, dir, self.visit)\n\tif err != nil {\n\t\tfmt.Printf(\"Walk() returned %v\\n\", err)\n\t\treturn err\n\t}\n\tbuildAllFiles := len(files) == 0\n\tfor _, v := range self.files {\n\t\tfor _, file := range v {\n\t\t\tif buildAllFiles || utils.InSlice(file, files) {\n\t\t\t\ttemplatesLock.Lock()\n\t\t\t\text := filepath.Ext(file)\n\t\t\t\tvar t *template.Template\n\t\t\t\tif len(ext) == 0 {\n\t\t\t\t\tt, err = getTemplate(self.root, fs, file, v...)\n\t\t\t\t} else if fn, ok := beeTemplateEngines[ext[1:]]; ok {\n\t\t\t\t\tt, err = fn(self.root, file, beegoTplFuncMap)\n\t\t\t\t} else {\n\t\t\t\t\tt, err = getTemplate(self.root, fs, file, v...)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogs.Error(\"parse template err:\", file, err)\n\t\t\t\t\ttemplatesLock.Unlock()\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbeeTemplates[file] = t\n\t\t\t\ttemplatesLock.Unlock()\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (self *WebServer) BuildTemplate(\n\tlayoutFileMap, templateFileMap map[string]string) map[string]map[string]*template.Template {\n\n\tlayoutTemplateMap := make(map[string]map[string]*template.Template)\n\n\tfor layoutName, layoutFile := range layoutFileMap {\n\t\tlayoutTemplateMap[layoutName] = make(map[string]*template.Template)\n\n\t\tfor templateName, templateFile := range templateFileMap {\n\t\t\tparsedTemplate := template.Must(template.New(\"template\").Funcs(self.customFuncMap).ParseFiles(layoutFile, templateFile))\n\n\t\t\tself.VerboseLog(\"Building template '%s:%s'\\n\", layoutName, templateName)\n\t\t\tlayoutTemplateMap[layoutName][templateName] = parsedTemplate\n\t\t}\n\t}\n\n\treturn layoutTemplateMap\n}", "func (g *Generator) loadTemplate(t *template.Template, tmplPath string) (*template.Template, error) {\n\t// Make the filepath relative to the filemap.\n\ttmplPath = g.FileMap.relative(tmplPath)[0]\n\n\t// Determine the open function.\n\treadFile := g.ReadFile\n\tif readFile == nil {\n\t\treadFile = ioutil.ReadFile\n\t}\n\n\t// Read the file.\n\tdata, err := readFile(tmplPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create a new template and parse.\n\t_, name := path.Split(tmplPath)\n\treturn t.New(name).Parse(string(data))\n}", "func (self templateEngine) templateFilepath(name string) string {\n if strings.Count(name, \"..\") > 0 {\n return \"\"\n }\n return filepath.Join(self.template_dir, name)\n}", "func (c *ConfigTemplate) Execute(args []string) error {\n\t_, err := os.Stat(c.Options.OutputDirectory)\n\tif os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"output-directory does not exist: %s\", c.Options.OutputDirectory)\n\t}\n\n\terr = c.Validate()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar userSetSizeOfCollections bool\n\tif c.Options.SizeOfCollections > 0 {\n\t\tuserSetSizeOfCollections = true\n\t} else {\n\t\tc.Options.SizeOfCollections = 10\n\t}\n\n\tmetadataSource := c.newMetadataSource()\n\tmetadataBytes, err := metadataSource.MetadataBytes()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting metadata for %s at version %s: %s\", c.Options.PivnetProductSlug, c.Options.ProductVersion, err)\n\t}\n\n\treturn generator.NewExecutor(\n\t\tmetadataBytes,\n\t\tc.Options.OutputDirectory,\n\t\tc.Options.ExcludeVersion,\n\t\ttrue,\n\t\tc.Options.SizeOfCollections,\n\t\tuserSetSizeOfCollections,\n\t).Generate()\n}", "func NewTemplate(fileName string) (*Template, error) {\n\ttmplFile, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unexpected error reading template %v\", tmplFile)\n\t}\n\ttmpl, err := text_template.New(\"gateway\").Funcs(funcMap).Parse(string(tmplFile))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Template{\n\t\ttmpl: tmpl,\n\t\tbp: NewBufferPool(defBufferSize),\n\t}, nil\n}", "func (templateManager *TemplateManager) Execute(templateName string, writer io.Writer, data interface{}) (err error) {\n\ttpl, err := templateManager.GetTemplate(templateName)\n\n\tif err == nil {\n\t\terr = tpl.Execute(writer, data)\n\t}\n\treturn\n}", "func readFile(name string, template interface{}) (interface{}, error) {\n\t// Open json file\n\tjsonFile, err := os.Open(fmt.Sprintf(\"%s/%s.json\", configsDir, name))\n\t// if os.Open returns an error then handle it\n\tif err != nil {\n\t\tlogrus.Println(err)\n\n\t\t// file is not exist, create file\n\t\tif _, ok := err.(*os.PathError); ok {\n\t\t\treturn createFile(name, template)\n\t\t}\n\n\t\treturn nil, err\n\t}\n\t//logrus.Printf(\"Successfully Opened %s.json\\n\", name)\n\t// defer the closing of json file\n\tdefer func() {\n\t\terr := jsonFile.Close()\n\t\tif err != nil {\n\t\t\tlogrus.Println(err)\n\t\t}\n\t}()\n\n\t// read opened jsonFile as a byte array.\n\tbytes, err := ioutil.ReadAll(jsonFile)\n\tif err != nil {\n\t\tlogrus.Println(err)\n\t\treturn nil, err\n\t}\n\n\t// filling the template with data from a file\n\terr = json.Unmarshal(bytes, &template)\n\tif err != nil {\n\t\tlogrus.Println(err)\n\t\treturn nil, err\n\t}\n\n\treturn template, nil\n}", "func (h *TemplateHelper) loadTemplate(name string) ([]byte, error) {\n\tpath := fmt.Sprintf(\"%s/%s.yaml\", h.TemplatePath, name)\n\ttpl, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tparser := template.New(\"application-monitoring\")\n\tparser.Funcs(template.FuncMap{\n\t\t\"JoinQuote\": joinQuote,\n\t}).Funcs(sprig.TxtFuncMap())\n\n\tparsed, err := parser.Parse(string(tpl))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar buffer bytes.Buffer\n\terr = parsed.Execute(&buffer, h.Parameters)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "func openTemplateFile() (fp *os.File, err error) {\n\tfp, err = os.Open(*templateArg)\n\treturn\n}", "func (c *Config) GenTemplate(opts interface{}, fname string) error {\n\tvar tomap map[string]interface{} = make(map[string]interface{})\n\tinnserResolve(opts, nil, nil, tomap, false)\n\treturn genTemplate(tomap, fname)\n}", "func RenderTemplate(w http.ResponseWriter, tmpl string) {\n\n\t_, err := RenderTemplateTest(w)\n\tif err != nil {\n\t\tfmt.Println(\"Error getting template cache:\", err)\n\t}\n\n\tpasredTemplate, _ := template.ParseFiles(\"./templates/\" + tmpl)\n\terr = pasredTemplate.Execute(w, nil)\n\tif err != nil {\n\t\tfmt.Println(\"Error parsing template:\", err)\n\t\treturn\n\t}\n}", "func main() {\n\terr := tpl.ExecuteTemplate(os.Stdout, \"tpl.gohtml\", nil)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}", "func (tmplEng TemplateEngine) GenerateTemplate(viewName string) (*template.Template, error) {\n\ttmpl, err := template.ParseFiles(tmplEng.ViewsPath+viewName+\".html\", tmplEng.HeaderPath, tmplEng.FooterPath, tmplEng.HeadPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn tmpl, nil\n}", "func ExecuteTemplate(wr io.Writer, name string, data interface{}) error {\n\treturn ExecuteViewPathTemplate(wr, name, BConfig.WebConfig.ViewsPath, data)\n}", "func GenerateTemplate(profile *Profile, sortedSectionList *[]SectionIndexRank, templateFile string) {\n\tswitch profile.Config.Theme.Value {\n\tcase ProfileThemes[BasicTheme]:\n\t\tgenerateTemplateBasic(profile, *sortedSectionList, templateFile)\n\n\tcase ProfileThemes[PantherTheme]:\n\t\tgenerateTemplatePanther(profile, *sortedSectionList, templateFile)\n\t}\n}", "func executeTemplate(w io.Writer, templateDefinition []byte, data interface{}) error {\n\tt, err := template.New(\"cfn\").Parse(string(templateDefinition))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn t.Execute(w, data)\n}", "func (e *ComponentStackConfig) Template() (string, error) {\n\tworkloadTemplate, err := e.box.FindString(templatePath)\n\tif err != nil {\n\t\treturn \"\", &ErrTemplateNotFound{templateLocation: templatePath, parentErr: err}\n\t}\n\n\ttemplate, err := template.New(\"template\").\n\t\tFuncs(templateFunctions).\n\t\tFuncs(sprig.FuncMap()).\n\t\tParse(workloadTemplate)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar buf bytes.Buffer\n\tif err := template.Execute(&buf, e.ComponentInput); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(buf.Bytes()), nil\n}", "func renderTemplate(w io.Writer, name string, data interface{}) {\n\tif err := templates.ExecuteTemplate(w, name+\".html\", data); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (h *TemplateHelper) loadTemplate(name string) ([]byte, error) {\n\tpath := fmt.Sprintf(\"%s/%s.yaml\", h.TemplatePath, name)\n\ttpl, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tparser := template.New(\"application-monitoring\")\n\tparser.Funcs(template.FuncMap{\n\t\t\"JoinQuote\": joinQuote,\n\t})\n\n\tparsed, err := parser.Parse(string(tpl))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar buffer bytes.Buffer\n\terr = parsed.Execute(&buffer, h.Parameters)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}" ]
[ "0.7149074", "0.67122024", "0.6695799", "0.6583514", "0.64977914", "0.6476879", "0.63664204", "0.63381994", "0.62933046", "0.62473583", "0.6188287", "0.6182314", "0.6150731", "0.6140894", "0.6135779", "0.6125098", "0.6113959", "0.608692", "0.60588443", "0.60361314", "0.5984917", "0.59767723", "0.5916298", "0.5912567", "0.5896214", "0.5878803", "0.58747005", "0.58633626", "0.5840291", "0.58330256", "0.58265907", "0.5810123", "0.580844", "0.58038515", "0.57919586", "0.5774449", "0.57729477", "0.57728624", "0.57695687", "0.57661927", "0.57416975", "0.57288074", "0.572675", "0.5723783", "0.57222664", "0.5720823", "0.56998384", "0.56929153", "0.56808686", "0.5680015", "0.5678159", "0.5677983", "0.5676016", "0.5664905", "0.56421477", "0.5639161", "0.56332994", "0.5633246", "0.5629713", "0.56283396", "0.5628319", "0.56241137", "0.56227374", "0.5622358", "0.56129533", "0.56077605", "0.5604186", "0.55802304", "0.5570284", "0.55551565", "0.55524015", "0.5544891", "0.553136", "0.5530917", "0.5515233", "0.55088055", "0.5507529", "0.55003524", "0.54997736", "0.5499672", "0.54974496", "0.5494444", "0.5492646", "0.5488757", "0.54835975", "0.5482681", "0.5481273", "0.5480969", "0.54804975", "0.5470725", "0.54660004", "0.54640543", "0.5450605", "0.5448834", "0.54426974", "0.5437113", "0.5435911", "0.5432584", "0.5426797", "0.5423831" ]
0.8018812
0
templateDir runs through a directory recursively templating every file on the way down in the tree
func (t *templater) templateDir(workDir string, outDir string, d map[string]interface{}) { log.Info("templating", "dir", workDir) err := os.Mkdir(outDir, 0755) if err != nil && !os.IsExist(err) { log.Error(err, "Failed to create output dir") return } files, err := ioutil.ReadDir(workDir) if err != nil { log.Error(err, "Failed to read dir") } for _, file := range files { if file.IsDir() { t.templateDir(workDir+"/"+file.Name(), outDir+"/"+file.Name(), d) } else { t.templateFile(workDir, outDir, file, d) } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func setupTemplates(folder string) error {\n\n\tcontents, err := ioutil.ReadDir(folder)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar files []string\n\n\tfor _, file := range contents {\n\t\tfull_name := file.Name()\n\t\tfiles = append(files, filepath.Join(folder, full_name))\n\t}\n\n\tvar temperr error\n\n\ttemplates, temperr = ParseFiles(files...)\n\n\tif temperr != nil {\n\t\treturn temperr\n\t}\n\n\treturn nil\n}", "func BuildTemplate(dir string, files ...string) error {\n\tif _, err := os.Stat(dir); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.New(\"dir open err\")\n\t}\n\tself := &templateFile{\n\t\troot: dir,\n\t\tfiles: make(map[string][]string),\n\t}\n\terr := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {\n\t\treturn self.visit(path, f, err)\n\t})\n\tif err != nil {\n\t\tfmt.Printf(\"filepath.Walk() returned %v\\n\", err)\n\t\treturn err\n\t}\n\tbuildAllFiles := len(files) == 0\n\tfor _, v := range self.files {\n\t\tfor _, file := range v {\n\t\t\tif buildAllFiles || yeestrings.IsInSlice(files, file) {\n\t\t\t\ttemplatesLock.Lock()\n\t\t\t\text := filepath.Ext(file)\n\t\t\t\tvar t *template.Template\n\t\t\t\tif len(ext) == 0 {\n\t\t\t\t\tt, err = getTemplate(self.root, file, v...)\n\t\t\t\t} else {\n\t\t\t\t\tt, err = getTemplate(self.root, file, v...)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t} else {\n\t\t\t\t\tcacheTemplates[file] = t\n\t\t\t\t}\n\t\t\t\ttemplatesLock.Unlock()\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (t *Repository) LoadDir(templatePath string) error {\n\terr := filepath.Walk(templatePath, func(path string, info os.FileInfo, err error) error {\n\n\t\tif strings.HasSuffix(path, \".gotmpl\") {\n\t\t\tif assetName, e := filepath.Rel(templatePath, path); e == nil {\n\t\t\t\tif data, e := ioutil.ReadFile(path); e == nil {\n\t\t\t\t\tif ee := t.AddFile(assetName, string(data)); ee != nil {\n\t\t\t\t\t\t// Fatality is decided by caller\n\t\t\t\t\t\t// log.Fatal(ee)\n\t\t\t\t\t\treturn fmt.Errorf(\"could not add template: %v\", ee)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Non-readable files are skipped\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Non-template files are skipped\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not complete template processing in directory \\\"%s\\\": %v\", templatePath, err)\n\t}\n\treturn nil\n}", "func walkTemplatesPath(path string, fileInfo os.FileInfo, err error) error {\n\n\t// if the current fileInfo is not a directory\n\tif fileInfo.IsDir() == false {\n\n\t\t// check that path exists\n\t\tfile, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// read the contents of the file\n\t\tfileContents, err := ioutil.ReadAll(file)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfile.Close()\n\n\t\t// clone the base template\n\t\tcontent := template.Must(layout.Clone())\n\t\tcontent.Funcs(timestampFM())\n\t\tcontent.Funcs(permissionFM(nil))\n\n\t\t// merge the base template and fileContents\n\t\t_, err = content.Parse(string(fileContents))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// add the merged content to the templates map\n\t\ttemplates[fileInfo.Name()] = content\n\n\t\tlog.Printf(\"INFO > controllers/controllers.go > walkTemplatesPath(): - %s\", fileInfo.Name())\n\t}\n\n\treturn nil\n}", "func loadTemplates(dir string) (multitemplate.Renderer, error) {\n\tr := multitemplate.NewRenderer()\n\tbase, err := filepath.Glob(dir + \"/*.html\")\n\tif err != nil {\n\t\treturn r, err\n\t}\n\n\tpages, err := filepath.Glob(\"templates/pages/*.html\")\n\tif err != nil {\n\t\treturn r, err\n\t}\n\n\tfor _, page := range pages {\n\t\ttemplates := make([]string, len(base))\n\t\tcopy(templates, base)\n\t\ttemplates = append(templates, page)\n\t\tr.AddFromFiles(filepath.Base(page), templates...)\n\t}\n\n\treturn r, nil\n}", "func Templates(basepath string) (messages []Message) {\n\tmessages = []Message{}\n\tpath := filepath.Join(basepath, \"templates\")\n\tif fi, err := os.Stat(path); err != nil {\n\t\tmessages = append(messages, Message{Severity: WarningSev, Text: \"No templates\"})\n\t\treturn\n\t} else if !fi.IsDir() {\n\t\tmessages = append(messages, Message{Severity: ErrorSev, Text: \"'templates' is not a directory\"})\n\t\treturn\n\t}\n\n\ttpl := template.New(\"tpl\").Funcs(sprig.TxtFuncMap())\n\n\terr := filepath.Walk(basepath, func(name string, fi os.FileInfo, e error) error {\n\t\t// If an error is returned, we fail. Non-fatal errors should just be\n\t\t// added directly to messages.\n\t\tif e != nil {\n\t\t\treturn e\n\t\t}\n\t\tif fi.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\tdata, err := ioutil.ReadFile(name)\n\t\tif err != nil {\n\t\t\tmessages = append(messages, Message{\n\t\t\t\tSeverity: ErrorSev,\n\t\t\t\tText: fmt.Sprintf(\"cannot read %s: %s\", name, err),\n\t\t\t})\n\t\t\treturn nil\n\t\t}\n\n\t\t// An error rendering a file should emit a warning.\n\t\tnewtpl, err := tpl.Parse(string(data))\n\t\tif err != nil {\n\t\t\tmessages = append(messages, Message{\n\t\t\t\tSeverity: ErrorSev,\n\t\t\t\tText: fmt.Sprintf(\"error processing %s: %s\", name, err),\n\t\t\t})\n\t\t\treturn nil\n\t\t}\n\t\ttpl = newtpl\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tmessages = append(messages, Message{Severity: ErrorSev, Text: err.Error()})\n\t}\n\n\treturn\n}", "func walkDir(dir string, outFileNamer func(string) (string, error), excludeGlob []string, mode os.FileMode, modeOverride bool) ([]*tplate, error) {\n\tdir = filepath.Clean(dir)\n\n\tdirStat, err := fs.Stat(dir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't stat %s: %w\", dir, err)\n\t}\n\tdirMode := dirStat.Mode()\n\n\ttemplates := make([]*tplate, 0)\n\tmatcher := xignore.NewMatcher(fs)\n\n\t// work around bug in xignore - a basedir of '.' doesn't work\n\tbasedir := dir\n\tif basedir == \".\" {\n\t\tbasedir, _ = os.Getwd()\n\t}\n\tmatches, err := matcher.Matches(basedir, &xignore.MatchesOptions{\n\t\tIgnorefile: gomplateignore,\n\t\tNested: true, // allow nested ignorefile\n\t\tAfterPatterns: excludeGlob,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ignore matching failed for %s: %w\", basedir, err)\n\t}\n\n\t// Unmatched ignorefile rules's files\n\tfiles := matches.UnmatchedFiles\n\tfor _, file := range files {\n\t\tnextInPath := filepath.Join(dir, file)\n\t\tnextOutPath, err := outFileNamer(file)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfMode := mode\n\t\tif mode == 0 {\n\t\t\tstat, perr := fs.Stat(nextInPath)\n\t\t\tif perr == nil {\n\t\t\t\tfMode = stat.Mode()\n\t\t\t} else {\n\t\t\t\tfMode = dirMode\n\t\t\t}\n\t\t}\n\n\t\t// Ensure file parent dirs\n\t\tif err = fs.MkdirAll(filepath.Dir(nextOutPath), dirMode); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttemplates = append(templates, &tplate{\n\t\t\tname: nextInPath,\n\t\t\ttargetPath: nextOutPath,\n\t\t\tmode: fMode,\n\t\t\tmodeOverride: modeOverride,\n\t\t})\n\t}\n\n\treturn templates, nil\n}", "func renderTemplate(basePath string, templateConfig *rt.TemplateConfig, config *rt.Config) error {\n\tfor _, fromTo := range templateConfig.FromTo {\n\t\tif *showOutputDir {\n\t\t\tlog.Printf(\"Rendering %s\", fromTo)\n\t\t}\n\t\ttemplateInstance, err := loadTemplate(basePath, fromTo.From)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor _, render := range templateConfig.Render {\n\t\t\terr = renderFileFromTemplate(basePath, templateInstance, *render, config, fromTo)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Failed render %s file\", fromTo.To)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func FindAndParseTemplates(rootDir, ext string, funcMap template.FuncMap) (*template.Template, error) {\n\tcleanRoot := filepath.Clean(rootDir)\n\tpfx := len(cleanRoot) + 1\n\troot := template.New(\"\")\n\n\terr := filepath.Walk(cleanRoot, func(path string, info os.FileInfo, e1 error) error {\n\t\tif !info.IsDir() && strings.HasSuffix(path, ext) {\n\t\t\tif e1 != nil {\n\t\t\t\treturn e1\n\t\t\t}\n\n\t\t\tb, e2 := ioutil.ReadFile(path)\n\t\t\tif e2 != nil {\n\t\t\t\treturn e2\n\t\t\t}\n\n\t\t\tname := path[pfx:]\n\t\t\tt := root.New(name).Funcs(funcMap)\n\t\t\t_, e2 = t.Parse(string(b))\n\t\t\tif e2 != nil {\n\t\t\t\treturn e2\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn root, err\n}", "func CopyTemplateDir(boxed, to string, templateData interface{}) {\n\tvar files []string\n\terr := filepath.Walk(boxed, func(path string, info os.FileInfo, err error) error {\n\t\tfiles = append(files, path)\n\t\treturn nil\n\t})\n\tfiles = files[1:]\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to list files in directory %s: %v\\n\", boxed, err)\n\t\tos.Exit(1)\n\t}\n\tfor _, file := range files {\n\t\tnewFile := filepath.Join(to, strings.Join(strings.Split(file, \"\")[len(boxed)+1:], \"\"))\n\t\ttmplFile, err := template.New(\"\").Option(\"missingkey=error\").Parse(newFile)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Failed to parse template string: %v\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tvar tmplBytes bytes.Buffer\n\t\terr = tmplFile.Execute(&tmplBytes, templateData)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tnewFile = tmplBytes.String()\n\t\tfi, err := os.Stat(file)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\tswitch mode := fi.Mode(); {\n\t\tcase mode.IsDir():\n\t\t\terr := os.MkdirAll(newFile, 0755)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Failed to create directory %s: %v\\n\", newFile, err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\tcase mode.IsRegular():\n\t\t\tif strings.HasSuffix(newFile, \".tmpl\") {\n\t\t\t\tnewFile = strings.TrimSuffix(newFile, \".tmpl\")\n\t\t\t}\n\t\t\tExecuteTemplateFromFile(file, newFile, templateData)\n\t\t}\n\t}\n}", "func BuildTemplate(dir string, files ...string) error {\n\tvar err error\n\tfs := beeTemplateFS()\n\tf, err := fs.Open(dir)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.New(\"dir open err\")\n\t}\n\tdefer f.Close()\n\n\tbeeTemplates, ok := beeViewPathTemplates[dir]\n\tif !ok {\n\t\tpanic(\"Unknown view path: \" + dir)\n\t}\n\tself := &templateFile{\n\t\troot: dir,\n\t\tfiles: make(map[string][]string),\n\t}\n\terr = Walk(fs, dir, self.visit)\n\tif err != nil {\n\t\tfmt.Printf(\"Walk() returned %v\\n\", err)\n\t\treturn err\n\t}\n\tbuildAllFiles := len(files) == 0\n\tfor _, v := range self.files {\n\t\tfor _, file := range v {\n\t\t\tif buildAllFiles || utils.InSlice(file, files) {\n\t\t\t\ttemplatesLock.Lock()\n\t\t\t\text := filepath.Ext(file)\n\t\t\t\tvar t *template.Template\n\t\t\t\tif len(ext) == 0 {\n\t\t\t\t\tt, err = getTemplate(self.root, fs, file, v...)\n\t\t\t\t} else if fn, ok := beeTemplateEngines[ext[1:]]; ok {\n\t\t\t\t\tt, err = fn(self.root, file, beegoTplFuncMap)\n\t\t\t\t} else {\n\t\t\t\t\tt, err = getTemplate(self.root, fs, file, v...)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogs.Error(\"parse template err:\", file, err)\n\t\t\t\t\ttemplatesLock.Unlock()\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbeeTemplates[file] = t\n\t\t\t\ttemplatesLock.Unlock()\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func checkDir(relativePath string, pOpt *ParseOptions, isNonBase bool) {\n\tvar files []os.FileInfo\n\tvar err error\n\n\tfiles, err = ioutil.ReadDir(relativePath)\n\n\t// If there is an error: PANIC!\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Iterate all found files and folders\n\tfor _, file := range files {\n\t\t// Extract the filename without extension\n\t\tfilename := strings.Split(file.Name(), \".\")[0]\n\t\thasChildren := checkIfHasChildren(pOpt, filename, files)\n\n\t\t// Check for inheritance marked by \"-\"\n\t\tif strings.Contains(filename, pOpt.Delimiter) && !file.IsDir() && !hasChildren {\n\t\t\t// Split the filename\n\t\t\tpartialTmpl := strings.Split(filename, pOpt.Delimiter)\n\t\t\trebuildTmpl := make([]string, len(partialTmpl))\n\n\t\t\t// Rename the strings correctly\n\t\t\t// Like: views/index.html && views/index-login.html\n\t\t\t// So index-login.html inherits from index.html\n\t\t\t// and index.html inherits from base.html\n\t\t\tfor i, _ := range partialTmpl {\n\t\t\t\tvar parent string\n\t\t\t\tfor j := 0; j <= i; j++ {\n\t\t\t\t\tif j == i {\n\t\t\t\t\t\tparent += partialTmpl[j]\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparent += partialTmpl[j] + pOpt.Delimiter\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\trebuildTmpl[i] = createPathToView(relativePath, parent, true, pOpt)\n\t\t\t}\n\n\t\t\t// Saving the templates like e.g.:\n\t\t\t// index.html inherits from base.html: templates[\"#index\"]\n\t\t\t// index-login.html inherits from index.html ...: templates[\"#index.login\"]\n\t\t\t// index-login-special.html inherits from index-login.html ...: templates[\"#login.special\"]\n\t\t\t// In NonBase, the '#' dissapears (doesn't extends base), like: templates[\"superspecial\"] for views/nonbase/superspecial.html\n\t\t\tif !isNonBase {\n\t\t\t\ttemplates[\"#\"+partialTmpl[len(partialTmpl)-2]+\".\"+partialTmpl[len(partialTmpl)-1]] = createInheritedTemplate(pOpt, true, rebuildTmpl...)\n\t\t\t} else if isNonBase && len(partialTmpl) == 2 {\n\t\t\t\ttemplates[partialTmpl[0]+\".\"+partialTmpl[1]] = createInheritedTemplate(pOpt, false, rebuildTmpl...)\n\t\t\t} else if isNonBase && len(partialTmpl) > 2 {\n\t\t\t\ttemplates[partialTmpl[0]+\".\"+partialTmpl[len(partialTmpl)-2]+\".\"+partialTmpl[len(partialTmpl)-1]] = createInheritedTemplate(pOpt, false, rebuildTmpl...)\n\t\t\t}\n\n\t\t} else if !file.IsDir() && !hasChildren {\n\t\t\t// Add template with inheritance\n\t\t\tif filename != pOpt.BaseName {\n\t\t\t\tif !isNonBase {\n\t\t\t\t\ttemplates[\"#\"+filename] = createInheritedTemplate(pOpt, true, createPathToView(relativePath, file.Name(), false, pOpt))\n\t\t\t\t} else {\n\t\t\t\t\ttemplates[filename] = createInheritedTemplate(pOpt, false, createPathToView(relativePath, file.Name(), false, pOpt))\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else if file.IsDir() && file.Name() == pOpt.NonBaseFolder {\n\t\t\t// Check if entering NonBase Folder\n\t\t\tcheckDir(filepath.Join(relativePath, file.Name()), pOpt, true)\n\n\t\t} else if file.IsDir() {\n\t\t\t// Check subfolder the same way.\n\t\t\tcheckDir(filepath.Join(relativePath, file.Name()), pOpt, isNonBase)\n\t\t}\n\t}\n}", "func parseTemplates() (){\n templates = make(map[string]*template.Template)\n if files, err := ioutil.ReadDir(CONFIG.TemplatesDir) ; err != nil {\n msg := \"Error reading templates directory: \" + err.Error()\n log.Fatal(msg)\n } else {\n for _, f := range files {\n fmt.Println(f.Name())\n err = nil\n\n tpl, tplErr := template.New(f.Name()).Funcs(template.FuncMap{\n \"humanDate\": humanDate,\n \"humanSize\": humanSize,}).ParseFiles(CONFIG.TemplatesDir + \"/\" + f.Name())\n if tplErr != nil {\n log.Fatal(\"Error parsing template: \" + tplErr.Error())\n } else {\n templates[f.Name()] = tpl\n }\n }\n }\n return\n}", "func SetupTemplates(cfg chef.ServerConfig) ([]string, error) {\n\tfiles := make([]string, 0)\n\tlog.Debug().Msg(\"setting up templates\")\n\n\tlog.Debug().Msg(\"cleaning output directory\")\n\t// clean static output dir\n\terr := os.RemoveAll(TemplateOutputDir)\n\tif err != nil {\n\t\treturn nil,\n\t\t\tfmt.Errorf(\"error cleaning ouput directory %v : %w\", TemplateOutputDir, err)\n\t}\n\n\tlog.Debug().Str(\"OutputDir\", TemplateOutputDir).Msg(\"creating new output directories\")\n\t// Create/ensure output directory\n\tif err = EnsureDir(TemplateOutputDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create subdirs\n\thtmlOutputDir := filepath.Join(TemplateOutputDir, \"html\")\n\tif err = EnsureDir(htmlOutputDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\tjsOutputDir := filepath.Join(TemplateOutputDir, \"js\")\n\tif err = EnsureDir(jsOutputDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\tcssOutputDir := filepath.Join(TemplateOutputDir, \"css\")\n\tif err = EnsureDir(cssOutputDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\ttsOutputDir := filepath.Join(TemplateOutputDir, \"src\")\n\tif err = EnsureDir(tsOutputDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\timgOutputDir := filepath.Join(TemplateOutputDir, \"img\")\n\tif err = EnsureDir(imgOutputDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\tmiscFilesOutputDir := filepath.Join(TemplateOutputDir, \"files\")\n\tif err = EnsureDir(miscFilesOutputDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Debug().Str(\"BaseDir\", TemplateBaseDir).Msg(\"ensuring template base directory exists\")\n\t// Ensure base template directory exists\n\tif !Exists(TemplateBaseDir) {\n\t\treturn nil,\n\t\t\tfmt.Errorf(\"base Dir %v does not exist\", TemplateBaseDir)\n\t}\n\n\t// walk through all files in the template resource dir\n\terr = filepath.Walk(TemplateBaseDir,\n\t\tfunc(path string, info os.FileInfo, err error) error {\n\t\t\t// skip certain directories\n\t\t\tif info.IsDir() && info.Name() == \"node_modules\" {\n\t\t\t\treturn filepath.SkipDir\n\t\t\t}\n\n\t\t\thandleCopyFileErr := func(err error) {\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatal().Err(err).Msg(\"error copying file\")\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thandleExecuteTemlateErr := func(err error) {\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatal().Err(err).Msg(\"error executing HTML template\")\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch filepath.Ext(path) {\n\t\t\tcase \".html\":\n\t\t\t\tnewPath := filepath.Join(htmlOutputDir, filepath.Base(path))\n\t\t\t\tlog.Debug().Str(\"fromPath\", path).Str(\"toPath\", newPath).Msg(\"moving static web resources\")\n\t\t\t\thandleExecuteTemlateErr(ExecuteTemplateHTML(cfg, path, newPath))\n\t\t\tcase \".js\", \".map\":\n\t\t\t\tnewPath := filepath.Join(jsOutputDir, filepath.Base(path))\n\t\t\t\tif filepath.Base(path) == \"serviceWorker.js\" || filepath.Base(path) == \"serviceWorker.js.map\" {\n\t\t\t\t\tnewPath = filepath.Join(\"./\", filepath.Base(path))\n\t\t\t\t}\n\t\t\t\tlog.Debug().Str(\"fromPath\", path).Str(\"toPath\", newPath).Msg(\"moving static web resources\")\n\t\t\t\thandleCopyFileErr(CopyFile(path, newPath))\n\t\t\tcase \".css\":\n\t\t\t\tnewPath := filepath.Join(cssOutputDir, filepath.Base(path))\n\t\t\t\tlog.Debug().Str(\"fromPath\", path).Str(\"toPath\", newPath).Msg(\"moving static web resources\")\n\t\t\t\thandleCopyFileErr(CopyFile(path, newPath))\n\t\t\tcase \".ts\":\n\t\t\t\tnewPath := filepath.Join(tsOutputDir, filepath.Base(path))\n\t\t\t\tlog.Debug().Str(\"fromPath\", path).Str(\"toPath\", newPath).Msg(\"moving static web resources\")\n\t\t\t\thandleCopyFileErr(CopyFile(path, newPath))\n\t\t\tcase \".ico\", \".png\", \".jpg\", \".svg\", \".gif\":\n\t\t\t\tnewPath := filepath.Join(imgOutputDir, filepath.Base(path))\n\t\t\t\tlog.Debug().Str(\"fromPath\", path).Str(\"toPath\", newPath).Msg(\"moving static web resources\")\n\t\t\t\thandleCopyFileErr(CopyFile(path, newPath))\n\t\t\tcase \".pdf\", \".doc\", \".docx\", \".xml\":\n\t\t\t\tnewPath := filepath.Join(miscFilesOutputDir, filepath.Base(path))\n\t\t\t\tlog.Debug().Str(\"fromPath\", path).Str(\"toPath\", newPath).Msg(\"moving static web resources\")\n\t\t\t\thandleCopyFileErr(CopyFile(path, newPath))\n\t\t\t}\n\n\t\t\treturn nil\n\t\t})\n\tif err != nil {\n\t\treturn nil,\n\t\t\tfmt.Errorf(\"error walking %v : %w\", TemplateBaseDir, err)\n\t}\n\n\tlog.Debug().Msg(\"template setup complete.\")\n\treturn files, nil\n}", "func (t *Tmpl) LoadTemplates(dir string) error {\n\t// Lock mutex\n\tt.rw.Lock()\n\tdefer t.rw.Unlock()\n\n\t// Walk over the views directory\n\terr := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {\n\n\t\t// Check for walking error\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Check if file has .html extension\n\t\tif strings.HasSuffix(info.Name(), \".html\") {\n\t\t\tif t.Tmpl, err = t.Tmpl.ParseFiles(path); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn err\n}", "func gatherTemplates(cfg *config.Config, outFileNamer func(string) (string, error)) (templates []*tplate, err error) {\n\tmode, modeOverride, err := cfg.GetMode()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch {\n\t// the arg-provided input string gets a special name\n\tcase cfg.Input != \"\":\n\t\ttemplates = []*tplate{{\n\t\t\tname: \"<arg>\",\n\t\t\tcontents: cfg.Input,\n\t\t\tmode: mode,\n\t\t\tmodeOverride: modeOverride,\n\t\t\ttargetPath: cfg.OutputFiles[0],\n\t\t}}\n\tcase cfg.InputDir != \"\":\n\t\t// input dirs presume output dirs are set too\n\t\ttemplates, err = walkDir(cfg.InputDir, outFileNamer, cfg.ExcludeGlob, mode, modeOverride)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase cfg.Input == \"\":\n\t\ttemplates = make([]*tplate, len(cfg.InputFiles))\n\t\tfor i := range cfg.InputFiles {\n\t\t\ttemplates[i], err = fileToTemplates(cfg.InputFiles[i], cfg.OutputFiles[i], mode, modeOverride)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn processTemplates(cfg, templates)\n}", "func LoadTemplates(dir string, basefile string) (*Templates, error) {\n\tt := &Templates{BaseDir: dir, BaseFile: basefile}\n\treturn t, t.Scan()\n}", "func (t *Tmpl) LoadTemplates(dir string) error {\n\t// Lock mutex\n\tt.rw.Lock()\n\tdefer t.rw.Unlock()\n\n\t// Walk over the views directory\n\terr := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {\n\n\t\t// Check if file has .html extension\n\t\tif strings.HasSuffix(info.Name(), \".html\") {\n\t\t\tif t.Tmpl, err = t.Tmpl.ParseFiles(path); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn err\n}", "func (e *Engine) BuildTemplates() error {\n\tif e.Config.Extensions == nil || len(e.Config.Extensions) == 0 {\n\t\te.Config.Extensions = []string{\".html\"}\n\t}\n\n\t// register the global helpers\n\tif e.Config.Handlebars.Helpers != nil {\n\t\traymond.RegisterHelpers(e.Config.Handlebars.Helpers)\n\t}\n\n\t// the render works like {{ render \"myfile.html\" theContext.PartialContext}}\n\t// instead of the html/template engine which works like {{ render \"myfile.html\"}} and accepts the parent binding, with handlebars we can't do that because of lack of runtime helpers (dublicate error)\n\traymond.RegisterHelper(\"render\", func(partial string, binding interface{}) raymond.SafeString {\n\t\tcontents, err := e.executeTemplateBuf(partial, binding)\n\t\tif err != nil {\n\t\t\treturn raymond.SafeString(\"Template with name: \" + partial + \" couldn't not be found.\")\n\t\t}\n\t\treturn raymond.SafeString(contents)\n\t})\n\n\tvar templateErr error\n\n\tdir := e.Config.Directory\n\tfilepath.Walk(dir, func(path string, info os.FileInfo, err error) error {\n\t\tif info == nil || info.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\trel, err := filepath.Rel(dir, path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\text := \"\"\n\t\tif strings.Index(rel, \".\") != -1 {\n\t\t\text = filepath.Ext(rel)\n\t\t}\n\n\t\tfor _, extension := range e.Config.Extensions {\n\t\t\tif ext == extension {\n\n\t\t\t\tbuf, err := ioutil.ReadFile(path)\n\t\t\t\tcontents := string(buf)\n\n\t\t\t\tif err != nil {\n\t\t\t\t\ttemplateErr = err\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tname := filepath.ToSlash(rel)\n\n\t\t\t\ttmpl, err := raymond.Parse(contents)\n\t\t\t\tif err != nil {\n\t\t\t\t\ttemplateErr = err\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\te.mu.Lock()\n\t\t\t\te.templateCache[name] = tmpl\n\t\t\t\te.mu.Unlock()\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\treturn templateErr\n\n}", "func LintWorkflowTemplateDir(wfClientset wfclientset.Interface, namespace, dirPath string, strict bool) error {\n\twalkFunc := func(path string, info os.FileInfo, err error) error {\n\t\tif info == nil || info.IsDir() {\n\t\t\treturn nil\n\t\t}\n\t\tfileExt := filepath.Ext(info.Name())\n\t\tswitch fileExt {\n\t\tcase \".yaml\", \".yml\", \".json\":\n\t\tdefault:\n\t\t\treturn nil\n\t\t}\n\t\treturn LintWorkflowTemplateFile(wfClientset, namespace, path, strict)\n\t}\n\treturn filepath.Walk(dirPath, walkFunc)\n}", "func (self templateEngine) templateFilepath(name string) string {\n if strings.Count(name, \"..\") > 0 {\n return \"\"\n }\n return filepath.Join(self.template_dir, name)\n}", "func prepareTemplates(templatedir string, fn ...string) (t *template.Template) {\n\tvar files []string\n\tfor _, file := range fn {\n\t\tfiles = append(files, fmt.Sprintf(\"%s/%s.html\", templatedir, file))\n\t}\n\tt = template.Must(template.ParseFiles(files...))\n\treturn\n}", "func joinTemplateDir(filenames ...string) []string {\n\trs := make([]string, len(filenames))\n\tfor i, x := range filenames {\n\t\trs[i] = filepath.Join(templateDir, x) + \".tmpl\"\n\t}\n\treturn rs\n}", "func Template(paths ...string) (templates []*template.Template, err error) {\n\twatcher, err := fsnotify.NewWatcher()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer watcher.Close()\n\tfor i, path := range paths {\n\t\ttemplates[i], err = template.ParseFiles(path)\n\t}\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase event, ok := <-watcher.Events:\n\t\t\t\tif !ok {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tlog.Println(\"Event:\", event)\n\t\t\t\tfor i, path := range paths {\n\t\t\t\t\ttemplates[i], err = template.ParseFiles(path)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t}\n\t\t\t\tlog.Println(\"Updated templates\")\n\t\t\tcase err, ok := <-watcher.Errors:\n\t\t\t\tif !ok {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t}\n\t}()\n\n\tfor _, path := range paths {\n\t\terr = watcher.Add(path)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn nil, nil\n}", "func FindTemplates(root, base string) (map[string]TemplateLoader, error) {\n\ttemplates := make(map[string]TemplateLoader)\n\trootBase := filepath.Join(root, base)\n\terr := filepath.Walk(rootBase, func(path string, fi os.FileInfo, err error) error {\n\t\tif fi.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\text := filepath.Ext(path)\n\t\tif ext != \".tpl\" {\n\t\t\treturn nil\n\t\t}\n\n\t\trelative, err := filepath.Rel(root, path)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"could not find relative path to base root: %s\", rootBase)\n\t\t}\n\n\t\trelative = strings.TrimLeft(relative, string(os.PathSeparator))\n\t\ttemplates[relative] = FileLoader(path)\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn templates, nil\n}", "func applyTemplates(files []string, op string, args UserRepoArgs) error {\n\tfor _, f := range files {\n\n\t\treplaced := replaceDir(f, args)\n\n\t\t// fetch the template\n\t\ttb, err := Asset(f)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Remove the .tmpl from the suffix\n\t\tnp := filepath.Join(op, strings.TrimSuffix(replaced, \".tmpl\"))\n\n\t\t// Create the *template.Template with name f\n\t\tt, err := template.New(np).Parse(string(tb))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Create the file at path f\n\t\tf, err := os.Create(np)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Render template and write it to file\n\t\terr = t.Execute(f, args)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Printf(\"Created %s...\\n\", np)\n\t}\n\treturn nil\n}", "func GenerateTemplates() error {\n\n\t// ensure qtc is available\n\tif err := exsh.EnsureGoBin(\"qtc\", \"github.com/valyala/quicktemplate/qtc\"); err != nil {\n\t\treturn err\n\t}\n\n\t// run qtc command\n\tif err := sh.Run(\"qtc\", \"-dir=\"+templateDir, \"-skipLineComments\"); err != nil {\n\t\treturn err\n\t}\n\n\t// move templates from templateDir to the corresponding location in ./internal/pages\n\terr := filepath.Walk(\n\t\ttemplateDir,\n\t\tfunc(filename string, info os.FileInfo, err error) error {\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif strings.HasSuffix(filename, \".qtpl.go\") {\n\t\t\t\tnewFilename := strings.Replace(filename, templateDir, generatedTemplatesOutputDir, 1)\n\n\t\t\t\tif mg.Verbose() {\n\t\t\t\t\tfmt.Printf(\"Moving %s to %s\\n\", filename, newFilename)\n\t\t\t\t}\n\n\t\t\t\tif err := sh.Copy(newFilename, filename); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn sh.Rm(filename)\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t)\n\n\treturn err\n}", "func loadTemplates() {\n\n\tfmt.Println(\"About to load templates\")\n\n\t// get layouts\n\tlayouts, err := filepath.Glob(\"templates/layouts/*.layout\")\n\tpanicOnError(err)\n\n\t// get list of main pages\n\tpages, err := filepath.Glob(\"templates/pages/*.html\")\n\tpanicOnError(err)\n\n\tfor _, page := range pages {\n\t\tfiles := append(layouts, page)\n\t\ttemplateName := filepath.Base(page)\n\n\t\tnewTemplate := template.Must(template.ParseFiles(files...))\n\t\tnewTemplate.Option(\"missingkey=default\")\n\n\t\tappTemplates[templateName] = newTemplate\n\t}\n\n\t// loaded templates\n\tfor file, _ := range appTemplates {\n\t\tfmt.Printf(\"Loaded Template: %s\\n\", file)\n\t\tfmt.Printf(\"loaded: %s\\n\", file)\n\t}\n\n}", "func ParseTemplates() error {\n\ttemplates = template.New(\"\").Funcs(fMap)\n\treturn filepath.Walk(\"./templates\", func(path string, info os.FileInfo, err error) error {\n\t\tif strings.Contains(path, \".html\") {\n\t\t\t_, err = templates.ParseFiles(path)\n\t\t\treturn err\n\t\t}\n\t\treturn err\n\t})\n}", "func ParseTemplates() *template.Template {\n\ttempl := template.New(\"\")\n\terr := filepath.Walk(\"./templates\", func(path string, info os.FileInfo, err error) error {\n\t\tif strings.Contains(path, \".gohtml\") {\n\t\t\t_, err = templ.ParseFiles(path)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t}\n\t\treturn err\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn templ\n}", "func ListTemplates() {\n\tfor _, file := range readDir(TemplatesDir()) {\n\t\tlog.Println(file)\n\t}\n}", "func (ui *GUI) loadTemplates() error {\n\tvar templates []string\n\tfindTemplate := func(path string, f os.FileInfo, err error) error {\n\t\t// If path doesn't exist, or other error with path, return error so\n\t\t// that Walk will quit and return the error to the caller.\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !f.IsDir() && strings.HasSuffix(f.Name(), \".html\") {\n\t\t\ttemplates = append(templates, path)\n\t\t}\n\t\treturn nil\n\t}\n\n\terr := filepath.Walk(ui.cfg.GUIDir, findTemplate)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thttpTemplates := template.New(\"template\").Funcs(template.FuncMap{\n\t\t\"hashString\": util.HashString,\n\t\t\"upper\": strings.ToUpper,\n\t\t\"percentString\": util.PercentString,\n\t})\n\n\t// Since template.Must panics with non-nil error, it is much more\n\t// informative to pass the error to the caller to log it and exit\n\t// gracefully.\n\thttpTemplates, err = httpTemplates.ParseFiles(templates...)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tui.templates = template.Must(httpTemplates, nil)\n\treturn nil\n}", "func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl interface{}, err error) {\n\tvar (\n\t\tmapKey = fmt.Sprintf(\"%s_%v\", filePath, view.config.Delimiters)\n\t\tmapFunc = func() interface{} {\n\t\t\ttplName := filePath\n\t\t\tif view.config.AutoEncode {\n\t\t\t\ttpl = htmltpl.New(tplName).Delims(\n\t\t\t\t\tview.config.Delimiters[0],\n\t\t\t\t\tview.config.Delimiters[1],\n\t\t\t\t).Funcs(view.funcMap)\n\t\t\t} else {\n\t\t\t\ttpl = texttpl.New(tplName).Delims(\n\t\t\t\t\tview.config.Delimiters[0],\n\t\t\t\t\tview.config.Delimiters[1],\n\t\t\t\t).Funcs(view.funcMap)\n\t\t\t}\n\t\t\t// Firstly checking the resource manager.\n\t\t\tif !gres.IsEmpty() {\n\t\t\t\tif files := gres.ScanDirFile(folderPath, pattern, true); len(files) > 0 {\n\t\t\t\t\tif view.config.AutoEncode {\n\t\t\t\t\t\tvar t = tpl.(*htmltpl.Template)\n\t\t\t\t\t\tfor _, v := range files {\n\t\t\t\t\t\t\t_, err = t.New(v.FileInfo().Name()).Parse(string(v.Content()))\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(v.Name(), tplName, err)\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar t = tpl.(*texttpl.Template)\n\t\t\t\t\t\tfor _, v := range files {\n\t\t\t\t\t\t\t_, err = t.New(v.FileInfo().Name()).Parse(string(v.Content()))\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(v.Name(), tplName, err)\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn tpl\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Secondly checking the file system,\n\t\t\t// and then automatically parsing all its sub-files recursively.\n\t\t\tvar files []string\n\t\t\tfiles, err = gfile.ScanDir(folderPath, pattern, true)\n\t\t\tif err != nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif view.config.AutoEncode {\n\t\t\t\tt := tpl.(*htmltpl.Template)\n\t\t\t\tfor _, file := range files {\n\t\t\t\t\tif _, err = t.Parse(gfile.GetContents(file)); err != nil {\n\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(file, tplName, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tt := tpl.(*texttpl.Template)\n\t\t\t\tfor _, file := range files {\n\t\t\t\t\tif _, err = t.Parse(gfile.GetContents(file)); err != nil {\n\t\t\t\t\t\terr = view.formatTemplateObjectCreatingError(file, tplName, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tpl\n\t\t}\n\t)\n\tresult := templates.GetOrSetFuncLock(mapKey, mapFunc)\n\tif result != nil {\n\t\treturn result, nil\n\t}\n\treturn\n}", "func (s *server) loadTemplates() error {\n includePath := \"templates/\"\n layoutPath := \"templates/layout/\"\n\n if s.templates == nil {\n s.templates = make(map[string]*template.Template)\n }\n\n layoutFiles, err := filepath.Glob(layoutPath + \"*.tmpl\")\n if err != nil {\n log.Println(\"failed to get included templates\")\n return err\n }\n\n includeFiles, err := filepath.Glob(includePath + \"*.tmpl\")\n if err != nil {\n log.Println(\"failed to get layout templates\")\n return err\n }\n\n mainTemplate := template.New(\"main\")\n mainTemplate, err = mainTemplate.Parse(mainTmpl)\n if err != nil {\n log.Println(\"failed to parse main template\")\n return err\n }\n\n for _, file := range includeFiles {\n fileName := filepath.Base(file)\n files := append(layoutFiles, file)\n s.templates[fileName], err = mainTemplate.Clone()\n if err != nil {\n return err\n }\n s.templates[fileName] = template.Must(\n s.templates[fileName].ParseFiles(files...))\n }\n\n s.bufpool = bpool.NewBufferPool(64)\n return nil\n}", "func RenderTemplateTest(w http.ResponseWriter) (map[string]*template.Template, error) {\n\ttemplateCache := map[string]*template.Template{}\n\n\tpages, err := filepath.Glob(\"./templates/*.page.html\")\n\tif err != nil {\n\t\treturn templateCache, err\n\t}\n\n\tfor _, page := range pages {\n\t\tfmt.Println(\"selected page path is\", page)\n\t\tname := filepath.Base(page)\n\t\tfmt.Println(\"selected page is\", name)\n\n\t\tts, err := template.New(name).Funcs(functions).ParseFiles(page)\n\t\tif err != nil {\n\t\t\treturn templateCache, err\n\t\t}\n\n\t\tmatches, err := filepath.Glob(\"./templates/*.layout.html\")\n\t\tif err != nil {\n\t\t\treturn templateCache, err\n\t\t}\n\n\t\tif len(matches) > 0 {\n\t\t\tts, err = ts.ParseGlob(\"./templates/*.layout.html\")\n\t\t\tif err != nil {\n\t\t\t\treturn templateCache, err\n\t\t\t}\n\t\t}\n\n\t\ttemplateCache[name] = ts\n\t}\n\n\treturn templateCache, nil\n}", "func MinifiedTemplates(dir string) ([]string, error) {\n\tfilenames, err := filepath.Glob(path.Join(dir, \"*\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult := []string{}\n\tm := minify.New()\n\tm.Add(\"text/html\", &html.Minifier{\n\t\tKeepDocumentTags: true,\n\t})\n\tfor _, filename := range filenames {\n\t\tb, err := ioutil.ReadFile(filename)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tmb, err := m.Bytes(\"text/html\", b)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresult = append(result, string(mb))\n\t\tlog.Println(\"read template with:\", filename)\n\t}\n\treturn result, nil\n}", "func (t *Templates) Parse(dir string) (*Templates, error) {\n\tt.Dir = dir\n\tif err := filepath.Walk(dir, t.parseFile); err != nil {\n\t\treturn t, err\n\t}\n\n\tif len(t.Views) == 0 {\n\t\treturn t, fmt.Errorf(\"no views were found\")\n\t}\n\n\t// create view templates\n\tfor name, tmpl := range t.Views {\n\t\tvar err error\n\t\tt.Templates[name], err = template.New(name).Parse(tmpl)\n\t\tif err != nil {\n\t\t\treturn t, err\n\t\t}\n\t}\n\n\t// add partials to the view templates\n\tfor _, baseTmpl := range t.Templates {\n\t\tfor name, tmpl := range t.Partials {\n\t\t\tvar err error\n\t\t\tbaseTmpl, err = baseTmpl.New(name).Parse(tmpl)\n\t\t\tif err != nil {\n\t\t\t\treturn t, err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn t, nil\n}", "func (s *Static) GenerateStaticTemplates() (fNames []string, err error) {\n\n\t// begin of new part\n\ttmlFiles, err := glob(s.SrcDir, \"*\"+\".gotmpl\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// end of new part\n\n\tfor _, f := range tmlFiles {\n\n\t\t// start of new part\n\t\tfi, err := pkger.Stat(f)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Stat: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttf, err := pkger.Open(f)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Open: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer tf.Close()\n\n\t\t// read the template source from pkger\n\t\tbuf := make([]byte, fi.Size())\n\t\t_, err = tf.Read(buf)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Unable to read template: %s %v\\n\", f, err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tst := template.Must(template.New(\"Static template\").Parse(string(buf)))\n\t\tif st == nil {\n\t\t\tlog.Printf(\"Parse error: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\t// end of new part\n\n\t\t// create the file-path if required\n\t\t_, err = os.Stat(s.DstDir)\n\t\tif err != nil {\n\t\t\tos.Mkdir(s.DstDir, 0755)\n\t\t}\n\n\t\t// create the static source file\n\t\tfileName := filepath.Base(f)\n\t\tfileName = strings.TrimSuffix(fileName, \"tmpl\")\n\t\tf, err := os.Create(s.DstDir + \"/\" + fileName)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"generateStaticTemplates: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer f.Close()\n\n\t\t// set permissions\n\t\terr = f.Chmod(0755)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"generateStaticTemplates: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// execute the template using the new controller file as a target\n\t\terr = st.Execute(f, s)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"generateStaticTemplates: %v\\n\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tfName := s.DstDir + \"/\" + fileName\n\t\tfNames = append(fNames, fName)\n\t\tlog.Println(\"generated:\", fName)\n\t\tf.Close()\n\t}\n\treturn fNames, nil\n}", "func (gen *Generator) WalkFiles(inPath string, file os.FileInfo, err error) error {\n\t// identify template files\n\tisTemplate, err := gen.Template.FileIsTemplate(inPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// skip all directories\n\tif file.IsDir() {\n\t\treturn nil\n\t}\n\n\t// skip template files if we are only generating statics.\n\tif isTemplate && gen.Options.StaticOnly == true {\n\t\treturn nil\n\t}\n\n\tLog.Info(\"walk_files\", fmt.Sprintf(\"source %s\", inPath))\n\n\toutPath := strings.Replace(inPath, gen.Template.Files, gen.Project.Directory, 1)\n\n\tif err := os.MkdirAll(filepath.Dir(outPath), 0700); err != nil {\n\t\treturn err\n\t}\n\n\tif isTemplate {\n\t\tLog.Info(\"walk_files\", fmt.Sprintf(\"expanding template %s\", outPath))\n\t\toutPath = strings.Replace(outPath, \".tmpl\", \"\", 1)\n\n\t\tgenerated, err := templates.ExpandFile(inPath, gen.Project.helpers)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tLog.Info(\"walk_files\", fmt.Sprintf(\"writing %s\", outPath))\n\t\treturn utils.WriteFile(outPath, generated)\n\t}\n\n\treturn gen.Copy(inPath, outPath)\n}", "func PopulateTemplates() *template.Template {\n\ttemplates, err := template.ParseGlob(\"*.html\")\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tos.Exit(1) // no point in our webapp if templates aren't read\n\t}\n\n\treturn templates\n}", "func (i *Instance) GenerateConfigFilesFromDir(dirToGenerateFrom string) *Instance {\n\tnoGenerate := getBoolFlagValue(i.Flags, flag.NoGenerate)\n\tif i.Error != nil {\n\t\treturn i\n\t}\n\tvar configDir string\n\tvar err error\n\tif dirToGenerateFrom != \"\" {\n\t\tconfigDir, err = static.GetActualDirName(static.ResourceType, dirToGenerateFrom, templateDir)\n\t\tif err != nil {\n\t\t\ti.Error = fmt.Errorf(\"could not get ActualDirName for dir %v, err : %v \", dirToGenerateFrom, err)\n\t\t\treturn i\n\t\t}\n\t\tif configDir == \"\" {\n\t\t\ti.Error = fmt.Errorf(\"could not find directory or directory is empty %v\", dirToGenerateFrom)\n\t\t\treturn i\n\t\t}\n\t}\n\t// fmt.Println(\"configDir : \", configDir)\n\ti.ConfigDir = configDir\n\tif !noGenerate {\n\t\t//cleaning up all scripts in dir if it exists\n\t\tif _, err := os.Stat(generatedDir + configDir); !os.IsNotExist(err) {\n\t\t\tfilesDeleted, err := cleanupFilesInDir(generatedDir + configDir)\n\t\t\tif err != nil {\n\t\t\t\ti.Error = fmt.Errorf(\"could not delete files in %v directory, err: %v\", generatedDir+configDir, err)\n\t\t\t\treturn i\n\t\t\t}\n\t\t\tif getBoolFlagValue(i.Flags, flag.Verbose) {\n\t\t\t\tfmt.Printf(\"\\n%v directory exists, cleaned up %v files inside...\\n\\n\", generatedDir+configDir, filesDeleted)\n\t\t\t}\n\t\t}\n\t\terr := template.Generate(i.Config,\n\t\t\tconfigDir,\n\t\t\ttemplateDir,\n\t\t\tgeneratedDir)\n\t\tif err != nil {\n\t\t\ti.Error = fmt.Errorf(\"error while creating configuration : %v\", err)\n\t\t\treturn i\n\t\t}\n\t}\n\ti.PrintSeparator()\n\treturn i\n}", "func processTemplates(cfg *config.Config, templates []*tplate) ([]*tplate, error) {\n\tfor _, t := range templates {\n\t\tif t.contents == \"\" {\n\t\t\tvar in io.Reader\n\t\t\tif t.name == \"-\" {\n\t\t\t\tin = cfg.Stdin\n\t\t\t}\n\n\t\t\tb, err := t.loadContents(in)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tt.contents = string(b)\n\t\t}\n\n\t\tif t.target == nil {\n\t\t\tout, err := openOutFile(cfg, t.targetPath, 0755, t.mode, t.modeOverride)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tt.target = out\n\t\t}\n\t}\n\n\treturn templates, nil\n}", "func LoadTemplates(relativePath string, pOpt *ParseOptions) {\n\t// Initializes the template map\n\ttemplates = make(map[string]*template.Template)\n\n\t// Save Path to Base file\n\tpOpt.BasePath = relativePath\n\n\t// Check if every option is set\n\tif pOpt.BaseName == \"\" {\n\t\tpOpt.BaseName = DefaultParseOptions.BaseName\n\t}\n\n\tif pOpt.Delimiter == \"\" {\n\t\tpOpt.Delimiter = DefaultParseOptions.Delimiter\n\t}\n\n\tif pOpt.Ext == \"\" {\n\t\tpOpt.Ext = DefaultParseOptions.Ext\n\t}\n\n\tif pOpt.NonBaseFolder == \"\" {\n\t\tpOpt.NonBaseFolder = DefaultParseOptions.NonBaseFolder\n\t}\n\n\t// Start checking the main dir of the views\n\tcheckDir(relativePath, pOpt, false)\n}", "func ApplyTemplating(stackPath string, templateMetadata interface{}) error {\n\n\terr := filepath.Walk(stackPath, func(path string, info os.FileInfo, err error) error {\n\n\t\t//Skip .git folder\n\t\tif info.IsDir() && info.Name() == \".git\" {\n\t\t\treturn filepath.SkipDir\n\t\t} else if !info.IsDir() {\n\n\t\t\t//get file name\n\t\t\tfile := filepath.Base(path)\n\n\t\t\t// get permission of file\n\t\t\tpermission := info.Mode()\n\n\t\t\tbinaryFile, err := ioutil.ReadFile(path)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error reading file for binary test: %v\", err)\n\t\t\t}\n\n\t\t\t// skip binary files\n\t\t\tif isbinary.Test(binaryFile) {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// set file permission to writable to apply templating\n\t\t\terr = os.Chmod(path, 0666)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error changing file permision: %v\", err)\n\t\t\t}\n\n\t\t\t// create new template from parsing file\n\t\t\ttmpl, err := template.New(file).Delims(\"{{.stack\", \"}}\").ParseFiles(path)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error creating new template from file: %v\", err)\n\t\t\t}\n\n\t\t\t// open file at path\n\t\t\tf, err := os.Create(path)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error opening file: %v\", err)\n\t\t\t}\n\n\t\t\t// apply template to file\n\t\t\terr = tmpl.ExecuteTemplate(f, file, templateMetadata)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error executing template: %v\", err)\n\t\t\t}\n\n\t\t\t// set old file permission to new file\n\t\t\terr = os.Chmod(path, permission)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"Error reverting file permision: %v\", err)\n\t\t\t}\n\t\t\tf.Close()\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn errors.Errorf(\"Error walking through directory: %v\", err)\n\t}\n\n\treturn nil\n\n}", "func (t Template) ProcessTemplates(sourceFolder, targetFolder string, templates ...string) (resultFiles []string, err error) {\n\tsourceFolder = iif(sourceFolder == \"\", t.folder, sourceFolder).(string)\n\ttargetFolder = iif(targetFolder == \"\", t.folder, targetFolder).(string)\n\tresultFiles = make([]string, 0, len(templates))\n\n\tprint := t.options[OutputStdout]\n\n\tvar errors errors.Array\n\tfor i := range templates {\n\t\tt.options[OutputStdout] = print // Some file may change this option at runtime, so we restore it back to its originalSourceLines value between each file\n\t\tresultFile, err := t.ProcessTemplate(templates[i], sourceFolder, targetFolder)\n\t\tif err == nil {\n\t\t\tif resultFile != \"\" {\n\t\t\t\tresultFiles = append(resultFiles, resultFile)\n\t\t\t}\n\t\t} else {\n\t\t\terrors = append(errors, err)\n\t\t}\n\t}\n\tif len(errors) > 0 {\n\t\terr = errors\n\t}\n\treturn\n}", "func (u Options) CopyTemplate(rootFs billy.Filesystem, chartsScriptOptions options.ChartsScriptOptions, templateDir string) error {\n\ttemplateFiles, ok := u[chartsScriptOptions.Template]\n\tif !ok {\n\t\treturn fmt.Errorf(\"No templates defined for type %s. Only staging or live are supported\", chartsScriptOptions.Template)\n\t}\n\ttemplateFileMap := make(map[string]bool, len(templateFiles))\n\tfor _, p := range templateFiles {\n\t\ttemplateFileMap[p] = true\n\t}\n\tabsTempDir, err := ioutil.TempDir(filepath.Join(rootFs.Root(), templateDir), \"generated\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Encountered error while trying to create temporary directory: %s\", err)\n\t}\n\tdefer os.RemoveAll(absTempDir)\n\ttempDir, err := filesystem.GetRelativePath(rootFs, absTempDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Encountered error while getting relative path for %s in %s: %s\", absTempDir, rootFs.Root(), err)\n\t}\n\ttempFs := filesystem.GetFilesystem(absTempDir)\n\terr = filesystem.WalkDir(rootFs, templateDir, func(fs billy.Filesystem, path string, isDir bool) error {\n\t\trepoPath, err := filesystem.MovePath(path, templateDir, \"\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to get path of %s within %s: %s\", repoPath, templateDir, err)\n\t\t}\n\t\tif exists, ok := templateFileMap[repoPath]; !ok || !exists {\n\t\t\treturn nil\n\t\t}\n\t\tf, err := filesystem.CreateFileAndDirs(tempFs, repoPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer f.Close()\n\t\tt := template.Must(template.New(filepath.Base(path)).ParseFiles(filesystem.GetAbsPath(rootFs, path)))\n\t\tif err := t.Execute(f, chartsScriptOptions); err != nil {\n\t\t\treturn fmt.Errorf(\"Error while executing Go template for %s: %s\", path, err)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn filesystem.CopyDir(rootFs, tempDir, \".\")\n}", "func (t *templater) templateFile(workDir string, outDir string, file os.FileInfo, d map[string]interface{}) {\n\tif strings.Contains(file.Name(), \"yaml\") {\n\n\t\tfilePath := workDir + \"/\" + file.Name()\n\t\ttEx := templ.New(file.Name())\n\t\ttEx.Funcs(templateFuncs(workDir))\n\t\ttEx.ParseFiles(filePath)\n\t\tb := bytes.NewBuffer([]byte{})\n\t\terr := tEx.Execute(b, d)\n\t\tif err != nil {\n\t\t\tlog.Error(err, \"Failed to execute template\")\n\t\t}\n\t\tnewF, err := os.Create(outDir + \"/\" + file.Name())\n\t\tif err != nil {\n\t\t\tlog.Error(err, \"Failed to create file\", \"file\", file.Name())\n\t\t\treturn\n\t\t}\n\t\tnewF.Write(b.Bytes())\n\t\tnewF.Close()\n\t}\n}", "func (app *App) compileTemplates(tmplDir string) error {\n\ttmpl, err := compileTemplates(tmplDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tapp.tmpl = tmpl\n\treturn nil\n}", "func LoadAllTemplates() (Templates, error) {\n\ttemplateMap := make(map[string]*template.Template)\n\n\t// We walk through every file in the templates folder.\n\terr := filepath.Walk(\"./assets/templates\", func(path string, info fs.FileInfo, err error) error {\n\t\t// We only care about files which are actual templates and are not of special use (like \"_base\")\n\t\tif !strings.HasPrefix(info.Name(), \"_\") && strings.HasSuffix(path, \".template.html\") {\n\t\t\t// We bundle the templates together with the base template so that we can render them together later.\n\t\t\tt, err := template.ParseFiles(\"./assets/templates/_base.template.html\", path)\n\t\t\tif err == nil {\n\t\t\t\t// We keep the parsed template in the templateMap by it's filename.\n\t\t\t\ttemplateMap[info.Name()] = t\n\t\t\t}\n\t\t}\n\n\t\treturn err\n\t})\n\n\tif err != nil {\n\t\treturn Templates{}, err\n\t}\n\n\treturn Templates{\n\t\ttemplateMap: templateMap,\n\t}, nil\n}", "func FindTemplate(name string, limit int) string {\n const NOT_FOUND = \"\"\n path, count := WorkingDirectory()\n path_back := \"\" //start in current directory\n var max int\n if count < limit {\n max = count\n } else {\n max = limit\n }\n for i:=0 ; i<max; i++ {\n new_path := path + \"/\" + path_back + name\n if FileExists(new_path) {\n return new_path\n }\n path_back = path_back + \"../\" //look back one directory\n }\n return NOT_FOUND\n}", "func CompileTemplates(dir string, funcs template.FuncMap) (tmpl *template.Template, err error) {\n\ttmpl = template.New(\"\").Funcs(funcs)\n\terr = compileTemplates(tmpl, dir, \"\")\n\treturn\n}", "func init() {\n\ttmpl = template.Must(template.ParseGlob(\"templates/*\"))\n}", "func writeTemplate(dirToWrite, dirType, parentDir, templateName string) error {\n\tfmt.Printf(\"\\n\\n\\nAbsolute Directory: %v\\nDirrectory Type: %v\\nParent Dir: %v\\nName of template: %v\\n\\n\\n\", dirToWrite, dirType, parentDir, templateName)\n\n\t// Open index file in components directory and read data\n\tdata, err := getIndexData(filepath.Join(parentDir, \"index.js\"))\n\thandleError(err, \"from Get index data\")\n\n\ttoSliceOn := toSliceOnRoot + \"/\" + dirType\n\n\tdata.RestImports = append(data.RestImports, \"import \"+templateName+\" from '.\"+strings.Split(dirToWrite, toSliceOn)[1]+\"/\"+templateName+\"';\")\n\n\tdata.Name = templateName\n\tfmt.Println(data.RestImports)\n\n\t// Write Template of index\n\twriteNewIndexFile(filepath.Join(parentDir, \"index.js\"), data)\n\tos.Chdir(dirToWrite)\n\tnewComponentFile, err := os.Create(templateName + \".js\")\n\thandleError(err, \"from creating a new component file\")\n\tdefer newComponentFile.Close()\n\n\tsassFile, err := os.Create(templateName + \".css\")\n\thandleError(err, \"from creating new css file\")\n\tdefer sassFile.Close()\n\n\tos.Chmod(newComponentFile.Name(), fullPermission)\n\tos.Chmod(sassFile.Name(), fullPermission)\n\n\ttemplateType := getTemplate(dirType)\n\tfmt.Printf(\"Template Type is: %v\\n\", templateType)\n\n\ttmpl := template.Must(template.New(dirType).Delims(\"[){[\", \"]}(]\").Parse(templateType))\n\n\terr = tmpl.Execute(newComponentFile, data)\n\thandleError(err, \"from executing new component template\")\n\treturn nil\n}", "func loadRelTemplates(ps []string) (*template.Template, error) {\n\tif len(ps) == 0 {\n\t\treturn nil, errors.New(\"muta-template: At least one path is required\")\n\t}\n\n\t// TODO: Intelligently assign base to the most base path\n\tbase := filepath.Dir(ps[0])\n\n\tvar t *template.Template\n\tvar lt *template.Template\n\tfor _, tmpl := range ps {\n\t\ttmplName, err := filepath.Rel(base, tmpl)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif t == nil {\n\t\t\tt = template.New(tmplName)\n\t\t\tlt = t\n\t\t} else {\n\t\t\tlt = t.New(tmplName)\n\t\t}\n\n\t\tb, err := ioutil.ReadFile(tmpl)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t_, err = lt.Parse(string(b))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn t, nil\n}", "func GetTemplateNamesInDirs(paths []string) ([]string, error) {\n\tvar tnames []string\n\tfor _, p := range paths {\n\t\tfiles, err := os.ReadDir(p)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, file := range files {\n\t\t\tif file.IsDir() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvar tn string\n\t\t\tfn := file.Name()\n\t\t\tif strings.Contains(fn, \"__\") {\n\t\t\t\ttn = strings.Split(fn, \"__\")[0]\n\t\t\t}\n\n\t\t\ttnames = append(tnames, tn)\n\t\t}\n\t}\n\n\treturn tnames, nil\n}", "func (app *App) buildTemplates() map[string]*template.Template {\n\tdir := app.Config.General.Templates\n\ttemplates := make(map[string]*template.Template, 0)\n\tmust := template.Must\n\n\tif dir == \"\" {\n\t\tdir = \"templates/\"\n\t}\n\n\tbuf, err := ioutil.ReadFile(dir + \"layout.tmpl\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlayout := must(template.New(\"main\").Funcs(app.viewhelpers()).Parse(string(buf)))\n\n\tfilepath.Walk(dir, func(path string, info os.FileInfo, err error) error {\n\t\tr, err := filepath.Rel(dir, path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\text := filepath.Ext(r)\n\t\tif ext == \".tmpl\" {\n\n\t\t\tbuf, err := ioutil.ReadFile(path)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tname := (r[0 : len(r)-len(ext)])\n\t\t\tif name == \"layout\" {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tnewLayout := must(layout.Clone())\n\t\t\tmust(newLayout.New(\"body\").Parse(string(buf)))\n\t\t\ttemplates[name] = newLayout\n\t\t\t// store the template without layout as a partial\n\t\t\ttemplates[\"partial/\"+name] = must(template.New(name).Funcs(app.viewhelpers()).Parse(string(buf)))\n\t\t}\n\t\treturn nil\n\t})\n\n\treturn templates\n}", "func InitTemplating(path ...string) error {\n\ttpls, err = template.ParseGlob(path[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(path) > 1 {\n\t\tfor _, p := range path {\n\t\t\ttpls, err = tpls.ParseGlob(p)\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 init() {\n\ttopLevelTemplates = template.Must(template.ParseGlob(\"./views/*.go.html\"))\n\tpageTemplates = template.Must(template.ParseGlob(\"./views/pages/*.go.html\"))\n}", "func (s *server) parseTemplates(w http.ResponseWriter, files ...string) (tpl *template.Template, err error) {\n\t// Automatically adds app layout\n\tfiles = append(files, filepath.Join(\"layouts\", \"app\"))\n\tfor i, v := range files {\n\t\tfiles[i] = filepath.Join(\"client\", \"templates\", v) + \".tpl\"\n\t}\n\t// Automatically adds components folder\n comps, err := ioutil.ReadDir(\".\" + filepath.Join(\"client\", \"templates\", \"components\"))\n if err != nil {\n s.logErr(\"failed to read components\", err)\n return nil, err\n }\n\tfor _, v := range comps {\n files = append(files, v.Name())\n }\n\n\ttpl, err = template.New(\"\").Funcs(template.FuncMap{\n\t\t\"echo\": func(input string) string {\n\t\t\treturn input\n\t\t},\n\t\t\"isMarkdown\": func(data interface{}) bool {\n\t\t\tswitch data.(type) {\n\t\t\tcase markdown:\n\t\t\t\treturn true\n\t\t\tdefault:\n\t\t\t\treturn false\n\t\t\t}\n\t\t},\n\t}).ParseFiles(files...)\n\tif err != nil {\n\t\ts.logErr(\"Error parsing template file\", err)\n\t\treturn nil, err\n\t}\n\treturn tpl, nil\n}", "func ParseTemplates(path string) *template.Template {\n\treturn template.Must(template.ParseFiles(\n\t\t\"web/templates/partial/head.html\",\n\t\t\"web/templates/partial/header.html\",\n\t\t\"web/templates/partial/footer.html\",\n\t\tpath,\n\t\t\"web/templates/base.html\",\n\t))\n}", "func BuildBeegoTemplate(dir string, files ...string) error {\n\tif _, err := os.Stat(dir); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.New(\"dir open err\")\n\t}\n\n\tself := &templateFile{\n\t\troot: dir,\n\t\tfiles: make(map[string][]string),\n\t}\n\terr := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {\n\t\treturn self.visit(path, f, err)\n\t})\n\tif err != nil {\n\t\tfmt.Printf(\"filepath.Walk() returned %v\\n\", err)\n\t\treturn err\n\t}\n\n\tfor _, v := range self.files {\n\t\tfor _, file := range v {\n\t\t\tt, _ := getTemplate(self.root, file, v...)\n\t\t\tbeeViewPathTemplates[file] = t\n\t\t}\n\t}\n\treturn nil\n}", "func LoadTemplates(rootTemp string, childTemps []string) {\n\trootTemplate = rootTemp\n\tchildTemplates = childTemps\n}", "func parseTemplate(filename string) *appTemplate {\n\ttmpl := template.Must(template.ParseFiles(\"templates/base.html\"))\n\n\t// Put the named file into a template called \"body\"\n\tpath := filepath.Join(\"templates\", filename)\n\tb, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tApp.Log.Errorf(\"could not read template: %v\", err)\n\t\tpanic(fmt.Errorf(\"could not read template: %v\", err))\n\t}\n\ttemplate.Must(tmpl.New(\"body\").Parse(string(b)))\n\n\treturn &appTemplate{tmpl.Lookup(\"base.html\")}\n}", "func loadTemplate() (*template.Template, error) {\n\tt := template.New(\"\")\n\tfor name, file := range Assets.Files {\n\t\tif file.IsDir() || !strings.HasSuffix(name, \".gohtml\") {\n\t\t\tcontinue\n\t\t}\n\t\th, err := ioutil.ReadAll(file)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tt, err = t.New(name).Parse(string(h))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn t, nil\n}", "func GetAllDirsInsideTmpl() ([]string, error) {\n\tdirs, err := static.GetAllDirsInDir(static.ResourceType, templateDir, ignoreIfPrefix)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// fmt.Println(\"dirs : \", dirs)\n\treturn dirs, nil\n}", "func (t *Templates) Scan() error {\n\tt.html_cache = make(map[string]*template.Template)\n\tt.text_cache = make(map[string]*text_template.Template)\n\tfilepath.Walk(t.BaseDir, func(path string, f os.FileInfo, err error) error {\n\t\tif f.IsDir() {\n\t\t\terr = t.parseTemplates(path)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\treturn nil\n}", "func setupDir(c testutil.Cleanuper) {\n\ttestutil.InTempDir(c)\n\twriteFile(\"a.go\", `package x\n//elvdoc:fn f2\n//\n// Function 2 from a.\n//\n// Some indented code.\n`)\n\twriteFile(\"b.go\", `package x\n//elvdoc:fn f1\n//\n// Function 1 from b.\n\n//elvdoc:var v2\n//\n// Variable 2 from b.\n`)\n\twriteFile(\"c.go\", `package x\n//elvdoc:var v1\n//\n// Variable 1 from c.\n`)\n\twriteFile(\"notgo.gox\", `package x\n//elvdoc:var wontappear\n//\n// This won't appear because it is not in a .go file.\n`)\n\t// Subdirectories are ignored with -dir.\n\twriteFile(\"subpkg/a.go\", `package subpkg\n//elvdoc:fn subpkg:f\n//\n// Function f from subpkg/a.\n\n//elvdoc:var subpkg:v\n//\n// Variable v from subpkg/a.\n`)\n}", "func LoadVirtualTemplateDir(tree *template.Template, vd *VDir, name, ext string) error {\n\tvar err error\n\n\tvd.EveryFile(func(vf *VFile, path string, stop func()) {\n\t\tif filepath.Ext(vf.Name()) == ext {\n\t\t\t_, ex := LoadVirtualTemplateFile(vf, tree)\n\n\t\t\tif ex != nil {\n\t\t\t\terr = ex\n\t\t\t\tstop()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t})\n\n\treturn err\n}", "func parseTemplateFiles(filenames ...string) (t *template.Template) {\n\tvar files []string\n\tt = template.New(\"layout\")\n\tfor _, file := range filenames {\n\t\tfiles = append(files, fmt.Sprintf(\"templates/%s.html\", file))\n\t}\n\tt = template.Must(t.ParseFiles(files...))\n\treturn\n}", "func Generate(dirList ...string) {\n\tvar root = NewEmptyFileTree()\n\tfor _, dir := range dirList {\n\t\ttree := LoadFileTree(dir)\n\t\troot.Children = append(root.Children, tree)\n\t}\n\n\tvar RawFuncList []RawFunc\n\tWalkFileTree(root, &RawFuncList)\n\n\tvar handlers []HandlerFunc\n\tvar middlewares = make(map[string]*MiddlewareFunc)\n\tvar imports = make(map[string]bool)\n\tTraverseRawFuncList(&RawFuncList, &handlers, middlewares, imports)\n\n\tvar ctx GenContext\n\tctx.InitGroupTree(middlewares, &handlers)\n\n\ttplFile := GenTemplate()\n\tfor k, _ := range imports {\n\t\tAddImport(tplFile, k)\n\t}\n\n\tlist := ctx.Root.GenAST()\n\tfileExprListAppend(tplFile, &list)\n\n\texport(tplFile)\n}", "func buildTemplates(filenames ...string) *template.Template {\n\t// Build a slice of paths\n\tfs := []string{}\n\tfor _, fn := range filenames {\n\t\tf := buildFilePath(templatesPath, fn)\n\t\tfs = append(fs, f)\n\t}\n\n\treturn template.Must(template.ParseFiles(fs...))\n}", "func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) {\r\n t, err := template.ParseFiles(tmpl + \".html\")\r\n if err != nil {\r\n http.Error(w, err.Error(), http.StatusInternalServerError)\r\n return\r\n }\r\n err = t.Execute(w, p)\r\n if err != nil {\r\n http.Error(w, err.Error(), http.StatusInternalServerError)\r\n }\r\n}", "func copyTemplates(outputdir string) error {\n\tsub_fs, _ := fs.Sub(content, \"graphs\")\n\tfs.WalkDir(sub_fs, \".\", func(path string, info fs.DirEntry, err error) error {\n\t\tlog.Debugf(\"walkFn processing: %s\", path)\n\t\t//log.Debugf(\"info=%v\", info)\n\t\tdest := outputdir + \"/\" + path\n\n\t\t// Regular file or directory ?\n\t\tif info.IsDir() {\n\t\t\tlog.Debugf(\"This a directory\")\n\t\t\t_, err := os.Stat(dest)\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tif err := os.Mkdir(dest, 0755); err != nil {\n\t\t\t\t\tlog.Errorf(\"copyTemplates could not create directory %s (%s)\", dest, err)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Debugf(\"This is a file\")\n\t\t\tsource, err := fs.ReadFile(sub_fs, path)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"copyTemplates could not open file %s for reading (%s)\", path, err)\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err := os.WriteFile(dest, source, 0666); err != nil {\n\t\t\t\tlog.Errorf(\"copyTemplates could not write file %s for writing (%s)\", dest, err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\treturn nil\n}", "func main() {\n\tl := []yamlFile{\n\t\t{\"configurations.yml\", false, cfgTemplate},\n\t\t{\"configurationsResponse.yml\", true, responseTemplate},\n\t}\n\tfor _, file := range l {\n\t\tf, err := os.Create(file.Name)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdoc := document{\n\t\t\tItems: userCfgItems(file.IsResponse),\n\t\t}\n\t\ttmpl, err := template.New(\"test\").Parse(file.TempName)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\terr = tmpl.Execute(f, doc)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tf.Close()\n\t}\n}", "func (self templateEngine) reloadAllTemplates() {\n loadThese := []string{}\n // get all the names of the templates we have loaded\n for tname, _ := range self.templates {\n loadThese = append(loadThese, tname)\n }\n // for each template we have loaded, reload the contents from file\n for _, tname := range loadThese {\n self.reloadTemplate(tname)\n }\n}", "func main() {\n\n\tbase_dirs, _ := ioutil.ReadDir(\".\")\n\n\tfor _, f := range base_dirs {\n\t\tif !f.IsDir() {\n\t\t\tfn := strings.Split(f.Name(),\".\")\n\t\t\tif fn[len(fn)-1] == \"html\" {\n\t\t\t\tfmt.Printf(\"Processing %s.html\\n\", fn[0])\t\n\t\t\t\tprocessFile(fn[0])\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\n\n\t\n\n}", "func (application *Application) LoadTemplates() error {\n\tvar templates []string\n\n\t// Create function to collect our template files\n\tfn := func(path string, f os.FileInfo, err error) error {\n\t\tif f.IsDir() != true && strings.HasSuffix(f.Name(), \".html\") {\n\t\t\ttemplates = append(templates, path)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Look for all the template files\n\terr := filepath.Walk(application.Configuration.TemplatePath, fn)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Make sure we can parse all the template files\n\tapplication.Template = template.Must(template.ParseFiles(templates...))\n\treturn nil\n}", "func exec(fl FileStructure) {\n\tdirBuff := loadTemplate(fl.TargetDir, fl.DataSource)\n\tdirName := string(dirBuff)\n\n\tif fl.Skip {\n\t\tgoto execChild\n\t}\n\n\tif _, err := os.Stat(dirName); os.IsExist(err) {\n\t\tpanic(err)\n\t}\n\n\tif fl.IsDir {\n\t\t_, err := os.Stat(dirName)\n\t\tif os.IsNotExist(err) {\n\t\t\tfmt.Printf(\"creating %s...\\n\", dirName)\n\t\t\tif errDir := os.Mkdir(dirName, 0700); errDir != nil {\n\t\t\t\tfmt.Println(\"mkdir err:\", errDir)\n\t\t\t\tpanic(errDir)\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif fl.FileName != \"\" {\n\t\tvar buff []byte\n\t\tif fl.FromTemplate {\n\t\t\tif fl.Source != \"\" {\n\t\t\t\tbuff = loadTemplate(fl.Source, fl.DataSource)\n\t\t\t} else {\n\t\t\t\tlastDir := filepath.Dir(fl.TargetDir)\n\t\t\t\tbuff = defaultDataSource(lastDir[strings.LastIndex(lastDir, \"/\")+1:])\n\t\t\t}\n\t\t} else {\n\t\t\tbuff = []byte(fl.Source)\n\t\t}\n\t\tif len(dirName) > 0 {\n\t\t\tdirName = strings.TrimSuffix(dirName, \"/\")\n\t\t\tif err := ioutil.WriteFile(dirName+\"/\"+fl.FileName, buff, 0644); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t} else {\n\t\t\tif err := ioutil.WriteFile(fl.FileName, buff, 0644); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\n\t}\n\nexecChild:\n\tfor _, child := range fl.Childs {\n\t\tchild.TargetDir = dirName + child.TargetDir\n\t\texec(child)\n\t}\n}", "func layoutFiles() []string {\n\tfiles, err := filepath.Glob(LayoutDir + \"*\" + TemplateExt)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn files\n\n}", "func parseTemplates() (map[string]*template.Template, error) {\n\t// template name to required template files\n\tpaths := map[string][]string{\n\t\t\"index.html\": {\"template/base.html\", \"template/index.html\"},\n\t}\n\ttmpl := make(map[string]*template.Template, len(paths))\n\tvar err error\n\tfor name, files := range paths {\n\t\ttmpl[name], err = template.ParseFiles(files...)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn tmpl, nil\n}", "func init() {\r\n\ttpl = template.Must(template.ParseGlob(\"templates/*\"))\r\n}", "func init() {\n\ttpl = template.Must(template.ParseGlob(\"templates/*\"))\n}", "func init() {\n\t// var err error\n\t// tmpl, err = template.ParseFiles(\"templates/hello.gohtml\")\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n\ttmpl = template.Must(template.ParseGlob(\"templates/*.gohtml\"))\n\n}", "func RenderTemplate(tmpfile string, pairs map[string]interface{}) (string, error) {\n\n\tfile, err := os.Open(tmpfile)\n\tif err != nil {\n\t\tLogWarning.Println(err)\n\t}\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\t//var srcContent string\n\tvar srcContent bytes.Buffer\n\tfor scanner.Scan() {\n\t\tt := fmt.Sprintln(scanner.Text())\n\t\tif strings.Index(t, \"<%file:\") > -1 {\n\t\t\tLogDebug.Println(\"Including file external file\")\n\t\t\tif strings.Index(t, \"%>\") > -1 {\n\t\t\t\tre := regexp.MustCompile(\"\\\\<\\\\%file:(.*?)\\\\%\\\\>\")\n\t\t\t\tmatch := re.FindStringSubmatch(t)\n\t\t\t\tif len(match) == 0 {\n\t\t\t\t\tLogError.Println(\"invalid file: syntax \", t)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tincludeFileName := fmt.Sprintf(\"%s/%s\", path.Dir(tmpfile), match[1])\n\t\t\t\tincludeContent, err := ioutil.ReadFile(includeFileName)\n\t\t\t\tif err != nil {\n\t\t\t\t\tLogWarning.Println(err)\n\t\t\t\t}\n\t\t\t\tLogInfo.Println(\"including file :\", includeFileName)\n\t\t\t\tLogDebug.Println(\"includeContent\", string(includeContent))\n\t\t\t\tsrcContent.WriteString(string(includeContent))\n\t\t\t} else {\n\t\t\t\tLogWarning.Println(\"Found incomplete tag in include from file \", tmpfile)\n\t\t\t}\n\t\t} else if strings.Index(t, \"<%LookupFile:\") > -1 {\n\t\t\tLogDebug.Println(\"Rendering LookupFile\")\n\t\t\tvar lookup LookupList\n\t\t\tre := regexp.MustCompile(\"\\\\<\\\\%LookupFile:(.*?),(.*?),(.*?),(.*?)\\\\%\\\\>\")\n\n\t\t\t/*\n\t\t\t\t//\n\t\t\t\t// Fist we need to find if there is a template within the lookup definition\n\t\t\t\tt := fasttemplate.New(t, \"{{\", \"}}\")\n\t\t\t\ts := t.ExecuteString(pairs)\n\t\t\t*/\n\t\t\t//var tmpl = template.Must(template.ParseFiles(t))\n\t\t\t// Create a new template and parse the letter into it.\n\t\t\t// Get the Sprig function map.\n\t\t\tfmap := sprig.TxtFuncMap()\n\t\t\tvar tmpl = template.Must(template.New(\"LookupFile\").Funcs(fmap).Parse(t))\n\n\t\t\tvar bytes bytes.Buffer\n\t\t\twriter := bufio.NewWriter(&bytes)\n\n\t\t\terr = tmpl.Execute(writer, pairs)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = writer.Flush()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tLogDebug.Println(bytes.String())\n\n\t\t\tmatch := re.FindStringSubmatch(bytes.String())\n\n\t\t\tif len(match) == 0 {\n\t\t\t\tLogError.Println(\"invalid LookupFile: syntax \", t)\n\t\t\t\t//BUG/FIX: Should push up a error to rest calling function\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tLogDebug.Println(\"LookupFile: \", match[LookupFile])\n\t\t\tLogDebug.Println(\"LookupKey: \", match[LookupKey])\n\t\t\tLogDebug.Println(\"LookupSubkey: \", match[LookupSubkey])\n\t\t\tLogDebug.Println(\"LookupDefaultValue: \", match[LookupDefaultValue])\n\n\t\t\tyamlFile, err := ioutil.ReadFile(fmt.Sprintf(match[LookupFile]))\n\t\t\tif err != nil {\n\t\t\t\tLogError.Println(\"reading LookupFile \", match[LookupFile])\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = yaml.Unmarshal(yamlFile, &lookup)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tvar lookupvalue string\n\t\t\tvar ok bool\n\t\t\tLogDebug.Println(lookup.Lookup)\n\t\t\tif lookupvalue, ok = lookup.Lookup[match[LookupKey]][match[LookupSubkey]]; ok {\n\t\t\t\tLogDebug.Println(\"Found lookup value in file :\", lookupvalue)\n\t\t\t} else {\n\t\t\t\tlookupvalue = match[LookupDefaultValue]\n\t\t\t\tLogDebug.Println(\"Using default lookup Value :\", lookupvalue)\n\t\t\t}\n\n\t\t\tsrcContent.WriteString(re.ReplaceAllString(bytes.String(), lookupvalue))\n\n\t\t} else {\n\t\t\tsrcContent.WriteString(t)\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tLogWarning.Println(err)\n\t}\n\n\t//var tmpl = template.Must(template.ParseFiles(tmpl_file))\n\t// Get the Sprig function map.\n\tfmap := sprig.TxtFuncMap()\n\tvar tmpl = template.Must(template.New(\"rendered_template\").Funcs(fmap).Parse(srcContent.String()))\n\n\tvar bytes bytes.Buffer\n\twriter := bufio.NewWriter(&bytes)\n\n\terr = tmpl.Execute(writer, pairs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\terr = writer.Flush()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tLogDebug.Println(bytes.String())\n\n\treturn bytes.String(), nil\n\n}", "func (st *Stemplate) loadTemplate(tname string) *template.Template {\n\n\ttemplates, terr := filepath.Glob(st.templatesDir + \"*.tmpl\")\n\tif terr != nil {\n\t\tfmt.Println(\"[JIT template]: ERROR ~ \" + terr.Error())\n\t\treturn nil\n\t}\n\n\ttemplates = append(templates, st.templatesDir+tname)\n\n\treturn template.Must(template.ParseFiles(templates...))\n}", "func (r *innerRenderer) parseFiles(fileNames ...string) (*template.Template, error) {\n\tvar realFileNames []string\n\tvar filesCacheKey string\n\tvar err error\n\tfor _, v := range fileNames {\n\t\tif !file.Exist(v) {\n\t\t\tv = path.Join(r.templatePath, v)\n\t\t}\n\t\trealFileNames = append(realFileNames, v)\n\t\tfilesCacheKey = filesCacheKey + v\n\t}\n\n\tvar t *template.Template\n\tvar exists bool\n\tif r.enabledCache {\n\t\t//check from chach\n\t\tt, exists = r.parseFilesFromCache(filesCacheKey)\n\t}\n\tif !exists{\n\t\tt, err = template.ParseFiles(realFileNames...)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tr.templateCacheMutex.Lock()\n\t\tdefer r.templateCacheMutex.Unlock()\n\t\tr.templateCache[filesCacheKey] = t\n\t}\n\n\tt = registeTemplateFunc(t)\n\treturn t, nil\n}", "func Templ(target string) (t *template.Template) {\n\tt = template.New(\"\")\n\tgo func() {\n\t\tfor {\n\t\t\tf, err := ioutil.ReadFile(target)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"%s, %v\", target, err)\n\t\t\t} else {\n\t\t\t\tt.Parse(string(f))\n\t\t\t}\n\t\t\tsleep()\n\t\t}\n\t}()\n\treturn t\n}", "func (g *Generator) parse(path string, stringTemplates map[string]string) (*Template, error) {\n\tif g.cache {\n\t\tif tpl, prs := g.gtemplates[path]; prs {\n\t\t\treturn tpl, nil\n\t\t}\n\t}\n\tvar s string\n\tif stringTemplates == nil {\n\t\tb, err := ioutil.ReadFile(path)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ts = string(b)\n\t} else {\n\t\ts = stringTemplates[path]\n\t}\n\tlines := strings.Split(formatLf(s), \"\\n\")\n\ti, l := 0, len(lines)\n\ttpl := NewTemplate(path, g)\n\tfor i < l {\n\t\tline := lines[i]\n\t\ti++\n\t\tif empty(line) {\n\t\t\tcontinue\n\t\t}\n\t\tif topElement(line) {\n\t\t\tswitch {\n\t\t\tcase isExtends(line):\n\t\t\t\ttokens := strings.Split(strings.TrimSpace(line), \" \")\n\t\t\t\tif l := len(tokens); l != extendsBlockTokensLen {\n\t\t\t\t\treturn nil, errors.New(fmt.Sprintf(\"The line tokens length is invalid. (expected: %d, actual: %d, line no: %d)\", extendsBlockTokensLen, l, i))\n\t\t\t\t}\n\t\t\t\tsuperTplPath := tokens[1]\n\t\t\t\tvar superTpl *Template\n\t\t\t\tvar err error\n\t\t\t\tif stringTemplates == nil {\n\t\t\t\t\tsuperTpl, err = g.parse(tpl.Dir()+superTplPath+goldExtension, nil)\n\t\t\t\t} else {\n\t\t\t\t\tsuperTpl, err = g.parse(superTplPath, stringTemplates)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tsuperTpl.Sub = tpl\n\t\t\t\ttpl.Super = superTpl\n\t\t\tcase tpl.Super != nil && isBlock(line):\n\t\t\t\ttokens := strings.Split(strings.TrimSpace(line), \" \")\n\t\t\t\tif l := len(tokens); l != extendsBlockTokensLen {\n\t\t\t\t\treturn nil, errors.New(fmt.Sprintf(\"The lien tokens length is invalid. (expected: %d, actual: %d, line no: %d)\", extendsBlockTokensLen, l, i))\n\t\t\t\t}\n\t\t\t\tblock := &Block{Name: tokens[1], Template: tpl}\n\t\t\t\ttpl.AddBlock(block.Name, block)\n\t\t\t\tif err := appendChildren(block, lines, &i, &l, indentTop, false, \"\"); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\te, err := NewElement(line, i, indentTop, nil, tpl, nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\ttpl.AppendElement(e)\n\t\t\t\tif err := appendChildren(e, lines, &i, &l, indentTop, e.RawContent, e.Type); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif g.cache {\n\t\tg.gtemplates[path] = tpl\n\t}\n\treturn tpl, nil\n}", "func layoutFiles() []string {\n\tfiles, err := filepath.Glob(LayoutDir + \"*\" + TemplateExt)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn files\n}", "func (tf *templateFile) visit(paths string, f os.FileInfo, err error) error {\n\tif f == nil {\n\t\treturn err\n\t}\n\tif f.IsDir() || (f.Mode()&os.ModeSymlink) > 0 {\n\t\treturn nil\n\t}\n\tif !HasTemplateExt(paths) {\n\t\treturn nil\n\t}\n\n\treplace := strings.NewReplacer(\"\\\\\", \"/\")\n\tfile := strings.TrimLeft(replace.Replace(paths[len(tf.root):]), \"/\")\n\tsubDir := filepath.Dir(file)\n\n\ttf.files[subDir] = append(tf.files[subDir], file)\n\treturn nil\n}", "func (tf *templateFile) visit(paths string, f os.FileInfo, err error) error {\n\tif f == nil {\n\t\treturn err\n\t}\n\tif f.IsDir() || (f.Mode()&os.ModeSymlink) > 0 {\n\t\treturn nil\n\t}\n\tif !HasTemplateExt(paths) {\n\t\treturn nil\n\t}\n\n\treplace := strings.NewReplacer(\"\\\\\", \"/\")\n\tfile := strings.TrimLeft(replace.Replace(paths[len(tf.root):]), \"/\")\n\tsubDir := filepath.Dir(file)\n\n\ttf.files[subDir] = append(tf.files[subDir], file)\n\treturn nil\n}", "func (p *FileMap) loadFilesRecursively(cwd string) error {\n\tfileList, err := ioutil.ReadDir(cwd)\n\n\tif err != nil {\n\t\terr = StringError{s: \"ERROR: Can't open \\\"\" + cwd + \"\\\" directory!\"}\n\t\treturn err\n\t}\n\n\tfor _, f := range fileList {\n\t\tfileName := f.Name()\n\n\t\tif f.IsDir() {\n\t\t\terr := p.loadFilesRecursively(cwd + fileName + \"/\")\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tbaseName, ext := getBaseAndExt(fileName)\n\n\t\t\t_, err := p.load(cwd+baseName, ext)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfmt.Println(\"INFO: Loaded file: \" + cwd + filepath.Base(fileName))\n\t\t}\n\t}\n\treturn nil\n}", "func main() {\n\t// go through each directory in go using os package\n\thtmlFiles := []string{}\n\toutputFolder := \"gh-pages\"\n\treg := []string{\"rm\", \"-rf\", outputFolder}\n\tcmd := strings.Join(reg[:], \" \")\n\n\ttmpl := `\n\t<html>\n\t\t<head>\n\t\t\t<title>List of Matlab Reports and Files</title>\n\t\t</head>\n\t\t<body>\n\t\t\t<h1>List of Files</h1>\n\t\t\t<ul>\n\t\t\t{{ range . }}\n\t\t\t\t<li><a href={{.}}>{{ . }}</a></li>\n\t\t\t{{ end }}\n\t\t\t</ul>\n\t\t</body>\n\t</html>\n\t`\n\tscript.IfExists(outputFolder).Exec(cmd).Stdout()\n\tscript.FindFiles(\".\").FilterScan(func(line string, w io.Writer) {\n\t\t// if line contains html print it\n\t\tif strings.Contains(line, \".html\") || strings.Contains(line, \".pdf\") {\n\t\t\tfmt.Fprintf(w, \"scanned line: %q\\n\", line)\n\t\t\thtmlFiles = append(htmlFiles, line)\n\t\t}\n\t}).Stdout()\n\n\tfmt.Println(htmlFiles)\n\t// create html directory\n\tscript.Exec(\"mkdir \" + outputFolder).Stdout()\n\n\t// for each html file\n\tfor _, file := range htmlFiles {\n\t\treg = []string{\"cp\", file, outputFolder}\n\t\tcmd = strings.Join(reg[:], \" \")\n\t\t// copy file to html directory\n\t\tscript.Exec(cmd).Stdout()\n\t}\n\n\t// move ads.txt to html directory\n\tscript.Exec(\"mv ads.txt \" + outputFolder).Stdout()\n\n\tt, err := template.New(\"files\").Parse(tmpl)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tfile, err := os.Create(outputFolder + \"/index.html\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\t// remove outputFolder from htmlFiles\n\tfor i, file := range htmlFiles {\n\t\t// get basename of file\n\t\tbaseName := filepath.Base(file)\n\t\thtmlFiles[i] = baseName\n\t}\n\terr = t.Execute(file, htmlFiles)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n}", "func (ctx *Context) Populate() error {\n\tctx.Templates = make(map[string]*template.Template)\n\tctx.Imports = make(map[string]bool)\n\n\tfor _, dir := range ctx.SearchPaths {\n\t\terr := ctx.searchDir(dir)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func TemplateRootDir() (string, error) {\n\tconfig, err := os.UserConfigDir()\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"failed to get UserConfigDir\")\n\t}\n\n\ttmplPath := filepath.Join(config, \"suborbital\", \"templates\")\n\n\tif os.Stat(tmplPath); err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\tif err := os.MkdirAll(tmplPath, os.ModePerm); err != nil {\n\t\t\t\treturn \"\", errors.Wrap(err, \"failed to MkdirAll template directory\")\n\t\t\t}\n\t\t} else {\n\t\t\treturn \"\", errors.Wrap(err, \"failed to Stat template directory\")\n\t\t}\n\t}\n\n\treturn tmplPath, nil\n}", "func (t *Tmpl) Load() (err error) {\n\t// time point\n\tt.loadedAt = time.Now()\n\n\t// unnamed root template\n\tvar root = template.New(\"\")\n\n\tvar walkFunc = func(path string, info os.FileInfo, err error) (_ error) {\n\t\t// handle walking error if any\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// skip all except regular files\n\t\tif !info.Mode().IsRegular() {\n\t\t\treturn\n\t\t}\n\n\t\t// filter by extension\n\t\tif filepath.Ext(path) != t.ext {\n\t\t\treturn\n\t\t}\n\n\t\t// get relative path\n\t\tvar rel string\n\t\tif rel, err = filepath.Rel(t.dir, path); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// name of a template is its relative path\n\t\t// without extension\n\t\trel = strings.TrimSuffix(rel, t.ext)\n\n\t\t// load or reload\n\t\tvar (\n\t\t\tnt = root.New(rel)\n\t\t\tb []byte\n\t\t)\n\n\t\tif b, err = ioutil.ReadFile(path); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = nt.Parse(string(b))\n\t\treturn err\n\t}\n\n\tif err = filepath.Walk(t.dir, walkFunc); err != nil {\n\t\treturn\n\t}\n\n\t// necessary for reloading\n\tif t.funcs != nil {\n\t\troot = root.Funcs(t.funcs)\n\t}\n\n\tt.Template = root // set or replace\n\treturn\n}", "func layoutFiles() []string {\n\tfiles, err := filepath.Glob(layoutDir + \"*\" + templateExt)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn files\n}", "func (h *talksHandler) renderDir(w io.Writer, path string, d dirReader) error {\n\tfis, err := d.Readdir(0)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdl := &dirList{Base: h.base, Path: path}\n\tif path != \"/\" {\n\t\tdl.Dirs = append(dl.Dirs, dirEntry{\n\t\t\tPath: pathpkg.Join(path, \"..\"),\n\t\t\tName: \"..\",\n\t\t})\n\t}\n\thasSlides := hasSlides(fis)\n\tfor _, fi := range fis {\n\t\tswitch dir, ext := fi.IsDir(), pathpkg.Ext(fi.Name()); {\n\t\t// Add directories to Dirs, if no slides.\n\t\tcase dir && !hasSlides:\n\t\t\tdl.Dirs = append(dl.Dirs, dirEntry{\n\t\t\t\tPath: pathpkg.Join(path, fi.Name()),\n\t\t\t\tName: fi.Name(),\n\t\t\t})\n\n\t\t// Add .slide files to Slides.\n\t\tcase !dir && ext == \".slide\":\n\t\t\ttitle, err := parseTitle(h.fs, pathpkg.Join(path, fi.Name()))\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\ttitle = \"\"\n\t\t\t}\n\t\t\tdl.Slides = append(dl.Slides, dirEntry{\n\t\t\t\tPath: pathpkg.Join(path, fi.Name()),\n\t\t\t\tName: fi.Name(),\n\t\t\t\tTitle: title,\n\t\t\t})\n\n\t\t// Add .pdf files to Files.\n\t\tcase !dir && ext == \".pdf\":\n\t\t\tdl.Files = append(dl.Files, dirEntry{\n\t\t\t\tPath: pathpkg.Join(path, fi.Name()),\n\t\t\t\tName: fi.Name(),\n\t\t\t})\n\t\t}\n\t}\n\tsort.Sort(dl.Dirs)\n\tsort.Sort(dl.Slides)\n\tsort.Sort(dl.Files)\n\n\t_, err = io.WriteString(w, htmlg.Render(dl.Render()...))\n\treturn err\n}", "func (t *Renderer) ReloadTemplates() {\n\tt.template = template.Must(template.ParseGlob(t.location))\n}", "func FindStepTemplates(dir, stepName string, platform config.Platform) (string, error) {\n\tstepDir := filepath.Join(dir, stepsBaseDir, stepName)\n\tfor _, path := range []string{\n\t\tfilepath.Join(stepDir, string(platform)),\n\t\tstepDir} {\n\n\t\tstat, err := os.Stat(path)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn \"\", fmt.Errorf(\"invalid path for %q templates: %s\", path, err)\n\t\t}\n\t\tif !stat.IsDir() {\n\t\t\treturn \"\", fmt.Errorf(\"invalid path for %q templates\", path)\n\t\t}\n\t\treturn path, nil\n\t}\n\treturn \"\", os.ErrNotExist\n}" ]
[ "0.71167123", "0.6988426", "0.6940073", "0.68628114", "0.67087746", "0.66926205", "0.66885155", "0.667753", "0.66757613", "0.66010064", "0.6564374", "0.6556842", "0.6528031", "0.6474018", "0.6458112", "0.6447552", "0.6434968", "0.64225084", "0.62655014", "0.62508416", "0.6185642", "0.6156191", "0.613565", "0.61032367", "0.60927904", "0.60898167", "0.6065319", "0.6043452", "0.601303", "0.6005443", "0.6002862", "0.5988594", "0.59860826", "0.59809136", "0.5945943", "0.59325355", "0.59150493", "0.59124464", "0.5898647", "0.5897283", "0.5896082", "0.5892562", "0.5884715", "0.58627486", "0.5855943", "0.5815668", "0.58022094", "0.57838774", "0.5783146", "0.5779371", "0.57539964", "0.57349145", "0.57093626", "0.5706491", "0.57043856", "0.56942046", "0.5686175", "0.56636906", "0.5662847", "0.5662317", "0.56591", "0.56585735", "0.56553096", "0.5650947", "0.56478155", "0.5619425", "0.5615608", "0.5613138", "0.56116074", "0.5593287", "0.5589454", "0.5580391", "0.55754375", "0.5542502", "0.55424035", "0.5540786", "0.55402356", "0.55323935", "0.5532342", "0.55299085", "0.5522178", "0.5505863", "0.55036736", "0.548685", "0.54827106", "0.54825395", "0.54764533", "0.5470972", "0.5453744", "0.5438303", "0.5438303", "0.54297537", "0.54131424", "0.5404335", "0.5402147", "0.5391048", "0.53879035", "0.5377191", "0.5372119", "0.5358732" ]
0.7967958
0
RunPreExecutor runs an arbitary preexecutor to template the yaml files
func RunPreExecutor(spec *opsv1alpha1.GitOps, dir string) error { if spec.Spec.Templating != nil { t := spec.Spec.Templating if t.Executor != nil { // Create a new context and add a timeout to it ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() // The cancel should be deferred so resources are cleaned up cmd := exec.CommandContext(ctx, t.Executor.Exec) cmd.Dir = GetGitRootDir(spec) if spec.Spec.Templating.SourceFolder != "" { cmd.Dir += "/" + spec.Spec.Templating.SourceFolder } if len(t.Executor.Args) >= 1 { a := []string{t.Executor.Exec} for _, add := range t.Executor.Args { a = append(a, add) } cmd.Args = a } out, err := cmd.CombinedOutput() if ctx.Err() == context.DeadlineExceeded { log.Error(err, "Command timed out") return err } if err != nil { log.Error(err, "Command failed", "output", string(out)) } return err } } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (k *PluginRunner) preRun(cmd *cobra.Command, args []string) error {\n\tlr := fLdr.RestrictionRootOnly\n\tfSys := filesys.MakeFsOnDisk()\n\tldr, err := fLdr.NewLoader(lr, filepath.Clean(k.root), fSys)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tv := validator.NewKustValidator()\n\n\tuf := kunstruct.NewKunstructuredFactoryImpl()\n\tvar pm resmap.Merginator // TODO The actual implementation is internal now...\n\trf := resmap.NewFactory(resource.NewFactory(uf), pm)\n\n\tk.h = resmap.NewPluginHelpers(ldr, v, rf)\n\n\tif c, ok := k.plugin.(resmap.Configurable); ok {\n\t\tconfig, err := k.config(cmd, args)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := c.Config(k.h, config); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func ExecutePre(ctx context.Context, c string) {\n\texecute(ctx, c, preJobMap)\n}", "func preRunPublish(cmd *cobra.Command, args []string) error {\n\tlanguage, _ = validateLanguageFlag(language)\n\n\tmapped, err := parseBuildArgs(buildArgs)\n\n\tif err == nil {\n\t\tbuildArgMap = mapped\n\t}\n\n\tbuildLabelMap, err = util.ParseMap(buildLabels, \"build-label\")\n\n\tif parallel < 1 {\n\t\treturn fmt.Errorf(\"the --parallel flag must be great than 0\")\n\t}\n\n\tif len(yamlFile) == 0 {\n\t\treturn fmt.Errorf(\"--yaml or -f is required\")\n\t}\n\n\treturn err\n}", "func (*configureExecutor) PreCheck(ctx context.Context) error {\n\treturn nil\n}", "func (gen *Generator) RunBefore() (err error) {\n\tfor _, cmd := range gen.Template.RunBefore {\n\t\tvar command string\n\n\t\tif command, err = templates.Expand(cmd, gen.Project.helpers); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tLog.Info(\"run_before\", command)\n\n\t\tCommand := templates.CommandOptions{\n\t\t\tCmd: command,\n\t\t\tDir: gen.Project.Directory,\n\t\t\tUseStdOut: true,\n\t\t}\n\n\t\tif _, err := templates.Run(Command); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn err\n}", "func (tr *TaskRunner) prestart() error {\n\t// Determine if the allocation is terminal and we should avoid running\n\t// prestart hooks.\n\tif tr.shouldShutdown() {\n\t\ttr.logger.Trace(\"skipping prestart hooks since allocation is terminal\")\n\t\treturn nil\n\t}\n\n\tif tr.logger.IsTrace() {\n\t\tstart := time.Now()\n\t\ttr.logger.Trace(\"running prestart hooks\", \"start\", start)\n\t\tdefer func() {\n\t\t\tend := time.Now()\n\t\t\ttr.logger.Trace(\"finished prestart hooks\", \"end\", end, \"duration\", end.Sub(start))\n\t\t}()\n\t}\n\n\t// use a join context to allow any blocking pre-start hooks\n\t// to be canceled by either killCtx or shutdownCtx\n\tjoinedCtx, joinedCancel := joincontext.Join(tr.killCtx, tr.shutdownCtx)\n\tdefer joinedCancel()\n\n\tfor _, hook := range tr.runnerHooks {\n\t\tpre, ok := hook.(interfaces.TaskPrestartHook)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tname := pre.Name()\n\n\t\t// Build the request\n\t\treq := interfaces.TaskPrestartRequest{\n\t\t\tTask: tr.Task(),\n\t\t\tTaskDir: tr.taskDir,\n\t\t\tTaskEnv: tr.envBuilder.Build(),\n\t\t\tTaskResources: tr.taskResources,\n\t\t}\n\n\t\torigHookState := tr.hookState(name)\n\t\tif origHookState != nil {\n\t\t\tif origHookState.PrestartDone {\n\t\t\t\ttr.logger.Trace(\"skipping done prestart hook\", \"name\", pre.Name())\n\n\t\t\t\t// Always set env vars from hooks\n\t\t\t\tif name == HookNameDevices {\n\t\t\t\t\ttr.envBuilder.SetDeviceHookEnv(name, origHookState.Env)\n\t\t\t\t} else {\n\t\t\t\t\ttr.envBuilder.SetHookEnv(name, origHookState.Env)\n\t\t\t\t}\n\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Give the hook it's old data\n\t\t\treq.PreviousState = origHookState.Data\n\t\t}\n\n\t\treq.VaultToken = tr.getVaultToken()\n\t\treq.NomadToken = tr.getNomadToken()\n\n\t\t// Time the prestart hook\n\t\tvar start time.Time\n\t\tif tr.logger.IsTrace() {\n\t\t\tstart = time.Now()\n\t\t\ttr.logger.Trace(\"running prestart hook\", \"name\", name, \"start\", start)\n\t\t}\n\n\t\t// Run the prestart hook\n\t\tvar resp interfaces.TaskPrestartResponse\n\t\tif err := pre.Prestart(joinedCtx, &req, &resp); err != nil {\n\t\t\ttr.emitHookError(err, name)\n\t\t\treturn structs.WrapRecoverable(fmt.Sprintf(\"prestart hook %q failed: %v\", name, err), err)\n\t\t}\n\n\t\t// Store the hook state\n\t\t{\n\t\t\thookState := &state.HookState{\n\t\t\t\tData: resp.State,\n\t\t\t\tPrestartDone: resp.Done,\n\t\t\t\tEnv: resp.Env,\n\t\t\t}\n\n\t\t\t// Store and persist local state if the hook state has changed\n\t\t\tif !hookState.Equal(origHookState) {\n\t\t\t\ttr.stateLock.Lock()\n\t\t\t\ttr.localState.Hooks[name] = hookState\n\t\t\t\ttr.stateLock.Unlock()\n\n\t\t\t\tif err := tr.persistLocalState(); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Store the environment variables returned by the hook\n\t\tif name == HookNameDevices {\n\t\t\ttr.envBuilder.SetDeviceHookEnv(name, resp.Env)\n\t\t} else {\n\t\t\ttr.envBuilder.SetHookEnv(name, resp.Env)\n\t\t}\n\n\t\t// Store the resources\n\t\tif len(resp.Devices) != 0 {\n\t\t\ttr.hookResources.setDevices(resp.Devices)\n\t\t}\n\t\tif len(resp.Mounts) != 0 {\n\t\t\ttr.hookResources.setMounts(resp.Mounts)\n\t\t}\n\n\t\tif tr.logger.IsTrace() {\n\t\t\tend := time.Now()\n\t\t\ttr.logger.Trace(\"finished prestart hook\", \"name\", name, \"end\", end, \"duration\", end.Sub(start))\n\t\t}\n\t}\n\n\treturn nil\n}", "func (l *LauncherV2) prePublish(ctx context.Context) (execution *metadata.Execution, err error) {\n\tdefer func() {\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"failed to pre-publish Pod info to ML Metadata: %w\", err)\n\t\t}\n\t}()\n\texecution, err = l.metadataClient.GetExecution(ctx, l.executionID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tecfg := &metadata.ExecutionConfig{\n\t\tPodName: l.options.PodName,\n\t\tPodUID: l.options.PodUID,\n\t\tNamespace: l.options.Namespace,\n\t}\n\treturn l.metadataClient.PrePublishExecution(ctx, execution, ecfg)\n}", "func runPreInit(ctx context.Context, workingDir string, deps *clientset.Clientset, cmdline cmdline.Cmdline, msg string) error {\n\tisEmptyDir, err := location.DirIsEmpty(deps.FS, workingDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif isEmptyDir {\n\t\treturn NewNoDevfileError(workingDir)\n\t}\n\n\tinitFlags := deps.InitClient.GetFlags(cmdline.GetFlags())\n\n\terr = deps.InitClient.InitDevfile(ctx, initFlags, workingDir,\n\t\tfunc(interactiveMode bool) {\n\t\t\tscontext.SetInteractive(cmdline.Context(), interactiveMode)\n\t\t\tif interactiveMode {\n\t\t\t\tlog.Title(msg, messages.SourceCodeDetected, \"odo version: \"+version.VERSION)\n\t\t\t\tlog.Info(\"\\n\" + messages.InteractiveModeEnabled)\n\t\t\t}\n\t\t},\n\t\tfunc(newDevfileObj parser.DevfileObj) error {\n\t\t\tdErr := newDevfileObj.WriteYamlDevfile()\n\t\t\tif dErr != nil {\n\t\t\t\treturn dErr\n\t\t\t}\n\t\t\tdErr = files.ReportLocalFileGeneratedByOdo(deps.FS, workingDir, filepath.Base(newDevfileObj.Ctx.GetAbsPath()))\n\t\t\tif dErr != nil {\n\t\t\t\tklog.V(4).Infof(\"error trying to report local file generated: %v\", dErr)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (*checksExecutor) PreCheck(ctx context.Context) error {\n\treturn nil\n}", "func (a *Agent) ExecutePreHooks(ctx context.Context, request json.RawMessage) context.Context {\n\ta.Reporter.FlushFlag()\n\n\t// Sort plugins w.r.t their orders\n\tsort.Slice(a.Plugins, func(i, j int) bool {\n\t\treturn a.Plugins[i].Order() < a.Plugins[j].Order()\n\t})\n\tplugin.TraceID = utils.GenerateNewID()\n\tplugin.TransactionID = utils.GenerateNewID()\n\n\t// Traverse sorted plugin slice\n\tfor _, p := range a.Plugins {\n\t\tctx = p.BeforeExecution(ctx, request)\n\t}\n\n\treturn ctx\n}", "func (p *PrecheckHandler) Precheck(c echo.Context, clusterID uint, driverID uint, modules []model.ModuleType, moduleConfig string) error {\n\tavailableModules := make(map[string]string)\n\n\tcluster, err := p.clusterStore.GetByID(clusterID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif cluster == nil {\n\t\treturn fmt.Errorf(\"not able to find cluster with id %d\", clusterID)\n\t}\n\n\tcfs, err := p.configFileStore.GetAll()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif driverID > 0 {\n\t\tdriver, err := p.driverStore.GetByID(driverID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif driver == nil {\n\t\t\treturn fmt.Errorf(\"not able to find driver with id %d\", driverID)\n\t\t}\n\n\t\tdriverPrechecks := p.precheckGetter.GetDriverPrechecks(driver.StorageArrayType.Name, cluster.ConfigFileData, cluster.ClusterDetails.Nodes, modules, c.Logger())\n\t\tfor _, precheck := range driverPrechecks {\n\t\t\tc.Logger().Printf(\"Running precheck: %T for driver of type %s\", precheck, driver.StorageArrayType.Name)\n\t\t\terr := precheck.Validate()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tavailableModules[\"csidriver\"] = driver.StorageArrayType.Name\n\t}\n\n\tfor _, m := range modules {\n\t\tavailableModules[m.Name] = m.Name\n\t}\n\n\t// Run pre-checks for standalone modules (ex: observability)\n\tfor _, module := range modules {\n\t\tmodulePrechecks := p.precheckGetter.GetModuleTypePrechecks(module.Name, moduleConfig, cluster.ConfigFileData, cfs, availableModules)\n\t\tfor _, precheck := range modulePrechecks {\n\t\t\tc.Logger().Printf(\"Running precheck: %T for %s module\", precheck, module.Name)\n\t\t\terr := precheck.Validate()\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 (*clusterPackagesExecutor) PreCheck(ctx context.Context) error {\n\treturn nil\n}", "func (w *DefaultPreWorkflowHooksCommandRunner) RunPreHooks(\n\tbaseRepo models.Repo,\n\theadRepo models.Repo,\n\tpull models.PullRequest,\n\tuser models.User,\n) {\n\tif opStarted := w.Drainer.StartOp(); !opStarted {\n\t\tif commentErr := w.VCSClient.CreateComment(baseRepo, pull.Num, ShutdownComment, \"pre_workflow_hooks\"); commentErr != nil {\n\t\t\tw.Logger.Log(logging.Error, \"unable to comment that Atlantis is shutting down: %s\", commentErr)\n\t\t}\n\t\treturn\n\t}\n\tdefer w.Drainer.OpDone()\n\n\tlog := w.buildLogger(baseRepo.FullName, pull.Num)\n\tdefer w.logPanics(baseRepo, pull.Num, log)\n\n\tlog.Info(\"running pre hooks\")\n\n\tunlockFn, err := w.WorkingDirLocker.TryLock(baseRepo.FullName, pull.Num, DefaultWorkspace)\n\tif err != nil {\n\t\tlog.Warn(\"workspace is locked\")\n\t\treturn\n\t}\n\tlog.Debug(\"got workspace lock\")\n\tdefer unlockFn()\n\n\trepoDir, _, err := w.WorkingDir.Clone(log, headRepo, pull, DefaultWorkspace)\n\tif err != nil {\n\t\tlog.Err(\"unable to run pre workflow hooks: %s\", err)\n\t\treturn\n\t}\n\n\tpreWorkflowHooks := make([]*valid.PreWorkflowHook, 0)\n\tfor _, repo := range w.GlobalCfg.Repos {\n\t\tif repo.IDMatches(baseRepo.ID()) && len(repo.PreWorkflowHooks) > 0 {\n\t\t\tpreWorkflowHooks = append(preWorkflowHooks, repo.PreWorkflowHooks...)\n\t\t}\n\t}\n\n\tctx := models.PreWorkflowHookCommandContext{\n\t\tBaseRepo: baseRepo,\n\t\tHeadRepo: headRepo,\n\t\tLog: log,\n\t\tPull: pull,\n\t\tUser: user,\n\t\tVerbose: false,\n\t}\n\n\terr = w.runHooks(ctx, preWorkflowHooks, repoDir)\n\n\tif err != nil {\n\t\tlog.Err(\"pre workflow hook run error results: %s\", err)\n\t}\n}", "func (r *registryExecutor) PreCheck(context.Context) error {\n\treturn nil\n}", "func setupPreparers(fixture consultest.Fixture) {\n\tfor _, node := range testNodes {\n\t\tkey := fmt.Sprintf(\"reality/%s/p2-preparer\", node)\n\t\tfixture.SetKV(key, []byte(testPreparerManifest))\n\t}\n}", "func PreLoadInitImages(bc *bits.BuildContext, srcFolder string) error {\n\t// Currently docker images preloaded at build time gets lost at commit time, so this is a NOP\n\t// and images tars are loaded at node create time.\n\t// If we manage to get this working then we will speed up node creation time for docker;\n\t// A possible hint to solve is to remove VOLUME [ \"/var/lib/docker\" ] from the base image and add \"--change\", `VOLUME [ \"/var/lib/docker\" ]`\n\t// on commit, however this will force kinder to start using a new base image for all the docker jobs in ci\n\treturn nil\n}", "func (f *fsmUpdateEngine) PreExecute(ctx context.Context, p fsm.Params) error {\n\treturn nil\n}", "func (panel *Panel) PreExecute(*html.Session, string, http.ResponseWriter, *http.Request) (html.ExecutionResult, error) {\n\treturn html.ContinueExecution, nil\n}", "func (opts *globalOpts) PreRunE(cbs ...cmdOpt) error {\n\tif opts.ProjectID() == \"\" {\n\t\treturn errMissingProjectID\n\t}\n\tif err := validate.ObjectID(opts.ProjectID()); err != nil {\n\t\treturn err\n\t}\n\tfor _, f := range cbs {\n\t\tif err := f(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func NewPreRunner(name string, fn func() error) PreRunner {\n\treturn preRunner{name: name, fn: fn}\n}", "func persistentPreRunEFn(context *server.Context) func(*cobra.Command, []string) error {\n\treturn func(cmd *cobra.Command, args []string) error {\n\t\t// run sdk/tendermint configuration\n\t\tif err := server.PersistentPreRunEFn(context)(cmd, args); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// custom plasma config\n\t\tplasmaConfigFilePath := filepath.Join(context.Config.RootDir, \"config/plasma.toml\")\n\n\t\tif _, err := os.Stat(plasmaConfigFilePath); os.IsNotExist(err) {\n\t\t\tplasmaConfig := config.DefaultPlasmaConfig()\n\t\t\tconfig.WritePlasmaConfigFile(plasmaConfigFilePath, plasmaConfig)\n\t\t}\n\n\t\t// read in plasma.toml from the config directory\n\t\tviper.SetConfigName(\"plasma\")\n\t\terr := viper.MergeInConfig()\n\t\treturn err\n\t}\n}", "func PersistentPreRunEFn(ctx *Context) func(*cobra.Command, []string) error {\n\treturn func(cmd *cobra.Command, args []string) error {\n\t\trootViper := viper.New()\n\t\trootViper.BindPFlags(cmd.Flags())\n\t\trootViper.BindPFlags(cmd.PersistentFlags())\n\n\t\tif cmd.Name() == version.Cmd.Name() {\n\t\t\treturn nil\n\t\t}\n\n\t\tconfig, err := interceptConfigs(ctx, rootViper)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tlogger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))\n\t\tlogger, err = tmflags.ParseLogLevel(config.LogLevel, logger, tmcfg.DefaultLogLevel())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif rootViper.GetBool(tmcli.TraceFlag) {\n\t\t\tlogger = log.NewTracingLogger(logger)\n\t\t}\n\n\t\tlogger = logger.With(\"module\", \"main\")\n\t\tctx.Config = config\n\t\tctx.Logger = logger\n\n\t\treturn nil\n\t}\n}", "func (test *RestTest) PreExecute(testcase *TestCase, ctx *TestContext) error {\n\n\ttestcase.SetVerifyTestFunc(VerifyRestTestByDefault)\n\n\tswitch testcase.Method {\n\tcase METHOD_CREATE_SERVICE:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPostTestFunc(PostCreateGetServiceTest)\n\t\tbreak\n\tcase METHOD_GET_SERVICE:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPostTestFunc(PostCreateGetServiceTest)\n\t\tbreak\n\tcase METHOD_QUERY_SERVICE:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPostTestFunc(PostListServiceTest)\n\t\tbreak\n\tcase METHOD_DELETE_SERVICE:\n\t\ttest.Client = NewRestClient_PMS()\n\t\tbreak\n\tcase METHOD_CREATE_POLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPostTestFunc(PostCreateGetPolicyTest)\n\t\tbreak\n\tcase METHOD_GET_POLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPreTestFunc(PreGetDeletePolicyTest)\n\t\ttestcase.SetPostTestFunc(PostCreateGetPolicyTest)\n\t\tbreak\n\tcase METHOD_QUERY_POLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPostTestFunc(PostListPolicyTest)\n\t\tbreak\n\tcase METHOD_DELETE_POLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPreTestFunc(PreGetDeletePolicyTest)\n\t\tbreak\n\tcase METHOD_CREATE_ROLEPOLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPostTestFunc(PostCreateGetRolePolicyTest)\n\t\tbreak\n\tcase METHOD_GET_ROLEPOLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPreTestFunc(PreGetDeletePolicyTest)\n\t\ttestcase.SetPostTestFunc(PostCreateGetRolePolicyTest)\n\t\tbreak\n\tcase METHOD_QUERY_ROLEPOLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPostTestFunc(PostListRolePolicyTest)\n\t\tbreak\n\tcase METHOD_DELETE_ROLEPOLICY:\n\t\ttest.Client = NewRestClient_PMS()\n\t\ttestcase.SetPreTestFunc(PreGetDeletePolicyTest)\n\t\tbreak\n\tcase METHOD_IS_ALLOWED:\n\t\ttest.Client = NewRestClient_ADS()\n\t\tbreak\n\tcase METHOD_GET_GRANTED_PERMISSIONS:\n\t\ttest.Client = NewRestClient_ADS()\n\t\tbreak\n\tcase METHOD_GET_GRANTED_ROLES:\n\t\ttest.Client = NewRestClient_ADS()\n\t\tbreak\n\tdefault:\n\t\treturn errors.New(ERROR_SPEEDLE_NOT_SUPPORTED)\n\t}\n\n\treturn nil\n}", "func (*etcdExecutor) PreCheck(ctx context.Context) error {\n\treturn nil\n}", "func preRun(c *cobra.Command, args []string) error {\n\tif len(args) < 1 {\n\t\treturn errors.New(\"Missing name argument\")\n\t}\n\n\tname = args[0]\n\treturn nil\n}", "func (s *Scheduler) prepareAndExec(r gaia.PipelineRun) {\n\t// Mark the scheduled run as running\n\tr.Status = gaia.RunRunning\n\tr.StartDate = time.Now()\n\n\t// Update entry in store\n\terr := s.storeService.PipelinePutRun(&r)\n\tif err != nil {\n\t\tgaia.Cfg.Logger.Debug(\"could not put pipeline run into store during executing work\", \"error\", err.Error())\n\t\treturn\n\t}\n\n\t// Get related pipeline from pipeline run\n\tpipeline, _ := s.storeService.PipelineGet(r.PipelineID)\n\n\t// Check if this pipeline has jobs declared\n\tif len(r.Jobs) == 0 {\n\t\t// Finish pipeline run\n\t\ts.finishPipelineRun(&r, gaia.RunSuccess)\n\t\treturn\n\t}\n\n\t// Check if circular dependency exists\n\tfor _, job := range r.Jobs {\n\t\tif _, err := s.checkCircularDep(job, []*gaia.Job{}, []*gaia.Job{}); err != nil {\n\t\t\tgaia.Cfg.Logger.Info(\"circular dependency detected\", \"pipeline\", pipeline)\n\t\t\tgaia.Cfg.Logger.Info(\"information\", \"info\", err.Error())\n\n\t\t\t// Update store\n\t\t\ts.finishPipelineRun(&r, gaia.RunFailed)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Create logs folder for this run\n\tpath := filepath.Join(gaia.Cfg.WorkspacePath, strconv.Itoa(r.PipelineID), strconv.Itoa(r.ID), gaia.LogsFolderName)\n\terr = os.MkdirAll(path, 0700)\n\tif err != nil {\n\t\tgaia.Cfg.Logger.Error(\"cannot create pipeline run folder\", \"error\", err.Error(), \"path\", path)\n\t}\n\n\t// Create the start command for the pipeline\n\tc := createPipelineCmd(pipeline)\n\tif c == nil {\n\t\tgaia.Cfg.Logger.Debug(\"cannot create pipeline start command\", \"error\", errCreateCMDForPipeline.Error())\n\t\ts.finishPipelineRun(&r, gaia.RunFailed)\n\t\treturn\n\t}\n\n\t// Create new plugin instance\n\tpS := s.pluginSystem.NewPlugin(s.ca)\n\n\t// Init the plugin\n\tpath = filepath.Join(path, gaia.LogsFileName)\n\tif err := pS.Init(c, &path); err != nil {\n\t\tgaia.Cfg.Logger.Debug(\"cannot initialize the plugin\", \"error\", err.Error(), \"pipeline\", pipeline)\n\t\ts.finishPipelineRun(&r, gaia.RunFailed)\n\t\treturn\n\t}\n\n\t// Validate the plugin(pipeline)\n\tif err := pS.Validate(); err != nil {\n\t\tgaia.Cfg.Logger.Debug(\"cannot validate pipeline\", \"error\", err.Error(), \"pipeline\", pipeline)\n\t\ts.finishPipelineRun(&r, gaia.RunFailed)\n\t\treturn\n\t}\n\tdefer pS.Close()\n\n\t// Schedule jobs and execute them.\n\t// Also update the run in the store.\n\ts.executeScheduledJobs(r, pS)\n}", "func (p *PreInplaceControl) createHookRun(metaObj metav1.Object, runtimeObj runtime.Object,\n\tpreInplaceHook *hookv1alpha1.HookStep, pod *v1.Pod, podTemplate *v1.PodTemplateSpec, labels map[string]string,\n\tpodNameLabelKey string) (*hookv1alpha1.HookRun, error) {\n\targuments := []hookv1alpha1.Argument{}\n\tfor _, arg := range preInplaceHook.Args {\n\t\tvalue := arg.Value\n\t\thookArg := hookv1alpha1.Argument{\n\t\t\tName: arg.Name,\n\t\t\tValue: &value,\n\t\t}\n\t\targuments = append(arguments, hookArg)\n\t}\n\t// add PodName and PodNamespace args\n\tpodArgs := []hookv1alpha1.Argument{\n\t\t{\n\t\t\tName: PodNameArgKey,\n\t\t\tValue: &pod.Name,\n\t\t},\n\t\t{\n\t\t\tName: NamespaceArgKey,\n\t\t\tValue: &pod.Namespace,\n\t\t},\n\t\t{\n\t\t\tName: PodIPArgKey,\n\t\t\tValue: &pod.Status.PodIP,\n\t\t},\n\t\t{\n\t\t\tName: HostArgKey,\n\t\t\tValue: &pod.Status.HostIP,\n\t\t},\n\t}\n\targuments = append(arguments, podArgs...)\n\n\tfor i, value := range pod.Spec.Containers {\n\t\ttmp := new(string)\n\t\t*tmp = value.Name\n\t\timageArgs := []hookv1alpha1.Argument{\n\t\t\t{\n\t\t\t\tName: PodImageArgKey + \"[\" + strconv.Itoa(i) + \"]\",\n\t\t\t\tValue: tmp,\n\t\t\t},\n\t\t}\n\t\targuments = append(arguments, imageArgs...)\n\t}\n\n\t// append ModifiedContainers args\n\tmodifiedContainers, err := findModifiedContainers(podTemplate, pod)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\targuments = append(arguments, modifiedContainers...)\n\tklog.Infof(\"args: %+v\", arguments)\n\n\thr, err := p.newHookRunFromHookTemplate(metaObj, runtimeObj, arguments, pod, preInplaceHook, labels, podNameLabelKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\thookRunIf := p.hookClient.TkexV1alpha1().HookRuns(pod.Namespace)\n\treturn commonhookutil.CreateWithCollisionCounter(hookRunIf, *hr)\n}", "func preRun(cmd *cobra.Command, args []string) (err error) {\n\t// make sure the directory exists\n\tif !util.FileExists(rwDir) {\n\t\treturn fmt.Errorf(\"could not find %q\", rwDir)\n\t} else if !util.IsDir(rwDir) {\n\t\treturn fmt.Errorf(\"%q is a file, not a directory\", rwDir)\n\t} else {\n\t\tfmt.Printf(\"Found directory at %s...\\n\", rwDir)\n\t}\n\n\t// make sure config dir exists before going further\n\tconfigDir = filepath.Join(rwDir, \"Config\")\n\tif !util.FileExists(configDir) || !util.IsDir(configDir){\n\t\t// there is no config dir, we are probably pointed at the wrong place, bail\n\t\treturn fmt.Errorf(\"could not find config dir at %q\", configDir)\n\t} else {\n\t\tfmt.Printf(\"Found config dir...\\n\")\n\t}\n\n\t// and verify that a config file exists and is writable\n\tconfigFile = filepath.Join(configDir, xml.ModsConfigFilename)\n\tif !util.FileExists(configFile) {\n\t\t// we don't have a config - they've probably never run a compatible build of rimworld with this config dir\n\t\tfmt.Printf(\"!! Could not find mods config, have you launched RimWorld?\\n\")\n\t\treturn fmt.Errorf(\"could not find config file at %q\", configFile)\n\t}\n\n\t// make sure we have save dir - creating if necessary\n\tsaveDir = filepath.Join(rwDir, \"Saves\")\n\tif !util.FileExists(saveDir) {\n\t\tif err = os.Mkdir(saveDir, 0755); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create missing save dir %w\", err)\n\t\t} else {\n\t\t\tfmt.Printf(\"Created missing save dir...\\n\")\n\t\t}\n\t} else if !util.IsDir(saveDir) {\n\t\treturn fmt.Errorf(\"could not use %q as save dir\", saveDir)\n\t} else {\n\t\tfmt.Printf(\"Found save dir...\\n\")\n\t}\n\n\t// and now that everything else is known okay - let's read in the current config file\n\tmodsConfig, err = xml.LoadModsConfig(configFile)\n\tif err == nil {\n\t\tfmt.Printf(\"Loaded config xml...\\n\")\n\t}\n\n\treturn err\n}", "func (w *DefaultPreWorkflowHooksCommandRunner) RunPreHooks(\n\tctx context.Context,\n\tcmdCtx *command.Context,\n) error {\n\tpull := cmdCtx.Pull\n\tbaseRepo := pull.BaseRepo\n\theadRepo := cmdCtx.HeadRepo\n\tuser := cmdCtx.User\n\tlog := cmdCtx.Log\n\n\tpreWorkflowHooks := make([]*valid.PreWorkflowHook, 0)\n\tfor _, repo := range w.GlobalCfg.Repos {\n\t\tif repo.IDMatches(baseRepo.ID()) && len(repo.PreWorkflowHooks) > 0 {\n\t\t\tpreWorkflowHooks = append(preWorkflowHooks, repo.PreWorkflowHooks...)\n\t\t}\n\t}\n\n\t// short circuit any other calls if there are no pre-hooks configured\n\tif len(preWorkflowHooks) == 0 {\n\t\treturn nil\n\t}\n\n\tunlockFn, err := w.WorkingDirLocker.TryLock(baseRepo.FullName, pull.Num, DefaultWorkspace)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"locking working dir\")\n\t}\n\tdefer unlockFn()\n\n\trepoDir, _, err := w.WorkingDir.Clone(log, headRepo, pull, DefaultWorkspace)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"cloning repository\")\n\t}\n\n\terr = w.runHooks(\n\t\tctx,\n\t\tmodels.PreWorkflowHookCommandContext{\n\t\t\tBaseRepo: baseRepo,\n\t\t\tHeadRepo: headRepo,\n\t\t\tLog: log,\n\t\t\tPull: pull,\n\t\t\tUser: user,\n\t\t},\n\t\tpreWorkflowHooks, repoDir)\n\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"running pre workflow hooks\")\n\t}\n\n\treturn nil\n}", "func (tc ConcreteTemplatesCompiler) Precompile(release bprel.Release) error {\n\tvar allPkgs []bprel.Package\n\n\tfor _, pkg := range release.Packages {\n\t\tif pkg == nil {\n\t\t\t// todo panic or should not be here?\n\t\t\treturn bosherr.Error(\"Expected release to not have nil package\")\n\t\t}\n\n\t\tallPkgs = append(allPkgs, *pkg)\n\t}\n\n\tfor _, job := range release.Jobs {\n\t\tjobRec, found, err := tc.jobsRepo.Find(job)\n\t\tif err != nil {\n\t\t\treturn bosherr.WrapErrorf(err, \"Finding job source blob %s\", job.Name)\n\t\t}\n\n\t\tif !found {\n\t\t\tblobID, fingerprint, err := tc.blobstore.Create(job.TarPath)\n\t\t\tif err != nil {\n\t\t\t\treturn bosherr.WrapErrorf(err, \"Creating job source blob %s\", job.Name)\n\t\t\t}\n\n\t\t\tjobRec = bpjobsrepo.JobRecord{\n\t\t\t\tBlobID: blobID,\n\t\t\t\tSHA1: fingerprint,\n\t\t\t}\n\n\t\t\terr = tc.jobsRepo.Save(job, jobRec)\n\t\t\tif err != nil {\n\t\t\t\treturn bosherr.WrapErrorf(err, \"Saving job record %s\", job.Name)\n\t\t\t}\n\t\t}\n\n\t\treleaseJobRec, err := tc.tplToJobRepo.SaveForJob(release, job)\n\t\tif err != nil {\n\t\t\treturn bosherr.WrapErrorf(err, \"Saving release job %s\", job.Name)\n\t\t}\n\n\t\t// todo associate to release instead\n\t\terr = tc.runPkgsRepo.SaveAll(releaseJobRec, allPkgs)\n\t\tif err != nil {\n\t\t\treturn bosherr.WrapErrorf(err, \"Saving release job %s\", job.Name)\n\t\t}\n\t}\n\n\treturn nil\n}", "func RunPreps(\n\tb conf.Block,\n\tvars map[string]string,\n\tmod *moddwatch.Mod,\n\tlog termlog.TermLog,\n\tnotifiers []notify.Notifier,\n\tinitial bool,\n) error {\n\tshell := vars[shellVarName]\n\tvar modified []string\n\tif mod != nil {\n\t\tmodified = mod.All()\n\t}\n\tvcmd := varcmd.VarCmd{Block: &b, Modified: modified, Vars: vars}\n\tfor _, p := range b.Preps {\n\t\tcmd, err := vcmd.Render(p.Command)\n\t\tif initial && p.Onchange {\n\t\t\tlog.Say(niceHeader(\"skipping prep: \", cmd))\n\t\t\tcontinue\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = RunProc(cmd, shell, log.Stream(niceHeader(\"prep: \", cmd)))\n\t\tif err != nil {\n\t\t\tif pe, ok := err.(ProcError); ok {\n\t\t\t\tfor _, n := range notifiers {\n\t\t\t\t\tn.Push(\"modd error\", pe.Output, \"\")\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (c *kubernetesDeploymentManifest) PreBootstrap(ctx context.Context) error {\n\treturn nil\n}", "func TestPreprocess(t *testing.T) {\n\tdefaultRes := resource.JobResource{\n\t\tWorkerCPU: \"1000m\",\n\t\tWorkerMemory: \"1Gi\",\n\t\tPSCPU: \"1000m\",\n\t\tPSMemory: \"1Gi\",\n\t\tMasterCPU: \"1000m\",\n\t\tMasterMemory: \"1Gi\",\n\t}\n\n\ti := New(defaultRes)\n\ttype TestCase struct {\n\t\tCode string\n\t\tExpected *types.Parameter\n\t}\n\ttestCases := []TestCase{\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1\n%worker=1\nsome code here.\n`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tWorkerCount: 1,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1\nsome code here.\n`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=running`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyRunning,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=all`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyAll,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=none`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyNone,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t// Invalid clean policy will use default value none.\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=test`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyNone,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1;%cpu=100m;%memory=100Mi`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tResource: resource.JobResource{\n\t\t\t\t\tPSCPU: \"100m\",\n\t\t\t\t\tPSMemory: \"100Mi\",\n\t\t\t\t\tWorkerCPU: defaultRes.WorkerCPU,\n\t\t\t\t\tWorkerMemory: defaultRes.WorkerMemory,\n\t\t\t\t\tMasterCPU: defaultRes.MasterCPU,\n\t\t\t\t\tMasterMemory: defaultRes.MasterMemory,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1;%cpu=100m;%memory=100Mi\n%worker=2;%cpu=10m;%memory=10Mi`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tWorkerCount: 2,\n\t\t\t\tResource: resource.JobResource{\n\t\t\t\t\tPSCPU: \"100m\",\n\t\t\t\t\tPSMemory: \"100Mi\",\n\t\t\t\t\tWorkerCPU: \"10m\",\n\t\t\t\t\tWorkerMemory: \"10Mi\",\n\t\t\t\t\tMasterCPU: defaultRes.MasterCPU,\n\t\t\t\t\tMasterMemory: defaultRes.MasterMemory,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=pytorch\n%master=1;%cpu=100m;%memory=100Mi\n%worker=2;%cpu=10m;%memory=10Mi`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypePyTorch,\n\t\t\t\tMasterCount: 1,\n\t\t\t\tWorkerCount: 2,\n\t\t\t\tResource: resource.JobResource{\n\t\t\t\t\tPSCPU: defaultRes.PSCPU,\n\t\t\t\t\tPSMemory: defaultRes.PSMemory,\n\t\t\t\t\tWorkerCPU: \"10m\",\n\t\t\t\t\tWorkerMemory: \"10Mi\",\n\t\t\t\t\tMasterCPU: \"100m\",\n\t\t\t\t\tMasterMemory: \"100Mi\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tactual, err := i.Preprocess(tc.Code)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Expected nil got error: %v\", err)\n\t\t}\n\t\tif !reflect.DeepEqual(actual, tc.Expected) {\n\t\t\tt.Errorf(\"Expected %v, got %v\", tc.Expected, actual)\n\t\t}\n\t}\n}", "func (tf *TestFixture) PreTest(ctx context.Context, s *testing.FixtTestState) {\n}", "func preRunAction(cmd *cobra.Command, args []string) error {\n\tif dot.Action == \"\" {\n\t\t// fmt.Printf(\"preRunAction set dot.Action %q to %s\\n\", dot.Action, cmd.Name())\n\t\tdot.Action = cmd.Name()\n\t}\n\tc := make(chan actionResult)\n\t// Parse roles config\n\tif err := dotConfig.ParseRoles(); err != nil {\n\t\treturn err\n\t}\n\t// roles := dotConfig.Roles\n\tgo func() {\n\t\tvar wg sync.WaitGroup\n\t\tfor _, r := range dotConfig.Roles {\n\t\t\tif !r.ShouldRun() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\twg.Add(1)\n\t\t\tgo checkAllTasks(r, c, &wg)\n\t\t}\n\t\t// All calls to wg.Add are done. Start a goroutine\n\t\t// to close c once all the sends are done.\n\t\tgo func() {\n\t\t\twg.Wait()\n\t\t\tclose(c)\n\t\t}()\n\t}()\n\treturn checkResults(c)\n}", "func (ct *Chronicle) performPreOrder(workerFct func(*Chronicle) error, getChildrenFct func(ct *Chronicle) []*Chronicle) (err error) {\n\tif err = workerFct(ct); err != nil {\n\t\treturn err\n\t}\n\n\tfor _, child := range getChildrenFct(ct) {\n\t\tif err = child.performPreOrder(workerFct, getChildrenFct); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *Task) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range taskBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func preSeedAgentPool(t *testing.T, data templateData) error {\n\tnaData := data\n\tnaData.SeedType = \"never\"\n\tnaData.ScaledJobName = \"never-agent-demand-scaledjob\"\n\tKubectlApplyWithTemplate(t, naData, \"demandScaledJobTemplate\", demandScaledJobTemplate)\n\n\tnaData.ScaledJobName = \"never-agent-parent-scaledjob\"\n\tKubectlApplyWithTemplate(t, naData, \"parentScaledJobTemplate\", parentScaledJobTemplate)\n\n\terr := KubectlApplyWithErrors(t, naData, \"deploymentTemplateSeed\", seedDeploymentTemplate)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = KubectlApplyWithErrors(t, data, \"deploymentTemplateSeed\", seedDeploymentTemplate)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// wait for deployment to be ready in AzDO\n\tfor !checkAgentState(t, data, \"online\") {\n\t\ttime.Sleep(10 * time.Second)\n\t}\n\tfor !checkAgentState(t, naData, \"online\") {\n\t\ttime.Sleep(10 * time.Second)\n\t}\n\t// delete the deployment\n\tKubectlDeleteWithTemplate(t, naData, \"deploymentTemplateSeed\", seedDeploymentTemplate)\n\tKubectlDeleteWithTemplate(t, data, \"deploymentTemplateSeed\", seedDeploymentTemplate)\n\tfor !checkAgentState(t, data, \"offline\") {\n\t\ttime.Sleep(10 * time.Second)\n\t}\n\tfor !checkAgentState(t, naData, \"offline\") {\n\t\ttime.Sleep(10 * time.Second)\n\t}\n\treturn nil\n}", "func (w *YAMLWriter) PreWrite(columns []string, types []string) error {\n\tw.results = make([]yaml.MapSlice, 0)\n\treturn nil\n}", "func (d *deployer) PreDeploy(ctx context.Context) error {\n\t// deploy global rbac\n\terr := d.deployRPGlobalSubscription(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td.log.Infof(\"deploying rg %s in %s\", *d.config.Configuration.SubscriptionResourceGroupName, *d.config.Configuration.SubscriptionResourceGroupLocation)\n\t_, err = d.groups.CreateOrUpdate(ctx, *d.config.Configuration.SubscriptionResourceGroupName, mgmtfeatures.ResourceGroup{\n\t\tLocation: d.config.Configuration.SubscriptionResourceGroupLocation,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td.log.Infof(\"deploying rg %s in %s\", *d.config.Configuration.GlobalResourceGroupName, *d.config.Configuration.GlobalResourceGroupLocation)\n\t_, err = d.globalgroups.CreateOrUpdate(ctx, *d.config.Configuration.GlobalResourceGroupName, mgmtfeatures.ResourceGroup{\n\t\tLocation: d.config.Configuration.GlobalResourceGroupLocation,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td.log.Infof(\"deploying rg %s in %s\", d.config.RPResourceGroupName, d.config.Location)\n\t_, err = d.groups.CreateOrUpdate(ctx, d.config.RPResourceGroupName, mgmtfeatures.ResourceGroup{\n\t\tLocation: &d.config.Location,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td.log.Infof(\"deploying rg %s in %s\", d.config.GatewayResourceGroupName, d.config.Location)\n\t_, err = d.groups.CreateOrUpdate(ctx, d.config.GatewayResourceGroupName, mgmtfeatures.ResourceGroup{\n\t\tLocation: &d.config.Location,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// deploy action groups\n\terr = d.deployRPSubscription(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// deploy managed identity\n\terr = d.deployManagedIdentity(ctx, d.config.RPResourceGroupName, generator.FileRPProductionManagedIdentity)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trpMSI, err := d.userassignedidentities.Get(ctx, d.config.RPResourceGroupName, \"aro-rp-\"+d.config.Location)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// deploy managed identity\n\terr = d.deployManagedIdentity(ctx, d.config.GatewayResourceGroupName, generator.FileGatewayProductionManagedIdentity)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgwMSI, err := d.userassignedidentities.Get(ctx, d.config.GatewayResourceGroupName, \"aro-gateway-\"+d.config.Location)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// deploy ACR RBAC, RP version storage account\n\terr = d.deployRPGlobal(ctx, rpMSI.PrincipalID.String(), gwMSI.PrincipalID.String())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Due to https://github.com/Azure/azure-resource-manager-schemas/issues/1067\n\t// we can't use conditions to define ACR replication object deployment.\n\t// Also, an ACR replica cannot be defined in the home registry location.\n\tacrLocation := *d.config.Configuration.GlobalResourceGroupLocation\n\tif d.config.Configuration.ACRLocationOverride != nil && *d.config.Configuration.ACRLocationOverride != \"\" {\n\t\tacrLocation = *d.config.Configuration.ACRLocationOverride\n\t}\n\tif !strings.EqualFold(d.config.Location, acrLocation) &&\n\t\t(d.config.Configuration.ACRReplicaDisabled == nil || !*d.config.Configuration.ACRReplicaDisabled) {\n\t\terr = d.deployRPGlobalACRReplication(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// deploy NSGs, keyvaults\n\t// gateway first because RP predeploy will peer its vnet to the gateway vnet\n\n\t// key the decision to deploy NSGs on the existence of the gateway\n\t// predeploy. We do this in order to refresh the RP NSGs when the gateway\n\t// is deployed for the first time.\n\tisCreate := false\n\t_, err = d.deployments.Get(ctx, d.config.GatewayResourceGroupName, strings.TrimSuffix(generator.FileGatewayProductionPredeploy, \".json\"))\n\tif isDeploymentNotFoundError(err) {\n\t\tisCreate = true\n\t\terr = nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = d.deployPreDeploy(ctx, d.config.GatewayResourceGroupName, generator.FileGatewayProductionPredeploy, \"gatewayServicePrincipalId\", gwMSI.PrincipalID.String(), isCreate)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = d.deployPreDeploy(ctx, d.config.RPResourceGroupName, generator.FileRPProductionPredeploy, \"rpServicePrincipalId\", rpMSI.PrincipalID.String(), isCreate)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn d.configureServiceSecrets(ctx)\n}", "func (p *DockerProcessor) PreCheck() (string, error) {\n\tif len(p.foundContainers) == 0 {\n\t\tvalidationErr := taskerrors.NewContainerNotFoundError()\n\t\treturn validationErr.Param(), validationErr\n\t}\n\n\tif len(p.foundContainers) > 1 {\n\t\tvalidationErr := taskerrors.NewContainerNameDuplicatedError()\n\t\treturn validationErr.Param(), validationErr\n\t}\n\n\tfoundContainer := p.foundContainers[0]\n\tp.foundContainerName = dockerutil.StripAndSelectName(foundContainer.Names)\n\t// TODO: FIXME: Use uniform container state representation and convert to it\n\tcanonicalizedContainerState := strings.ToUpper(foundContainer.State)\n\tif canonicalizedContainerState != \"RUNNING\" {\n\t\tvalidationErr := taskerrors.NewContainerStateAbnormalError(canonicalizedContainerState)\n\t\treturn validationErr.Param(), validationErr\n\t}\n\n\treturn \"\", nil\n}", "func persistentPreRunEFn(context *server.Context) func(*cobra.Command, []string) error {\n\toriginPreRun := server.PersistentPreRunEFn(context)\n\treturn func(cmd *cobra.Command, args []string) error {\n\t\tif cmd.Name() == version.Cmd.Name() {\n\t\t\treturn nil\n\t\t}\n\n\t\terr := originPreRun(cmd, args)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\trootDir := viper.GetString(flags.FlagHome)\n\n\t\t// load application DBDir and set wasm DBDir\n\t\twasmconfig.DBDir = filepath.Base(context.Config.DBDir()) + \"/wasm\"\n\t\twasmConfigFilePath := filepath.Join(rootDir, \"config/wasm.toml\")\n\t\tif _, err := os.Stat(wasmConfigFilePath); os.IsNotExist(err) {\n\t\t\twasmConf, _ := wasmconfig.ParseConfig()\n\t\t\twasmconfig.WriteConfigFile(wasmConfigFilePath, wasmConf)\n\t\t}\n\n\t\tviper.SetConfigName(\"wasm\")\n\t\terr = viper.MergeInConfig()\n\n\t\treturn err\n\t}\n}", "func (a *Vault) PreInsert(s gorp.SqlExecutor) error {\n\ta.Created = time.Now() // or time.Now().UnixNano()\n\ta.Updated = a.Created\n\treturn nil\n}", "func (t *PT) before() {\n\tt.T.Helper()\n\tif t.hasRun {\n\t\tt.T.Fatal(\"has already run\")\n\t}\n}", "func configExecutor(args prompter.CmdArgs) error {\n\tfmt.Println(\"inside templateExecutor\")\n\tfmt.Printf(\"config args: %v\\n\", args)\n\n\tif args.Contains(\"restore\") {\n\t\trestoreFile, err := args.GetFirstValue(\"restore\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Create a backup with the current timestamp.\n\t\terr = config.Backup(\"\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn config.Restore(restoreFile)\n\t}\n\treturn nil\n}", "func doPrepare(env env.Project, options *PrepareOptions) (err error) {\n\t// Create the dep manager\n\tdepManager := dep.DepManager{Env: env}\n\tif !depManager.IsInitialized() {\n\t\t// This is an old app\n\t\terr = MigrateOldApp(env, depManager)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif options == nil {\n\t\toptions = &PrepareOptions{}\n\t}\n\n\t// Call external preprocessor\n\tif options.PreProcessor != nil {\n\t\terr = options.PreProcessor.PrepareForBuild(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t//generate metadata\n\terr = generateGoMetadata(env)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//load descriptor\n\tappJson, err := fgutil.LoadLocalFile(filepath.Join(env.GetRootDir(), \"flogo.json\"))\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tdescriptor, err := ParseAppDescriptor(appJson)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tremoveEmbeddedAppGoFile(env.GetAppDir())\n\tremoveShimGoFiles(env.GetAppDir())\n\n\tif options.Shim != \"\" {\n\n\t\tremoveMainGoFile(env.GetAppDir()) //todo maybe rename if it exists\n\t\tcreateShimSupportGoFile(env.GetAppDir(), appJson, options.EmbedConfig)\n\n\t\tfmt.Println(\"Shim:\", options.Shim)\n\n\t\tfor _, value := range descriptor.Triggers {\n\n\t\t\tfmt.Println(\"Id:\", value.Id)\n\t\t\tif value.Id == options.Shim {\n\t\t\t\ttriggerPath := filepath.Join(env.GetVendorSrcDir(), value.Ref, \"trigger.json\")\n\n\t\t\t\tmdJson, err := fgutil.LoadLocalFile(triggerPath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tmetadata, err := ParseTriggerMetadata(mdJson)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tfmt.Println(\"Shim Metadata:\", metadata.Shim)\n\n\t\t\t\tif metadata.Shim != \"\" {\n\n\t\t\t\t\t//todo blow up if shim file not found\n\t\t\t\t\tshimFilePath := filepath.Join(env.GetVendorSrcDir(), value.Ref, dirShim, fileShimGo)\n\t\t\t\t\tfmt.Println(\"Shim File:\", shimFilePath)\n\t\t\t\t\tfgutil.CopyFile(shimFilePath, filepath.Join(env.GetAppDir(), fileShimGo))\n\n\t\t\t\t\t// ensure deps after the shim.go has been copied to main.go...\n\t\t\t\t\tdepManager.Ensure()\n\n\t\t\t\t\t// This is a bit of a workaround, will resolve with a better solution in the future\n\t\t\t\t\t// generate metadata again... ensure will remove it\n\t\t\t\t\terr = generateGoMetadata(env)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check if this shim based trigger has a gobuild file. If the trigger has a gobuild\n\t\t\t\t\t// execute that file, otherwise check if there is a Makefile to execute\n\t\t\t\t\tgobuildFilePath := filepath.Join(env.GetVendorSrcDir(), value.Ref, dirShim, gobuildFile)\n\t\t\t\t\tif _, err := os.Stat(gobuildFilePath); err == nil {\n\t\t\t\t\t\tfmt.Println(\"This trigger makes use if a gobuild file...\")\n\t\t\t\t\t\tfmt.Println(\"Go build file:\", gobuildFilePath)\n\t\t\t\t\t\tfgutil.CopyFile(gobuildFilePath, filepath.Join(env.GetAppDir(), gobuildFile))\n\n\t\t\t\t\t\t// Execute go run gobuild.go\n\t\t\t\t\t\tcmd := exec.Command(\"go\", \"run\", gobuildFile, env.GetAppDir())\n\t\t\t\t\t\tcmd.Stdout = os.Stdout\n\t\t\t\t\t\tcmd.Stderr = os.Stderr\n\t\t\t\t\t\tcmd.Dir = env.GetAppDir()\n\t\t\t\t\t\tcmd.Env = append(os.Environ(),\n\t\t\t\t\t\t\tfmt.Sprintf(\"GOPATH=%s\", env.GetRootDir()),\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\terr = cmd.Run()\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if metadata.Shim == \"plugin\" {\n\t\t\t\t\t\t//look for Makefile and execute it\n\t\t\t\t\t\tmakeFilePath := filepath.Join(env.GetVendorSrcDir(), value.Ref, dirShim, makeFile)\n\t\t\t\t\t\tfmt.Println(\"Make File:\", makeFilePath)\n\t\t\t\t\t\tfgutil.CopyFile(makeFilePath, filepath.Join(env.GetAppDir(), makeFile))\n\n\t\t\t\t\t\t// Execute make\n\t\t\t\t\t\tcmd := exec.Command(\"make\", \"-C\", env.GetAppDir())\n\t\t\t\t\t\tcmd.Stdout = os.Stdout\n\t\t\t\t\t\tcmd.Stderr = os.Stderr\n\t\t\t\t\t\tcmd.Env = append(os.Environ(),\n\t\t\t\t\t\t\tfmt.Sprintf(\"GOPATH=%s\", env.GetRootDir()),\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\terr = cmd.Run()\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t} else if options.EmbedConfig {\n\t\tcreateEmbeddedAppGoFile(env.GetAppDir(), appJson)\n\t}\n\treturn\n}", "func TestGetPreProcessedCode(t *testing.T) {\n\ti := New(resource.JobResource{})\n\ttype TestCase struct {\n\t\tCode string\n\t\tExpected string\n\t}\n\ttestCases := []TestCase{\n\t\tTestCase{\n\t\t\tCode: `%framework=tensorflow\n%ps=1\n%worker=1\nsome code here.\n`,\n\t\t\tExpected: `\nsome code here.`,\n\t\t},\n\t}\n\tfor _, tc := range testCases {\n\t\tactual := i.PreprocessedCode(tc.Code)\n\t\tif actual != tc.Expected {\n\t\t\tt.Errorf(\"Expected %s, got %s\", tc.Expected, actual)\n\t\t}\n\t}\n}", "func (e *TknRunner) Prepare(t *testing.T) func(args ...string) icmd.Cmd {\n\trun := func(args ...string) icmd.Cmd {\n\t\treturn icmd.Cmd{Command: append([]string{e.Path}, args...), Timeout: 10 * time.Minute}\n\t}\n\treturn run\n}", "func PreprocessRunData(temp_dir_name string,\n\tvcf_path string,\n\tbed_path string,\n\trefseq_path string,\n\tbam_path string,\n\tstructvar_path string,\n\tshortstructvar_path string,\n\tbreakpoints_path string,\n\ttargets_path string,\n\tfragments_path string,\n\tcontig_path string,\n\toutput_path string,\n\texternal_summary_paths map[string]string) error {\n\n\tlog.Printf(\"Storing temporary files in %v\", temp_dir_name)\n\n\twriter, err := NewCompressedWriter(output_path, 4096)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tindex := make(map[string]LoupeSection)\n\n\treference_hash := HashFiles([]string{bed_path, contig_path})\n\tlog.Printf(\"Reference set hash code: %v\", reference_hash)\n\n\t/* This is a little bit disgusting and perhaps could be improved...\n\t * We create a new json file that will have the phase block histogram\n\t * in it and then add that file to external_summary_paths so that it\n\t * gets merged in with the rest of the summary data.\n\t */\n\tphase_block_histogram_path := temp_dir_name + \"/pb-histogram.json\"\n\texternal_summary_paths[phase_block_histogram_path] = \"phase_block_histogram\"\n\n\tlog.Printf(\"Processing contig DB\")\n\tindex[\"contigs_db\"] = BuildContigDB(contig_path, writer)\n\n\t/* Step 1: Load the VCF file */\n\tlog.Printf(\"Loading Customer VCF file\")\n\tvar vcf_data []*SimpleVCFRow\n\tif vcf_path != \"\" {\n\t\tvcf_data, err = ReadVCFToArray(vcf_path)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Cannot read VCF file: %v\", err)\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tvcf_data = make([]*SimpleVCFRow, 0, 0)\n\t}\n\n\t/* Step 2: Compute a histogram of phase block lengths. This will be\n\t * assembled into the summary section, later\n\t */\n\tlog.Printf(\"Computeing Phase block histogram\")\n\tWritePBHistogram(phase_block_histogram_path, vcf_data)\n\n\t/* Step 3: Compute a nice gene index */\n\tlog.Printf(\"Loading genes file\")\n\t\n\tindex[\"ref_annotations\"], err = writer.WriteFromFile(bed_path)\n\n\t/* Step 4. Associate DBSNP/refseq data */\n\tlog.Printf(\"Associating SNPs with RefSeq data\")\n\trefseq_annotation, err := ComputeVCFAnnotation(refseq_path, vcf_data)\n\n\tif err != nil {\n\t\tlog.Printf(\"Cannot load refseq data: %v\", err)\n\t\tlog.Printf(\"Continuing without refseq data\")\n\t}\n\t/* Step 5: Compute the jsonified VCF data and index. This will also decorate SNPs\n\t * with their genes and genes with the number of SNPs they contain\n\t */\n\tlog.Printf(\"Computing indexed JSON representation of VCF data\")\n\tindex[\"vcf_index\"] = VCFtoJSON(vcf_data, writer, 512, nil, refseq_annotation)\n\n\t/* STep 6, write out the gene data */\n\n\tindex[\"summary\"] = WriteSummaryFile(writer,\n\t\t\"Some loupe data\",\n\t\tvcf_path,\n\t\tbed_path,\n\t\texternal_summary_paths)\n\n\t/* Step 7 Build the phase summary file */\n\tlog.Printf(\"Creating Phase-block summary file \")\n\tpbs, err := GeneratePhaseBlockSummary(nil, vcf_data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tindex[\"phase_block_summary2\"] = WriteTrackDataToFile(writer, pbs)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t/* Step 8 Write out the refseq index */\n\tlog.Printf(\"Creating RSID index\")\n\tindex[\"refseq_index\"] = WriteRSIndexToFile(writer, refseq_annotation)\n\n\t/* Step 9 Write out the BAM data and index. This appends the BAM\n\t * data to the VCF data so that offsets that are encoded into the indeces\n\t * will line up nicely.\n\t */\n\n\tlog.Printf(\"Storing and indexing read data\")\n\tif bam_path != \"\" {\n\t\tindex[\"bam_data\"], _ = BuildBAMIndexAndData(bam_path, writer, nil)\n\t} else {\n\t\t/* No BAM data? Write an innocuous bam index. */\n\t\tindex[\"bam_data\"], err = writer.WriteChunk([]byte(\"{\\\"Database\\\":{}, \\\"Index\\\":{}}\"))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t}\n\n\tlog.Printf(\"Loading structural variant calls\")\n\t/* Step 10. WRite structural variant data tin .loupe file */\n\tif structvar_path != \"\" {\n\t\tvar sv_track *BundledTrackData\n\t\tvar err error\n\t\tif breakpoints_path != \"\" {\n\t\t\tsv_track, err = LoadSVsWithDetails(structvar_path, breakpoints_path)\n\t\t} else {\n\t\t\tsv_track, err = LoadSVs(structvar_path)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tindex[\"sv_track\"] = WriteTrackDataToFile(writer, sv_track)\n\n\t} else {\n\t\tindex[\"sv_track\"], err = writer.WriteChunk([]byte(\"{}\"))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\t/* Step 11. Write short structural variant data in .loupe file */\n\t// todo ShortSV \n\tlog.Printf(\"Loading short structural variant calls\")\n\tif shortstructvar_path != \"\" {\n\t\tvar shortSV_track *BundledTrackData\n\t\tvar err error\n\t\tif breakpoints_path != \"\" {\n\t\t\tshortSV_track, err = LoadShortSVsWithDetails(shortstructvar_path, breakpoints_path)\n\t\t} else {\n\t\t\tshortSV_track, err = LoadShortSVs(shortstructvar_path)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tindex[\"shortSV_track\"] = WriteTrackDataToFile(writer, shortSV_track)\n\n\t} else {\n\t\tindex[\"shortSV_track\"], err = writer.WriteChunk([]byte(\"{}\"))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\t/* Step 12 write target set information */\n\tlog.Printf(\"Loading target set\")\n\tif targets_path != \"\" {\n\t\ttargets_track, err := ReadGenericBedFile(targets_path, []string{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_ = targets_track\n\t\tindex[\"targets_track\"] = BuildBlockedJSONIndex(writer, targets_track)\n\t}\n\n\t/* step 13. Write the preamble */\n\tlog.Printf(\"Creating summary file \")\n\n\terr = WriteIndexFile(writer, index, reference_hash)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func GenCreateByReleasePipelineYaml(releaseID string, workspaces []string) apistructs.PipelineYml {\n\tyml := apistructs.PipelineYml{\n\t\tVersion: \"1.1\",\n\t\tStages: [][]*apistructs.PipelineYmlAction{\n\t\t\t{},\n\t\t\t{},\n\t\t\t{},\n\t\t\t{},\n\t\t},\n\t}\n\tfor _, workspace := range workspaces {\n\t\tyml.Stages[0] = append(yml.Stages[0], &apistructs.PipelineYmlAction{\n\t\t\tType: \"dice-deploy-release\",\n\t\t\tAlias: fmt.Sprintf(\"dice-deploy-release-%s\", workspace),\n\t\t\tVersion: \"1.0\",\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"release_id\": releaseID,\n\t\t\t\t\"workspace\": workspace,\n\t\t\t},\n\t\t})\n\t\tyml.Stages[1] = append(yml.Stages[1], &apistructs.PipelineYmlAction{\n\t\t\tType: \"dice-deploy-addon\",\n\t\t\tAlias: fmt.Sprintf(\"dice-deploy-addon-%s\", workspace),\n\t\t\tVersion: \"1.0\",\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"deployment_id\": fmt.Sprintf(\"${dice-deploy-release-%s:OUTPUT:deployment_id}\", workspace),\n\t\t\t},\n\t\t})\n\t\tyml.Stages[2] = append(yml.Stages[2], &apistructs.PipelineYmlAction{\n\t\t\tType: \"dice-deploy-service\",\n\t\t\tAlias: fmt.Sprintf(\"dice-deploy-service-%s\", workspace),\n\t\t\tVersion: \"1.0\",\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"deployment_id\": fmt.Sprintf(\"${dice-deploy-release-%s:OUTPUT:deployment_id}\", workspace),\n\t\t\t},\n\t\t})\n\t\tyml.Stages[3] = append(yml.Stages[3], &apistructs.PipelineYmlAction{\n\t\t\tType: \"dice-deploy-domain\",\n\t\t\tAlias: fmt.Sprintf(\"dice-deploy-domain-%s\", workspace),\n\t\t\tVersion: \"1.0\",\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"deployment_id\": fmt.Sprintf(\"${dice-deploy-release-%s:OUTPUT:deployment_id}\", workspace),\n\t\t\t},\n\t\t})\n\t}\n\n\treturn yml\n}", "func (s *Consumer) BeforeRun() error {\n\treturn nil\n}", "func run(contextName string) error {\n\tcfg, err := config.Read(\"qaq15.yml\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t// select context\n\tvar selectedContext config.Context\n\tfor _, ctx := range cfg.Contexts {\n\t\tif ctx.Name == contextName {\n\t\t\tselectedContext = ctx\n\t\t\tbreak\n\t\t}\n\t}\n\tif selectedContext.Name == \"\" {\n\t\treturn errors.Errorf(\"context not found no %s\", contextName)\n\t}\n\n\tcontainers, err := extendContainer(cfg.Containers)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor i := range containers {\n\t\tif err := resolveEnv(&containers[i], cfg.Parameters); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tnow := time.Now()\n\tlogPrefix, err := NewLogDir(cfg.Data, now)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\tvar wg sync.WaitGroup\n\twg.Add(len(containers) + 1)\n\tmerr := errors.NewMultiErrSafe()\n\n\t// Run containers\n\tfor _, container := range containers {\n\t\tcontainer := container\n\t\tcontainer.Image = selectedContext.Image\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\n\t\t\treportError := func(err error) {\n\t\t\t\tmerr.Append(err)\n\t\t\t\tlog.Error(err)\n\t\t\t\tcancel() // TODO: is cancel go routine safe?\n\t\t\t}\n\n\t\t\t// Add a mount in $logdir/$container to /qaq16\n\t\t\tif p, err := NewMountDir(logPrefix, container.Name); err != nil {\n\t\t\t\treportError(err)\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tcontainer.Mounts = append(container.Mounts, config.Mount{\n\t\t\t\t\tSrc: p,\n\t\t\t\t\tDst: \"/qaq16\",\n\t\t\t\t})\n\t\t\t}\n\n\t\t\texecCtx := ExecContext{log: FormatLog(logPrefix, container.Name)}\n\t\t\tif err := RunContainer(ctx, container, execCtx); err != nil {\n\t\t\t\treportError(err)\n\t\t\t}\n\t\t}()\n\t}\n\t// FIXME: hack to wait container ready\n\ttime.Sleep(1 * time.Second)\n\n\t// Run score\n\tgo func() {\n\t\tdefer wg.Done()\n\n\t\texecCtx := ExecContext{log: FormatLog(logPrefix, \"score\")}\n\t\tif err := RunScore(ctx, cfg.Score, execCtx); err != nil {\n\t\t\tmerr.Append(err)\n\t\t\tlog.Error(err)\n\t\t\tcancel()\n\t\t}\n\t}()\n\n\twg.Wait()\n\treturn merr.ErrorOrNil()\n}", "func (a *Agent) PreInsert(s gorp.SqlExecutor) error {\n\ta.Created = time.Now() // or time.Now().UnixNano()\n\ta.Updated = a.Created\n\treturn nil\n}", "func (o *Task) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range taskBeforeUpsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *Project) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range projectBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *Project) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range projectBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *Manifest) SetPreStart(exec []string) error {\n\treturn m.setEventHandler(preStartName, exec)\n}", "func prepareNonInitCommand(originalTerragruntOptions *options.TerragruntOptions, terragruntOptions *options.TerragruntOptions, terragruntConfig *config.TerragruntConfig) error {\n\tneedsInit, err := needsInit(terragruntOptions, terragruntConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif needsInit {\n\t\tif err := runTerraformInit(originalTerragruntOptions, terragruntOptions, terragruntConfig, nil); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func testPipelineData() []byte {\n\treturn []byte(`\nversion: 1\n\nworker:\n flavor: large\n platform: docker\n\nservices:\n - name: redis\n image: redis\n\nsteps:\n - name: ping\n image: redis\n commands:\n - redis-cli -h redis ping\n`)\n}", "func (f *File) PreInsert(s gorp.SqlExecutor) error {\n\tf.Created = time.Now().UnixNano()\n\tf.Updated = f.Created\n\treturn nil\n}", "func (deployment *Deployment) RunPhasePreloads() (PreloadResults, error) {\n\tpreloadablePhases := make([]common.PreloadablePhase, 0)\n\tfor _, phase := range deployment.strategy.Phases() {\n\t\tif phase.CanPreload() {\n\t\t\tpreloadablePhases = append(preloadablePhases, phase.(common.PreloadablePhase))\n\t\t}\n\t}\n\n\tresultChan := make(chan preloadResult)\n\tfor _, phase := range preloadablePhases {\n\t\tgo func(currentPhase common.PreloadablePhase) {\n\t\t\tdata, err := currentPhase.Preload(deployment)\n\t\t\tresultChan <- preloadResult{data: data, err: err}\n\t\t}(phase)\n\t}\n\n\tresults := make(PreloadResults)\n\tfor _, phase := range preloadablePhases {\n\t\tresult := <-resultChan\n\t\tif result.err != nil {\n\t\t\treturn nil, result.err\n\t\t} else {\n\t\t\tresults.Set(phase.(common.Phase), result.data)\n\t\t}\n\t}\n\n\treturn results, nil\n}", "func (p *JSONGOFPDF) PreRunOperation(pdf *gofpdf.Fpdf, name string, logic string) (opdf *gofpdf.Fpdf) {\n\tswitch name {\n\tcase \"multicell\":\n\t\tp.PreRowMultiCell(pdf, logic)\n\t\tbreak\n\t}\n\treturn pdf\n}", "func (tr *TaskRunner) preKill() {\n\tif tr.logger.IsTrace() {\n\t\tstart := time.Now()\n\t\ttr.logger.Trace(\"running pre kill hooks\", \"start\", start)\n\t\tdefer func() {\n\t\t\tend := time.Now()\n\t\t\ttr.logger.Trace(\"finished pre kill hooks\", \"end\", end, \"duration\", end.Sub(start))\n\t\t}()\n\t}\n\n\tfor _, hook := range tr.runnerHooks {\n\t\tkillHook, ok := hook.(interfaces.TaskPreKillHook)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tname := killHook.Name()\n\n\t\t// Time the pre kill hook\n\t\tvar start time.Time\n\t\tif tr.logger.IsTrace() {\n\t\t\tstart = time.Now()\n\t\t\ttr.logger.Trace(\"running prekill hook\", \"name\", name, \"start\", start)\n\t\t}\n\n\t\t// Run the pre kill hook\n\t\treq := interfaces.TaskPreKillRequest{}\n\t\tvar resp interfaces.TaskPreKillResponse\n\t\tif err := killHook.PreKilling(context.Background(), &req, &resp); err != nil {\n\t\t\ttr.emitHookError(err, name)\n\t\t\ttr.logger.Error(\"prekill hook failed\", \"name\", name, \"error\", err)\n\t\t}\n\n\t\t// No need to persist as TaskKillResponse is currently empty\n\n\t\tif tr.logger.IsTrace() {\n\t\t\tend := time.Now()\n\t\t\ttr.logger.Trace(\"finished prekill hook\", \"name\", name, \"end\", end, \"duration\", end.Sub(start))\n\t\t}\n\t}\n}", "func PreTrainedRun(af AdaptiveFilter, d []float64, x [][]float64, nTrain float64, epochs int) (y, e []float64, w [][]float64, err error) {\n\tvar nTrainI = int(float64(len(d)) * nTrain)\n\t//train\n\tfor i := 0; i < epochs; i++ {\n\t\t_, _, _, err = af.Run(d[:nTrainI], x[:nTrainI])\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t}\n\t//run\n\ty, e, w, err = af.Run(d[:nTrainI], x[:nTrainI])\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\treturn y, e, w, nil\n}", "func (o *Asset) doBeforeInsertHooks(exec boil.Executor) (err error) {\n\tfor _, hook := range assetBeforeInsertHooks {\n\t\tif err := hook(exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (b *Executor) Execute(ctx context.Context, stage imagebuilder.Stage) error {\n\tib := stage.Builder\n\tnode := stage.Node\n\tcheckForLayers := true\n\tchildren := node.Children\n\tcommitName := b.output\n\tb.containerIDs = nil\n\n\tvar leftoverArgs []string\n\tfor arg := range b.builder.Args {\n\t\tif !builtinAllowedBuildArgs[arg] {\n\t\t\tleftoverArgs = append(leftoverArgs, arg)\n\t\t}\n\t}\n\tfor i, node := range node.Children {\n\t\tstep := ib.Step()\n\t\tif err := step.Resolve(node); err != nil {\n\t\t\treturn errors.Wrapf(err, \"error resolving step %+v\", *node)\n\t\t}\n\t\tlogrus.Debugf(\"Parsed Step: %+v\", *step)\n\t\tif step.Command == \"arg\" {\n\t\t\tfor index, arg := range leftoverArgs {\n\t\t\t\tfor _, Arg := range step.Args {\n\t\t\t\t\tlist := strings.SplitN(Arg, \"=\", 2)\n\t\t\t\t\tif arg == list[0] {\n\t\t\t\t\t\tleftoverArgs = append(leftoverArgs[:index], leftoverArgs[index+1:]...)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !b.quiet {\n\t\t\tb.log(\"%s\", step.Original)\n\t\t}\n\t\trequiresStart := false\n\t\tif i < len(node.Children)-1 {\n\t\t\trequiresStart = ib.RequiresStart(&parser.Node{Children: node.Children[i+1:]})\n\t\t}\n\n\t\tif !b.layers && !b.noCache {\n\t\t\terr := ib.Run(step, b, requiresStart)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"error building at step %+v\", *step)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif i < len(children)-1 {\n\t\t\tb.output = \"\"\n\t\t} else {\n\t\t\tb.output = commitName\n\t\t}\n\n\t\tvar (\n\t\t\tcacheID string\n\t\t\terr error\n\t\t\timgID string\n\t\t)\n\n\t\tb.copyFrom = \"\"\n\t\t// Check if --from exists in the step command of COPY or ADD\n\t\t// If it exists, set b.copyfrom to that value\n\t\tfor _, n := range step.Flags {\n\t\t\tif strings.Contains(n, \"--from\") && (step.Command == \"copy\" || step.Command == \"add\") {\n\t\t\t\tarr := strings.Split(n, \"=\")\n\t\t\t\tb.copyFrom = b.named[arr[1]].mountPoint\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// checkForLayers will be true if b.layers is true and a cached intermediate image is found.\n\t\t// checkForLayers is set to false when either there is no cached image or a break occurs where\n\t\t// the instructions in the Dockerfile change from a previous build.\n\t\t// Don't check for cache if b.noCache is set to true.\n\t\tif checkForLayers && !b.noCache {\n\t\t\tcacheID, err = b.layerExists(ctx, node, children[:i])\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"error checking if cached image exists from a previous build\")\n\t\t\t}\n\t\t}\n\n\t\tif cacheID != \"\" {\n\t\t\tfmt.Fprintf(b.out, \"--> Using cache %s\\n\", cacheID)\n\t\t}\n\n\t\t// If a cache is found for the last step, that means nothing in the\n\t\t// Dockerfile changed. Just create a copy of the existing image and\n\t\t// save it with the new name passed in by the user.\n\t\tif cacheID != \"\" && i == len(children)-1 {\n\t\t\tif err := b.copyExistingImage(ctx, cacheID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tb.containerIDs = append(b.containerIDs, b.builder.ContainerID)\n\t\t\tbreak\n\t\t}\n\n\t\tif cacheID == \"\" || !checkForLayers {\n\t\t\tcheckForLayers = false\n\t\t\terr := ib.Run(step, b, requiresStart)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"error building at step %+v\", *step)\n\t\t\t}\n\t\t}\n\n\t\t// Commit if no cache is found\n\t\tif cacheID == \"\" {\n\t\t\timgID, _, err = b.Commit(ctx, ib, getCreatedBy(node))\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"error committing container for step %+v\", *step)\n\t\t\t}\n\t\t\tif i == len(children)-1 {\n\t\t\t\tb.log(\"COMMIT %s\", b.output)\n\t\t\t}\n\t\t} else {\n\t\t\t// Cache is found, assign imgID the id of the cached image so\n\t\t\t// it is used to create the container for the next step.\n\t\t\timgID = cacheID\n\t\t}\n\t\t// Add container ID of successful intermediate container to b.containerIDs\n\t\tb.containerIDs = append(b.containerIDs, b.builder.ContainerID)\n\t\t// Prepare for the next step with imgID as the new base image.\n\t\tif i != len(children)-1 {\n\t\t\tif err := b.Prepare(ctx, stage, imgID); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"error preparing container for next step\")\n\t\t\t}\n\t\t}\n\t}\n\tif len(leftoverArgs) > 0 {\n\t\tfmt.Fprintf(b.out, \"[Warning] One or more build-args %v were not consumed\\n\", leftoverArgs)\n\t}\n\treturn nil\n}", "func (*Factory) Instantiate(m *workflow.Manager, w *workflowpb.Workflow, rootNode *workflow.Node) (workflow.Workflow, error) {\n\trootNode.Message = \"This is a workflow to execute horizontal resharding automatically.\"\n\n\tcheckpoint := &workflowpb.WorkflowCheckpoint{}\n\tif err := proto.Unmarshal(w.Data, checkpoint); err != nil {\n\t\treturn nil, err\n\t}\n\n\tphaseEnableApprovals := make(map[string]bool)\n\tfor _, phase := range parsePhaseEnableApprovals(checkpoint.Settings[\"phase_enable_approvals\"]) {\n\t\tphaseEnableApprovals[phase] = true\n\t}\n\n\thw := &horizontalReshardingWorkflow{\n\t\tcheckpoint: checkpoint,\n\t\trootUINode: rootNode,\n\t\tlogger: logutil.NewMemoryLogger(),\n\t\twr: wrangler.New(logutil.NewConsoleLogger(), m.TopoServer(), tmclient.NewTabletManagerClient()),\n\t\ttopoServer: m.TopoServer(),\n\t\tmanager: m,\n\t\tphaseEnableApprovals: phaseEnableApprovals,\n\t}\n\tcopySchemaUINode := &workflow.Node{\n\t\tName: \"CopySchemaShard\",\n\t\tPathName: string(phaseCopySchema),\n\t}\n\tcloneUINode := &workflow.Node{\n\t\tName: \"SplitClone\",\n\t\tPathName: string(phaseClone),\n\t}\n\twaitForFilteredReplicationUINode := &workflow.Node{\n\t\tName: \"WaitForFilteredReplication\",\n\t\tPathName: string(phaseWaitForFilteredReplication),\n\t}\n\n\tdiffUINode := &workflow.Node{\n\t\tName: checkpoint.Settings[\"split_diff_cmd\"],\n\t\tPathName: string(phaseDiff),\n\t}\n\n\tmigrateRdonlyUINode := &workflow.Node{\n\t\tName: \"MigrateServedTypeRDONLY\",\n\t\tPathName: string(phaseMigrateRdonly),\n\t}\n\tmigrateReplicaUINode := &workflow.Node{\n\t\tName: \"MigrateServedTypeREPLICA\",\n\t\tPathName: string(phaseMigrateReplica),\n\t}\n\tmigrateMasterUINode := &workflow.Node{\n\t\tName: \"MigrateServedTypeMASTER\",\n\t\tPathName: string(phaseMigrateMaster),\n\t}\n\n\thw.rootUINode.Children = []*workflow.Node{\n\t\tcopySchemaUINode,\n\t\tcloneUINode,\n\t\twaitForFilteredReplicationUINode,\n\t\tdiffUINode,\n\t\tmigrateRdonlyUINode,\n\t\tmigrateReplicaUINode,\n\t\tmigrateMasterUINode,\n\t}\n\n\tsourceShards := strings.Split(hw.checkpoint.Settings[\"source_shards\"], \",\")\n\tdestinationShards := strings.Split(hw.checkpoint.Settings[\"destination_shards\"], \",\")\n\n\tif err := createUINodes(hw.rootUINode, phaseCopySchema, destinationShards); err != nil {\n\t\treturn hw, err\n\t}\n\tif err := createUINodes(hw.rootUINode, phaseClone, sourceShards); err != nil {\n\t\treturn hw, err\n\t}\n\tif err := createUINodes(hw.rootUINode, phaseWaitForFilteredReplication, destinationShards); err != nil {\n\t\treturn hw, err\n\t}\n\tvar shardsToUseForDiff []string\n\n\tswitch hw.checkpoint.Settings[\"split_diff_cmd\"] {\n\tcase \"SplitDiff\":\n\t\tshardsToUseForDiff = destinationShards\n\tcase \"MultiSplitDiff\":\n\t\tshardsToUseForDiff = sourceShards\n\t}\n\n\tif err := createUINodes(hw.rootUINode, phaseDiff, shardsToUseForDiff); err != nil {\n\t\treturn hw, err\n\t}\n\n\tif err := createUINodes(hw.rootUINode, phaseMigrateRdonly, sourceShards); err != nil {\n\t\treturn hw, err\n\t}\n\tif err := createUINodes(hw.rootUINode, phaseMigrateReplica, sourceShards); err != nil {\n\t\treturn hw, err\n\t}\n\tif err := createUINodes(hw.rootUINode, phaseMigrateMaster, sourceShards); err != nil {\n\t\treturn hw, err\n\t}\n\n\treturn hw, nil\n}", "func (h *Hook) PreInsert(s gorp.SqlExecutor) error {\n\th.CreatedAt = util.NowMilli()\n\th.UpdatedAt = h.CreatedAt\n\treturn nil\n}", "func (o *AssetRevision) doBeforeInsertHooks(exec boil.Executor) (err error) {\n\tfor _, hook := range assetRevisionBeforeInsertHooks {\n\t\tif err := hook(exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func TestYAMLPipelineSpec(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"Skipping integration tests in short mode\")\n\t}\n\tc, _ := minikubetestenv.AcquireCluster(t)\n\t// Note that BashCmd dedents all lines below including the YAML (which\n\t// wouldn't parse otherwise)\n\trequire.NoError(t, tu.PachctlBashCmd(t, c, `\n\t\tyes | pachctl delete all\n\t\tpachctl create project P\n\t\tpachctl create repo input --project P\n\t\tpachctl create pipeline -f - <<EOF\n\t\tpipeline:\n\t\t name: first\n\t\t project:\n\t\t name: P\n\t\tinput:\n\t\t pfs:\n\t\t glob: /*\n\t\t repo: input\n\t\t project: P\n\t\ttransform:\n\t\t cmd: [ /bin/bash ]\n\t\t stdin:\n\t\t - \"cp /pfs/input/* /pfs/out\"\n\t\t---\n\t\tpipeline:\n\t\t name: second\n\t\tinput:\n\t\t pfs:\n\t\t glob: /*\n\t\t repo: first\n\t\t project: P\n\t\ttransform:\n\t\t cmd: [ /bin/bash ]\n\t\t stdin:\n\t\t - \"cp /pfs/first/* /pfs/out\"\n\t\tEOF\n\t\tpachctl start commit input@master --project P\n\t\techo foo | pachctl put file input@master:/foo --project P\n\t\techo bar | pachctl put file input@master:/bar --project P\n\t\techo baz | pachctl put file input@master:/baz --project P\n\t\tpachctl finish commit input@master --project P\n\t\tpachctl wait commit second@master\n\t\tpachctl get file second@master:/foo | match foo\n\t\tpachctl get file second@master:/bar | match bar\n\t\tpachctl get file second@master:/baz | match baz\n\t\t`,\n\t).Run())\n}", "func deployExecutor(args prompter.CmdArgs) error {\n\tfmt.Println(\"inside deployExecutor\")\n\tfmt.Printf(\"args: %v\\n\", args)\n\n\treturn config.Deploy()\n\t// err := config.Deploy()\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\n\t// // Read config.\n\t// cfg, err = config.Read()\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\n\t// // Enable all commands.\n\t// configCmd.Hidden = false\n\t// templateCmd.Hidden = false\n\t// dataCmd.Hidden = false\n\n\t// return nil\n}", "func Prepare() error {\n\n\t// log.Println(\"Preparing work...\")\n\n\t// commands := [][]string{\n\t// \t[]string{\"yum\", \"update\", \"-y\"},\n\t// \t[]string{\"yum\", \"install\", \"-y\", \"docker\"},\n\t// \t[]string{\"service\", \"docker\", \"start\"},\n\t// \t[]string{\"docker\", \"pull\", \"tnolet/scraper:0.1.0\"},\n\t// }\n\n\t// for _, command := range commands {\n\t// \tout, err := exec.Command(command).Output()\n\n\t// \tif err != nil {\n\t// \t\tlog.Printf(\"Prepare command unsuccessful: %v, %v\", err.Error(), out)\n\t// \t\treturn err\n\t// \t}\n\n\t// \tlog.Printf(\"Succesfully executed preparation: %v\", out)\n\t// }\n\treturn nil\n\n}", "func beforeBuild() error {\n\terr := runPrepareScript()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (p *Preparer) Prepare(render resource.Renderer) (resource.Task, error) {\n\tenv := transform.StringsMapToStringSlice(\n\t\tp.Env,\n\t\tfunc(k, v string) string {\n\t\t\treturn fmt.Sprintf(\"%s=%s\", k, v)\n\t\t},\n\t)\n\n\tgenerator := &CommandGenerator{\n\t\tInterpreter: p.Interpreter,\n\t\tFlags: p.ExecFlags,\n\t\tDir: p.Dir,\n\t\tEnv: env,\n\t}\n\n\tif duration, err := time.ParseDuration(p.Timeout); err == nil {\n\t\tgenerator.Timeout = &duration\n\t}\n\n\tshell := &Shell{\n\t\tCmdGenerator: generator,\n\t\tCheckStmt: p.Check,\n\t\tApplyStmt: p.Apply,\n\t\tDir: p.Dir,\n\t\tEnv: env,\n\t}\n\n\treturn shell, checkSyntax(p.Interpreter, p.CheckFlags, p.Check)\n}", "func WithPreRunE(preRunE func(cmd *cobra.Command, args []string) error) RunnerOption {\n\treturn func(k *PluginRunner) {\n\t\tk.cmd.PreRunE = func(cmd *cobra.Command, args []string) error {\n\t\t\tif err := preRunE(cmd, args); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Explicitly call through to the default implementation to invoke Configurable.Config\n\t\t\treturn k.preRun(cmd, args)\n\t\t}\n\t}\n}", "func preConfigureCallback(vars resource.PropertyMap, c shim.ResourceConfig) error {\n\treturn nil\n}", "func (o *Project) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range projectBeforeUpsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *Project) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range projectBeforeUpsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d *Driver) PreCreateCheck() error {\n\tif d.UserDataFile != \"\" {\n\t\tif _, err := os.Stat(d.UserDataFile); os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"user-data file %s could not be found\", d.UserDataFile)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *Smallblog) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range smallblogBeforeUpsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\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 PreRunEFunc(config *Config) func(*cobra.Command, []string) error {\n\treturn func(cmd *cobra.Command, args []string) error {\n\t\tformatter := cmd.Annotations[\"command\"]\n\n\t\t// root command must have an argument, otherwise we're going to show help\n\t\tif formatter == \"root\" && len(args) == 0 {\n\t\t\tcmd.Help() //nolint:errcheck\n\t\t\tos.Exit(0)\n\t\t}\n\n\t\tcmd.Flags().VisitAll(func(f *pflag.Flag) {\n\t\t\tchangedfs[f.Name] = f.Changed\n\t\t})\n\n\t\t// read config file if provided and/or available\n\t\tif config.File == \"\" {\n\t\t\treturn fmt.Errorf(\"value of '--config' can't be empty\")\n\t\t}\n\n\t\tfile := filepath.Join(args[0], config.File)\n\t\tcfgreader := &cfgreader{\n\t\t\tfile: file,\n\t\t\tconfig: config,\n\t\t}\n\n\t\tif found, err := cfgreader.exist(); !found {\n\t\t\t// config is explicitly provided and file not found, this is an error\n\t\t\tif changedfs[\"config\"] {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\t// config is not provided and file not found, only show an error for the root command\n\t\t\tif formatter == \"root\" {\n\t\t\t\tcmd.Help() //nolint:errcheck\n\t\t\t\tos.Exit(0)\n\t\t\t}\n\t\t} else {\n\t\t\t// config file is found, we're now going to parse it\n\t\t\tif err := cfgreader.parse(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t// explicitly setting formatter to Config for non-root commands this\n\t\t// will effectively override formattter properties from config file\n\t\t// if 1) config file exists and 2) formatter is set and 3) explicitly\n\t\t// a subcommand was executed in the terminal\n\t\tif formatter != \"root\" {\n\t\t\tconfig.Formatter = formatter\n\t\t}\n\n\t\tconfig.process()\n\n\t\tif err := config.validate(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t}\n}", "func Preload(L *lua.LState) int {\n\tframeworkUD := L.NewTypeMetatable(`testing_framework_ud`)\n\tL.SetGlobal(`testing_framework_ud`, frameworkUD)\n\tL.SetField(frameworkUD, \"__index\", L.SetFuncs(L.NewTable(), map[string]lua.LGFunction{\n\t\t\"create\": createPlugin,\n\t\t\"remove\": removePlugin,\n\t\t\"restart_count\": restartCount,\n\t\t\"error_count\": errorCount,\n\t\t\"last_error\": lastError,\n\t\t\"host\": hostName,\n\t}))\n\treturn 0\n}", "func (o *CMFSlideItem) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range cmfSlideItemBeforeUpsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *CMFSlideItem) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range cmfSlideItemBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *RestaurantRank) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range restaurantRankBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func Preprocess(source io.Reader, config *configuration.Configuration, opts ...Option) (string, error) {\n\tctx := NewParseContext(config, opts...) // each pipeline step will have its own clone of `ctx`\n\treturn preprocess(ctx, source)\n}", "func (o *Board) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range boardBeforeUpsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func TestYAMLFactory(t *testing.T) {\n\tlabels := make(map[string]string)\n\tlabels[\"app\"] = \"trident\"\n\n\townerRef := make(map[string]string)\n\townerRef[\"uid\"] = \"123456789\"\n\townerRef[\"kind\"] = \"TridentOrchestrator\"\n\n\timagePullSecrets := []string{\"thisisasecret\"}\n\n\tversion := versionutils.MustParseSemantic(\"1.21.0\")\n\n\tdeploymentArgs := &DeploymentYAMLArguments{\n\t\tDeploymentName: Name,\n\t\tTridentImage: ImageName,\n\t\tAutosupportImage: AutosupportImageName,\n\t\tAutosupportProxy: \"\",\n\t\tAutosupportCustomURL: \"\",\n\t\tAutosupportSerialNumber: \"\",\n\t\tAutosupportHostname: \"\",\n\t\tLogFormat: LogFormat,\n\t\tLogLevel: \"info\",\n\t\tImageRegistry: \"\",\n\t\tImagePullSecrets: imagePullSecrets,\n\t\tLabels: labels,\n\t\tControllingCRDetails: ownerRef,\n\t\tUseIPv6: false,\n\t\tSilenceAutosupport: false,\n\t\tVersion: version,\n\t\tTopologyEnabled: false,\n\t\tHTTPRequestTimeout: config.HTTPTimeoutString,\n\t}\n\n\tyamlsOutputs := []string{\n\t\tGetServiceAccountYAML(Name, nil, nil, nil),\n\t\tGetServiceAccountYAML(Name, Secrets, labels, ownerRef),\n\t\tGetRoleYAML(Namespace, Name, labels, ownerRef),\n\t\tGetRoleBindingYAML(Namespace, Name, labels, ownerRef),\n\t\tGetClusterRoleYAML(Name, nil, nil),\n\t\tGetClusterRoleYAML(Name, labels, ownerRef),\n\t\tGetClusterRoleBindingYAML(Namespace, Name, FlavorOpenshift, nil, ownerRef),\n\t\tGetClusterRoleBindingYAML(Namespace, Name, FlavorK8s, labels, ownerRef),\n\t\tGetCSIDeploymentYAML(deploymentArgs),\n\t\tGetCSIServiceYAML(Name, labels, ownerRef),\n\t\tGetSecretYAML(Name, Namespace, labels, ownerRef, nil, nil),\n\t\tGetResourceQuotaYAML(Name, Namespace, labels, nil),\n\t}\n\tfor _, yamlData := range yamlsOutputs {\n\t\t_, err := yaml.YAMLToJSON([]byte(yamlData))\n\t\tif err != nil {\n\t\t\tt.Fatalf(err.Error(), yamlData)\n\t\t}\n\t}\n}", "func (o *Board) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range boardBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (p *updatePhaseSELinux) PreCheck(context.Context) error { return nil }", "func (o *RecipeLipid) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range recipeLipidBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func runTerragruntWithConfig(originalTerragruntOptions *options.TerragruntOptions, terragruntOptions *options.TerragruntOptions, terragruntConfig *config.TerragruntConfig, allowSourceDownload bool, target *Target) error {\n\t// Add extra_arguments to the command\n\tif terragruntConfig.Terraform != nil && terragruntConfig.Terraform.ExtraArgs != nil && len(terragruntConfig.Terraform.ExtraArgs) > 0 {\n\t\targs := filterTerraformExtraArgs(terragruntOptions, terragruntConfig)\n\t\tterragruntOptions.InsertTerraformCliArgs(args...)\n\t\tfor k, v := range filterTerraformEnvVarsFromExtraArgs(terragruntOptions, terragruntConfig) {\n\t\t\tterragruntOptions.Env[k] = v\n\t\t}\n\t}\n\n\tif err := setTerragruntInputsAsEnvVars(terragruntOptions, terragruntConfig); err != nil {\n\t\treturn err\n\t}\n\n\tif util.FirstArg(terragruntOptions.TerraformCliArgs) == CommandNameInit {\n\t\tif err := prepareInitCommand(terragruntOptions, terragruntConfig, allowSourceDownload); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tif err := prepareNonInitCommand(originalTerragruntOptions, terragruntOptions, terragruntConfig); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfileName, err := setTerragruntNullValues(terragruntOptions, terragruntConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif fileName != \"\" {\n\t\t\tif err := os.Remove(fileName); err != nil {\n\t\t\t\tterragruntOptions.Logger.Debugf(\"Failed to remove null values file %s: %v\", fileName, err)\n\t\t\t}\n\t\t}\n\t}()\n\n\t// Now that we've run 'init' and have all the source code locally, we can finally run the patch command\n\tif target.isPoint(TargetPointInitCommand) {\n\t\treturn target.runCallback(terragruntOptions, terragruntConfig)\n\t}\n\n\tif err := checkProtectedModule(terragruntOptions, terragruntConfig); err != nil {\n\t\treturn err\n\t}\n\n\treturn runActionWithHooks(\"terraform\", terragruntOptions, terragruntConfig, func() error {\n\t\trunTerraformError := runTerraformWithRetry(terragruntOptions)\n\n\t\tvar lockFileError error\n\t\tif shouldCopyLockFile(terragruntOptions.TerraformCliArgs) {\n\t\t\t// Copy the lock file from the Terragrunt working dir (e.g., .terragrunt-cache/xxx/<some-module>) to the\n\t\t\t// user's working dir (e.g., /live/stage/vpc). That way, the lock file will end up right next to the user's\n\t\t\t// terragrunt.hcl and can be checked into version control. Note that in the past, Terragrunt allowed the\n\t\t\t// user's working dir to be different than the directory where the terragrunt.hcl file lived, so just in\n\t\t\t// case, we are using the user's working dir here, rather than just looking at the parent dir of the\n\t\t\t// terragrunt.hcl. However, the default value for the user's working dir, set in options.go, IS just the\n\t\t\t// parent dir of terragrunt.hcl, so these will likely always be the same.\n\t\t\tlockFileError = util.CopyLockFile(terragruntOptions.WorkingDir, originalTerragruntOptions.WorkingDir, terragruntOptions.Logger)\n\t\t}\n\n\t\treturn multierror.Append(runTerraformError, lockFileError).ErrorOrNil()\n\t})\n}", "func (*DungeonScene) Preload() {\n\tstructs.LoadSprites()\n\n\t// Load a font\n\tif err := engo.Files.Load(\"fonts/Gamegirl.ttf\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := structs.LoadItems(); err != nil {\n\t\tpanic(err)\n\t}\n}", "func preprocessDockerfileContents(r io.ReadCloser, ctxDir string) (rdrCloser *io.ReadCloser, err error) {\n\tcppPath := \"/usr/bin/cpp\"\n\tif _, err = os.Stat(cppPath); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\terr = errors.Errorf(\"error: Dockerfile.in support requires %s to be installed\", cppPath)\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tstdout := bytes.Buffer{}\n\tstderr := bytes.Buffer{}\n\n\tcmd := exec.Command(cppPath, \"-E\", \"-iquote\", ctxDir, \"-\")\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\n\tpipe, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tpipe.Close()\n\t\t}\n\t}()\n\n\tif err = cmd.Start(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif _, err = io.Copy(pipe, r); err != nil {\n\t\treturn nil, err\n\t}\n\n\tpipe.Close()\n\tif err = cmd.Wait(); err != nil {\n\t\tif stderr.Len() > 0 {\n\t\t\terr = fmt.Errorf(\"%v: %s\", err, strings.TrimSpace(stderr.String()))\n\t\t}\n\t\treturn nil, errors.Wrapf(err, \"error pre-processing Dockerfile\")\n\t}\n\n\trc := ioutil.NopCloser(bytes.NewReader(stdout.Bytes()))\n\treturn &rc, nil\n}", "func Run(isNonInitCmd bool) error {\n\t// check if policy paths exist\n\tif path, err := os.Stat(config.GetPolicyRepoPath()); err == nil && path.IsDir() {\n\t\tif isNonInitCmd {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tzap.S().Debug(\"initializing terrascan\")\n\n\tif !connected(terrascanReadmeURL) {\n\t\treturn errNoConnection\n\t}\n\n\t// download policies\n\tif err := DownloadPolicies(); err != nil {\n\t\treturn err\n\t}\n\n\tzap.S().Debug(\"initialized successfully\")\n\treturn nil\n}", "func (t TemplateHelmChartTask) Run() error {\n\terr := afero.Walk(t.fs, t.chartDir, func(path string, info os.FileInfo, err error) error {\n\t\tif info != nil && strings.HasSuffix(info.Name(), \".tgz\") {\n\t\t\treturn nil\n\t\t}\n\n\t\tcontents, err := afero.ReadFile(t.fs, path)\n\t\tif err != nil {\n\t\t\tmicroerror.Mask(err)\n\t\t}\n\n\t\tbuildInfo := BuildInfo{\n\t\t\tSHA: t.sha,\n\t\t\tVersion: t.version,\n\t\t}\n\n\t\ttmpl, err := template.New(path).Delims(\"[[\", \"]]\").Parse(string(contents))\n\t\tif err != nil {\n\t\t\tmicroerror.Mask(err)\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\tif err := tmpl.Execute(&buf, buildInfo); err != nil {\n\t\t\tmicroerror.Mask(err)\n\t\t}\n\n\t\tif err := afero.WriteFile(t.fs, path, buf.Bytes(), permission); err != nil {\n\t\t\tmicroerror.Mask(err)\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn microerror.Mask(err)\n\t}\n\n\treturn nil\n}", "func (o *Weather) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range weatherBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *RecipeAdditive) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range recipeAdditiveBeforeInsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func InstallIpvsYaml(mode string, currentDir string, masterArray []string, subProcessDir string, logName string) {\n var ipvsinitYaml string\n master_num := len(masterArray)\n for i := 0; i < master_num; i++ {\n ipvsinitYaml = ipvsinitYaml+\" - ip: \"+masterArray[i]+\" \\n\"\n }\n ipvsinitYamlFile, err := os.Create(currentDir+\"/data/output\"+subProcessDir+\"/sys/0x000certificate/copycfssl/templates/ipvsinit_ep.yaml\") \n CheckErr(err,currentDir,logName,mode)\n defer ipvsinitYamlFile.Close()\n ipvsinitYamlFile.WriteString(\"apiVersion: v1\\nkind: Endpoints\\nmetadata:\\n name: ipvsinit-lb\\n namespace: kube-system\\n labels:\\n k8sapp: ipvsinit-lb\\nsubsets:\\n- addresses:\\n\"+ipvsinitYaml+\" ports:\\n - name: k8s-api\\n port: 6443\\n protocol: TCP\\n\")\n}" ]
[ "0.62390107", "0.6202845", "0.6157384", "0.6145199", "0.61007977", "0.58247554", "0.57876694", "0.5771327", "0.5714059", "0.5706957", "0.5641635", "0.5640143", "0.5631724", "0.56255126", "0.5613145", "0.556822", "0.5548587", "0.5501238", "0.5452613", "0.5401187", "0.53920096", "0.53845525", "0.53770745", "0.5342893", "0.53341395", "0.5317871", "0.52897227", "0.5252843", "0.5235051", "0.52343005", "0.5218737", "0.5144901", "0.51375866", "0.5102268", "0.5081421", "0.50637347", "0.5001055", "0.49847907", "0.49777466", "0.49756077", "0.49737227", "0.49715617", "0.49267548", "0.4926543", "0.49140063", "0.49030948", "0.4874707", "0.4868303", "0.48607072", "0.48542076", "0.483982", "0.48253578", "0.48225763", "0.4800798", "0.47986183", "0.47986183", "0.47924787", "0.4791575", "0.4790244", "0.47854328", "0.47810507", "0.47798565", "0.4754476", "0.4740169", "0.47377712", "0.4733624", "0.4731651", "0.47275224", "0.47184452", "0.4715047", "0.47102594", "0.470952", "0.47018135", "0.4698657", "0.46792114", "0.467343", "0.46705577", "0.46705577", "0.4665908", "0.46645716", "0.466303", "0.46602866", "0.46593887", "0.46543223", "0.4650284", "0.4648723", "0.46480975", "0.4647725", "0.46455973", "0.46435872", "0.46413884", "0.4635282", "0.46299917", "0.46293607", "0.4629036", "0.46236244", "0.4612218", "0.46120325", "0.46087214", "0.4607016" ]
0.6956221
0
NewConverter creates and returns a new Converter for the given Lua state.
func NewConverter(L *lua.LState) *Converter { c := &Converter{ lstate: L, } c.metatable = c.ctyMetatable() return c }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewConverter(config *Config) (*Converter, error) {\n if config == nil {\n\t\treturn nil, errors.New(\"config cannot be nil\")\n\t}\n\treturn &Converter{\n\t\tconfig: config,\n\t}, nil\n}", "func NewConverter() *converter {\n\treturn &converter{}\n}", "func NewConverter(config *ConverterConfig) *Converter {\n\treturn &Converter{\n\t\tencodeAsFlow: config.EncodeAsFlow,\n\t}\n}", "func NewConverter() *coinConverter {\n\treturn &coinConverter{\n\t\tcmds: make(map[string]command),\n\t\ttokens: make(map[string]tokenv1.TokenI),\n\t}\n}", "func NewConverter(webhook WebhookConverter) *converter {\n\treturn &converter{webhook: webhook}\n}", "func (n NewConverter) New(ctx DocumentContext) (Converter, error) {\n\treturn n(ctx)\n}", "func NewConverter() (rtfConverter) {\n\tc := rtfConverter{}\n\treturn c;\n}", "func NewConverter(NameFunc) *Converter {\n\tc := &Converter{\n\t\tconversionFuncs: NewConversionFuncs(),\n\t\tgeneratedConversionFuncs: NewConversionFuncs(),\n\t\tignoredUntypedConversions: make(map[typePair]struct{}),\n\t}\n\tc.RegisterUntypedConversionFunc(\n\t\t(*[]byte)(nil), (*[]byte)(nil),\n\t\tfunc(a, b interface{}, s Scope) error {\n\t\t\treturn Convert_Slice_byte_To_Slice_byte(a.(*[]byte), b.(*[]byte), s)\n\t\t},\n\t)\n\treturn c\n}", "func New(workspace string, host string, port int) (*Converter, error) {\n\tclient := marionette_client.NewClient()\n\terr := client.Connect(host, port)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuName := fmt.Sprintf(\"%d.xml\", port)\n\treturn &Converter{\n\t\tworkspace: workspace,\n\t\tclient: client,\n\t\tuniqueXmlName: uName,\n\t}, nil\n}", "func NewConverter(data float64, from Unit, to Unit) Converter {\n\treturn Converter{data: data, from: from, to: to}\n}", "func New(config *types.Config, logger *logrus.Logger) (*Converter, error) {\n\n\t// Load the OpenAPI spec:\n\tspec, err := openapi2proto.LoadFile(config.SpecPath)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Unable to load spec (%s)\", config.SpecPath)\n\t}\n\n\t// Make sure the provided spec is really OpenAPI 2.x:\n\tif !strings.HasPrefix(spec.Swagger, \"2\") {\n\t\treturn nil, fmt.Errorf(\"This spec (%s) is not OpenAPI 2.x\", spec.Swagger)\n\t}\n\n\tlogger.WithField(\"title\", spec.Info.Title).WithField(\"version\", spec.Info.Version).Info(\"Ready to convert Swagger / OpenAPI2\")\n\tlogger.WithField(\"description\", spec.Info.Description).Trace(\"Description\")\n\n\t// Return a new *Converter:\n\treturn &Converter{\n\t\tspec: spec,\n\t\tconfig: config,\n\t\tlogger: logger,\n\t\tnestedAdditionalProperties: make(map[string]json.RawMessage),\n\t}, nil\n}", "func NewConverter(fileName string, allowEmpty bool, anyHeader bool) *Converter {\n\treturn &Converter{fileName: fileName, allowEmpty: allowEmpty, anyHeader: anyHeader}\n}", "func NewConversion() Conversion {\n\treturn Conversion{}\n}", "func NewConvert(option *option.Option, outStream io.Writer) Convert {\n\treturn &convert{option: option, outStream: outStream}\n}", "func (converterName converterName) CreateConverter() (cliConverter, error) {\n\tconv, err := Resolve(string(converterName))\n\treturn cliConverter{Converter: conv}, err\n}", "func NewConversion(from, to Unit, formula string) {\n\texpr, err := govaluate.NewEvaluableExpression(formula)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// create conversion function\n\tfn := func(x float64) float64 {\n\t\tparams := make(map[string]interface{})\n\t\tparams[\"x\"] = x\n\n\t\tres, err := expr.Evaluate(params)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treturn res.(float64)\n\t}\n\n\tNewConversionFromFn(from, to, fn, formula)\n}", "func NewTypeConverter(h PackageNameResolver, optionalEntries map[string]FieldMapperEntry) *TypeConverter {\n\treturn &TypeConverter{\n\t\tLineBuilder: LineBuilder{},\n\t\tHelper: h,\n\t\tuninitialized: make(map[string]*fieldStruct),\n\t\tconvStructMap: make(map[string]string),\n\t\toptionalEntries: optionalEntries,\n\t}\n}", "func Create(dictName string) (*Converter, error) {\n\tvar dict map[string]string\n\tvar name = strings.ToLower(dictName)\n\tswitch name {\n\tcase \"ru\":\n\t\tdict = ruDict\n\t\tbreak\n\tcase \"dvorak\":\n\t\tdict = dvorakDict\n\t\tbreak\n\tcase \"by\":\n\t\tdict = byDict\n\t\tbreak\n\tcase \"uk\":\n\t\tdict = ukDict\n\t\tbreak\n\tcase \"de\":\n\t\tdict = deDict\n\t\tbreak\n\tcase \"es\":\n\t\tdict = esDict\n\t\tbreak\n\tcase \"fa\":\n\t\tdict = faDict\n\t\tbreak\n\tcase \"he\":\n\t\tdict = heDict\n\t\tbreak\n\tcase \"kk\":\n\t\tdict = kkDict\n\t\tbreak\n\tcase \"kr\":\n\t\tdict = krDict\n\t\tbreak\n\tdefault:\n\t\treturn nil, errors.New(\"dict not found\")\n\t}\n\n\treturn createFromDict(dict)\n}", "func NewRuntimeConverter(t mockConstructorTestingTNewRuntimeConverter) *RuntimeConverter {\n\tmock := &RuntimeConverter{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewConvertCommand(reportLocation string, containerized bool) *ConvertCommand {\n\tcmd := &ConvertCommand{\n\t\tCommand: Command{\n\t\t\treportLocation: reportLocation,\n\t\t\tVersion: OVConvertCommand, //convert command 'results' version (report and artifacts)\n\t\t\tType: command.Convert,\n\t\t\tState: command.StateUnknown,\n\t\t},\n\t}\n\n\tcmd.Command.init(containerized)\n\treturn cmd\n}", "func New(eef func() briee.EventEmitter) Logic {\n\treturn newBL(eef)\n}", "func NewTranslator(service *stackdriver.Service, gceConf *config.GceConfig, rateInterval time.Duration, alignmentPeriod time.Duration, mapper apimeta.RESTMapper, useNewResourceModel, supportDistributions bool) *Translator {\n\treturn &Translator{\n\t\tservice: service,\n\t\tconfig: gceConf,\n\t\treqWindow: rateInterval,\n\t\talignmentPeriod: alignmentPeriod,\n\t\tclock: realClock{},\n\t\tmapper: mapper,\n\t\tuseNewResourceModel: useNewResourceModel,\n\t\tsupportDistributions: supportDistributions,\n\t}\n}", "func NewTranslator(b *i18n.Bundle, cfg config.AllProvider, logger loggers.Logger) Translator {\n\tt := Translator{cfg: cfg, logger: logger, translateFuncs: make(map[string]translateFunc)}\n\tt.initFuncs(b)\n\treturn t\n}", "func NewAPIDefinitionConverter(t mockConstructorTestingTNewAPIDefinitionConverter) *APIDefinitionConverter {\n\tmock := &APIDefinitionConverter{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func New(cfg *config.Config) (*Deduplicator, error) {\n\tif err := os.MkdirAll(cfg.DedupDir, 0700); err != nil {\n\t\treturn nil, fmt.Errorf(\"create state dir: %w\", err)\n\t}\n\tdedup := &Deduplicator{config: *cfg}\n\tdata, err := ioutil.ReadFile(dedup.stateFileName())\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn nil, fmt.Errorf(\"read state file: %w\", err)\n\t\t}\n\t} else if err := json.Unmarshal(data, &dedup.state); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse state: %w\", err)\n\t}\n\treturn dedup, nil\n}", "func New(conversion string, opts ...Option) (*OpenCC, error) {\n\tif strings.TrimSpace(conversion) == \"\" {\n\t\treturn nil, fmt.Errorf(\"Please select a conversion mode: %s\", supportedConversions)\n\t}\n\tif _, has := conversions[conversion]; !has {\n\t\treturn nil, fmt.Errorf(\"%s The conversion mode does not exist\", conversion)\n\t}\n\tcc := &OpenCC{Conversion: conversion}\n\tfor _, opt := range opts {\n\t\topt(cc)\n\t}\n\tif cc.dataDir == \"\" {\n\t\tcc.dataDir = defaultDir()\n\t}\n\terr := cc.initDict()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cc, nil\n}", "func MakeLinearConverter(imgWidth, imgHeight int, pc ProjectionConverter) ProjectionConverter {\n\treturn &LinearConverter{\n\t\tminLat: pc.MinLatitude(),\n\t\tmaxLat: pc.MaxLatitude(),\n\t\tminLon: pc.MinLongitude(),\n\t\tmaxLon: pc.MaxLongitude(),\n\t\timgWidth: imgWidth,\n\t\timgHeight: imgHeight,\n\t}\n}", "func New(root string, config *converter.Config) (runtime.Source, error) {\n\treturn newFsSource(root, config, kube_meta.Types.All())\n}", "func NewTranslator(lang string, loader Loader, opts ...TranslatorOption) *Translator {\n\tt := &Translator{\n\t\tlang: lang,\n\t\tloader: loader,\n\t\tlogger: log.New(os.Stderr, \"pogo\", log.LstdFlags),\n\t}\n\tfor _, opt := range opts {\n\t\topt.apply(t)\n\t}\n\n\treturn t\n}", "func New() (g *Glutton, err error) {\n\tg = &Glutton{}\n\tg.protocolHandlers = make(map[string]protocolHandlerFunc, 0)\n\tviper.SetDefault(\"var-dir\", \"/var/lib/glutton\")\n\tif err = g.makeID(); err != nil {\n\t\treturn nil, err\n\t}\n\tg.logger = NewLogger(g.id.String())\n\n\t// Loading the congiguration\n\tg.logger.Info(\"Loading configurations from: config/conf.yaml\", zap.String(\"reporter\", \"glutton\"))\n\tg.conf, err = config.Init(g.logger)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trulesPath := g.conf.GetString(\"rules_path\")\n\trulesFile, err := os.Open(rulesPath)\n\tdefer rulesFile.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tg.rules, err = freki.ReadRulesFromFile(rulesFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn g, nil\n\n}", "func NewTranslator() *Translator {\n\treturn &Translator{\n\t\tresources: make(map[string]string),\n\t}\n}", "func NewLanguage() language.Language {\n\tvar cmd *exec.Cmd\n\tvar err error\n\n\tplugin := GetPluginConfig()\n\taddress := plugin.Address\n\tif address == \"\" {\n\t\taddress = \"0.0.0.0:50051\"\n\t\tlog.Printf(\"Launching subprocess: %s (%s)\", plugin.Path, address)\n\t\tcmd, err = startPlugin(plugin.Root, plugin.Path, nil, []string{\n\t\t\tfmt.Sprintf(\"%sADDRESS=%s\", PluginEnvVarNamePrefix, address),\n\t\t})\n\t\tif err != nil {\n\t\t\tfatalError(fmt.Errorf(\"could not start plugin %q: %v\", plugin.Path, err))\n\t\t}\n\t}\n\n\tconn, err := grpc.Dial(address,\n\t\tgrpc.WithInsecure(),\n\t)\n\n\tif err != nil {\n\t\tfatalError(err)\n\t}\n\n\treturn &subzelle{\n\t\tplugin: plugin,\n\t\tclient: lpb.NewLanguageClient(conn),\n\t\tconn: conn,\n\t\tcmd: cmd,\n\t}\n}", "func init() {\n\t// Up-converters\n\tconvert.RegisterConverter(\"0.1.0\", supportedVersions, convertFrom02x)\n\tconvert.RegisterConverter(\"0.2.0\", supportedVersions, convertFrom02x)\n\tconvert.RegisterConverter(\"0.3.0\", supportedVersions, convertInternal)\n\tconvert.RegisterConverter(\"0.3.1\", supportedVersions, convertInternal)\n\n\t// Down-converters\n\tconvert.RegisterConverter(\"0.4.0\", []string{\"0.3.0\", \"0.3.1\"}, convertInternal)\n\tconvert.RegisterConverter(\"0.4.0\", []string{\"0.1.0\", \"0.2.0\"}, convertTo02x)\n\tconvert.RegisterConverter(\"0.3.1\", []string{\"0.1.0\", \"0.2.0\"}, convertTo02x)\n\tconvert.RegisterConverter(\"0.3.0\", []string{\"0.1.0\", \"0.2.0\"}, convertTo02x)\n\n\t// Creator\n\tconvert.RegisterCreator(supportedVersions, NewResult)\n}", "func New(input string) *Lexer {\n\treturn &Lexer{\n\t\tinput: input,\n\t}\n}", "func newLabelStage(logger log.Logger, configs interface{}) (*labelStage, error) {\n\tcfgs := &LabelsConfig{}\n\terr := mapstructure.Decode(configs, cfgs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = validateLabelsConfig(*cfgs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &labelStage{\n\t\tcfgs: *cfgs,\n\t\tlogger: logger,\n\t}, nil\n}", "func MakeLang() Lang {\n\treturn Lang{\n\t\tDict: symbol.NewDict(),\n\t\tTrans: make(Trans),\n\t}\n}", "func NewTranslator(name, namespace, secretsNamespace string, enforceHTTPs bool, hostNameSuffixMatch bool, idleTimeoutSeconds int) Translator {\n\treturn &defaultTranslator{\n\t\tname: name,\n\t\tnamespace: namespace,\n\t\tsecretsNamespace: secretsNamespace,\n\t\tenforceHTTPs: enforceHTTPs,\n\t\thostNameSuffixMatch: hostNameSuffixMatch,\n\t\tidleTimeoutSeconds: idleTimeoutSeconds,\n\t}\n}", "func NewTranslator() *Translator {\n\treturn &Translator{\n\t\tclient: NewClient(nil),\n\t\tparser: NewParser(),\n\t}\n}", "func New(grammarString string) (*grammar.Grammar, tree.Reducer, error) {\n\tparseTree, err := runner.Run(grammarString)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tg, r := evalGrammar(parseTree.(*tree.PN))\n\treturn g, r, nil\n}", "func NewState() (string, error) {\n\trawState := make([]byte, 16)\n\t_, err := rand.Read(rawState)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn hex.EncodeToString(rawState), nil\n}", "func New(input string) *Lexer {\n\treturn &Lexer{\n\t\tinput: input,\n\t\tcurrentPos: 0,\n\t}\n}", "func New(start StateFn, input string) *Lexer {\n\tif start == nil {\n\t\tpanic(\"nil start state\")\n\t}\n\treturn &Lexer{\n\t\tstate: start,\n\t\tinput: input,\n\t\titems: list.New(),\n\t}\n}", "func New() *Transformer {\n\treturn &Transformer{}\n}", "func New(config *configuration.Config, vs *library.Library) *Downloader {\n\treturn &Downloader{\n\t\tBase: subapp.NewBase(AppName),\n\t\tconfig: config,\n\t\tlibrary: vs,\n\t}\n}", "func New(\n\trepo repository.Repository,\n\ttranslator errortranslator.RepositoryErrorTranslatorFn,\n) Service {\n\treturn &service{\n\t\trepository: repo,\n\t\terrTranslator: translator,\n\t}\n}", "func New(value interface{}) error {\n\tif value == nil {\n\t\treturn nil\n\t}\n\treturn NewText(gconv.String(value))\n}", "func NewLanguage() language.Language { return &okapiLang{} }", "func (s *MemStateStore) NewState(url string) (string, error) {\n\tstate := s.valueGenerator.String()\n\terr := s.Add(state, url)\n\treturn state, err\n}", "func NewFromFunc(fs http.FileSystem, pathPrefix string, converterFunc func(w io.Writer) *tailwind.Converter) *Handler {\n\treturn &Handler{\n\t\tconverterFunc: converterFunc,\n\t\tfs: fs,\n\t\tpathPrefix: pathPrefix,\n\t\tcache: make(map[string]cacheValue),\n\t\theaderFunc: defaultHeaderFunc,\n\t}\n}", "func NewCalibreBookConverter(booksRoot, cacheDir string, numWorkers int) BookConverter {\n\tconverter := &calibreBookConverter{\n\t\tfileCh: make(chan books.BookFile),\n\t\tconverting: make(map[int64]error),\n\t\tbooksRoot: booksRoot,\n\t\tcacheDir: cacheDir,\n\t}\n\n\tfor i := 0; i < numWorkers; i++ {\n\t\tgo converter.work()\n\t}\n\n\treturn converter\n}", "func NewTranslator() common.Translator[component.Config] {\n\treturn NewTranslatorWithName(\"\")\n}", "func New(name string) error {\n\treturn createMigration(name, \"/* Your up migration code here */\", \"/* Your down migration code here */\")\n}", "func CreateFromFile(path string) (*Converter, error) {\n\tvar data, err = ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar dict map[string]string\n\terr = json.Unmarshal(data, &dict)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn createFromDict(dict)\n}", "func NewConvertCmd() *cobra.Command {\n\tconvertCmd.Flags().Bool(\"noindent\", false, \"skip format json\")\n\treturn convertCmd\n}", "func New(lang string, options ...N2wOption) *N2w {\n\tselectedLang := languages[lang]\n\tif selectedLang == nil {\n\t\t//default is english if not found\n\t\tselectedLang = languages[\"en\"]\n\t}\n\tfor _, opt := range options {\n\t\topt()\n\t}\n\treturn selectedLang\n}", "func New(src string) *Lexer {\n\tl := &Lexer{\n\t\tinput: src,\n\t}\n\t// step to the first character in order to be ready\n\tl.readChar()\n\treturn l\n}", "func New() *StateMachine {\n\treturn &StateMachine{database: make(map[string]string)}\n}", "func NewConvertor(c *config.HL7Config) Convertor {\n\treturn Convertor{hl7ToFHIR: &hl7tofhirmap.Convertor{\n\t\tObservationStatusCodeMap: map[string]cpb.ObservationStatusCode_Value{\n\t\t\tc.ResultStatus.Final: cpb.ObservationStatusCode_FINAL,\n\t\t\tc.ResultStatus.Corrected: cpb.ObservationStatusCode_AMENDED,\n\t\t},\n\t}}\n}", "func (s *LPSolver) Convert(phi br.ClauseSet, nbvar int) (*LPB, error) {\n\tlp := NewLinearProgram(phi, nbvar, s.SortMatrix, s.SortClauses)\n\tres, err := lp.Solve(s.Tighten, s.RegTest)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// undo renaming\n\treturn res.Rename(lp.ReverseRenaming), nil\n}", "func New(input io.Reader) Solution {\n\treturn Solution{Passports: parse(input)}\n}", "func New() (interface{}, error) {\n\treturn Backend(), nil\n}", "func New(\n\tconfig Config,\n\tclk clock.Clock,\n\tlocalPeerID core.PeerID,\n\tnetevents networkevent.Producer,\n\tlogger *zap.SugaredLogger) *State {\n\n\tconfig = config.applyDefaults()\n\n\treturn &State{\n\t\tconfig: config,\n\t\tclk: clk,\n\t\tnetevents: netevents,\n\t\tlocalPeerID: localPeerID,\n\t\tlogger: logger,\n\t\tconns: make(map[core.InfoHash]map[core.PeerID]entry),\n\t\tblacklist: make(map[connKey]*blacklistEntry),\n\t}\n}", "func New(input string) *Lexer {\n\tl := &Lexer{input: input}\n\tl.readChar() // initialize\n\treturn l\n}", "func New(client *scm.Client) core.HookParser {\n\treturn &parser{client}\n}", "func NewFromString(input string) Scanner {\n\ttoks := lexer.ParseString(input)\n\treturn &scanner{toks: toks}\n}", "func New(input string) *Lexer {\n\tl := &Lexer{input: input}\n\tl.readChar() // start up the lexer.\n\treturn l\n}", "func New(input string) *Lexer {\n\tl := &Lexer{input: input}\n\tl.readChar()\n\treturn l\n}", "func New(target, filename string) *Parser {\n\treturn &Parser{\n\t\ttarget: target,\n\t\tfilename: filename,\n\t\tfields: make(map[string]*types.Field),\n\t\ttypeConv: make(map[string]string),\n\t}\n}", "func New(s *Server, serverAddr string) *rpc.Server {\n\treturn languageRpc.NewLanguageServer(s, serverAddr)\n}", "func New(h webhook.Hook) *Validator {\n\treturn &Validator{h: h}\n}", "func NewFromString(exp string) *Pipeline {\n\tcmds := ParseCommand(exp)\n\treturn NewPipeline(cmds...)\n}", "func NewTranslator(log log.Logger) *Translator {\n\tt := &Translator{\n\t\tLogger: log,\n\t}\n\tt.ClusterCache.init()\n\tt.ClusterLoadAssignmentCache.init()\n\tt.ListenerCache.init()\n\tt.ListenerCache.Add(defaultListener()) // insert default listerner\n\tt.ListenerCache.Notify() // bump version to notify streamers\n\tt.VirtualHostCache.init()\n\treturn t\n}", "func New(options ...Option) (result translator.Proxy, err error) {\n\tresult = &proxy{\n\t\tlogger: zap.NewNop(),\n\t}\n\n\t// Apply options.\n\tfor _, opt := range options {\n\t\topt(result.(*proxy))\n\t}\n\n\treturn\n}", "func New(lhs, rhs string, binds pattern.Binds) (*T, error) {\n\tlp, err := pattern.Parse(lhs, binds)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing %q: %v\", lhs, err)\n\t}\n\trp, err := lp.Derive(rhs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &T{lhs: lp, rhs: rp}, nil\n}", "func New(language string) (Compiler, error) {\n\tif len(language) <= 0 {\n\t\treturn nil, compiler_error.ErrEmptyLanguage\n\t}\n\n\tcnst := constructor(language)\n\tif cnst == nil {\n\t\treturn nil, fmt.Errorf(\"invalid compiler language: %s\", language)\n\t}\n\n\tcmp, err := cnst()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create compiler: %s\", err)\n\t}\n\n\treturn cmp, nil\n}", "func New(input string) *Lexer {\n\ts := &Lexer{\n\t\tinput: input,\n\t\tstate: lexCode,\n\t\ttokens: make(chan token.Token, len(input)), // buffer is same size as input to avoid deadlock\n\t\tline: 1,\n\t}\n\treturn s\n}", "func NewKelvinConverter() Converter {\n\treturn &kelvinHandler{\n\t\tBase: Kelvin,\n\t}\n}", "func NewM3U8Converter(inputDir, outputDir string) (*M3U8Converter, error) {\n\tif inputDir == \"\" {\n\t\treturn nil, errors.New(\"empty input dir\")\n\t}\n\n\tif outputDir == \"\" {\n\t\treturn nil, errors.New(\"empty output dir\")\n\t}\n\n\terr := makeSureDirExist(outputDir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &M3U8Converter{outputDir, inputDir}, nil\n}", "func New(input string) *Lexer {\n\tlexer := Lexer{input: input}\n\tlexer.readChar()\n\treturn &lexer\n}", "func New(store stores.Store, writer stores.Writer) Transactor {\n\treturn &transactor{\n\t\tstore: store,\n\t\ttransactionCommands: make(map[int64][]kvdb.Command),\n\t\twriter: writer,\n\t}\n}", "func newTemplateDecoder(config *Config, decoder resources.Decoder) *templateDecoder {\n\treturn &templateDecoder{\n\t\tconfig: config,\n\t\tdecoder: decoder,\n\t}\n}", "func New() Go { return Go{} }", "func New(input string) *Lexer {\n\tl := &Lexer{input: input}\n\tl.readChar() //initialize lexer to state pos = 0 readPos = 1\n\treturn l\n}", "func NewDockerConverter(deps Dependencies) *DockerConverter {\n\td := &DockerConverter{\n\t\tDependencies: deps,\n\t\tprefix: dockerSecretPrefix,\n\t}\n\treturn d\n}", "func New(_ runtime.Object, h framework.Handle) (framework.Plugin, error) {\n\treturn &PodState{handle: h}, nil\n}", "func NewState(ctx context.Context) (*api.State, error) {\n\tc, err := Resolve(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.NewState(), nil\n}", "func NewConvertParams() *ConvertParams {\n\tvar ()\n\treturn &ConvertParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func New(plArgs *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {\n\targs := &Args{}\n\tif err := framework.DecodeInto(plArgs, args); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &NodeLabel{\n\t\tpredicate: predicates.NewNodeLabelPredicate(args.Labels, args.Presence),\n\t}, nil\n}", "func (s *ServiceState) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfig) (onet.ProtocolInstance, error) {\n\n\tpi, err := dissent_protocol.NewDissentProtocol(tn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\twrapper := pi.(*dissent_protocol.DissentProtocol)\n\ts.setConfigToDissentProtocol(wrapper)\n\ts.DissentProtocol = wrapper\n\n\treturn pi, nil\n}", "func New(t interface{}, err error, msg string, wrapArgs ...interface{}) error {\n\twrapped := errors.WrapIfWithDetails(err, msg, wrapArgs...)\n\tswitch t.(type) {\n\tcase ResourceNotReady:\n\t\treturn ResourceNotReady{wrapped}\n\tcase APIFailure:\n\t\treturn APIFailure{wrapped}\n\tcase VaultAPIFailure:\n\t\treturn VaultAPIFailure{wrapped}\n\tcase StatusUpdateError:\n\t\treturn StatusUpdateError{wrapped}\n\tcase NodesUnreachable:\n\t\treturn NodesUnreachable{wrapped}\n\tcase NodesNotReady:\n\t\treturn NodesNotReady{wrapped}\n\tcase NodesRequestError:\n\t\treturn NodesRequestError{wrapped}\n\tcase GracefulUpscaleFailed:\n\t\treturn GracefulUpscaleFailed{wrapped}\n\tcase TooManyResources:\n\t\treturn TooManyResources{wrapped}\n\tcase InternalError:\n\t\treturn InternalError{wrapped}\n\tcase FatalReconcileError:\n\t\treturn FatalReconcileError{wrapped}\n\tcase ReconcileRollingUpgrade:\n\t\treturn ReconcileRollingUpgrade{wrapped}\n\t}\n\treturn wrapped\n}", "func New(b, n int) (Decomposition, error) {\n\t// n must be non negative\n\tif n < 0 {\n\t\treturn Decomposition{}, fmt.Errorf(\"n must be non negative\")\n\t}\n\n\t// base must at least 2\n\tif b < 2 {\n\t\treturn Decomposition{}, fmt.Errorf(\"base must be at least 2\")\n\t}\n\n\treturn Decomposition{recDecompose(b, n, 0)}.clean(), nil\n}", "func New(opts ...OptionFunc) Currency {\n\tc := Currency{}\n\tc.applyDefaults()\n\tc.Option(opts...)\n\treturn c\n}", "func NewConverterController(promCl versioned.Interface, vclient client.Client) *ConverterController {\n\tc := &ConverterController{\n\t\tpromClient: promCl,\n\t\tvclient: vclient,\n\t}\n\tc.ruleInf = cache.NewSharedIndexInformer(\n\t\t&cache.ListWatch{\n\t\t\tListFunc: func(options metav1.ListOptions) (runtime.Object, error) {\n\t\t\t\treturn promCl.MonitoringV1().PrometheusRules(\"\").List(context.TODO(), options)\n\t\t\t},\n\t\t\tWatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {\n\t\t\t\treturn promCl.MonitoringV1().PrometheusRules(\"\").Watch(context.TODO(), options)\n\t\t\t},\n\t\t},\n\t\t&v1.PrometheusRule{},\n\t\t0,\n\t\tcache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},\n\t)\n\tc.ruleInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: c.CreatePrometheusRule,\n\t\tUpdateFunc: c.UpdatePrometheusRule,\n\t})\n\tc.podInf = cache.NewSharedIndexInformer(\n\t\t&cache.ListWatch{\n\t\t\tListFunc: func(options metav1.ListOptions) (runtime.Object, error) {\n\t\t\t\treturn promCl.MonitoringV1().PodMonitors(\"\").List(context.TODO(), options)\n\t\t\t},\n\t\t\tWatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {\n\t\t\t\treturn promCl.MonitoringV1().PodMonitors(\"\").Watch(context.TODO(), options)\n\t\t\t},\n\t\t},\n\t\t&v1.PodMonitor{},\n\t\t0,\n\t\tcache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},\n\t)\n\tc.podInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: c.CreatePodMonitor,\n\t\tUpdateFunc: c.UpdatePodMonitor,\n\t})\n\tc.serviceInf = cache.NewSharedIndexInformer(\n\t\t&cache.ListWatch{\n\t\t\tListFunc: func(options metav1.ListOptions) (runtime.Object, error) {\n\t\t\t\treturn promCl.MonitoringV1().ServiceMonitors(\"\").List(context.TODO(), options)\n\t\t\t},\n\t\t\tWatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {\n\t\t\t\treturn promCl.MonitoringV1().ServiceMonitors(\"\").Watch(context.TODO(), options)\n\t\t\t},\n\t\t},\n\t\t&v1.ServiceMonitor{},\n\t\t0,\n\t\tcache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},\n\t)\n\tc.serviceInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: c.CreateServiceMonitor,\n\t\tUpdateFunc: c.UpdateServiceMonitor,\n\t})\n\treturn c\n}", "func NewConverterController(promCl versioned.Interface, vclient client.Client) *ConverterController {\n\tc := &ConverterController{\n\t\tpromClient: promCl,\n\t\tvclient: vclient,\n\t}\n\tc.ruleInf = cache.NewSharedIndexInformer(\n\t\t&cache.ListWatch{\n\t\t\tListFunc: func(options metav1.ListOptions) (runtime.Object, error) {\n\t\t\t\treturn promCl.MonitoringV1().PrometheusRules(\"\").List(context.TODO(), options)\n\t\t\t},\n\t\t\tWatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {\n\t\t\t\treturn promCl.MonitoringV1().PrometheusRules(\"\").Watch(context.TODO(), options)\n\t\t\t},\n\t\t},\n\t\t&v1.PrometheusRule{},\n\t\t0,\n\t\tcache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},\n\t)\n\tc.ruleInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: c.CreatePrometheusRule,\n\t\tUpdateFunc: c.UpdatePrometheusRule,\n\t})\n\tc.podInf = cache.NewSharedIndexInformer(\n\t\t&cache.ListWatch{\n\t\t\tListFunc: func(options metav1.ListOptions) (runtime.Object, error) {\n\t\t\t\treturn promCl.MonitoringV1().PodMonitors(\"\").List(context.TODO(), options)\n\t\t\t},\n\t\t\tWatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {\n\t\t\t\treturn promCl.MonitoringV1().PodMonitors(\"\").Watch(context.TODO(), options)\n\t\t\t},\n\t\t},\n\t\t&v1.PodMonitor{},\n\t\t0,\n\t\tcache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},\n\t)\n\tc.podInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: c.CreatePodMonitor,\n\t\tUpdateFunc: c.UpdatePodMonitor,\n\t})\n\tc.serviceInf = cache.NewSharedIndexInformer(\n\t\t&cache.ListWatch{\n\t\t\tListFunc: func(options metav1.ListOptions) (runtime.Object, error) {\n\t\t\t\treturn promCl.MonitoringV1().ServiceMonitors(\"\").List(context.TODO(), options)\n\t\t\t},\n\t\t\tWatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {\n\t\t\t\treturn promCl.MonitoringV1().ServiceMonitors(\"\").Watch(context.TODO(), options)\n\t\t\t},\n\t\t},\n\t\t&v1.ServiceMonitor{},\n\t\t0,\n\t\tcache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},\n\t)\n\tc.serviceInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: c.CreateServiceMonitor,\n\t\tUpdateFunc: c.UpdateServiceMonitor,\n\t})\n\tc.probeInf = cache.NewSharedIndexInformer(\n\t\t&cache.ListWatch{\n\t\t\tListFunc: func(options metav1.ListOptions) (runtime.Object, error) {\n\t\t\t\treturn promCl.MonitoringV1().Probes(\"\").List(context.TODO(), options)\n\t\t\t},\n\t\t\tWatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {\n\t\t\t\treturn promCl.MonitoringV1().Probes(\"\").Watch(context.TODO(), options)\n\t\t\t},\n\t\t},\n\t\t&v1.Probe{},\n\t\t0,\n\t\tcache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},\n\t)\n\tc.probeInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: c.CreateProbe,\n\t\tUpdateFunc: c.UpdateProbe,\n\t})\n\treturn c\n}", "func New(store dapp.Store) *Protocol {\n\treturn &Protocol{store: store}\n}", "func NewListener(ctx *pulumi.Context,\n\tname string, args *ListenerArgs, opts ...pulumi.ResourceOption) (*Listener, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.DefaultAction == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'DefaultAction'\")\n\t}\n\tif args.Protocol == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Protocol'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Listener\n\terr := ctx.RegisterResource(\"aws-native:vpclattice:Listener\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewCurrency(l *log.Logger) *Currency {\n\treturn &Currency{l}\n}", "func New(rs []Rule, options ...Option) *Decoder {\n\td := &Decoder{\n\t\tencoder: newDefaultEncoder(rs),\n\t\tmsgTranslator: defaultMessageTranslator,\n\t}\n\tfor _, option := range options {\n\t\toption(d)\n\t}\n\treturn d\n}", "func NewBool(input bool) *bool {\n\treturn &input\n}", "func (f FactoryFunc) ConverterFor(dst reflect.Type, src reflect.Type) (Converter, error) {\n\treturn f(dst, src)\n}" ]
[ "0.70830095", "0.7060295", "0.678922", "0.6786389", "0.66167057", "0.65999913", "0.6595154", "0.65438426", "0.6493315", "0.6200213", "0.6107004", "0.59985536", "0.595151", "0.58438957", "0.5787515", "0.57420427", "0.55313313", "0.5462134", "0.5317193", "0.52470976", "0.5179084", "0.5162907", "0.51371104", "0.5109354", "0.5024213", "0.4983383", "0.4977695", "0.49598625", "0.4950024", "0.49354863", "0.49203762", "0.48866197", "0.4863279", "0.48159683", "0.4811016", "0.4799493", "0.47991514", "0.47965243", "0.4793809", "0.47873136", "0.47872436", "0.47807872", "0.4774709", "0.47571683", "0.47559428", "0.47535524", "0.47484225", "0.47477964", "0.47363186", "0.47285947", "0.47232494", "0.47183445", "0.47168493", "0.4715804", "0.47091955", "0.47079444", "0.47047126", "0.47044578", "0.46882603", "0.46811858", "0.46798664", "0.46760836", "0.4673005", "0.4667036", "0.46511835", "0.46477872", "0.4647483", "0.46442315", "0.4643941", "0.46425235", "0.4636427", "0.4634401", "0.46247888", "0.4624325", "0.46196994", "0.46102113", "0.46071523", "0.4601247", "0.45964262", "0.45931274", "0.45835567", "0.45818588", "0.45790198", "0.4578252", "0.4572967", "0.45680892", "0.4567852", "0.45537472", "0.4552264", "0.45500854", "0.45478004", "0.45459554", "0.4542112", "0.4542112", "0.45391053", "0.45366687", "0.4536638", "0.4534391", "0.45275334", "0.4527026" ]
0.83710945
0
phi6primeSq evaluates the 6th cyclotomic polynomial, \phi_6(x) = x^2x+1, at p^2.
func phi6primeSq() []byte { one := big.NewInt(1) p := new(big.Int).SetBytes(fpOrder[:]) // p p2 := new(big.Int).Mul(p, p) // p^2 p4 := new(big.Int).Sub(p2, one) // p^2 - 1 p4.Mul(p4, p2) // p^4 - p^2 p4.Add(p4, one) // p^4 - p^2 + 1 return p4.Bytes() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func hash6(u uint64, h uint8) uint32 {\n\treturn uint32(((u << (64 - 48)) * prime6bytes) >> ((64 - h) & 63))\n}", "func Pow6(in *big.Float) *big.Float {\n\treturn Pow(in, 6)\n}", "func (r thinPoly) Toom6(f, g *[768]int32) thinPoly {\n\tvar e = [][]int32 {\n\t\tmake(thinPoly, 256).Karatsuba1(f[0:128], g[0:128]),\n\t\ttoomEval(+1, f, g),\n\t\ttoomEval(-1, f, g),\n\t\ttoomEval(+2, f, g),\n\t\ttoomEval(-2, f, g),\n\t\ttoomEval(+3, f, g),\n\t\ttoomEval(-3, f, g),\n\t\ttoomEval(+4, f, g),\n\t\ttoomEval(-4, f, g),\n\t\ttoomEval(+5, f, g),\n\t\tmake(thinPoly, 256).Karatsuba1(f[640:768], g[640:768]),\n\t}\n\tvar c = [][]int32 {\n\t\te[0],\n\t\ttoomInterpolate(e, toomParam[0]),\n\t\ttoomInterpolate(e, toomParam[1]),\n\t\ttoomInterpolate(e, toomParam[2]),\n\t\ttoomInterpolate(e, toomParam[3]),\n\t\ttoomInterpolate(e, toomParam[4]),\n\t\ttoomInterpolate(e, toomParam[5]),\n\t\ttoomInterpolate(e, toomParam[6]),\n\t\ttoomInterpolate(e, toomParam[7]),\n\t\ttoomInterpolate(e, toomParam[8]),\n\t\te[10],\n\t}\n\n\tcopy(r[:128], c[0])\n\tr[128:].Add(c[0][128:], c[1][:128])\n\tr[256:].Add(c[1][128:], c[2][:128])\n\tr[384:].Add(c[2][128:], c[3][:128])\n\tr[512:].Add(c[3][128:], c[4][:128])\n\tr[640:].Add(c[4][128:], c[5][:128])\n\tr[768:].Add(c[5][128:], c[6][:128])\n\tr[896:].Add(c[6][128:], c[7][:128])\n\tr[1024:].Add(c[7][128:], c[8][:128])\n\tr[1152:].Add(c[8][128:], c[9][:128])\n\tr[1280:].Add(c[9][128:], c[10][:128])\n\tcopy(r[1408:], c[10][128:])\n\n\treturn r\n}", "func Run6(scanner *bufio.Scanner) string {\n\tmessage := [8]*col{&col{}, &col{}, &col{}, &col{}, &col{}, &col{}, &col{}, &col{}}\n\tecVersion := \"\"\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfor i, c := range line {\n\t\t\tmessage[i].Add(string(c))\n\t\t}\n\t}\n\tfor _, m := range message {\n\t\tmin := 100000\n\t\tcommon := \"\"\n\t\tfor char, count := range m.c {\n\t\t\tif count < min {\n\t\t\t\tcommon = char\n\t\t\t\tmin = count\n\t\t\t}\n\t\t}\n\t\tecVersion += common\n\t}\n\treturn fmt.Sprintf(\"%s\", ecVersion)\n}", "func (ip IP) v6(i uint8) uint8 {\n\tif i >= 8 {\n\t\treturn uint8(ip.lo >> ((15 - i) * 8))\n\t} else {\n\t\treturn uint8(ip.hi >> ((7 - i) * 8))\n\t}\n}", "func Root6(in *big.Float) *big.Float {\n\treturn Root(in, 6)\n}", "func NewConcurrentServerFactory6(processorFactory ConcurrentProcessorFactory, serverTransport ServerTransport,\n\tinputTransportFactory TransportFactory, outputTransportFactory TransportFactory,\n\tinputProtocolFactory ProtocolFactory, outputProtocolFactory ProtocolFactory) *ConcurrentServer {\n\treturn NewConcurrentServerFactory(\n\t\tprocessorFactory,\n\t\tserverTransport,\n\t\tInputTransportFactory(inputTransportFactory),\n\t\tOutputTransportFactory(outputTransportFactory),\n\t\tInputProtocolFactory(inputProtocolFactory),\n\t\tOutputProtocolFactory(outputProtocolFactory),\n\t)\n}", "func hash7(u uint64, h uint8) uint32 {\n\treturn uint32(((u << (64 - 56)) * prime7bytes) >> ((64 - h) & 63))\n}", "func NewConcurrentServer6(processor ConcurrentProcessor, serverTransport ServerTransport,\n\tinputTransportFactory TransportFactory, outputTransportFactory TransportFactory,\n\tinputProtocolFactory ProtocolFactory, outputProtocolFactory ProtocolFactory) *ConcurrentServer {\n\treturn NewConcurrentServerFactory(NewConcurrentProcessorFactory(processor),\n\t\tserverTransport,\n\t\tInputTransportFactory(inputTransportFactory),\n\t\tOutputTransportFactory(outputTransportFactory),\n\t\tInputProtocolFactory(inputProtocolFactory),\n\t\tOutputProtocolFactory(outputProtocolFactory),\n\t)\n}", "func (app *App) finalDrift6(i int) sc.Input {\n\treturn sc.LFNoise{\n\t\tInterpolation: sc.NoiseQuadratic,\n\t\tFreq: sc.C(0.1),\n\t}.Rate(sc.KR).Mul(sc.C(float32(i) / 3))\n}", "func hash7(u uint64, h uint8) uint32 {\n\treturn uint32(((u << (64 - 56)) * prime7bytes) >> ((64 - h) & reg8SizeMask64))\n}", "func isPrime(n uint64) bool {\n\tif n <= 3 {\n\t\treturn n > 1\n\t}\n\n\t// 不在6的倍数两侧的一定不是质数\n\tif n%6 != 1 && n%6 != 5 {\n\t\treturn false\n\t}\n\n\tsqrt := math.Sqrt(float64(n))\n\tfor i := uint64(5); i <= uint64(sqrt); i += 6 {\n\t\tif n%i == 0 || n%(i+2) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func D6() int {\n\treturn D(6) //nolint\n}", "func DoHV6(base string) (ip netip.Addr, ok bool) {\n\tpopulateOnce.Do(populate)\n\tfor _, ip := range dohIPsOfBase[base] {\n\t\tif ip.Is6() {\n\t\t\treturn ip, true\n\t\t}\n\t}\n\treturn ip, false\n}", "func H6(props *H6Props, children ...Element) *H6Elem {\n\trProps := &_H6Props{\n\t\tBasicHTMLElement: newBasicHTMLElement(),\n\t}\n\n\tif props != nil {\n\t\tprops.assign(rProps)\n\t}\n\n\treturn &H6Elem{\n\t\tElement: createElement(\"h6\", rProps, children...),\n\t}\n}", "func PrimeSqrt(a *big.Int, pa *big.Int) (*big.Int, bool) {\n\t// Handle the case a == 0\n\tif a.Cmp(bigZERO) == 0 {\n\t\treturn big.NewInt(0), true // should be a new big int!\n\t}\n\n\t// Check number is a square\n\tvalidation := new(big.Int).Exp(a, new(big.Int).Rsh(pa, 1), pa)\n\tif validation.Cmp(bigONE) != 0 {\n\t\treturn nil, false\n\t}\n\n\t// Shortcut when pa = 3 (mod 4)\n\trem := new(big.Int).Mod(pa, bigFOUR)\n\tif rem.Cmp(bigTHREE) == 0 {\n\t\tresult := new(big.Int).Exp(a, new(big.Int).Add(new(big.Int).Rsh(pa, 2), big.NewInt(1)), pa)\n\t\treturn result, true\n\t}\n\n\t// Find a non-residue\n\tz := big.NewInt(2) // Should be a new big int!\n\tfor LegendreSymbol(new(big.Int).Set(z), new(big.Int).Set(pa)) != -1 {\n\t\tz.Add(z, bigONE)\n\t}\n\n\t// Split pa-1 as 2^S*Q\n\tQ := new(big.Int).Sub(pa, big.NewInt(1))\n\tM := 0\n\tfor Q.Bit(0) == 0 {\n\t\tQ.Rsh(Q, 1)\n\t\tM++\n\t}\n\n\t// Setup for main loop\n\tc := new(big.Int).Exp(z, Q, pa)\n\tt := new(big.Int).Exp(a, Q, pa)\n\tR := new(big.Int).Exp(a, new(big.Int).Add(new(big.Int).Rsh(Q, 1), big.NewInt(1)), pa)\n\n\t// Main loop\n\tfor t.Cmp(bigONE) != 0 {\n\t\ttp := new(big.Int).Set(t)\n\t\ti := 0\n\t\tfor tp.Cmp(bigONE) != 0 {\n\t\t\ttp.Exp(tp, big.NewInt(2), pa)\n\t\t\ti++\n\t\t}\n\t\tb := new(big.Int).Exp(c, new(big.Int).Lsh(bigONE, uint(M-i-1)), pa)\n\t\tM = i\n\t\tc.Exp(b, bigTWO, pa)\n\t\tt.Mod(new(big.Int).Mul(t, c), pa)\n\t\tR.Mod(new(big.Int).Mul(R, b), pa)\n\t}\n\n\treturn R, true\n}", "func (app *App) sweepEnv6() sc.Input {\n\treturn sc.EnvGen{\n\t\tEnv: sc.Env{\n\t\t\tLevels: []sc.Input{\n\t\t\t\tsc.C(0),\n\t\t\t\tsc.C(rrand(0.1, 0.2)),\n\t\t\t\tsc.C(1),\n\t\t\t},\n\t\t\tTimes: []sc.Input{\n\t\t\t\tsc.C(rrand(5.5, 6)),\n\t\t\t\tsc.C(rrand(8.5, 9)),\n\t\t\t},\n\t\t\tCurve: []float64{\n\t\t\t\trrand(2, 3),\n\t\t\t\trrand(4, 5),\n\t\t\t},\n\t\t},\n\t}.Rate(sc.KR)\n}", "func IPv6FragmentHash(h header.IPv6, id uint32) uint32 {\n\tt := h.SourceAddress().As16()\n\ty := uint32(t[0]) | uint32(t[1])<<8 | uint32(t[2])<<16 | uint32(t[3])<<24\n\tt = h.DestinationAddress().As16()\n\tz := uint32(t[0]) | uint32(t[1])<<8 | uint32(t[2])<<16 | uint32(t[3])<<24\n\treturn Hash3Words(id, y, z, hashIV)\n}", "func NewOutputService6ProtocolTest(config aws.Config) *OutputService6ProtocolTest {\n\tsvc := &OutputService6ProtocolTest{\n\t\tClient: aws.NewClient(\n\t\t\tconfig,\n\t\t\taws.Metadata{\n\t\t\t\tServiceName: \"OutputService6ProtocolTest\",\n\t\t\t\tServiceID: \"OutputService6ProtocolTest\",\n\t\t\t\tEndpointsID: \"outputservice6protocoltest\",\n\t\t\t\tSigningName: \"outputservice6protocoltest\",\n\t\t\t\tSigningRegion: config.Region,\n\t\t\t\tAPIVersion: \"\",\n\t\t\t},\n\t\t),\n\t}\n\n\tif config.Retryer == nil {\n\t\tsvc.Retryer = retry.NewStandard()\n\t}\n\n\t// Handlers\n\tsvc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)\n\tsvc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)\n\tsvc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)\n\tsvc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)\n\tsvc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)\n\n\treturn svc\n}", "func NewInputService6ProtocolTest(config aws.Config) *InputService6ProtocolTest {\n\tsvc := &InputService6ProtocolTest{\n\t\tClient: aws.NewClient(\n\t\t\tconfig,\n\t\t\taws.Metadata{\n\t\t\t\tServiceName: \"InputService6ProtocolTest\",\n\t\t\t\tServiceID: \"InputService6ProtocolTest\",\n\t\t\t\tEndpointsID: \"inputservice6protocoltest\",\n\t\t\t\tSigningName: \"inputservice6protocoltest\",\n\t\t\t\tSigningRegion: config.Region,\n\t\t\t\tAPIVersion: \"2014-01-01\",\n\t\t\t},\n\t\t),\n\t}\n\n\tif config.Retryer == nil {\n\t\tsvc.Retryer = retry.NewStandard()\n\t}\n\n\t// Handlers\n\tsvc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)\n\tsvc.Handlers.Build.PushBackNamed(ec2query.BuildHandler)\n\tsvc.Handlers.Unmarshal.PushBackNamed(ec2query.UnmarshalHandler)\n\tsvc.Handlers.UnmarshalMeta.PushBackNamed(ec2query.UnmarshalMetaHandler)\n\tsvc.Handlers.UnmarshalError.PushBackNamed(ec2query.UnmarshalErrorHandler)\n\n\treturn svc\n}", "func f6(ctx *Context, l0 int32) {\n\tctx.f.F6(ctx, l0)\n}", "func decode6Bits(src int) byte {\n\tret := -1\n\tret += (((0x40 - src) & (src - 0x5b)) >> 8) & (src - 64)\n\tret += (((0x60 - src) & (src - 0x7b)) >> 8) & (src - 70)\n\tret += (((0x2f - src) & (src - 0x3a)) >> 8) & (src + 5)\n\tret += (((0x2c - src) & (src - 0x2e)) >> 8) & 63\n\tret += (((0x5e - src) & (src - 0x60)) >> 8) & 64\n\treturn byte(ret)\n}", "func cpu6() {\n\tx, kk := xkk()\n\n\t_V[x] = kk\n\tpc += 2\n}", "func IsPrimeSqrt(p int64) bool {\n\tif p < 2 {\n\t\treturn false\n\t}\n\tif p == 2 {\n\t\treturn true\n\t}\n\tif p%2 == 0 {\n\t\treturn false\n\t}\n\tfor i := int64(3); i*i <= p; i += 2 {\n\t\tif p%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func hash5(u uint64, h uint8) uint32 {\n\treturn uint32(((u << (64 - 40)) * prime5bytes) >> ((64 - h) & 63))\n}", "func encode6Bits(src int) byte {\n\tdiff := (0x41)\n\tdiff += ((25 - src) >> 8) & 6\n\tdiff -= ((51 - src) >> 8) & 75\n\tdiff -= ((61 - src) >> 8) & 15\n\tdiff += ((62 - src) >> 8) & 3\n\tret := src + diff\n\treturn byte(ret)\n}", "func (z *E6) Square(x *E6) *E6 {\n\n\t// Algorithm 16 from https://eprint.iacr.org/2010/354.pdf\n\tvar c4, c5, c1, c2, c3, c0 E2\n\tc4.Mul(&x.B0, &x.B1).Double(&c4)\n\tc5.Square(&x.B2)\n\tc1.MulByNonResidue(&c5).Add(&c1, &c4)\n\tc2.Sub(&c4, &c5)\n\tc3.Square(&x.B0)\n\tc4.Sub(&x.B0, &x.B1).Add(&c4, &x.B2)\n\tc5.Mul(&x.B1, &x.B2).Double(&c5)\n\tc4.Square(&c4)\n\tc0.MulByNonResidue(&c5).Add(&c0, &c3)\n\tz.B2.Add(&c2, &c4).Add(&z.B2, &c5).Sub(&z.B2, &c3)\n\tz.B0.Set(&c0)\n\tz.B1.Set(&c1)\n\n\treturn z\n}", "func GenE6() gopter.Gen {\n\treturn gopter.CombineGens(\n\t\tGenE3(),\n\t\tGenE3(),\n\t).Map(func(values []interface{}) *E6 {\n\t\treturn &E6{B0: *values[0].(*E3), B1: *values[1].(*E3)}\n\t})\n}", "func p256Square(out, in *[p256Limbs]uint32) {\n\tvar tmp [17]uint64\n\n\ttmp[0] = uint64(in[0]) * uint64(in[0])\n\ttmp[1] = uint64(in[0]) * (uint64(in[1]) << 1)\n\ttmp[2] = uint64(in[0])*(uint64(in[2])<<1) +\n\t\tuint64(in[1])*(uint64(in[1])<<1)\n\ttmp[3] = uint64(in[0])*(uint64(in[3])<<1) +\n\t\tuint64(in[1])*(uint64(in[2])<<1)\n\ttmp[4] = uint64(in[0])*(uint64(in[4])<<1) +\n\t\tuint64(in[1])*(uint64(in[3])<<2) +\n\t\tuint64(in[2])*uint64(in[2])\n\ttmp[5] = uint64(in[0])*(uint64(in[5])<<1) +\n\t\tuint64(in[1])*(uint64(in[4])<<1) +\n\t\tuint64(in[2])*(uint64(in[3])<<1)\n\ttmp[6] = uint64(in[0])*(uint64(in[6])<<1) +\n\t\tuint64(in[1])*(uint64(in[5])<<2) +\n\t\tuint64(in[2])*(uint64(in[4])<<1) +\n\t\tuint64(in[3])*(uint64(in[3])<<1)\n\ttmp[7] = uint64(in[0])*(uint64(in[7])<<1) +\n\t\tuint64(in[1])*(uint64(in[6])<<1) +\n\t\tuint64(in[2])*(uint64(in[5])<<1) +\n\t\tuint64(in[3])*(uint64(in[4])<<1)\n\t// tmp[8] has the greatest value of 2**61 + 2**60 + 2**61 + 2**60 + 2**60,\n\t// which is < 2**64 as required.\n\ttmp[8] = uint64(in[0])*(uint64(in[8])<<1) +\n\t\tuint64(in[1])*(uint64(in[7])<<2) +\n\t\tuint64(in[2])*(uint64(in[6])<<1) +\n\t\tuint64(in[3])*(uint64(in[5])<<2) +\n\t\tuint64(in[4])*uint64(in[4])\n\ttmp[9] = uint64(in[1])*(uint64(in[8])<<1) +\n\t\tuint64(in[2])*(uint64(in[7])<<1) +\n\t\tuint64(in[3])*(uint64(in[6])<<1) +\n\t\tuint64(in[4])*(uint64(in[5])<<1)\n\ttmp[10] = uint64(in[2])*(uint64(in[8])<<1) +\n\t\tuint64(in[3])*(uint64(in[7])<<2) +\n\t\tuint64(in[4])*(uint64(in[6])<<1) +\n\t\tuint64(in[5])*(uint64(in[5])<<1)\n\ttmp[11] = uint64(in[3])*(uint64(in[8])<<1) +\n\t\tuint64(in[4])*(uint64(in[7])<<1) +\n\t\tuint64(in[5])*(uint64(in[6])<<1)\n\ttmp[12] = uint64(in[4])*(uint64(in[8])<<1) +\n\t\tuint64(in[5])*(uint64(in[7])<<2) +\n\t\tuint64(in[6])*uint64(in[6])\n\ttmp[13] = uint64(in[5])*(uint64(in[8])<<1) +\n\t\tuint64(in[6])*(uint64(in[7])<<1)\n\ttmp[14] = uint64(in[6])*(uint64(in[8])<<1) +\n\t\tuint64(in[7])*(uint64(in[7])<<1)\n\ttmp[15] = uint64(in[7]) * (uint64(in[8]) << 1)\n\ttmp[16] = uint64(in[8]) * uint64(in[8])\n\n\tp256ReduceDegree(out, tmp)\n}", "func (s *XLSuite) BenchmarkHAMT_6(c *C) {\n\tif VERBOSITY > 0 {\n\t\tfmt.Println(\"\\nBenchmarkHAMT_6\")\n\t}\n\ts.doBenchmark(c, MAX_W, 18)\n}", "func (g *testGenerator) calcPoSSubsidy(heightVotedOn uint32) dcrutil.Amount {\n\tif int64(heightVotedOn+1) < g.params.StakeValidationHeight {\n\t\treturn 0\n\t}\n\n\tfullSubsidy := g.calcFullSubsidy(heightVotedOn)\n\tposProportion := dcrutil.Amount(g.params.StakeRewardProportion)\n\ttotalProportions := dcrutil.Amount(g.params.TotalSubsidyProportions())\n\treturn (fullSubsidy * posProportion) / totalProportions\n}", "func NewOutputService6ProtocolTest(config aws.Config) *OutputService6ProtocolTest {\n\tsvc := &OutputService6ProtocolTest{\n\t\tClient: aws.NewClient(\n\t\t\tconfig,\n\t\t\taws.Metadata{\n\t\t\t\tServiceName: \"OutputService6ProtocolTest\",\n\t\t\t\tServiceID: \"OutputService6ProtocolTest\",\n\t\t\t\tEndpointsID: \"outputservice6protocoltest\",\n\t\t\t\tSigningName: \"outputservice6protocoltest\",\n\t\t\t\tSigningRegion: config.Region,\n\t\t\t\tAPIVersion: \"\",\n\t\t\t},\n\t\t),\n\t}\n\n\tif config.Retryer == nil {\n\t\tsvc.Retryer = retry.NewStandard()\n\t}\n\n\t// Handlers\n\tsvc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)\n\tsvc.Handlers.Build.PushBackNamed(restxml.BuildHandler)\n\tsvc.Handlers.Unmarshal.PushBackNamed(restxml.UnmarshalHandler)\n\tsvc.Handlers.UnmarshalMeta.PushBackNamed(restxml.UnmarshalMetaHandler)\n\tsvc.Handlers.UnmarshalError.PushBackNamed(restxml.UnmarshalErrorHandler)\n\n\treturn svc\n}", "func Solve6() {\n\n\tzipRequest, err := http.Get(\"http://www.pythonchallenge.com/pc/def/channel.zip\")\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tzipBytes, err := io.ReadAll(zipRequest.Body)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tzipReader, err := zip.NewReader(bytes.NewReader(zipBytes), zipRequest.ContentLength)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tcomments := make([]string, 10)\n\n\tnavFunction := func(navigateId string) string {\n\t\tnextId, comment := zipNavigate(zipReader, navigateId)\n\n\t\tcomments = append(comments, comment)\n\t\treturn nextId\n\t}\n\n\tutility.ListWalker(navFunction, 90052)\n\n\tfor _, c := range comments {\n\t\tfmt.Print(c)\n\t}\n\n\tfmt.Println(\"Next: http://www.pythonchallenge.com/pc/def/☝️ .html\")\n}", "func Ping6(ifname, addr string) Node {\n\treturn &ping6{\n\t\tifname: ifname,\n\t\taddr: addr,\n\t}\n}", "func NewInputService6ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *InputService6ProtocolTest {\n\tc := p.ClientConfig(\"inputservice6protocoltest\", cfgs...)\n\treturn newInputService6ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)\n}", "func (app *App) ampEnv6() sc.Input {\n\treturn sc.EnvGen{\n\t\tEnv: sc.Env{\n\t\t\tLevels: []sc.Input{\n\t\t\t\tsc.C(0),\n\t\t\t\tsc.C(1),\n\t\t\t\tsc.C(1),\n\t\t\t\tsc.C(0),\n\t\t\t},\n\t\t\tTimes: []sc.Input{\n\t\t\t\tsc.C(3),\n\t\t\t\tsc.C(21),\n\t\t\t\tsc.C(3),\n\t\t\t},\n\t\t\tCurve: []int{2, 0, -4},\n\t\t},\n\t\tDone: sc.FreeEnclosing,\n\t}.Rate(sc.AR)\n}", "func (app *App) voicesTHX6() []sc.Input {\n\tvar (\n\t\tfundamentals = app.fundamentals()\n\t\tfinalPitches = app.finalPitches()\n\t\tvoices = make([]sc.Input, app.Config.NumVoices)\n\t\tsweepEnv = app.sweepEnv6()\n\t\tinvSweep = sweepEnv.MulAdd(sc.C(-1), sc.C(1))\n\t)\n\n\t// Reverse the order of the fundamentals.\n\tsort.Sort(sort.Reverse(sort.Float64Slice(fundamentals)))\n\n\tfor i := range voices {\n\t\tvar (\n\t\t\tinitialDrift = app.voiceDrift6(i)\n\t\t\tinitialFreq = sc.C(fundamentals[i]).Add(initialDrift)\n\t\t\tfinalDrift = app.finalDrift6(i)\n\t\t\tfinalFreq = sc.C(finalPitches[i]).Add(finalDrift)\n\t\t\tfreq = initialFreq.Mul(invSweep).Add(finalFreq.Mul(sweepEnv))\n\t\t\tamp = sc.C((1 - (1 / float64(i+1))) + 1.5)\n\t\t)\n\t\tvoices[i] = sc.Pan2{\n\t\t\tIn: sc.BLowPass{\n\t\t\t\tIn: sc.Saw{Freq: freq}.Rate(sc.AR),\n\t\t\t\tFreq: freq.Mul(sc.C(6)),\n\t\t\t\tRQ: sc.C(0.6),\n\t\t\t}.Rate(sc.AR),\n\t\t\tPos: sc.C(rrand(-0.5, 0.5)),\n\t\t\tLevel: amp,\n\t\t}.Rate(sc.AR)\n\t}\n\treturn voices\n}", "func mask6(n uint8) (hi, lo uint64) {\n\tif n > 64 {\n\t\treturn ^uint64(0), ^uint64(0) << (128 - n)\n\t} else {\n\t\treturn ^uint64(0) << (64 - n), 0\n\t}\n}", "func NewInputService6ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *InputService6ProtocolTest {\n\tc := p.ClientConfig(\"inputservice6protocoltest\", cfgs...)\n\tif c.SigningNameDerived || len(c.SigningName) == 0 {\n\t}\n\treturn newInputService6ProtocolTestClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName, c.ResolvedRegion)\n}", "func fqSqrt(c, u, v *Fq, s int) {\n\tt0, t1, t, r := &Fp{}, &Fp{}, &Fp{}, &Fp{}\n\ta, b, g := &Fp{}, &Fp{}, &Fp{}\n\n\t// a = u0*v0 + u1*v1\n\tfpMul(a, &u[0], &v[0])\n\tfpMul(t0, &u[1], &v[1])\n\tfpAdd(a, a, t0)\n\n\t// b = v0^2 + v1^2\n\tfpSqr(b, &v[0])\n\tfpSqr(t0, &v[1])\n\tfpAdd(b, b, t0)\n\n\t// g = u1*v0 - u0*v1\n\tfpMul(g, &u[1], &v[0])\n\tfpMul(t0, &u[0], &v[1])\n\tfpSub(g, g, t0)\n\n\t// t = 2(a + sqrt(a^2+g^2)) = 2*(a + (a^2+g^2)^(2^125))\n\t// if t=0; then t = 2*(a - (a^2+g^2)^(2^125))\n\tfpSqr(t0, a)\n\tfpSqr(t1, g)\n\tfpAdd(t0, t0, t1)\n\tfor i := 0; i < 125; i++ {\n\t\tfpSqr(t0, t0)\n\t}\n\tfpAdd(t, a, t0)\n\tif t.isZero() {\n\t\tfpSub(t, a, t0)\n\t}\n\tfpAdd(t, t, t)\n\n\t// r = (t*b^3)^(2^125-1)\n\tfpSqr(r, b)\n\tfpMul(r, r, b)\n\tfpMul(r, r, t)\n\tfpTwo1251(r, r)\n\n\t// x0 = (r*b*t)/2\n\t// x1 = (r*b*g)\n\tfpMul(&c[1], r, b)\n\tfpMul(&c[0], &c[1], t)\n\tfpHlf(&c[0], &c[0])\n\tfpMul(&c[1], &c[1], g)\n\n\t// if b*(2*x0)^2 == t then (x0,x1) <- (x1,x0)\n\tfpAdd(t0, &c[0], &c[0])\n\tfpSqr(t0, t0)\n\tfpMul(t0, t0, b)\n\tfpSub(t0, t0, t)\n\tif !t0.isZero() {\n\t\t*t0 = c[0]\n\t\tc[0] = c[1]\n\t\tc[1] = *t0\n\t}\n\n\tif fqSgn(c) != s {\n\t\tfqNeg(c, c)\n\t}\n}", "func SumOfSquares(n uint64) uint64 {\n\treturn (n * (n + 1) * ((2 * n) + 1)) / 6\n}", "func NewSRv6VppHandler(vppChan govppapi.Channel, log logging.Logger) *SRv6VppHandler {\n\treturn &SRv6VppHandler{\n\t\tcallsChannel: vppChan,\n\t\tlog: log,\n\t}\n}", "func pack6(src []uint64) uint64 {\n\t_ = src[5] // eliminate multiple bounds checks\n\treturn 10<<60 |\n\t\tsrc[0] |\n\t\tsrc[1]<<10 |\n\t\tsrc[2]<<20 |\n\t\tsrc[3]<<30 |\n\t\tsrc[4]<<40 |\n\t\tsrc[5]<<50\n}", "func SumOfSquares(n int) int {\n\t// for i := 1; i <= n; i++ {\n\t// \tssq += i * i\n\t// }\n\treturn n * (n + 1) * (2*n + 1) / 6\n}", "func QuantizedRelu6(scope *Scope, features tf.Output, min_features tf.Output, max_features tf.Output, optional ...QuantizedRelu6Attr) (activations tf.Output, min_activations tf.Output, max_activations tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{}\n\tfor _, a := range optional {\n\t\ta(attrs)\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"QuantizedRelu6\",\n\t\tInput: []tf.Input{\n\t\t\tfeatures, min_features, max_features,\n\t\t},\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0), op.Output(1), op.Output(2)\n}", "func (d *GF255e) Sqrt(a *GF255e) uint64 {\n\t// Since p = 5 mod 8, we use Atkin's algorithm:\n\t// b <- (2*a)^((p-5)/8)\n\t// c <- 2*a*b^2\n\t// return a*b*(c - 1)\n\tvar b, c, e, x, x2, x96, y [4]uint64\n\n\t// e <- 2*a\n\tgf_lsh(&e, (*[4]uint64)(a), 1, mq255e)\n\n\t// Raise e to the power (p-5)/8. We use an addition chain with\n\t// 251 squarings and 13 extra multiplications:\n\t// (p-5)/8 = (2^240-1)*2^12 + (2^2-1)*2^9 + (2^3-1)*2^5 + 2^2\n\n\t// x2 <- e^3\n\tgf_sqr(&x2, &e, mq255e)\n\tgf_mul(&x2, &x2, &e, mq255e)\n\n\t// x <- e^(2^4-1)\n\tgf_sqr_x(&x, &x2, 2, mq255e)\n\tgf_mul(&x, &x, &x2, mq255e)\n\n\t// x <- e^(2^8-1)\n\tgf_sqr_x(&y, &x, 4, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x <- e^(2^16-1)\n\tgf_sqr_x(&y, &x, 8, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x <- e^(2^48-1)\n\tgf_sqr_x(&y, &x, 16, mq255e)\n\tgf_mul(&y, &y, &x, mq255e)\n\tgf_sqr_x(&y, &y, 16, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x96 <- e^(2^96-1)\n\tgf_sqr_x(&y, &x, 48, mq255e)\n\tgf_mul(&x96, &y, &x, mq255e)\n\n\t// x <- e^(2^240-1)\n\tgf_sqr_x(&y, &x96, 96, mq255e)\n\tgf_mul(&y, &y, &x96, mq255e)\n\tgf_sqr_x(&y, &y, 48, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x <- e^((p-5)/8)\n\tgf_sqr_x(&x, &x, 3, mq255e)\n\tgf_mul(&x, &x, &x2, mq255e)\n\tgf_sqr_x(&x, &x, 2, mq255e)\n\tgf_mul(&x, &x, &e, mq255e)\n\tgf_sqr_x(&x, &x, 2, mq255e)\n\tgf_mul(&x, &x, &x2, mq255e)\n\tgf_sqr_x(&x, &x, 3, mq255e)\n\tgf_mul(&x, &x, &e, mq255e)\n\tgf_sqr_x(&b, &x, 2, mq255e)\n\n\t// We now have b = (2*a)^((p-5)/8).\n\n\t// c <- 2*a*b^2\n\tgf_sqr(&c, &b, mq255e)\n\tgf_mul(&c, &c, &e, mq255e)\n\n\t// x <- a*b*(c - 1)\n\tgf_sub(&x, &c, (*[4]uint64)(&GF255e_ONE), mq255e)\n\tgf_mul(&x, &x, (*[4]uint64)(a), mq255e)\n\tgf_mul(&x, &x, &b, mq255e)\n\n\t// Verify the result. If not square, then set the result to 0.\n\tgf_sqr(&y, &x, mq255e)\n\tqr := gf_eq(&y, (*[4]uint64)(a), mq255e)\n\tfor i := 0; i < 4; i ++ {\n\t\tx[i] &= -qr\n\t}\n\n\t// Normalize the result, and negate the value if the least\n\t// significant bit is 1.\n\tgf_norm(&x, &x, mq255e)\n\tgf_condneg(&x, &x, mq255e, x[0] & 1)\n\n\t// Return the result.\n\tcopy(d[:], x[:])\n\treturn qr\n}", "func NewText6(fontData draw2d.FontData, fontSize float64, text string,\n\tdepth int, startPoint Point, rotationDegrees float64) *Text {\n\ttextFigure := &Text{NewFigure(), fontData, fontSize, text}\n\ttextFigure.SetDepth(depth)\n\ttextFigure.SetStartPoint(startPoint)\n\ttextFigure.SetRotationDegrees(rotationDegrees)\n\ttextFigure.SetSubClass(textFigure)\n\n\treturn textFigure\n}", "func (o *DhcpLease6DataData) GetRange6ClassParameters() []ApiClassParameterOutputEntry {\n\tif o == nil || o.Range6ClassParameters == nil {\n\t\tvar ret []ApiClassParameterOutputEntry\n\t\treturn ret\n\t}\n\treturn *o.Range6ClassParameters\n}", "func New6DisigtHOTPOpts(issuer, account string) CryptorOpts {\n\topt, _ := NewCustomHOTPOpts(issuer, account, sha1.New, 6, DefaultMsg)\n\treturn opt\n}", "func NewPacket6(iface netlink.Link, p *dhcpv6.Message) *Packet6 {\n\treturn &Packet6{\n\t\tp: p,\n\t\tiface: iface,\n\t}\n}", "func D6C2() {\n\tvar coords [][2]int\n\tmaxD := int(1e4)\n\tmaxX, maxY, minX, minY := 0, 0, 0, 0\n\n\t// Populate coords\n\tfor in := bufio.NewScanner(os.Stdin); in.Scan(); {\n\t\tx, y := 0, 0\n\t\tfmt.Sscanf(in.Text(), \"%d, %d\", &x, &y)\n\t\tcoords = append(coords, [2]int{x, y})\n\n\t\t// Register max and min coords\n\t\tif x > maxX {\n\t\t\tmaxX = x\n\t\t}\n\t\tif y > maxY {\n\t\t\tmaxY = y\n\t\t}\n\t\tif x < minX {\n\t\t\tminX = x\n\t\t}\n\t\tif y < minY {\n\t\t\tminY = y\n\t\t}\n\t}\n\n\tvotes := 0\n\t// This assumes that the points are far enough from each other that we don't\n\t// need to look outside of the [(minX,minY), (maxX,maxY)] rectangles.\n\t// It should probably include a buffer zone calculated using maxD and the\n\t// distance between the points that are the farthest from each other on the\n\t// X or Y axis,\n\t// Works for me, so I'll spare my CPU the extra loops\n\tfor y := minY; y <= maxY; y++ {\n\touter:\n\t\tfor x := minX; x <= maxX; x++ {\n\t\t\taccumulator := 0\n\t\t\tfor _, c := range coords {\n\t\t\t\taccumulator += manhattanDistance(c, [2]int{x, y})\n\t\t\t\tif accumulator >= maxD {\n\t\t\t\t\t// We don't need to continue calculating\n\t\t\t\t\tcontinue outer\n\t\t\t\t}\n\t\t\t}\n\t\t\t// This point survived\n\t\t\tvotes++\n\t\t}\n\t}\n\n\tprintln(votes)\n}", "func IsIP6(val interface{}) bool {\n\treturn isMatch(ip6, val)\n}", "func (bc *Blockchain) ProofOfWorkCalc(proof int, previous_proof int, Timestamp int64) string {\n // calculate the proof of work function\n var hash_PoW = sha256.New()\n result := (proof * proof) - (previous_proof * previous_proof) - int(Timestamp)\n hash_PoW.Write([]byte(strconv.Itoa(result)))\n hashed_PoW := hash_PoW.Sum(nil)\n result_hash := hex.EncodeToString(hashed_PoW)\n return result_hash\n}", "func (b *Builder) H6(text string) *Builder {\n\treturn b.writeln(header(text, 6)).nl()\n}", "func TestSixteenBPL(t *testing.T) {\n\tkk, err := NewWithConfig(\n\t\tConfig{\n\t\t\tTreeLayerDef: SixteenBitsPerLayer,\n\t\t\tCellLayerDef: SixteenBitsPerLayer,\n\t\t},\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tbase := 5000000\n\ttd := time.Now()\n\tfor x := 0; x < 1000000; x++ {\n\t\tkk.Add(base+x, base+x)\n\t\tif x%100000 == 0 {\n\t\t\tnewt := time.Now()\n\t\t\tfmt.Println(x, newt.Sub(td))\n\t\t\ttd = newt\n\t\t}\n\t}\n\tfmt.Println(kk.Stats())\n}", "func Problem5() int {\n\t// The first solution:\n\t//\n\t// \tIt is like finding the least common multiple of set 1-20:\n\t// \t1, 2, 3, 4=2*2, 5, 6=2*3, 7, 8=2*2*2, 9=3*3, 10=2*5, 11, 12=2*2*3,\n\t// \t13, 14=2*7, 15=3*5, 16=2*2*2*2, 17, 18=2*3*3, 19, 20=2*2*5\n\t//\tNext multiple include all maximum occurrences of prime factors in numbers 2 to 20\n\t// \treturn 2 * 2 * 2 * 2 * 3 * 3 * 5 * 7 * 11 * 13 * 17 * 19\n\t//\n\n\t// The second solution, generalized:\n\tvar n float64 = 1\n\tvar k float64 = 20 // The upper limit of the range.\n\tprimes := []float64{2, 3, 5, 7, 11, 13, 17, 19} // List of all primes from range 1-20.\n\t// 'l' represents limit where we only need to evaluate exponent, after this limit\n\t// exponent is equal 1. This solution is optimization only for case 1-20!\n\tl := math.Sqrt(k)\n\tfor _, p := range primes {\n\t\tvar exp float64 = 1\n\t\t// Note that exp=1 for p^2>k; this solution is optimization only for case 1-20!\n\t\tif p <= l {\n\t\t\t// p^exp=k; after logarithmic both sides we get: exp*log(p)=log(k).\n\t\t\t// From which we get: exp=log(k)/log(prime); because the p^exp<=k\n\t\t\t// the exponent must be floor to integer.\n\t\t\texp = math.Floor(math.Log(k) / math.Log(p))\n\t\t}\n\t\t// The greatest perfect power of 'p' that is less than or equal to 'k'.\n\t\t// No other numbers in 'primes' can contain more than 'exp' times repeated factors of 'p'.\n\t\tn *= math.Pow(p, exp)\n\t}\n\treturn int(n)\n}", "func Graph6Encode(g Graph) string {\n\tvar s []byte\n\tn := g.N()\n\tif n <= 1 {\n\t\treturn string(rune(n + 63))\n\t} else if n <= 62 {\n\t\ts = make([]byte, 1, 1+((n*(n-1))/2+5)/6)\n\t\ts[0] = byte(n + 63)\n\t} else if n <= 258047 {\n\t\ts = make([]byte, 4, 4+((n*(n-1))/2+5)/6)\n\t\ts[0] = 126\n\t\ts[1] = byte((n>>12)&63) + 63\n\t\ts[2] = byte((n>>6)&63) + 63\n\t\ts[3] = byte(n&63) + 63\n\t} else if n <= 68719476735 {\n\t\ts = make([]byte, 8, 8+((n*(n-1))/2+5)/6)\n\t\ts[0] = 126\n\t\ts[1] = 126\n\t\ts[2] = byte((n>>30)&63) + 63\n\t\ts[3] = byte((n>>24)&63) + 63\n\t\ts[4] = byte((n>>18)&63) + 63\n\t\ts[5] = byte((n>>12)&63) + 63\n\t\ts[6] = byte((n>>6)&63) + 63\n\t\ts[7] = byte(n&63) + 63\n\t} else {\n\t\tpanic(\"Graph too large\")\n\t}\n\n\tvar b byte\n\tbIndex := 0\n\tfor i := 1; i < n; i++ {\n\t\tfor j := 0; j < i; j++ {\n\t\t\tif g.IsEdge(i, j) {\n\t\t\t\tb += 1 << uint(5-bIndex)\n\t\t\t}\n\t\t\tbIndex++\n\t\t\tif bIndex == 6 {\n\t\t\t\ts = append(s, b+63)\n\t\t\t\tbIndex = 0\n\t\t\t\tb = 0\n\t\t\t}\n\t\t}\n\t}\n\n\tif bIndex != 0 {\n\t\ts = append(s, b+63)\n\t}\n\n\treturn string(s)\n}", "func isPrime(n int) (bool) {\n\tif n == 2 || n == 3 {\n\t\treturn true\n\t}\n\tif n % 2 == 0 || n % 3 == 0 {\n\t\treturn false\n\t}\n\n\ti := 5\n\tw := 2\n\tfor i * i <= n {\n\t\tif n % i == 0 {\n\t\t\treturn false\n\t\t}\n\n\t\ti += w\n\t\tw = 6 - w\n\t}\n\n\treturn true\n}", "func (p *G1Jac) phi(a *G1Jac) *G1Jac {\n\tp.Set(a)\n\tp.X.Mul(&p.X, &thirdRootOneG1)\n\treturn p\n}", "func SumOfSquares(n int) int {\n\treturn (n * (n + 1) * (2*n + 1)) / 6\n}", "func SumOfSquares(n int) int {\n\treturn (n * (n + 1) * (2*n + 1)) / 6\n}", "func SumOfSquares(n int) int {\n\treturn (n * (n + 1) * (2*n + 1)) / 6\n}", "func SumOfSquares(n int) int {\n\treturn (n * (n + 1) * (2*n + 1)) / 6\n}", "func d6rectSphericalVolume(rect *d6rectT) float64 {\n\tvar sumOfSquares float64 = 0\n\tvar radius float64\n\n\tfor index := 0; index < d6numDims; index++ {\n\t\thalfExtent := (rect.max[index] - rect.min[index]) * 0.5\n\t\tsumOfSquares += halfExtent * halfExtent\n\t}\n\n\tradius = math.Sqrt(sumOfSquares)\n\n\t// Pow maybe slow, so test for common dims just use x*x, x*x*x.\n\tif d6numDims == 5 {\n\t\treturn (radius * radius * radius * radius * radius * d6unitSphereVolume)\n\t} else if d6numDims == 4 {\n\t\treturn (radius * radius * radius * radius * d6unitSphereVolume)\n\t} else if d6numDims == 3 {\n\t\treturn (radius * radius * radius * d6unitSphereVolume)\n\t} else if d6numDims == 2 {\n\t\treturn (radius * radius * d6unitSphereVolume)\n\t} else {\n\t\treturn (math.Pow(radius, d6numDims) * d6unitSphereVolume)\n\t}\n}", "func GoEcho6(s *C.char, length C.int) (unsafe.Pointer, int) {\n\tzslice := ZeroCopySlice(unsafe.Pointer(s), int(length))\n\tslice := append(zslice.Data, \" from golang6\"...)\n\treturn unsafe.Pointer(&(slice[0])), len(slice)\n}", "func HardExponentiation(u *URoot, g *Cyclo6) {\n\tvar t0, t1, _g, g3 Cyclo6\n\tvar c, a0, a1, a2, a3 Cyclo6\n\t_g.Inv(g) // _g = g^-1\n\tg3.Sqr(g) // g3 = g^2\n\tg3.Mul(&g3, g) // g3 = g^3\n\tt0.PowToX(g) // t0 = g^x\n\tt0.Mul(&t0, &_g) // t0 = g^(x-1)\n\tt1.PowToX(&t0) // t1 = g^(x-1)*x\n\tt0.Inv(&t0) // t0 = g^-(x-1)\n\ta3.Mul(&t1, &t0) // a3 = g^(x-1)*(x-1)\n\ta2.Frob(&a3) // a2 = a3*p\n\ta1.Frob(&a2) // a1 = a2*p = a3*p^2\n\tt0.Inv(&a3) // t0 = -a3\n\ta1.Mul(&a1, &t0) // a1 = a3*p^2-a3\n\ta0.Frob(&a1) // a0 = a3*p^3-a3*p\n\ta0.Mul(&a0, &g3) // a0 = a3*p^3-a3*p+3\n\n\tc.PowToX(&a3) // c = g^(a3*x)\n\tc.Mul(&c, &a2) // c = g^(a3*x+a2)\n\tc.PowToX(&c) // c = g^(a3*x+a2)*x = g^(a3*x^2+a2*x)\n\tc.Mul(&c, &a1) // c = g^(a3*x^2+a2*x+a1)\n\tc.PowToX(&c) // c = g^(a3*x^2+a2*x+a1)*x = g^(a3*x^3+a2*x^2+a1*x)\n\tc.Mul(&c, &a0) // c = g^(a3*x^3+a2*x^2+a1*x+a0)\n\n\t*u = (URoot)(c)\n}", "func get7BCDFrom6Bytes(bytes []byte) int64 {\n\treturn (int64(bytes[0]) * 1000000) + (int64(bytes[1]) * 100000) + (int64(bytes[2]) * 10000) + (int64(bytes[3]) * 1000) + (int64(bytes[4]) * 100) + (int64(bytes[5]) * 10)\n}", "func parseKerxSubtable6(data []byte, numGlyphs, tupleCount int) (out Kerx6, err error) {\n\tif len(data) < 12+20 {\n\t\treturn out, errors.New(\"invalid kerx subtable format 2 (EOF)\")\n\t}\n\tflags := binary.BigEndian.Uint32(data[12:])\n\tout.rowCount = binary.BigEndian.Uint16(data[12+4:])\n\tout.columnCount = binary.BigEndian.Uint16(data[12+6:])\n\trowTableOffset := binary.BigEndian.Uint32(data[12+8:])\n\tcolTableOffset := binary.BigEndian.Uint32(data[12+12:])\n\tarrayOffset := int(binary.BigEndian.Uint32(data[12+16:]))\n\n\tisLong := flags&1 != 0\n\n\tout.row, err = parseAATLookupTable(data, rowTableOffset, numGlyphs, isLong)\n\tif err != nil {\n\t\treturn out, err\n\t}\n\tout.column, err = parseAATLookupTable(data, colTableOffset, numGlyphs, isLong)\n\tif err != nil {\n\t\treturn out, err\n\t}\n\tif len(data) < arrayOffset {\n\t\treturn out, errors.New(\"invalid kerx subtable format 6 (EOF)\")\n\t}\n\tlength := int(out.rowCount) * int(out.columnCount)\n\tvar tmp []uint32\n\tif isLong {\n\t\tif len(data) < arrayOffset+length*4 {\n\t\t\treturn out, errors.New(\"invalid kerx subtable format 6 (EOF)\")\n\t\t}\n\t\ttmp = parseUint32s(data[arrayOffset:], length)\n\t} else {\n\t\tif len(data) < arrayOffset+length*2 {\n\t\t\treturn out, errors.New(\"invalid kerx subtable format 6 (EOF)\")\n\t\t}\n\t\ttmp = make([]uint32, length)\n\t\tfor i := range tmp {\n\t\t\ttmp[i] = uint32(binary.BigEndian.Uint16(data[arrayOffset+2*i:]))\n\t\t}\n\t}\n\n\tout.kernings = make([]int16, len(tmp))\n\tif tupleCount != 0 { // interpret kern values as offset\n\t\tif len(data) < 12+24 {\n\t\t\treturn out, errors.New(\"invalid kerx subtable format 2 (EOF)\")\n\t\t}\n\t\t// If the tupleCount is 1 or more, then the kerning array contains offsets from the beginning\n\t\t// of the kerningVectors table to a tupleCount-dimensional vector of FUnits controlling the kerning.\n\t\tkerningVectorsOffet := int(binary.BigEndian.Uint32(data[12+20:]))\n\t\tfor i, v := range tmp {\n\t\t\tif len(data) < kerningVectorsOffet+int(v)+2 {\n\t\t\t\treturn out, errors.New(\"invalid kerx subtable format 2 (EOF)\")\n\t\t\t}\n\t\t\tout.kernings[i] = int16(binary.BigEndian.Uint16(data[kerningVectorsOffet+int(v):]))\n\t\t}\n\t} else {\n\t\t// a kerning value greater than an int16 should not happen\n\t\tfor i, v := range tmp {\n\t\t\tout.kernings[i] = int16(v)\n\t\t}\n\t}\n\treturn out, err\n}", "func (x f26dot6) mul(y f26dot6) f26dot6 {\n\treturn f26dot6(int64(x) * int64(y) >> 6)\n}", "func isIP6AddrResolvable(fl FieldLevel) bool {\n\tif !isIPv6(fl) {\n\t\treturn false\n\t}\n\n\t_, err := net.ResolveIPAddr(\"ip6\", fl.Field().String())\n\n\treturn err == nil\n}", "func SumOfSquares(n int) int {\n\t// 1^2 + 2^2 + 3^2 ... + n^2 = n(n+1)(2n+1)/6\n\treturn n * (n + 1) * (2*n + 1) / 6\n}", "func Problem7() interface{} {\n\tvar primeIndex int = 1000\n\tfor i := primes[len(primes) - 1];; i++ {\n\t\tif isLikelyPrime(i) {\n\t\t\tprimeIndex ++\n\t\t\tif primeIndex == 10001 {\n\t\t\t\treturn i\n\t\t\t}\n\t\t}\n\t}\n\treturn 0\n}", "func is_prime(number int) bool {\n\tif (number <= 3) {\n\t\treturn number > 1\n\t}\n\n\tif (number%2 == 0 || number%3 == 0) {\n\t\treturn false\n\t}\n\n\tfor i := 5; i*i < number; i+=6 {\n\t\tif number%i == 0 || number%(i+2) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func (s *RestServer) getIPv6FlowPerformanceMetricsPoints() ([]*tsdb.Point, error) {\n\n\treturn nil, nil\n\n}", "func SumOfSquares(n int) int {\n\treturn n * (n + 1) * ((2 * n) + 1) / 6\n}", "func (o *DhcpLease6DataData) SetLease6Time(v string) {\n\to.Lease6Time = &v\n}", "func H6(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"h6\", Attributes: attrs, Children: children}\n}", "func SumOfSquares(n int) int {\n\treturn n * (n + 1) * (2*n + 1) / 6\n}", "func SumOfSquares(n int) int {\n\treturn n * (n + 1) * (2*n + 1) / 6\n}", "func SumOfSquares(n int) int {\n\treturn n * (n + 1) * (2*n + 1) / 6\n}", "func (z *Int) ModSqrt(x, p *Int) *Int {}", "func SumOfSquares(num int) int {\n\treturn num * (num + 1) * (num + num + 1) / 6\n}", "func NewDhcpLease6DataData() *DhcpLease6DataData {\n\tthis := DhcpLease6DataData{}\n\treturn &this\n}", "func Primes() [6]int {\n\tvar primes [6]int\n\tval := 0\n\ti := 2\n\tx := 0\n\tfor val < 6 {\n\t\tif i%2 == 1 {\n\t\t\tprimes[x] = i\n\t\t\tx++\n\t\t\tval++\n\t\t}\n\t\ti++\n\t}\n\treturn primes\n}", "func main2() {\n\tvar sum = 10\n\tvar n3 = 2\n\tvar n6 = 8\n\n\tfor ; n6 < 1000000; {\n\t\tvar tmp = n3 + n6 * 4\n\t\tsum += tmp\n\t\tn3 = n6\n\t\tn6 = tmp\n\t}\n\n\tfmt.Printf(\"Result: %d\", sum)\n}", "func (z *E6) Inverse(x *E6) *E6 {\n\t// Algorithm 17 from https://eprint.iacr.org/2010/354.pdf\n\t// step 9 is wrong in the paper it's t1-t4\n\tvar t0, t1, t2, t3, t4, t5, t6, c0, c1, c2, d1, d2 E2\n\tt0.Square(&x.B0)\n\tt1.Square(&x.B1)\n\tt2.Square(&x.B2)\n\tt3.Mul(&x.B0, &x.B1)\n\tt4.Mul(&x.B0, &x.B2)\n\tt5.Mul(&x.B1, &x.B2)\n\tc0.MulByNonResidue(&t5).Neg(&c0).Add(&c0, &t0)\n\tc1.MulByNonResidue(&t2).Sub(&c1, &t3)\n\tc2.Sub(&t1, &t4)\n\tt6.Mul(&x.B0, &c0)\n\td1.Mul(&x.B2, &c1)\n\td2.Mul(&x.B1, &c2)\n\td1.Add(&d1, &d2).MulByNonResidue(&d1)\n\tt6.Add(&t6, &d1)\n\tt6.Inverse(&t6)\n\tz.B0.Mul(&c0, &t6)\n\tz.B1.Mul(&c1, &t6)\n\tz.B2.Mul(&c2, &t6)\n\n\treturn z\n}", "func (o *DhcpLease6DataData) GetLease6Percent() string {\n\tif o == nil || o.Lease6Percent == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Lease6Percent\n}", "func (ip IP) Is6() bool {\n\treturn ip.z != z0 && ip.z != z4\n}", "func Relu6(scope *Scope, features tf.Output) (activations tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Relu6\",\n\t\tInput: []tf.Input{\n\t\t\tfeatures,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func GenerateNEP6Account(password string) (*NEP6Account, error) {\n\tpair, err := keys.GenerateKeyPair()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tscript, err := sc.CreateSignatureRedeemScript(pair.PublicKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcontract, err := NewNEP6Contract(script, []sc.ContractParameterType{sc.Signature}, []string{\"signature\"}, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tacc, err := NewNEP6AccountFromKeyPair(nil, contract.GetScriptHash(), pair, password)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tacc.Contract = contract\n\treturn acc, nil\n}", "func (s *RestServer) getIPv6FlowLatencyMetricsPoints() ([]*tsdb.Point, error) {\n\n\treturn nil, nil\n\n}", "func isTCP6AddrResolvable(fl FieldLevel) bool {\n\tif !isIP6Addr(fl) {\n\t\treturn false\n\t}\n\n\t_, err := net.ResolveTCPAddr(\"tcp6\", fl.Field().String())\n\n\treturn err == nil\n}", "func Dlaed6(kniter int, orgati bool, rho float64, d, z *mat.Vector, finit float64) (tau float64, info int) {\n\tvar scale bool\n\tvar a, b, base, c, ddf, df, eight, eps, erretm, eta, f, fc, four, lbd, one, sclfac, sclinv, small1, small2, sminv1, sminv2, temp, temp1, temp2, temp3, temp4, three, two, ubd, zero float64\n\tvar i, iter, maxit, niter int\n\tdscale := vf(3)\n\tzscale := vf(3)\n\n\tmaxit = 40\n\tzero = 0.0\n\tone = 1.0\n\ttwo = 2.0\n\tthree = 3.0\n\tfour = 4.0\n\teight = 8.0\n\n\tif orgati {\n\t\tlbd = d.Get(1)\n\t\tubd = d.Get(2)\n\t} else {\n\t\tlbd = d.Get(0)\n\t\tubd = d.Get(1)\n\t}\n\tif finit < zero {\n\t\tlbd = zero\n\t} else {\n\t\tubd = zero\n\t}\n\n\tniter = 1\n\ttau = zero\n\tif kniter == 2 {\n\t\tif orgati {\n\t\t\ttemp = (d.Get(2) - d.Get(1)) / two\n\t\t\tc = rho + z.Get(0)/((d.Get(0)-d.Get(1))-temp)\n\t\t\ta = c*(d.Get(1)+d.Get(2)) + z.Get(1) + z.Get(2)\n\t\t\tb = c*d.Get(1)*d.Get(2) + z.Get(1)*d.Get(2) + z.Get(2)*d.Get(1)\n\t\t} else {\n\t\t\ttemp = (d.Get(0) - d.Get(1)) / two\n\t\t\tc = rho + z.Get(2)/((d.Get(2)-d.Get(1))-temp)\n\t\t\ta = c*(d.Get(0)+d.Get(1)) + z.Get(0) + z.Get(1)\n\t\t\tb = c*d.Get(0)*d.Get(1) + z.Get(0)*d.Get(1) + z.Get(1)*d.Get(0)\n\t\t}\n\t\ttemp = math.Max(math.Abs(a), math.Max(math.Abs(b), math.Abs(c)))\n\t\ta = a / temp\n\t\tb = b / temp\n\t\tc = c / temp\n\t\tif c == zero {\n\t\t\ttau = b / a\n\t\t} else if a <= zero {\n\t\t\ttau = (a - math.Sqrt(math.Abs(a*a-four*b*c))) / (two * c)\n\t\t} else {\n\t\t\ttau = two * b / (a + math.Sqrt(math.Abs(a*a-four*b*c)))\n\t\t}\n\t\tif tau < lbd || tau > ubd {\n\t\t\ttau = (lbd + ubd) / two\n\t\t}\n\t\tif d.Get(0) == tau || d.Get(1) == tau || d.Get(2) == tau {\n\t\t\ttau = zero\n\t\t} else {\n\t\t\ttemp = finit + tau*z.Get(0)/(d.Get(0)*(d.Get(0)-tau)) + tau*z.Get(1)/(d.Get(1)*(d.Get(1)-tau)) + tau*z.Get(2)/(d.Get(2)*(d.Get(2)-tau))\n\t\t\tif temp <= zero {\n\t\t\t\tlbd = tau\n\t\t\t} else {\n\t\t\t\tubd = tau\n\t\t\t}\n\t\t\tif math.Abs(finit) <= math.Abs(temp) {\n\t\t\t\ttau = zero\n\t\t\t}\n\t\t}\n\t}\n\n\t// get machine parameters for possible scaling to avoid overflow\n\t//\n\t// modified by Sven: parameters SMALL1, SMINV1, SMALL2,\n\t// SMINV2, EPS are not SAVEd anymore between one call to the\n\t// others but recomputed at each call\n\teps = Dlamch(Epsilon)\n\tbase = Dlamch(Base)\n\tsmall1 = math.Pow(base, float64(int(math.Log(Dlamch(SafeMinimum))/math.Log(base)/three)))\n\tsminv1 = one / small1\n\tsmall2 = small1 * small1\n\tsminv2 = sminv1 * sminv1\n\n\t// Determine if scaling of inputs necessary to avoid overflow\n\t// when computing 1/TEMP**3\n\tif orgati {\n\t\ttemp = math.Min(math.Abs(d.Get(1)-tau), math.Abs(d.Get(2)-tau))\n\t} else {\n\t\ttemp = math.Min(math.Abs(d.Get(0)-tau), math.Abs(d.Get(1)-tau))\n\t}\n\tscale = false\n\tif temp <= small1 {\n\t\tscale = true\n\t\tif temp <= small2 {\n\t\t\t// Scale up by power of radix nearest 1/SAFMIN**(2/3)\n\t\t\tsclfac = sminv2\n\t\t\tsclinv = small2\n\t\t} else {\n\t\t\t// Scale up by power of radix nearest 1/SAFMIN**(1/3)\n\t\t\tsclfac = sminv1\n\t\t\tsclinv = small1\n\t\t}\n\n\t\t// Scaling up safe because D, Z, TAU scaled elsewhere to be O(1)\n\t\tfor i = 1; i <= 3; i++ {\n\t\t\tdscale.Set(i-1, d.Get(i-1)*sclfac)\n\t\t\tzscale.Set(i-1, z.Get(i-1)*sclfac)\n\t\t}\n\t\ttau = tau * sclfac\n\t\tlbd = lbd * sclfac\n\t\tubd = ubd * sclfac\n\t} else {\n\t\t// Copy D and Z to DSCALE and ZSCALE\n\t\tfor i = 1; i <= 3; i++ {\n\t\t\tdscale.Set(i-1, d.Get(i-1))\n\t\t\tzscale.Set(i-1, z.Get(i-1))\n\t\t}\n\t}\n\n\tfc = zero\n\tdf = zero\n\tddf = zero\n\tfor i = 1; i <= 3; i++ {\n\t\ttemp = one / (dscale.Get(i-1) - tau)\n\t\ttemp1 = zscale.Get(i-1) * temp\n\t\ttemp2 = temp1 * temp\n\t\ttemp3 = temp2 * temp\n\t\tfc = fc + temp1/dscale.Get(i-1)\n\t\tdf = df + temp2\n\t\tddf = ddf + temp3\n\t}\n\tf = finit + tau*fc\n\n\tif math.Abs(f) <= zero {\n\t\tgoto label60\n\t}\n\tif f <= zero {\n\t\tlbd = tau\n\t} else {\n\t\tubd = tau\n\t}\n\n\t// Iteration begins -- Use Gragg-Thornton-Warner cubic convergent\n\t// scheme\n\t//\n\t// It is not hard to see that\n\t//\n\t// 1) Iterations will go up monotonically\n\t// if FINIT < 0;\n\t//\n\t// 2) Iterations will go down monotonically\n\t// if FINIT > 0.\n\titer = niter + 1\n\n\tfor niter = iter; niter <= maxit; niter++ {\n\n\t\tif orgati {\n\t\t\ttemp1 = dscale.Get(1) - tau\n\t\t\ttemp2 = dscale.Get(2) - tau\n\t\t} else {\n\t\t\ttemp1 = dscale.Get(0) - tau\n\t\t\ttemp2 = dscale.Get(1) - tau\n\t\t}\n\t\ta = (temp1+temp2)*f - temp1*temp2*df\n\t\tb = temp1 * temp2 * f\n\t\tc = f - (temp1+temp2)*df + temp1*temp2*ddf\n\t\ttemp = math.Max(math.Abs(a), math.Max(math.Abs(b), math.Abs(c)))\n\t\ta = a / temp\n\t\tb = b / temp\n\t\tc = c / temp\n\t\tif c == zero {\n\t\t\teta = b / a\n\t\t} else if a <= zero {\n\t\t\teta = (a - math.Sqrt(math.Abs(a*a-four*b*c))) / (two * c)\n\t\t} else {\n\t\t\teta = two * b / (a + math.Sqrt(math.Abs(a*a-four*b*c)))\n\t\t}\n\t\tif f*eta >= zero {\n\t\t\teta = -f / df\n\t\t}\n\n\t\ttau = tau + eta\n\t\tif tau < lbd || tau > ubd {\n\t\t\ttau = (lbd + ubd) / two\n\t\t}\n\n\t\tfc = zero\n\t\terretm = zero\n\t\tdf = zero\n\t\tddf = zero\n\t\tfor i = 1; i <= 3; i++ {\n\t\t\tif (dscale.Get(i-1) - tau) != zero {\n\t\t\t\ttemp = one / (dscale.Get(i-1) - tau)\n\t\t\t\ttemp1 = zscale.Get(i-1) * temp\n\t\t\t\ttemp2 = temp1 * temp\n\t\t\t\ttemp3 = temp2 * temp\n\t\t\t\ttemp4 = temp1 / dscale.Get(i-1)\n\t\t\t\tfc = fc + temp4\n\t\t\t\terretm = erretm + math.Abs(temp4)\n\t\t\t\tdf = df + temp2\n\t\t\t\tddf = ddf + temp3\n\t\t\t} else {\n\t\t\t\tgoto label60\n\t\t\t}\n\t\t}\n\t\tf = finit + tau*fc\n\t\terretm = eight*(math.Abs(finit)+math.Abs(tau)*erretm) + math.Abs(tau)*df\n\t\tif (math.Abs(f) <= four*eps*erretm) || ((ubd - lbd) <= four*eps*math.Abs(tau)) {\n\t\t\tgoto label60\n\t\t}\n\t\tif f <= zero {\n\t\t\tlbd = tau\n\t\t} else {\n\t\t\tubd = tau\n\t\t}\n\t}\n\tinfo = 1\nlabel60:\n\t;\n\n\t// Undo scaling\n\tif scale {\n\t\ttau = tau * sclinv\n\t}\n\n\treturn\n}", "func (o *DhcpLease6DataData) HasLease6Percent() bool {\n\tif o != nil && o.Lease6Percent != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func NewServerV6() *ServerV6 {\n\tret := &ServerV6{\n\t\tPort: \"547\",\n\t}\n\treturn ret\n}", "func Square(n int) (uint64, error) {\n if n > 64 || n < 1 {\n return 0, errors.New(\"invalid chess board square\")\n }\n return power_of_two(n - 1), nil\n}", "func (_class PIFClass) GetIPv6(sessionID SessionRef, self PIFRef) (_retval []string, _err error) {\n\t_method := \"PIF.get_IPv6\"\n\t_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf(\"%s(%s)\", _method, \"session_id\"), sessionID)\n\tif _err != nil {\n\t\treturn\n\t}\n\t_selfArg, _err := convertPIFRefToXen(fmt.Sprintf(\"%s(%s)\", _method, \"self\"), self)\n\tif _err != nil {\n\t\treturn\n\t}\n\t_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)\n\tif _err != nil {\n\t\treturn\n\t}\n\t_retval, _err = convertStringSetToGo(_method + \" -> \", _result.Value)\n\treturn\n}", "func NewOp6(argLen int64, argModes []int64) *Op6 {\n\treturn &Op6{\n\t\tArgLen: argLen,\n\t\tArgModes: padMissingArgModes(argLen, argModes),\n\t}\n}", "func (o *DhcpLease6DataData) SetLease6EndTime(v string) {\n\to.Lease6EndTime = &v\n}", "func main() {\n\tfmt.Printf(\"Now you have %g problems. \\n\", math.Sqrt(7))\n}" ]
[ "0.6544208", "0.6188257", "0.56555146", "0.51578116", "0.5128709", "0.50900054", "0.5025849", "0.5000295", "0.49927026", "0.4945414", "0.490238", "0.4882119", "0.48817033", "0.48737305", "0.48098227", "0.47991794", "0.47904107", "0.47711647", "0.47703955", "0.47602263", "0.47375062", "0.47304216", "0.47223315", "0.4714406", "0.46892887", "0.46826127", "0.4672176", "0.46710435", "0.46661398", "0.46636948", "0.46492907", "0.4643219", "0.4640651", "0.46352875", "0.46212602", "0.4614579", "0.461026", "0.45808035", "0.45707282", "0.4569403", "0.45669863", "0.45661545", "0.45487708", "0.4541851", "0.45407823", "0.45262933", "0.4514506", "0.45066288", "0.45052853", "0.45039085", "0.44999626", "0.4488944", "0.44678217", "0.44638404", "0.44619033", "0.44449908", "0.4421861", "0.44148362", "0.4412694", "0.44088677", "0.44088677", "0.44088677", "0.44088677", "0.44066772", "0.4401445", "0.43956903", "0.43908274", "0.4384354", "0.43820268", "0.43722054", "0.43655753", "0.43600824", "0.4354324", "0.4353154", "0.43493396", "0.43463358", "0.43449625", "0.43394607", "0.43394607", "0.43394607", "0.43337494", "0.43298087", "0.43202224", "0.43112063", "0.43048558", "0.4300423", "0.42970493", "0.42878443", "0.42842525", "0.42783597", "0.4276421", "0.42727536", "0.42538354", "0.42506054", "0.42478", "0.4247678", "0.42449343", "0.4241742", "0.42401987", "0.42387083" ]
0.8614351
0
New instanciate the newapis
func New(key string) *Api { return &Api{&http.Client{}, key, "https://newsapi.org/v2/"} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func New() *Client {\n return &Client{&API{}}\n}", "func newAPI(cfg *ClientConfig, options ...ClientOption) *Client {\n\tclient := &Client{\n\t\tConfig: cfg,\n\t\thttpClient: &http.Client{},\n\t}\n\n\tfor _, option := range options {\n\t\toption(client)\n\t}\n\n\treturn client\n}", "func getNewAPI(anonymous bool) API {\n\t// ignore errors for now\n\td, err := xl.New()\n\tfatalIf(err.Trace(), \"Instantiating xl failed.\", nil)\n\n\treturn API{\n\t\tOP: make(chan APIOperation),\n\t\tXL: d,\n\t\tAnonymous: anonymous,\n\t}\n}", "func New() *API {\n\tapi := new(API)\n\tapi.msgCtrl = newMsgCtrl()\n\tapi.pingCtrl = newPingCtrl()\n\treturn api\n}", "func New(w http.ResponseWriter, r *http.Request) {\r\n\ttmpl.ExecuteTemplate(w, \"New\", nil)\r\n}", "func New(w http.ResponseWriter, r *http.Request) {\r\n\ttmpl.ExecuteTemplate(w, \"New\", nil)\r\n}", "func New(w http.ResponseWriter, r *http.Request) {\n\tgetTemplates().ExecuteTemplate(w, \"New\", nil)\n}", "func New(name ...string) *APITest {\n\tapiTest := &APITest{\n\t\tmeta: map[string]interface{}{},\n\t}\n\n\trequest := &Request{\n\t\tapiTest: apiTest,\n\t\theaders: map[string][]string{},\n\t\tquery: map[string][]string{},\n\t\tformData: map[string][]string{},\n\t}\n\tresponse := &Response{\n\t\tapiTest: apiTest,\n\t\theaders: map[string][]string{},\n\t}\n\tapiTest.request = request\n\tapiTest.response = response\n\n\tif len(name) > 0 {\n\t\tapiTest.name = name[0]\n\t}\n\n\treturn apiTest\n}", "func New(sess *session.Session, config *client.Config) *API {\n\treturn &API{\n\t\tV2010: v2010.New(sess, config),\n\t}\n}", "func New(config Config) API {\n\treturn API{\n\t\tClient: &http.Client{},\n\t\tConfig: config,\n\t}\n}", "func NewAPI() API {\n\treturn API{}\n}", "func NewAPI(name string) *API {\n\treturn &API{\n\t\tName: name,\n\t\tMethods: []*APIMethod{},\n\t\tAuth: \"\",\n\t}\n}", "func New(z *zoho.Zoho) *API {\n\tid := func() string {\n\t\tvar id []byte\n\t\tkeyspace := \"abcdefghijklmnopqrutuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n\t\tfor i := 0; i < 25; i++ {\n\t\t\tid = append(id, keyspace[rand.Intn(len(keyspace))])\n\t\t}\n\t\treturn string(id)\n\t}()\n\tAPI := &API{\n\t\tZoho: z,\n\t\tid: id,\n\t}\n\treturn API\n}", "func newClient(apiKey string) *Client {\n\tvar url *url.URL\n\turl, _ = url.Parse(\"https://vulners.com/api/v3\")\n\treturn &Client{baseURL: url, apiKey: apiKey}\n}", "func New(key string, org string) (*Api, error) {\n\ta := Api{}\n\ta.key = key\n\ta.org = org\n\ta.timezone = \"UTC\"\n\n\ta.client = pagerduty.NewClient(key)\n\n\t_, err := a.client.ListSchedules(pagerduty.ListSchedulesOptions{})\n\tif err != nil {\n\t\treturn &a, fmt.Errorf(\"Failed to list on-call schedules: %v\", err)\n\t}\n\n\tlog.Info(\"Authenticated with PagerDuty\")\n\n\treturn &a, nil\n}", "func New(store *store.Store) *API {\n\treturn &API{\n\t\tstore,\n\t}\n}", "func New(httpClient *http.Client) *Ali {\n\tc := apikit.NewClient(httpClient)\n\treturn &Ali{client: c}\n}", "func NewAPI(url string, t string) API {\n\ta := new(API)\n\ta.baseURL = url\n\ta.token = t\n\treturn *a\n}", "func (g *GoFlickr) newRequest(apiMethod string) ApiRequest {\n\n\treq := ApiRequest{\n\t\tMethodName: apiMethod,\n\t}\n\treq.addParam(\"api_key\", g.ApiKey)\n\treq.addParam(\"format\", \"json\")\n\treq.addParam(\"nojsoncallback\", \"1\")\n\treturn req\n\n}", "func New(\n\tlogger log.Logger,\n\tctx context.Context,\n\ttsDB influxdb2.Client,\n) *API {\n\n\treadAPI := tsDB.QueryAPI(\"my-org\")\n\ta := &API{\n\t\treadAPI: readAPI,\n\t\tnow: time.Now,\n\t\tlogger: logger,\n\t}\n\n\treturn a\n}", "func (s *SpotifyExtender) New() {\r\n\r\n}", "func New() {\n\ttypeOfProject()\n}", "func NewAPI(t blockchain.Translator) *API {\n\treturn &API{\n\t\tt: t,\n\t}\n}", "func newApiDefinitionFromAPI(a utils.API) *api {\n\treturn &api{a.ID, a.Name, a.Context, a.Version, a.Provider,\n\t\ta.LifeCycleStatus}\n}", "func NewAPI(client *scw.Client) *API {\n\treturn &API{\n\t\tclient: client,\n\t}\n}", "func NewAPI(client *scw.Client) *API {\n\treturn &API{\n\t\tclient: client,\n\t}\n}", "func NewAPI(client *scw.Client) *API {\n\treturn &API{\n\t\tclient: client,\n\t}\n}", "func NewAPI(client *scw.Client) *API {\n\treturn &API{\n\t\tclient: client,\n\t}\n}", "func NewNEUTRINOAPI() NEUTRINOAPI {\r\n neutrinoAPIClient := new(NEUTRINOAPI_IMPL)\r\n neutrinoAPIClient.config = configuration_pkg.NewCONFIGURATION()\r\n\r\n return neutrinoAPIClient\r\n}", "func New(logger model.Logger) API {\n\treturn API{logger: logger}\n}", "func New(i interface{}) *Resource {\n\tr := &Resource{}\n\tr.geth = mustMakeRpc(i, \"Get\")\n\tr.posth = mustMakeRpc(i, \"Post\")\n\tr.puth = mustMakeRpc(i, \"Put\")\n\tr.deleteh = mustMakeRpc(i, \"Delete\")\n\n\t// println(\"[debug]\", r.geth, r.posth, r.puth, r.deleteh)\n\treturn r\n}", "func newInteracts(c *HeliumV1Client, namespace string) *interacts {\n\treturn &interacts{\n\t\tclient: c.RESTClient(),\n\t\tns: namespace,\n\t}\n}", "func newOAPI(c container.Container) (x OAPI, err error) {\n\tx = OAPI{c: c}\n\terr = json.Unmarshal(c.Bytes(), &x.o.OpenAPI)\n\treturn x, err\n}", "func (qiwi *PersonalAPI) newRequest(apiKey, method, spath string, data map[string]interface{}) (req *http.Request, err error) {\n\n\tvar path = APIURL + spath\n\n\tvar body io.Reader\n\n\tif len(data) > 0 {\n\n\t\ts, err := json.Marshal(data)\n\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tbody = bytes.NewBuffer(s)\n\n\t}\n\n\treq, err = http.NewRequest(method, path, body)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"Accept\", \"application/json\")\n\treq.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n\n\treturn req, err\n}", "func Create(name string) *Frisby {\n\tF := new(Frisby)\n\tF.Name = name\n\tF.Req = request.NewRequest(new(http.Client))\n\tF.Errs = make([]error, 0)\n\n\t// copy in global settings\n\tF.Req.BasicAuth = Global.Req.BasicAuth\n\tF.Req.Proxy = Global.Req.Proxy\n\tF.SetHeaders(Global.Req.Headers)\n\tF.SetCookies(Global.Req.Cookies)\n\tF.SetDatas(Global.Req.Data)\n\tF.SetParams(Global.Req.Params)\n\tF.Req.Json = Global.Req.Json\n\tF.Req.Files = append(F.Req.Files, Global.Req.Files...)\n\n\treturn F\n}", "func NewAPI() *API {\n\treturn &API{}\n}", "func NewAPI(env *cfenv.App, b Broker, user, pass string, catalog *cf.Catalog) http.Handler {\n\t// create new router\n\tg := gin.Default()\n\n\tauthorised, err := withAuth(g, user, pass)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tapi := API{\n\t\tEnv: env,\n\t\tcatalog: catalog,\n\t\tBroker: &validatingBroker{\n\t\t\tBroker: b,\n\t\t},\n\t}\n\n\tauthorised.GET(\"/v2/catalog\", api.Catalog)\n\tauthorised.PUT(\"/v2/service_instances/:instance_id\", api.Provision)\n\tauthorised.DELETE(\"/v2/service_instances/:instance_id\", api.Deprovision)\n\tauthorised.PUT(\"/v2/service_instances/:instance_id/service_bindings/:binding_id\", api.Bind)\n\tauthorised.DELETE(\"/v2/service_instances/:instance_id/service_bindings/:binding_id\", api.Unbind)\n\n\treturn g\n}", "func New(configName string) (*Apnian, error) {\n\tapnian := ApnianConfigurer{configName, gobrick.GetGOPATH()}\n\treturn apnian.getApnian()\n}", "func New(\n\tctx context.Context,\n\tconf *apisettings.Service,\n\thandlers []Handler) *API {\n\n\tbaseHandler := newBaseHandler()\n\thandlers = append(handlers, baseHandler)\n\n\tapi := API{\n\t\tconf: conf,\n\t\thandlers: handlers}\n\n\tapi.initRouter(ctx)\n\treturn &api\n}", "func New(apiKey string) Interface {\n\tvar (\n\t\tcom communication.Interface\n\t\twbs *impl\n\t\turi string\n\t\tfromAt time.Time\n\t)\n\n\tcom, fromAt = communication.New(), time.Now().Truncate(time.Hour*24)\n\turi = fmt.Sprintf(serviceURNv1, serviceURL)\n\twbs = &impl{\n\t\tapiKey: apiKey,\n\t\tinc: incomes.New(com, uri, apiKey, fromAt),\n\t\tods: orders.New(com, uri, apiKey, fromAt),\n\t\tsle: sales.New(com, uri, apiKey, fromAt),\n\t\tstk: stocks.New(com, uri, apiKey, fromAt),\n\t\tmds: monthSale.New(com, uri, apiKey, fromAt),\n\t\tcom: com,\n\t\tfromAt: fromAt,\n\t}\n\n\treturn wbs\n}", "func New(token string) *API {\n\treturn &API{\n\t\tToken: token,\n\t\thasHandlers: false,\n\t}\n}", "func New() IApi {\n\treturn &api{\n\t\tRouter: pat.New(),\n\t\titemStore: make(map[string]apiStore),\n\t}\n}", "func newDemos(c *DemocontrollerV1alpha1Client, namespace string) *demos {\n\treturn &demos{\n\t\tclient: c.RESTClient(),\n\t\tns: namespace,\n\t}\n}", "func (a *api) newScenario(i interface{}) {\n\ta.c = nil\n\ta.resp = nil\n\ta.err = nil\n\ta.c = client.New(goaclient.HTTPClientDoer(http.DefaultClient))\n\ta.c.Host = \"localhost:8080\"\n}", "func New(config Config) IAPI {\n\tif config.BaseURL == \"\" {\n\t\tconfig.BaseURL = defaultAPIURL\n\t}\n\tif config.Timeout == nil {\n\t\tconfig.Timeout = newDuration(defaultTimeout)\n\t}\n\n\tapi := &API{config: config}\n\tapi.client = &http.Client{\n\t\tTransport: api,\n\t\tTimeout: *config.Timeout,\n\t}\n\treturn api\n}", "func New(this *Handler) *Handler {\n\ta := &API{Cfg: this.Cfg, Interactor: this.Interactor}\n\troutes(a).Register()\n\treturn this\n}", "func newResource() *resource.Resource {\n\tr, _ := resource.Merge(\n\t\tresource.Default(),\n\t\tresource.NewWithAttributes(\n\t\t\tsemconv.SchemaURL,\n\t\t\tsemconv.ServiceNameKey.String(\"opentelemetry-server\"),\n\t\t\tsemconv.ServiceVersionKey.String(\"v0.1.0\"),\n\t\t\tattribute.String(\"environment\", \"demo\"),\n\t\t),\n\t)\n\treturn r\n}", "func New(l logger.Logger, c cacher.Cacher, db *gorm.DB, mal *malscraper.Malscraper, ps pubsub.PubSub, es *elasticsearch.Client) *API {\n\treturn &API{\n\t\tlogger: l,\n\t\tcacher: c,\n\t\tdb: db,\n\t\tmal: mal,\n\t\tpubsub: ps,\n\t\tes: es,\n\t}\n}", "func New(token, api string) (*API, error) {\n\tu, err := url.Parse(api)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch u.Scheme {\n\tcase \"http\":\n\t\tfallthrough\n\tcase \"https\":\n\t\treturn NewHTTP(token, api)\n\tcase \"ws\":\n\t\tfallthrough\n\tcase \"wss\":\n\t\treturn NewWebsocket(token, api)\n\tdefault:\n\t\treturn nil, errors.New(\"invalid api's scheme\")\n\t}\n}", "func New(ctx context.Context, agent agent.Agent, storage check.Storage, persister persistence.PersisterService, uploader results.Uploader, sched *scheduler.Scheduler, addr string, log *logrus.Entry) API {\n\treturn API{\n\t\taddr: addr,\n\t\tagent: agent,\n\t\tstorage: storage,\n\t\tpersister: persister,\n\t\tuploader: uploader,\n\t\tsched: sched,\n\t\tlog: log,\n\t}\n}", "func New()BaseClient {\n return NewWithBaseURI(DefaultBaseURI, )\n}", "func (c *Controller) createInAPI(uri string, data io.Reader) error {\n\tresp, err := http.Post(uri, \"application/json; charset=utf-8\", data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif resp.StatusCode != http.StatusCreated {\n\t\tlog.Printf(\"status code received back was not expected during creation\")\n\t}\n\n\treturn nil\n}", "func new() exampleInterface {\n\treturn config{}\n}", "func CreateAPI() GetSamplesAllAPI {\n\tif api == nil {\n\t\treturn GetSamplesAllAPIImpl{\n\t\t\tInteractor: core.CreateDefaultGetSamples(\"Kaka\", \"Ronaldo\"),\n\t\t}\n\t}\n\treturn api\n}", "func New()ManagementClient {\n return NewWithBaseURI(DefaultBaseURI, )\n}", "func init() {\n\tRepoCreateClinic(model.Clinic{ID: 1, Name: \"Dentistas de Três Pontas\", Local: \"Rua Marques de Abrantes, 342, Centro, CEP 37190-000, Três Pontas, MG\", Phone: \"(35) 3265-2928\"})\n\tRepoCreateClinic(model.Clinic{ID: 2, Name: \"Dentistas da Lapa\", Local: \"Afonso Sardinha, número 199, Lapa, São Paulo, SP\", Phone: \"(11) 3644-7777\"})\n}", "func (mc *Client) New(base *url.URL) *Client {\n\n\tmarathon := mc\n\tmarathon.Session = requist.New(base.String())\n\n\tif marathon.Session != nil {\n\t\trequist.Logger = Logger\n\t\tmarathon.baseURL = base.String()\n\t\tmarathon.info = &data.Info{}\n\t\tmarathon.fail = &data.FailureMessage{}\n\n\t\tif base.User.String() != \"\" {\n\t\t\tif pass, check := base.User.Password(); check {\n\t\t\t\tmarathon.Session.SetBasicAuth(base.User.Username(), pass)\n\t\t\t}\n\t\t\tmarathon.auth = marathon.Session.GetBasicAuth()\n\t\t}\n\t\tmarathon.SetTimeout(DeploymentTimeout)\n\t\tmarathon.Session.Accept(\"application/json\")\n\t\tmarathon.Session.SetHeader(\"Cache-Control\", \"no-cache\")\n\t\tmarathon.Session.SetHeader(\"Accept-Encoding\", \"identity\")\n\n\t\tLogger.Debug(\"Marathon Client = %+v\", marathon)\n\t\treturn marathon\n\t}\n\treturn nil\n}", "func New() *API {\n\tapi := &API{\n\t\trouter: router.New(),\n\t\tchain: []alice.Constructor{},\n\t\tEncoders: encoding.New(),\n\t}\n\tapi.RouteGroup = &RouteGroup{[]HandleFunc{}, \"/\", nil, api}\n\treturn api\n}", "func New() *API {\n\treturn &API{\n\t\tprefix: \"/\",\n\t\tresources: make(map[string]Rest),\n\t\troutes: &node{},\n\t}\n}", "func (o *FakeObject) New(args ...interface{}) Object { return o.Invoke(args) }", "func NewTrainCar() TrainCar {\n c := TrainCar{name: \"TrainCar\", vehicle: \"TrainCar\", speed: 30, capacity: 30, railway: \"CNR\"}\n return c\n}", "func CreateServiceStatusRequest() (request *ServiceStatusRequest) {\nrequest = &ServiceStatusRequest{\nRpcRequest: &requests.RpcRequest{},\n}\nrequest.InitWithApiInfo(\"Yundun\", \"2015-04-16\", \"ServiceStatus\", \"yundun\", \"openAPI\")\nreturn\n}", "func New()(*Window,error){\n\n\n/*8:*/\n\n\n//line goacme.w:147\n\n{\nvar err error\nonce.Do(func(){fsys,err= client.MountService(\"acme\")})\nif err!=nil{\nreturn nil,err\n}\n}\n\n\n\n/*:8*/\n\n\n//line goacme.w:160\n\nf,err:=fsys.Open(\"new/ctl\",plan9.OREAD)\nif err!=nil{\nreturn nil,err\n}\ndefer f.Close()\nvar id int\nif _,err:=fmt.Fscan(f,&id);err!=nil{\nreturn nil,err\n}\nreturn Open(id)\n}", "func New(token string) Client {\n\tnewClient := NewWithBaseURL(token, \"https://ffxiv.ramirezrtg.app/API/\")\n\n\treturn newClient\n}", "func New(config *starr.Config) *Lidarr {\n\tif config.Client == nil {\n\t\tconfig.Client = starr.Client(0, false)\n\t}\n\n\tconfig.URL = strings.TrimSuffix(config.URL, \"/\")\n\n\treturn &Lidarr{APIer: config}\n}", "func CreateApplication() *Alpha {\n app := &Alpha{}\n app.Request = &Request{}\n app.Response = &Response{}\n app.init()\n return app\n}", "func New(c *core.Core, r *mux.Router, version string) *API {\n\ta := &API{}\n\ta.AppVersion = version\n\ta.c = c\n\ta.reqDecoder = schema.NewDecoder()\n\twireupRoutes(r, a)\n\treturn a\n}", "func newPersonalAPIWithHTTPClient(apiKey string, client *http.Client) *PersonalAPI {\n\tqiwi := new(PersonalAPI)\n\n\tqiwi.httpClient = client\n\tqiwi.apiKey = apiKey\n\n\treturn qiwi\n}", "func (c *InputService18ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func NewAPI(ctx Context) *API {\n\treturn &API{\n\t\tctx: ctx,\n\t}\n}", "func NewAPI(root string) *API {\n\tapi := &API{\n\t\troot: root,\n\t}\n\treturn api\n}", "func New(data []byte) (v Info, err error) {\n\terr = json.Unmarshal(data, &v)\n\treturn v, VerError.Wrap(err)\n}", "func NewAPI(log *logrus.Entry, config *conf.Config, db IApiDb, fs IApiFileSystem) *API {\n\techoServer := EchoServer{e: echo.New()}\n\n\t// create the api\n\tapi := &API{\n\t\tconfig: config,\n\t\tlog: log.WithField(\"component\", \"api\"),\n\t\tServer: echoServer,\n\t\tDb: db,\n\t\tFs: fs,\n\t}\n\n\treturn api\n}", "func InitAPI() {\n\n}", "func NewRECIPIENTS(config configuration_pkg.CONFIGURATION) *RECIPIENTS_IMPL {\r\n client := new(RECIPIENTS_IMPL)\r\n client.config = config\r\n return client\r\n}", "func (c *client) newClient() *gitea.Client {\n\treturn c.newClientToken(\"\")\n}", "func New(credentials config.UserCredential) *RestAPI {\n\treturn &RestAPI{credentials: credentials}\n\t//var api = new(RestAPI)\n\t//api.credentials = credentials\n\t//return api\n}", "func New(l *zap.SugaredLogger, timeout time.Duration, deduplicate bool, urls ...string) (*API, error) {\n\tclient, err := prometheus.New(urls...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treact, err := ui.ReactApp()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ta := API{\n\t\tl: l,\n\t\ttimeout: timeout,\n\t\tdeduplicate: deduplicate,\n\t\treactApp: react,\n\t\tlistenAddr: \":8080\",\n\t\turlPathPrefix: \"/\",\n\t\tcli: client,\n\t}\n\n\tif !strings.HasPrefix(a.urlPathPrefix, \"/\") {\n\t\treturn nil, errors.New(\"url prefix must start with '/'\")\n\t}\n\n\tr := chi.NewRouter()\n\ta.router = r\n\n\treturn &a, nil\n}", "func New() Go { return Go{} }", "func New(client *httpclient.Client, baseURL string) Data {\n\td := Data{\n\t\tclient: client,\n\t\tbaseURL: baseURL,\n\t}\n\n\treturn d\n}", "func newP(method, url, token string, body interface{}) (*http.Request, error) {\n\treader, err := encode(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trequest, err := NewRequest(method, url, reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbearer := fmt.Sprintf(\"Bearer %s\", token)\n\trequest.Header.Add(\"Authorization\", bearer)\n\trequest.Header.Add(\"Accept\", \"application/json\")\n\trequest.Header.Add(\"Content-Type\", \"application/json\")\n\treturn request, nil\n}", "func New(cfg *config.Config) (c *Client) {\n\tc = &Client{\n\t\tapi: httpclient.NewHttpClient(),\n\t\tdebug: cfg.Debug,\n\t\tlastAt: time.Now().UTC(),\n\t\tsecret: cfg.APISecret,\n\t\turl: cfg.APIUrl,\n\t\tversion: cfg.APIVersion,\n\t\twait: 1 * time.Second,\n\t}\n\n\tc.api.Defaults(httpclient.Map{\n\t\t\"Accept\": \"application/json\",\n\t\t\"Content-Type\": \"application/json\",\n\t\thttpclient.OPT_USERAGENT: \"go-crex24\",\n\t\t\"X-CREX24-API-KEY\": cfg.APIKey,\n\t})\n\tif c.debug {\n\t\tfmt.Println(\"X-CREX24-API-KEY:\", c.api.Headers[\"X-CREX24-API-KEY\"])\n\t\tfmt.Println(\"Client.api.Headers:\", c.api.Headers)\n\t}\n\treturn\n}", "func New(publicURL url.URL, logic *businesslogic.BusinessLogic) (*API, error) {\n\tapi := API{router: mux.NewRouter()}\n\n\tapi.router.NotFoundHandler = utils.HandlerNotFound()\n\tapi.router.MethodNotAllowedHandler = utils.HandlerMethodNotAllowed()\n\n\tapi.\n\t\twithMiddleware().\n\t\twithHealthServer()\n\n\tv1SubRouter := api.router.PathPrefix(\"/v1\").Subrouter()\n\tv1.New(v1SubRouter, publicURL).WithLogic(logic)\n\n\treturn &api, api.err\n}", "func (ot *openTelemetryWrapper) newResource(\n\twebEngineName,\n\twebEngineVersion string,\n) (*resource.Resource, error) {\n\treturn resource.Merge(resource.Default(), resource.NewSchemaless(\n\t\tsemconv.WebEngineName(webEngineName),\n\t\tsemconv.WebEngineVersion(webEngineVersion),\n\t))\n}", "func New(pingPeriod, pongTimeout time.Duration) *API {\n\treturn &API{\n\t\tclients: make(map[uint][]*client),\n\t\tpingPeriod: pingPeriod,\n\t\tpongTimeout: pingPeriod + pongTimeout,\n\t}\n}", "func New(secretKey string) *API {\n\tapi := API{\n\t\topt: xendit.Option{\n\t\t\tSecretKey: secretKey,\n\t\t\tXenditURL: \"https://api.xendit.co\",\n\t\t},\n\t\tapiRequester: xendit.GetAPIRequester(),\n\t}\n\tapi.init()\n\n\treturn &api\n}", "func NewApiResponse() *ApiResponse {\n this := ApiResponse{}\n return &this\n}", "func New(handler http.Handler) *Request {\n\tapiTest := &APITest{}\n\n\trequest := &Request{apiTest: apiTest}\n\tresponse := &Response{apiTest: apiTest}\n\tapiTest.request = request\n\tapiTest.response = response\n\tapiTest.handler = handler\n\n\treturn apiTest.request\n}", "func (c *InputService15ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (c *Controller) renderNew(ctx context.Context, w http.ResponseWriter, authApp *database.AuthorizedApp) {\n\tm := controller.TemplateMapFromContext(ctx)\n\tm.Title(\"New API key\")\n\tm[\"authApp\"] = authApp\n\tm[\"typeAdmin\"] = database.APIKeyTypeAdmin\n\tm[\"typeDevice\"] = database.APIKeyTypeDevice\n\tm[\"typeStats\"] = database.APIKeyTypeStats\n\tc.h.RenderHTML(w, \"apikeys/new\", m)\n}", "func (c *InputService17ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (c *InputService19ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func NewAPI(log *util.Logger, identity oauth2.TokenSource, brand, country string) *API {\n\tv := &API{\n\t\tHelper: request.NewHelper(log),\n\t\tbrand: brand,\n\t\tcountry: country,\n\t\tbaseURI: DefaultBaseURI,\n\t}\n\n\tv.Client.Transport = &oauth2.Transport{\n\t\tSource: identity,\n\t\tBase: v.Client.Transport,\n\t}\n\n\treturn v\n}", "func createAPIs() (apis APIs, err error) {\n\n\tparam := os.Getenv(\"OPSMAN\")\n\n\tvar config helpers.OpsManConfig\n\tif err = json.Unmarshal([]byte(param), &config); err == nil {\n\n\t\t// First find the opsman API\n\t\tvar opsMan *helpers.OpsManAPI\n\t\tif opsMan, err = helpers.NewOpsManAPI(config); err == nil {\n\t\t\tapis = APIs{\n\t\t\t\thelpers.None: nil,\n\t\t\t\thelpers.OpsMan: opsMan,\n\t\t\t}\n\n\t\t\tvar api helpers.API\n\t\t\tif api, err = helpers.NewAppsManAPI(opsMan); err == nil {\n\t\t\t\tapis[helpers.AppsMan] = api\n\t\t\t}\n\t\t}\n\t}\n\n\tif err != nil {\n\t\tlog.Printf(\"API Error: %s\", err)\n\t}\n\n\treturn apis, err\n}", "func newRpcServices(c *RpccontrollerV1Client, namespace string) *rpcServices {\n\treturn &rpcServices{\n\t\tclient: c.RESTClient(),\n\t\tns: namespace,\n\t}\n}", "func NewApi(apiKey string) *AlphaVantageApi {\n\treturn &AlphaVantageApi{apiKey: apiKey}\n}", "func New(db *gorm.DB, sk []byte) *API {\n\treturn &API{\n\t\tdb: db,\n\t\tsigningKey: sk,\n\t}\n}", "func NewAPI(log *util.Logger, identity *Identity, cache time.Duration) *API {\n\tv := &API{\n\t\tlog: log,\n\t\tidentity: identity,\n\t\tHelper: request.NewHelper(log),\n\t}\n\n\t// api is unbelievably slow when retrieving status\n\tv.Helper.Client.Timeout = 120 * time.Second\n\n\treturn v\n}", "func (c *InputService9ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (c *InputService9ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}" ]
[ "0.66781676", "0.64137304", "0.6388719", "0.6369072", "0.63019925", "0.63019925", "0.6297614", "0.6277084", "0.6175942", "0.6163042", "0.6157485", "0.610001", "0.60947263", "0.6075261", "0.6031725", "0.60286605", "0.6021817", "0.60109615", "0.60100245", "0.6003949", "0.59877384", "0.59784293", "0.59736", "0.5953772", "0.5950177", "0.5950177", "0.5950177", "0.5950177", "0.5948458", "0.59406155", "0.5935643", "0.5919777", "0.5917068", "0.5906388", "0.59016794", "0.58938706", "0.5869392", "0.58653164", "0.58602583", "0.58568925", "0.58508456", "0.5798868", "0.5797396", "0.57903606", "0.57890636", "0.57850707", "0.57640976", "0.5762167", "0.57497543", "0.5743767", "0.57347083", "0.5715183", "0.57136786", "0.570509", "0.57031983", "0.5689049", "0.5687119", "0.5679728", "0.5678876", "0.56674284", "0.56627935", "0.5659731", "0.56551176", "0.5654654", "0.564476", "0.5635226", "0.5632221", "0.563106", "0.5627608", "0.5625645", "0.562453", "0.5619982", "0.56182", "0.5617253", "0.56160814", "0.5614612", "0.5606174", "0.5605272", "0.5600677", "0.5596272", "0.5592137", "0.55860555", "0.5585454", "0.5582978", "0.5582035", "0.55815667", "0.5576007", "0.55747133", "0.55698997", "0.5569222", "0.556909", "0.55637056", "0.55631644", "0.5561877", "0.55601865", "0.55526084", "0.5552553", "0.55498666", "0.5549083", "0.5549083" ]
0.64275396
1
SerializeUrl implements the required interface
func (r ReqArticles) SerializeUrl() string { return r.baseUrl + "everything?q=" + r.q }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *InformationalUrl) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"logoUrl\", m.GetLogoUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"marketingUrl\", m.GetMarketingUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"privacyStatementUrl\", m.GetPrivacyStatementUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"supportUrl\", m.GetSupportUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"termsOfServiceUrl\", m.GetTermsOfServiceUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func (moo *JsonApiUrl) String() string {\n\tvar u *url.URL\n\tvar err error\n\n\tassert.NotEmpty(moo.T, moo.BaseUrl, \"error generating a JsonAPI URL from %v: %s\", moo, \"base url must not be empty\")\n\tassert.NotEmpty(moo.T, moo.DrupalEntity, \"error generating a JsonAPI URL from %v: %s\", moo, \"drupal entity must not be empty\")\n\tassert.NotEmpty(moo.T, moo.DrupalBundle, \"error generating a JsonAPI URL from %v: %s\", moo, \"drupal bundle must not be empty\")\n\n\tbaseUrl := env.BaseUrlOr(moo.BaseUrl)\n\tif strings.HasSuffix(baseUrl, \"/\") {\n\t\tbaseUrl = baseUrl[:len(baseUrl) - 1]\n\t}\n\tu, err = url.Parse(fmt.Sprintf(\"%s\", strings.Join([]string{baseUrl, \"jsonapi\", moo.DrupalEntity, moo.DrupalBundle}, \"/\")))\n\tassert.Nil(moo.T, err, \"error generating a JsonAPI URL from %v: %s\", moo, err)\n\n\t// If a raw filter is supplied, use it as-is, otherwise use the .Filter and .Value\n\tif moo.RawFilter != \"\" {\n\t\tu, err = url.Parse(fmt.Sprintf(\"%s?%s\", u.String(), moo.RawFilter))\n\t} else if moo.Filter != \"\" {\n\t\tu, err = url.Parse(fmt.Sprintf(\"%s?filter[%s]=%s\", u.String(), moo.Filter, moo.Value))\n\t}\n\n\tassert.Nil(moo.T, err, \"error generating a JsonAPI URL from %v: %s\", moo, err)\n\treturn u.String()\n}", "func (r ReqHeadlines) SerializeUrl() string {\n\treturn r.baseUrl + \"top-headlines?category=\" + r.category + \"&pageSize=\" + strconv.Itoa(r.pageSize) + \"&country=\" + r.country\n}", "func (group *Group) ToURL() string {\n\treturn toURL(group.endpoint, group.modifiers)\n}", "func Marshal(v interface{}) (s string) {\n\tu := &url.URL{}\n\tuVal := &url.Values{}\n\tvStruct := reflect.ValueOf(v)\n\tif vStruct.Kind() == reflect.Ptr {\n\t\tif vStruct.IsNil() {\n\t\t\tvStruct = reflect.New(vStruct.Type().Elem())\n\t\t}\n\t\tvStruct = vStruct.Elem()\n\t}\n\n\tparseStruct(u, uVal, vStruct)\n\n\t// Note: url values are sorted by string value as they are encoded\n\tu.RawQuery = uVal.Encode()\n\treturn u.String()\n}", "func (fu FileURL) ToString() string {\n\treturn fu.urlStr\n}", "func (o BlobOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Blob) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (u URL) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(u.URL().String())\n}", "func (o BackendProxyOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BackendProxy) string { return v.Url }).(pulumi.StringOutput)\n}", "func (_this *URL) ToString() string {\n\treturn _this.Href()\n}", "func genObjURL(isSecure, isXML bool) (s string) {\n\tif isSecure || !isXML { // Using JSON requires HTTPS: \"SSL is required to perform this operation.\"\n\t\ts = \"https://\"\n\t} else {\n\t\ts = \"http://\"\n\t}\n\tif isXML {\n\t\ts += fmt.Sprintf(\"storage.googleapis.com/%s/%s\", gcsBck, gcsObjXML)\n\t} else {\n\t\t// Reformat object name from XML to JSON API requirements.\n\t\tgcsObjJSON := strings.ReplaceAll(gcsObjXML, \"/\", \"%2F\")\n\t\ts += fmt.Sprintf(\"www.googleapis.com/storage/v1/b/%s/o/%s?alt=media\", gcsBck, gcsObjJSON)\n\t}\n\treturn s\n}", "func (this *DynMap) MarshalURL() (string, error) {\n\tvals := &url.Values{}\n\tfor key, value := range this.Map {\n\t\terr := this.urlEncode(vals, key, value)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\tstr := vals.Encode()\n\tlog.Printf(str)\n\treturn vals.Encode(), nil\n}", "func (v *Visualisation) URL(vo *VisualisationURLOptions) *url.URL {\n\tu, err := url.Parse(v.c.apiURL + \"/visualisation\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tvalues := u.Query()\n\tvalues.Set(\"k\", v.Key)\n\tif vo != nil {\n\t\tif vo.Names != nil {\n\t\t\tfor _, n := range vo.Names {\n\t\t\t\tvalues.Add(\"name\", n)\n\t\t\t}\n\t\t}\n\t\tif vo.Avatars != nil {\n\t\t\tfor _, a := range vo.Avatars {\n\t\t\t\tvalues.Add(\"avatar\", a)\n\t\t\t}\n\t\t}\n\t\tif vo.AvatarBaseURL != \"\" {\n\t\t\tvalues.Set(\"avatarBaseUrl\", vo.AvatarBaseURL)\n\t\t}\n\t\tif !vo.FixedAspect {\n\t\t\tvalues.Set(\"fixedAspect\", \"false\")\n\t\t}\n\t\tif vo.MinimalView {\n\t\t\tvalues.Set(\"minimalView\", \"true\")\n\t\t}\n\t\tif vo.DZML != \"\" {\n\t\t\tvalues.Set(\"dzml\", vo.DZML)\n\t\t}\n\t}\n\tu.RawQuery = values.Encode()\n\treturn u\n}", "func (o NodeDriverOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *NodeDriver) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (o *Object) String() string {\n\treturn o.URL.String()\n}", "func (o *Object) url() string {\n\treturn o.fs.url(o.remote)\n}", "func (o ContainerOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Container) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (s S3OutputUrl) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (u *URL) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(u.String())\n}", "func (u URL) MarshalJSON() ([]byte, error) {\n\tif u.URL == nil {\n\t\treturn json.Marshal(nil)\n\t}\n\n\treturn json.Marshal(u.URL.String())\n}", "func (o BucketOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Bucket) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (e *Encoder) Encode(v interface{}) (values url.Values, err error) {\n\n\tval, kind := ExtractType(reflect.ValueOf(v))\n\n\tif kind == reflect.Ptr || kind == reflect.Interface || kind == reflect.Invalid {\n\t\treturn nil, &InvalidEncodeError{reflect.TypeOf(v)}\n\t}\n\n\tenc := e.dataPool.Get().(*encoder)\n\tenc.values = make(url.Values)\n\n\tif kind == reflect.Struct && val.Type() != timeType {\n\t\tenc.traverseStruct(val, enc.namespace[0:0], -1)\n\t} else {\n\t\tenc.setFieldByType(val, enc.namespace[0:0], -1, false)\n\t}\n\n\tif len(enc.errs) > 0 {\n\t\terr = enc.errs\n\t\tenc.errs = nil\n\t}\n\n\tvalues = enc.values\n\n\te.dataPool.Put(enc)\n\n\treturn\n}", "func encode(value string) string {\n\tencode := &url.URL{Path: value}\n\treturn encode.String()\n}", "func (o *EventCollectionURL) String() string {\n\treturn o.Must(o.Build()).String()\n}", "func (object Object) URL(value interface{}) Object {\n\treturn object.Property(as.PropertyURL, value)\n}", "func (o SnapshotImportDiskContainerOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v SnapshotImportDiskContainer) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (me TURLType) String() string { return xsdt.AnyURI(me).String() }", "func (u *URLValue) String() string {\n\turl := url.URL(*u)\n\n\treturn fmt.Sprintf(\"%v\", url.String())\n}", "func (m *EmailUrlThreatSubmission) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.EmailThreatSubmission.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"messageUrl\", m.GetMessageUrl())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func (o PacketMirroringNetworkInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringNetworkInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func (h *Host) ToURL() string {\n\treturn fmt.Sprintf(\"%s:%d\", h.Address, h.Port)\n}", "func (url URL) String() string {\n\treturn string(url)\n}", "func (e *Endpoint) URL() string {\n\treturn e.url\n}", "func (o PacketMirroringMirroredResourceInfoInstanceInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringMirroredResourceInfoInstanceInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func (w *Worker) Url(path string, params url.Values) string {\n\t// random choice one host for load balance\n\ti := rand.Intn(len(w.ctx.addrs))\n\taddr := w.ctx.addrs[i]\n\ts := fmt.Sprintf(\"http://%s%s\", addr, path)\n\tif params == nil {\n\t\treturn s\n\t}\n\tp := params.Encode()\n\treturn fmt.Sprintf(\"%s?%s\", s, p)\n}", "func (o ApiLicenseOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApiLicense) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (self *AbtabURL) String() string {\n\treturn fmt.Sprintf(\"AbtabURL{OriginalUrl=%s; Scheme=%s; Host=%s; User=%s; Path=%s; Query=%s}\",\n\t\tself.OriginalUrl,\n\t\tself.Url.Scheme,\n\t\tself.Url.Host,\n\t\tself.Url.User,\n\t\tself.Url.Path,\n\t\tself.Url.RawQuery,\n\t)\n}", "func Encode(u *url.URL) string {\n\treturn base64.URLEncoding.EncodeToString([]byte(u.RequestURI()))\n}", "func (p *PackageURL) ToString() string {\n\t// Start with the type and a colon\n\tpurl := fmt.Sprintf(\"pkg:%s/\", p.Type)\n\t// Add namespaces if provided\n\tif p.Namespace != \"\" {\n\t\tvar ns []string\n\t\tfor _, item := range strings.Split(p.Namespace, \"/\") {\n\t\t\tns = append(ns, url.QueryEscape(item))\n\t\t}\n\t\tpurl = purl + strings.Join(ns, \"/\") + \"/\"\n\t}\n\t// The name is always required and must be a percent-encoded string\n\t// Use url.QueryEscape instead of PathEscape, as it handles @ signs\n\tpurl = purl + url.QueryEscape(p.Name)\n\t// If a version is provided, add it after the at symbol\n\tif p.Version != \"\" {\n\t\t// A name must be a percent-encoded string\n\t\tpurl = purl + \"@\" + url.PathEscape(p.Version)\n\t}\n\n\t// Iterate over qualifiers and make groups of key=value\n\tvar qualifiers []string\n\tfor _, q := range p.Qualifiers {\n\t\tqualifiers = append(qualifiers, q.String())\n\t}\n\t// If there are one or more key=value pairs, append on the package url\n\tif len(qualifiers) != 0 {\n\t\tpurl = purl + \"?\" + strings.Join(qualifiers, \"&\")\n\t}\n\t// Add a subpath if available\n\tif p.Subpath != \"\" {\n\t\tpurl = purl + \"#\" + p.Subpath\n\t}\n\treturn purl\n}", "func (o CustomPagesOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *CustomPages) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (output AmazonS3URL) String() string {\n\treturn fmt.Sprintf(\"{Region: %s; Bucket: %s; Key: %s; IsValidS3URI: %v; IsPathStyle: %v}\",\n\t\toutput.Region, output.Bucket, output.Key, output.IsValidS3URI, output.IsPathStyle)\n}", "func (o *GetMoveHistoryURL) String() string {\n\treturn o.Must(o.Build()).String()\n}", "func EncodeURL(api string, params RequestQueries) (string, error) {\n\turl, err := url.Parse(api)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tquery := url.Query()\n\n\tfor k, v := range params {\n\t\tquery.Set(k, v)\n\t}\n\n\turl.RawQuery = query.Encode()\n\n\treturn url.String(), nil\n}", "func (i *urls) String() string {\n\treturn fmt.Sprint(*i)\n}", "func (lk *Link) String() string {\n\tb, _ := json.Marshal(lk)\n\treturn \"vmess://\" + base64.Encode(string(b))\n}", "func (o ContainerServiceOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ContainerService) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (t *Target) URL() *url.URL {\n\tparams := url.Values{}\n\n\tfor k, v := range t.params {\n\t\tparams[k] = make([]string, len(v))\n\t\tcopy(params[k], v)\n\t}\n\tt.labels.Range(func(l labels.Label) {\n\t\tif !strings.HasPrefix(l.Name, model.ParamLabelPrefix) {\n\t\t\treturn\n\t\t}\n\t\tks := l.Name[len(model.ParamLabelPrefix):]\n\n\t\tif len(params[ks]) > 0 {\n\t\t\tparams[ks][0] = l.Value\n\t\t} else {\n\t\t\tparams[ks] = []string{l.Value}\n\t\t}\n\t})\n\n\treturn &url.URL{\n\t\tScheme: t.labels.Get(model.SchemeLabel),\n\t\tHost: t.labels.Get(model.AddressLabel),\n\t\tPath: t.labels.Get(model.MetricsPathLabel),\n\t\tRawQuery: params.Encode(),\n\t}\n}", "func (s PresignedUrlConfig) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o FluxConfigurationBucketOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v FluxConfigurationBucket) string { return v.Url }).(pulumi.StringOutput)\n}", "func (rc *RemoteConfig) ToURL() (*common.URL, error) {\n\tif len(rc.Protocol) == 0 {\n\t\treturn nil, perrors.Errorf(\"Must provide protocol in RemoteConfig.\")\n\t}\n\treturn common.NewURL(rc.Address,\n\t\tcommon.WithProtocol(rc.Protocol),\n\t\tcommon.WithUsername(rc.Username),\n\t\tcommon.WithPassword(rc.Password),\n\t\tcommon.WithLocation(rc.Address),\n\t\tcommon.WithParams(rc.getUrlMap()),\n\t)\n}", "func (m ExportImageViaObjectStorageURIDetails) MarshalJSON() ([]byte, error) {\n\tvar data struct {\n\t\tDestinationType string `json:\"destinationType\"`\n\n\t\t// The Object Storage Service URL to export the image to. See [Object Storage URLs](/Content/Compute/Tasks/imageimportexport.htm#URLs)\n\t\t// and [pre-authenticated requests](/Content/Object/Tasks/managingaccess.htm#pre-auth) for constructing URLs for image import/export.\n\t\t//\n\t\t// Required: true\n\t\tDestinationURI *string `json:\"destinationUri\"`\n\t}\n\n\tdata.DestinationURI = m.DestinationURI\n\tdata.DestinationType = DiscriminatorTypeValues[\"ExportImageViaObjectStorageUriDetails\"]\n\treturn json.Marshal(data)\n}", "func fmtURL(s string) string {\n\treturn baseURL + \"/item/\" + s + \".json?print=pretty\"\n}", "func (k *Key) URL() string {\n\treturn k.url.String()\n}", "func (o PacketMirroringMirroredResourceInfoSubnetInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringMirroredResourceInfoSubnetInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func (f *FastURL) Encode(b []byte) []byte {\n\tif len(f.protocol) > 0 {\n\t\tb = append(b, f.protocol...)\n\t\tb = append(b, ':')\n\t}\n\n\tvar appendslash bool\n\tif len(f.user) > 0 || len(f.pass) > 0 {\n\t\tb = append(b, \"//\"...)\n\t\tappendslash = true\n\t\tb = append(b, f.user...)\n\t\tb = append(b, ':')\n\t\tb = append(b, f.pass...)\n\t\tb = append(b, '@')\n\t}\n\n\tif len(f.hostname) > 0 {\n\t\tif !appendslash {\n\t\t\tb = append(b, \"//\"...)\n\t\t\tappendslash = true\n\t\t}\n\t\tb = append(b, f.hostname...)\n\t}\n\n\tif len(f.port) > 0 {\n\t\tif !appendslash {\n\t\t\tb = append(b, \"//\"...)\n\t\t\tappendslash = true\n\t\t}\n\t\tb = append(b, ':')\n\t\tb = append(b, f.port...)\n\t}\n\n\tif len(f.pathname) > 0 {\n\t\tb = append(b, f.pathname...)\n\t}\n\n\tif f.query.Len() > 0 {\n\t\tb = append(b, '?')\n\t\tb = f.query.Encode(b)\n\t}\n\n\tif len(f.hash) > 0 {\n\t\tb = append(b, f.hash...)\n\t}\n\n\treturn b\n}", "func (o PacketMirroringNetworkInfoOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PacketMirroringNetworkInfo) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (o WebhookOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Webhook) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func ToURL(s string) string {\n\ts = strings.Trim(s, \" \")\n\ts = strings.ReplaceAll(s, \" \", \"%20\")\n\treturn s\n}", "func (d *DeepLink) Encode() (string, error) {\n\tsrc, err := rlp.EncodeToBytes(d)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn base64.RawURLEncoding.EncodeToString(src), nil\n}", "func (req JourneyRequest) toURL() (url.Values, error) {\n\tparams := url.Values{}\n\n\t// Define a few useful functions\n\taddUint := func(key string, amount uint64) {\n\t\tif amount != 0 {\n\t\t\tstr := strconv.FormatUint(amount, 10)\n\t\t\tparams.Add(key, str)\n\t\t}\n\t}\n\taddInt := func(key string, amount int64) {\n\t\tif amount != 0 {\n\t\t\tstr := strconv.FormatInt(amount, 10)\n\t\t\tparams.Add(key, str)\n\t\t}\n\t}\n\taddString := func(key string, str string) {\n\t\tif str != \"\" {\n\t\t\tparams.Add(key, str)\n\t\t}\n\t}\n\taddIDSlice := func(key string, ids []types.ID) {\n\t\tif len(ids) != 0 {\n\t\t\tfor _, id := range ids {\n\t\t\t\tparams.Add(key, string(id))\n\t\t\t}\n\t\t}\n\t}\n\taddModes := func(key string, modes []string) {\n\t\tif len(modes) != 0 {\n\t\t\tfor _, mode := range modes {\n\t\t\t\tparams.Add(key, mode)\n\t\t\t}\n\t\t}\n\t}\n\taddFloat := func(key string, amount float64) {\n\t\tif amount != 0 {\n\t\t\tspeedStr := strconv.FormatFloat(amount, 'f', 3, 64)\n\t\t\tparams.Add(key, speedStr)\n\t\t}\n\t}\n\n\t// Encode the from and to\n\tif from := req.From; from != \"\" {\n\t\tparams.Add(\"from\", string(from))\n\t}\n\tif to := req.To; to != \"\" {\n\t\tparams.Add(\"to\", string(to))\n\t}\n\n\tif datetime := req.Date; !datetime.IsZero() {\n\t\tstr := datetime.Format(types.DateTimeFormat)\n\t\tparams.Add(\"datetime\", str)\n\t\tif req.DateIsArrival {\n\t\t\tparams.Add(\"datetime_represents\", \"arrival\")\n\t\t}\n\t}\n\n\taddString(\"traveler_type\", string(req.Traveler))\n\n\taddString(\"data_freshness\", string(req.Freshness))\n\n\taddIDSlice(\"forbidden_uris[]\", req.Forbidden)\n\n\taddIDSlice(\"allowed_id[]\", req.Allowed)\n\n\taddModes(\"first_section_mode[]\", req.FirstSectionModes)\n\n\taddModes(\"last_section_mode[]\", req.LastSectionModes)\n\n\t// max_duration_to_pt\n\taddInt(\"max_duration_to_pt\", int64(req.MaxDurationToPT/time.Second))\n\n\t// walking_speed, bike_speed, bss_speed & car_speed\n\taddFloat(\"walking_speed\", req.WalkingSpeed)\n\taddFloat(\"bike_speed\", req.BikeSpeed)\n\taddFloat(\"bss_speed\", req.BikeShareSpeed)\n\taddFloat(\"car_speed\", req.CarSpeed)\n\n\t// If count is defined don't bother with the minimimal and maximum amount of items to return\n\tif count := req.Count; count != 0 {\n\t\taddUint(\"count\", uint64(count))\n\t} else {\n\t\taddUint(\"min_nb_journeys\", uint64(req.MinJourneys))\n\t\taddUint(\"max_nb_journeys\", uint64(req.MaxJourneys))\n\t}\n\n\t// max_nb_transfers\n\taddUint(\"max_nb_transfers\", uint64(req.MaxTransfers))\n\n\t// max_duration\n\taddInt(\"max_duration\", int64(req.MaxDuration/time.Second))\n\n\t// wheelchair\n\tif req.Wheelchair {\n\t\tparams.Add(\"wheelchair\", \"true\")\n\t}\n\n\treturn params, nil\n}", "func (o PacketMirroringForwardingRuleInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringForwardingRuleInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func (s UrlReference) String() string {\n\treturn awsutil.Prettify(s)\n}", "func urlHandler(w http.ResponseWriter, r *http.Request) {\n if !customChannelSet {\n clientUrl = uniuri.NewLen(5)\n }\n customChannelSet = false\n clientUrlJSON, _ := json.Marshal(clientUrl)\n\n fmt.Println(\"Sending custom URL:\", clientUrl)\n w.Header().Set(\"Content-Type\", \"application/json\")\n w.WriteHeader(200)\n fmt.Fprintf(w, \"%s\", clientUrlJSON)\n}", "func urlQueryToString(options interface{}) (string, error) {\n\tv, err := query.Values(options)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn v.Encode(), nil\n}", "func (o ReleaseLinkOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ReleaseLink) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func URL(r *http.Request, data interface{}) error {\n\tq := r.URL.Query()\n\tv := reflect.ValueOf(data)\n\tt := v.Elem().Type()\n\tfor i := 0; i < v.Elem().NumField(); i++ {\n\t\tft := t.Field(i)\n\t\tfv := v.Elem().Field(i)\n\t\tif tv, exist := ft.Tag.Lookup(paramTag); exist {\n\t\t\tval := fmt.Sprintf(\"%v\", fv)\n\t\t\tif !(len(val) == 0 && strings.Contains(tv, omitEmpty)) {\n\t\t\t\tq.Add(strings.SplitN(tv, \",\", 2)[0], val)\n\t\t\t}\n\t\t}\n\t}\n\tr.URL.RawQuery = q.Encode()\n\treturn nil\n}", "func (s HttpUrlDestinationProperties) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o *Domainnetworkroute) String() string {\n \n \n \n \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func UrlEncode(str string) string {\r\n\ts := url.QueryEscape(str)\r\n\treturn s\r\n}", "func (list *LinkList) toJSON() string {\n\t// @TODO Get a module for this\n\treturn \"\"\n}", "func (o *GetAssetOperationsListURL) String() string {\n\treturn o.Must(o.Build()).String()\n}", "func (r *request) String() string {\n\tvar url string\n\n\tswitch {\n\tcase r.accountID != \"\":\n\t\turl += \"&sdr_o=\" + encode(r.accountID)\n\t\tfallthrough\n\tcase r.accountName != \"\":\n\t\turl += \"&sdr_odn=\" + encode(r.accountName)\n\t\tfallthrough\n\tcase r.userName != \"\":\n\t\turl += \"&sdr_u=\" + encode(r.userName)\n\t\tfallthrough\n\tcase r.activity != \"\":\n\t\turl += \"&sdr_a=\" + encode(r.activity)\n\t\tfallthrough\n\tcase r.module != \"\":\n\t\turl += \"&sdr_m=\" + encode(r.module)\n\t\tfallthrough\n\tcase len(r.attributes) > 0:\n\t\tfor name, val := range r.attributes {\n\t\t\turl += \"&sdr_o.\" + encode(name) + \"=\" + encode(val)\n\t\t}\n\t}\n\n\treturn url\n}", "func (s InstanceAssociationOutputUrl) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o ApiContactOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApiContact) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (s CreateUploadUrlOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o TimelineOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Timeline) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (i *instance) url() string {\n\treturn i.apiURL\n}", "func (o GroupContainerVolumeGitRepoOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GroupContainerVolumeGitRepo) string { return v.Url }).(pulumi.StringOutput)\n}", "func (o *MockOrderer) URL() string {\n\treturn o.OrdererURL\n}", "func (o BuildSpecSourceOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BuildSpecSource) string { return v.Url }).(pulumi.StringOutput)\n}", "func (o CatalogOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Catalog) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (s GetQueueUrlOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o *MockGrpcOrderer) URL() string {\n\treturn o.OrdererURL\n}", "func (w *KeystoreWallet) URL() accounts.URL {\n\treturn w.Account.URL\n}", "func (s GetQueueUrlInput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (a Asset) String() (result string, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tmsg := fmt.Sprintf(\"failed to build URL: %v\", r)\n\t\t\ta.logger.Error(msg)\n\t\t\tresult = \"\"\n\t\t\terr = errors.New(msg)\n\t\t}\n\t}()\n\n\tassetURL := joinUrl([]interface{}{a.distribution(), a.assetType(), a.signature(), a.Transformation, a.version(), a.source()})\n\tquery := a.query()\n\n\treturn joinNonEmpty([]interface{}{assetURL, query}, \"?\"), nil\n}", "func (s ServiceInfo) Url() string {\n\turl := fmt.Sprintf(\"%s://%s:%v\", DefaultHttpProtocol, s.Host, s.Port)\n\treturn url\n}", "func (f *FileBlob) Url() *url.URL {\n\treturn f.url\n}", "func (s CreateUploadUrlInput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (this *DynMap) urlEncode(vals *url.Values, key string, value interface{}) error {\n\n\tif DynMapConvertable(value) {\n\t\tmp, ok := ToDynMap(value)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Unable to convert %s\", mp)\n\t\t}\n\t\tfor k, v := range mp.Map {\n\t\t\t//encode in rails style key[key2]=value\n\t\t\tthis.urlEncode(vals, fmt.Sprintf(\"%s[%s]\", key, k), v)\n\t\t}\n\t\treturn nil\n\t}\n\tr := reflect.ValueOf(value)\n\t//now test if it is an array\n\tif r.Kind() == reflect.Array || r.Kind() == reflect.Slice {\n\t\tfor i :=0; i < r.Len(); i++ {\n\t\t\tthis.urlEncode(vals, key, r.Index(i).Interface())\n\t\t}\n\t}\n\n\tvals.Add(key, ToString(value))\n\treturn nil\n}", "func (o StudioOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Studio) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (ep *Endpoint) URL() (string, error) {\n\tbaseURL, err := deploys.GetDownloadURL(ep.Version)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn baseURL + \"/\" + ep.Resource + \".json\", nil\n}", "func (v UrlResolve) MarshalJSON() ([]byte, error) {\n\tw := jwriter.Writer{}\n\teasyjsonD3b49167EncodeContentApiModelUrlV2(&w, v)\n\treturn w.Buffer.BuildBytes(), w.Error\n}", "func URL(url *url.URL) zapcore.Field {\n\treturn zap.Object(\"url\", &URLField{URL: url})\n}", "func (o ApplicationSpecRolloutplanRolloutbatchesBatchrolloutwebhooksOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ApplicationSpecRolloutplanRolloutbatchesBatchrolloutwebhooks) string { return v.Url }).(pulumi.StringOutput)\n}", "func (u URI) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(string(u))\n}", "func Serialize(val interface{}) (string, error) {\n\tb := bytes.Buffer{}\n\terr := gob.NewEncoder(&b).Encode(val)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn base64.StdEncoding.EncodeToString(b.Bytes()), nil\n}", "func (url NodeURL) String() string {\n\tif url.ID.IsZero() {\n\t\treturn url.Address\n\t}\n\treturn url.ID.String() + \"@\" + url.Address\n}", "func (v UrlResolve) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD3b49167EncodeContentApiModelUrlV2(w, v)\n}", "func (c *Client) Url(method string, e ...Endpoint) Modifier {\n\t// TODO Create composite URLs? Add().Add().. etc? Easier to modify on the fly..\n\treturn func(r *http.Request) error {\n\t\tu := c.createURL(e...)\n\t\tr.URL = u\n\t\tr.Method = method\n\t\treturn nil\n\t}\n}" ]
[ "0.6716807", "0.63441896", "0.62649", "0.6165139", "0.6015502", "0.5903639", "0.58992463", "0.58314365", "0.5798447", "0.57529104", "0.57151", "0.57116693", "0.56682795", "0.5641105", "0.56274664", "0.5583831", "0.55663586", "0.55209136", "0.550381", "0.55001384", "0.54861057", "0.5469027", "0.5460085", "0.5455559", "0.5447391", "0.54322845", "0.5420147", "0.54103315", "0.5394661", "0.53914255", "0.5369494", "0.53679895", "0.53126496", "0.52997166", "0.52972853", "0.52968264", "0.5292468", "0.5286228", "0.52787954", "0.52754927", "0.52618915", "0.5247635", "0.5245437", "0.52439773", "0.5243976", "0.52403575", "0.52360487", "0.5227389", "0.5222718", "0.52119005", "0.5210828", "0.5210715", "0.5206587", "0.52009356", "0.51752", "0.5168872", "0.516803", "0.51666635", "0.51639384", "0.51577765", "0.5157678", "0.5157636", "0.5147956", "0.51372343", "0.5133378", "0.5131772", "0.51229316", "0.5121261", "0.5115405", "0.5110181", "0.5108106", "0.51063335", "0.510361", "0.50953484", "0.50945646", "0.50934684", "0.5088579", "0.50861686", "0.50843644", "0.50804794", "0.5075893", "0.50664705", "0.5066386", "0.5059012", "0.50572675", "0.50533557", "0.50426364", "0.5039985", "0.50353104", "0.5033215", "0.5029522", "0.5026773", "0.5023433", "0.5019173", "0.5017847", "0.50178", "0.501668", "0.50163454", "0.49971086", "0.4994149" ]
0.7404325
0
SerializeUrl implements the required interface
func (r ReqHeadlines) SerializeUrl() string { return r.baseUrl + "top-headlines?category=" + r.category + "&pageSize=" + strconv.Itoa(r.pageSize) + "&country=" + r.country }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r ReqArticles) SerializeUrl() string {\n\treturn r.baseUrl + \"everything?q=\" + r.q\n}", "func (m *InformationalUrl) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"logoUrl\", m.GetLogoUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"marketingUrl\", m.GetMarketingUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"privacyStatementUrl\", m.GetPrivacyStatementUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"supportUrl\", m.GetSupportUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"termsOfServiceUrl\", m.GetTermsOfServiceUrl())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func (moo *JsonApiUrl) String() string {\n\tvar u *url.URL\n\tvar err error\n\n\tassert.NotEmpty(moo.T, moo.BaseUrl, \"error generating a JsonAPI URL from %v: %s\", moo, \"base url must not be empty\")\n\tassert.NotEmpty(moo.T, moo.DrupalEntity, \"error generating a JsonAPI URL from %v: %s\", moo, \"drupal entity must not be empty\")\n\tassert.NotEmpty(moo.T, moo.DrupalBundle, \"error generating a JsonAPI URL from %v: %s\", moo, \"drupal bundle must not be empty\")\n\n\tbaseUrl := env.BaseUrlOr(moo.BaseUrl)\n\tif strings.HasSuffix(baseUrl, \"/\") {\n\t\tbaseUrl = baseUrl[:len(baseUrl) - 1]\n\t}\n\tu, err = url.Parse(fmt.Sprintf(\"%s\", strings.Join([]string{baseUrl, \"jsonapi\", moo.DrupalEntity, moo.DrupalBundle}, \"/\")))\n\tassert.Nil(moo.T, err, \"error generating a JsonAPI URL from %v: %s\", moo, err)\n\n\t// If a raw filter is supplied, use it as-is, otherwise use the .Filter and .Value\n\tif moo.RawFilter != \"\" {\n\t\tu, err = url.Parse(fmt.Sprintf(\"%s?%s\", u.String(), moo.RawFilter))\n\t} else if moo.Filter != \"\" {\n\t\tu, err = url.Parse(fmt.Sprintf(\"%s?filter[%s]=%s\", u.String(), moo.Filter, moo.Value))\n\t}\n\n\tassert.Nil(moo.T, err, \"error generating a JsonAPI URL from %v: %s\", moo, err)\n\treturn u.String()\n}", "func (group *Group) ToURL() string {\n\treturn toURL(group.endpoint, group.modifiers)\n}", "func Marshal(v interface{}) (s string) {\n\tu := &url.URL{}\n\tuVal := &url.Values{}\n\tvStruct := reflect.ValueOf(v)\n\tif vStruct.Kind() == reflect.Ptr {\n\t\tif vStruct.IsNil() {\n\t\t\tvStruct = reflect.New(vStruct.Type().Elem())\n\t\t}\n\t\tvStruct = vStruct.Elem()\n\t}\n\n\tparseStruct(u, uVal, vStruct)\n\n\t// Note: url values are sorted by string value as they are encoded\n\tu.RawQuery = uVal.Encode()\n\treturn u.String()\n}", "func (fu FileURL) ToString() string {\n\treturn fu.urlStr\n}", "func (o BlobOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Blob) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (u URL) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(u.URL().String())\n}", "func (o BackendProxyOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BackendProxy) string { return v.Url }).(pulumi.StringOutput)\n}", "func (_this *URL) ToString() string {\n\treturn _this.Href()\n}", "func genObjURL(isSecure, isXML bool) (s string) {\n\tif isSecure || !isXML { // Using JSON requires HTTPS: \"SSL is required to perform this operation.\"\n\t\ts = \"https://\"\n\t} else {\n\t\ts = \"http://\"\n\t}\n\tif isXML {\n\t\ts += fmt.Sprintf(\"storage.googleapis.com/%s/%s\", gcsBck, gcsObjXML)\n\t} else {\n\t\t// Reformat object name from XML to JSON API requirements.\n\t\tgcsObjJSON := strings.ReplaceAll(gcsObjXML, \"/\", \"%2F\")\n\t\ts += fmt.Sprintf(\"www.googleapis.com/storage/v1/b/%s/o/%s?alt=media\", gcsBck, gcsObjJSON)\n\t}\n\treturn s\n}", "func (this *DynMap) MarshalURL() (string, error) {\n\tvals := &url.Values{}\n\tfor key, value := range this.Map {\n\t\terr := this.urlEncode(vals, key, value)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\tstr := vals.Encode()\n\tlog.Printf(str)\n\treturn vals.Encode(), nil\n}", "func (v *Visualisation) URL(vo *VisualisationURLOptions) *url.URL {\n\tu, err := url.Parse(v.c.apiURL + \"/visualisation\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tvalues := u.Query()\n\tvalues.Set(\"k\", v.Key)\n\tif vo != nil {\n\t\tif vo.Names != nil {\n\t\t\tfor _, n := range vo.Names {\n\t\t\t\tvalues.Add(\"name\", n)\n\t\t\t}\n\t\t}\n\t\tif vo.Avatars != nil {\n\t\t\tfor _, a := range vo.Avatars {\n\t\t\t\tvalues.Add(\"avatar\", a)\n\t\t\t}\n\t\t}\n\t\tif vo.AvatarBaseURL != \"\" {\n\t\t\tvalues.Set(\"avatarBaseUrl\", vo.AvatarBaseURL)\n\t\t}\n\t\tif !vo.FixedAspect {\n\t\t\tvalues.Set(\"fixedAspect\", \"false\")\n\t\t}\n\t\tif vo.MinimalView {\n\t\t\tvalues.Set(\"minimalView\", \"true\")\n\t\t}\n\t\tif vo.DZML != \"\" {\n\t\t\tvalues.Set(\"dzml\", vo.DZML)\n\t\t}\n\t}\n\tu.RawQuery = values.Encode()\n\treturn u\n}", "func (o NodeDriverOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *NodeDriver) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (o *Object) String() string {\n\treturn o.URL.String()\n}", "func (o *Object) url() string {\n\treturn o.fs.url(o.remote)\n}", "func (o ContainerOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Container) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (s S3OutputUrl) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (u *URL) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(u.String())\n}", "func (u URL) MarshalJSON() ([]byte, error) {\n\tif u.URL == nil {\n\t\treturn json.Marshal(nil)\n\t}\n\n\treturn json.Marshal(u.URL.String())\n}", "func (o BucketOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Bucket) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (e *Encoder) Encode(v interface{}) (values url.Values, err error) {\n\n\tval, kind := ExtractType(reflect.ValueOf(v))\n\n\tif kind == reflect.Ptr || kind == reflect.Interface || kind == reflect.Invalid {\n\t\treturn nil, &InvalidEncodeError{reflect.TypeOf(v)}\n\t}\n\n\tenc := e.dataPool.Get().(*encoder)\n\tenc.values = make(url.Values)\n\n\tif kind == reflect.Struct && val.Type() != timeType {\n\t\tenc.traverseStruct(val, enc.namespace[0:0], -1)\n\t} else {\n\t\tenc.setFieldByType(val, enc.namespace[0:0], -1, false)\n\t}\n\n\tif len(enc.errs) > 0 {\n\t\terr = enc.errs\n\t\tenc.errs = nil\n\t}\n\n\tvalues = enc.values\n\n\te.dataPool.Put(enc)\n\n\treturn\n}", "func encode(value string) string {\n\tencode := &url.URL{Path: value}\n\treturn encode.String()\n}", "func (o *EventCollectionURL) String() string {\n\treturn o.Must(o.Build()).String()\n}", "func (object Object) URL(value interface{}) Object {\n\treturn object.Property(as.PropertyURL, value)\n}", "func (o SnapshotImportDiskContainerOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v SnapshotImportDiskContainer) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (me TURLType) String() string { return xsdt.AnyURI(me).String() }", "func (u *URLValue) String() string {\n\turl := url.URL(*u)\n\n\treturn fmt.Sprintf(\"%v\", url.String())\n}", "func (m *EmailUrlThreatSubmission) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.EmailThreatSubmission.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"messageUrl\", m.GetMessageUrl())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func (o PacketMirroringNetworkInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringNetworkInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func (h *Host) ToURL() string {\n\treturn fmt.Sprintf(\"%s:%d\", h.Address, h.Port)\n}", "func (url URL) String() string {\n\treturn string(url)\n}", "func (e *Endpoint) URL() string {\n\treturn e.url\n}", "func (o PacketMirroringMirroredResourceInfoInstanceInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringMirroredResourceInfoInstanceInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func (w *Worker) Url(path string, params url.Values) string {\n\t// random choice one host for load balance\n\ti := rand.Intn(len(w.ctx.addrs))\n\taddr := w.ctx.addrs[i]\n\ts := fmt.Sprintf(\"http://%s%s\", addr, path)\n\tif params == nil {\n\t\treturn s\n\t}\n\tp := params.Encode()\n\treturn fmt.Sprintf(\"%s?%s\", s, p)\n}", "func (o ApiLicenseOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApiLicense) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (self *AbtabURL) String() string {\n\treturn fmt.Sprintf(\"AbtabURL{OriginalUrl=%s; Scheme=%s; Host=%s; User=%s; Path=%s; Query=%s}\",\n\t\tself.OriginalUrl,\n\t\tself.Url.Scheme,\n\t\tself.Url.Host,\n\t\tself.Url.User,\n\t\tself.Url.Path,\n\t\tself.Url.RawQuery,\n\t)\n}", "func Encode(u *url.URL) string {\n\treturn base64.URLEncoding.EncodeToString([]byte(u.RequestURI()))\n}", "func (p *PackageURL) ToString() string {\n\t// Start with the type and a colon\n\tpurl := fmt.Sprintf(\"pkg:%s/\", p.Type)\n\t// Add namespaces if provided\n\tif p.Namespace != \"\" {\n\t\tvar ns []string\n\t\tfor _, item := range strings.Split(p.Namespace, \"/\") {\n\t\t\tns = append(ns, url.QueryEscape(item))\n\t\t}\n\t\tpurl = purl + strings.Join(ns, \"/\") + \"/\"\n\t}\n\t// The name is always required and must be a percent-encoded string\n\t// Use url.QueryEscape instead of PathEscape, as it handles @ signs\n\tpurl = purl + url.QueryEscape(p.Name)\n\t// If a version is provided, add it after the at symbol\n\tif p.Version != \"\" {\n\t\t// A name must be a percent-encoded string\n\t\tpurl = purl + \"@\" + url.PathEscape(p.Version)\n\t}\n\n\t// Iterate over qualifiers and make groups of key=value\n\tvar qualifiers []string\n\tfor _, q := range p.Qualifiers {\n\t\tqualifiers = append(qualifiers, q.String())\n\t}\n\t// If there are one or more key=value pairs, append on the package url\n\tif len(qualifiers) != 0 {\n\t\tpurl = purl + \"?\" + strings.Join(qualifiers, \"&\")\n\t}\n\t// Add a subpath if available\n\tif p.Subpath != \"\" {\n\t\tpurl = purl + \"#\" + p.Subpath\n\t}\n\treturn purl\n}", "func (o CustomPagesOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *CustomPages) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (output AmazonS3URL) String() string {\n\treturn fmt.Sprintf(\"{Region: %s; Bucket: %s; Key: %s; IsValidS3URI: %v; IsPathStyle: %v}\",\n\t\toutput.Region, output.Bucket, output.Key, output.IsValidS3URI, output.IsPathStyle)\n}", "func (o *GetMoveHistoryURL) String() string {\n\treturn o.Must(o.Build()).String()\n}", "func EncodeURL(api string, params RequestQueries) (string, error) {\n\turl, err := url.Parse(api)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tquery := url.Query()\n\n\tfor k, v := range params {\n\t\tquery.Set(k, v)\n\t}\n\n\turl.RawQuery = query.Encode()\n\n\treturn url.String(), nil\n}", "func (lk *Link) String() string {\n\tb, _ := json.Marshal(lk)\n\treturn \"vmess://\" + base64.Encode(string(b))\n}", "func (i *urls) String() string {\n\treturn fmt.Sprint(*i)\n}", "func (o ContainerServiceOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ContainerService) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (t *Target) URL() *url.URL {\n\tparams := url.Values{}\n\n\tfor k, v := range t.params {\n\t\tparams[k] = make([]string, len(v))\n\t\tcopy(params[k], v)\n\t}\n\tt.labels.Range(func(l labels.Label) {\n\t\tif !strings.HasPrefix(l.Name, model.ParamLabelPrefix) {\n\t\t\treturn\n\t\t}\n\t\tks := l.Name[len(model.ParamLabelPrefix):]\n\n\t\tif len(params[ks]) > 0 {\n\t\t\tparams[ks][0] = l.Value\n\t\t} else {\n\t\t\tparams[ks] = []string{l.Value}\n\t\t}\n\t})\n\n\treturn &url.URL{\n\t\tScheme: t.labels.Get(model.SchemeLabel),\n\t\tHost: t.labels.Get(model.AddressLabel),\n\t\tPath: t.labels.Get(model.MetricsPathLabel),\n\t\tRawQuery: params.Encode(),\n\t}\n}", "func (s PresignedUrlConfig) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o FluxConfigurationBucketOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v FluxConfigurationBucket) string { return v.Url }).(pulumi.StringOutput)\n}", "func (rc *RemoteConfig) ToURL() (*common.URL, error) {\n\tif len(rc.Protocol) == 0 {\n\t\treturn nil, perrors.Errorf(\"Must provide protocol in RemoteConfig.\")\n\t}\n\treturn common.NewURL(rc.Address,\n\t\tcommon.WithProtocol(rc.Protocol),\n\t\tcommon.WithUsername(rc.Username),\n\t\tcommon.WithPassword(rc.Password),\n\t\tcommon.WithLocation(rc.Address),\n\t\tcommon.WithParams(rc.getUrlMap()),\n\t)\n}", "func fmtURL(s string) string {\n\treturn baseURL + \"/item/\" + s + \".json?print=pretty\"\n}", "func (m ExportImageViaObjectStorageURIDetails) MarshalJSON() ([]byte, error) {\n\tvar data struct {\n\t\tDestinationType string `json:\"destinationType\"`\n\n\t\t// The Object Storage Service URL to export the image to. See [Object Storage URLs](/Content/Compute/Tasks/imageimportexport.htm#URLs)\n\t\t// and [pre-authenticated requests](/Content/Object/Tasks/managingaccess.htm#pre-auth) for constructing URLs for image import/export.\n\t\t//\n\t\t// Required: true\n\t\tDestinationURI *string `json:\"destinationUri\"`\n\t}\n\n\tdata.DestinationURI = m.DestinationURI\n\tdata.DestinationType = DiscriminatorTypeValues[\"ExportImageViaObjectStorageUriDetails\"]\n\treturn json.Marshal(data)\n}", "func (k *Key) URL() string {\n\treturn k.url.String()\n}", "func (o PacketMirroringMirroredResourceInfoSubnetInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringMirroredResourceInfoSubnetInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func (f *FastURL) Encode(b []byte) []byte {\n\tif len(f.protocol) > 0 {\n\t\tb = append(b, f.protocol...)\n\t\tb = append(b, ':')\n\t}\n\n\tvar appendslash bool\n\tif len(f.user) > 0 || len(f.pass) > 0 {\n\t\tb = append(b, \"//\"...)\n\t\tappendslash = true\n\t\tb = append(b, f.user...)\n\t\tb = append(b, ':')\n\t\tb = append(b, f.pass...)\n\t\tb = append(b, '@')\n\t}\n\n\tif len(f.hostname) > 0 {\n\t\tif !appendslash {\n\t\t\tb = append(b, \"//\"...)\n\t\t\tappendslash = true\n\t\t}\n\t\tb = append(b, f.hostname...)\n\t}\n\n\tif len(f.port) > 0 {\n\t\tif !appendslash {\n\t\t\tb = append(b, \"//\"...)\n\t\t\tappendslash = true\n\t\t}\n\t\tb = append(b, ':')\n\t\tb = append(b, f.port...)\n\t}\n\n\tif len(f.pathname) > 0 {\n\t\tb = append(b, f.pathname...)\n\t}\n\n\tif f.query.Len() > 0 {\n\t\tb = append(b, '?')\n\t\tb = f.query.Encode(b)\n\t}\n\n\tif len(f.hash) > 0 {\n\t\tb = append(b, f.hash...)\n\t}\n\n\treturn b\n}", "func (o PacketMirroringNetworkInfoOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PacketMirroringNetworkInfo) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (o WebhookOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Webhook) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func ToURL(s string) string {\n\ts = strings.Trim(s, \" \")\n\ts = strings.ReplaceAll(s, \" \", \"%20\")\n\treturn s\n}", "func (d *DeepLink) Encode() (string, error) {\n\tsrc, err := rlp.EncodeToBytes(d)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn base64.RawURLEncoding.EncodeToString(src), nil\n}", "func (s UrlReference) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (req JourneyRequest) toURL() (url.Values, error) {\n\tparams := url.Values{}\n\n\t// Define a few useful functions\n\taddUint := func(key string, amount uint64) {\n\t\tif amount != 0 {\n\t\t\tstr := strconv.FormatUint(amount, 10)\n\t\t\tparams.Add(key, str)\n\t\t}\n\t}\n\taddInt := func(key string, amount int64) {\n\t\tif amount != 0 {\n\t\t\tstr := strconv.FormatInt(amount, 10)\n\t\t\tparams.Add(key, str)\n\t\t}\n\t}\n\taddString := func(key string, str string) {\n\t\tif str != \"\" {\n\t\t\tparams.Add(key, str)\n\t\t}\n\t}\n\taddIDSlice := func(key string, ids []types.ID) {\n\t\tif len(ids) != 0 {\n\t\t\tfor _, id := range ids {\n\t\t\t\tparams.Add(key, string(id))\n\t\t\t}\n\t\t}\n\t}\n\taddModes := func(key string, modes []string) {\n\t\tif len(modes) != 0 {\n\t\t\tfor _, mode := range modes {\n\t\t\t\tparams.Add(key, mode)\n\t\t\t}\n\t\t}\n\t}\n\taddFloat := func(key string, amount float64) {\n\t\tif amount != 0 {\n\t\t\tspeedStr := strconv.FormatFloat(amount, 'f', 3, 64)\n\t\t\tparams.Add(key, speedStr)\n\t\t}\n\t}\n\n\t// Encode the from and to\n\tif from := req.From; from != \"\" {\n\t\tparams.Add(\"from\", string(from))\n\t}\n\tif to := req.To; to != \"\" {\n\t\tparams.Add(\"to\", string(to))\n\t}\n\n\tif datetime := req.Date; !datetime.IsZero() {\n\t\tstr := datetime.Format(types.DateTimeFormat)\n\t\tparams.Add(\"datetime\", str)\n\t\tif req.DateIsArrival {\n\t\t\tparams.Add(\"datetime_represents\", \"arrival\")\n\t\t}\n\t}\n\n\taddString(\"traveler_type\", string(req.Traveler))\n\n\taddString(\"data_freshness\", string(req.Freshness))\n\n\taddIDSlice(\"forbidden_uris[]\", req.Forbidden)\n\n\taddIDSlice(\"allowed_id[]\", req.Allowed)\n\n\taddModes(\"first_section_mode[]\", req.FirstSectionModes)\n\n\taddModes(\"last_section_mode[]\", req.LastSectionModes)\n\n\t// max_duration_to_pt\n\taddInt(\"max_duration_to_pt\", int64(req.MaxDurationToPT/time.Second))\n\n\t// walking_speed, bike_speed, bss_speed & car_speed\n\taddFloat(\"walking_speed\", req.WalkingSpeed)\n\taddFloat(\"bike_speed\", req.BikeSpeed)\n\taddFloat(\"bss_speed\", req.BikeShareSpeed)\n\taddFloat(\"car_speed\", req.CarSpeed)\n\n\t// If count is defined don't bother with the minimimal and maximum amount of items to return\n\tif count := req.Count; count != 0 {\n\t\taddUint(\"count\", uint64(count))\n\t} else {\n\t\taddUint(\"min_nb_journeys\", uint64(req.MinJourneys))\n\t\taddUint(\"max_nb_journeys\", uint64(req.MaxJourneys))\n\t}\n\n\t// max_nb_transfers\n\taddUint(\"max_nb_transfers\", uint64(req.MaxTransfers))\n\n\t// max_duration\n\taddInt(\"max_duration\", int64(req.MaxDuration/time.Second))\n\n\t// wheelchair\n\tif req.Wheelchair {\n\t\tparams.Add(\"wheelchair\", \"true\")\n\t}\n\n\treturn params, nil\n}", "func (o PacketMirroringForwardingRuleInfoResponseOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v PacketMirroringForwardingRuleInfoResponse) string { return v.Url }).(pulumi.StringOutput)\n}", "func urlHandler(w http.ResponseWriter, r *http.Request) {\n if !customChannelSet {\n clientUrl = uniuri.NewLen(5)\n }\n customChannelSet = false\n clientUrlJSON, _ := json.Marshal(clientUrl)\n\n fmt.Println(\"Sending custom URL:\", clientUrl)\n w.Header().Set(\"Content-Type\", \"application/json\")\n w.WriteHeader(200)\n fmt.Fprintf(w, \"%s\", clientUrlJSON)\n}", "func urlQueryToString(options interface{}) (string, error) {\n\tv, err := query.Values(options)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn v.Encode(), nil\n}", "func (o ReleaseLinkOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ReleaseLink) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func URL(r *http.Request, data interface{}) error {\n\tq := r.URL.Query()\n\tv := reflect.ValueOf(data)\n\tt := v.Elem().Type()\n\tfor i := 0; i < v.Elem().NumField(); i++ {\n\t\tft := t.Field(i)\n\t\tfv := v.Elem().Field(i)\n\t\tif tv, exist := ft.Tag.Lookup(paramTag); exist {\n\t\t\tval := fmt.Sprintf(\"%v\", fv)\n\t\t\tif !(len(val) == 0 && strings.Contains(tv, omitEmpty)) {\n\t\t\t\tq.Add(strings.SplitN(tv, \",\", 2)[0], val)\n\t\t\t}\n\t\t}\n\t}\n\tr.URL.RawQuery = q.Encode()\n\treturn nil\n}", "func (s HttpUrlDestinationProperties) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o *Domainnetworkroute) String() string {\n \n \n \n \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "func UrlEncode(str string) string {\r\n\ts := url.QueryEscape(str)\r\n\treturn s\r\n}", "func (list *LinkList) toJSON() string {\n\t// @TODO Get a module for this\n\treturn \"\"\n}", "func (o *GetAssetOperationsListURL) String() string {\n\treturn o.Must(o.Build()).String()\n}", "func (r *request) String() string {\n\tvar url string\n\n\tswitch {\n\tcase r.accountID != \"\":\n\t\turl += \"&sdr_o=\" + encode(r.accountID)\n\t\tfallthrough\n\tcase r.accountName != \"\":\n\t\turl += \"&sdr_odn=\" + encode(r.accountName)\n\t\tfallthrough\n\tcase r.userName != \"\":\n\t\turl += \"&sdr_u=\" + encode(r.userName)\n\t\tfallthrough\n\tcase r.activity != \"\":\n\t\turl += \"&sdr_a=\" + encode(r.activity)\n\t\tfallthrough\n\tcase r.module != \"\":\n\t\turl += \"&sdr_m=\" + encode(r.module)\n\t\tfallthrough\n\tcase len(r.attributes) > 0:\n\t\tfor name, val := range r.attributes {\n\t\t\turl += \"&sdr_o.\" + encode(name) + \"=\" + encode(val)\n\t\t}\n\t}\n\n\treturn url\n}", "func (s InstanceAssociationOutputUrl) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s CreateUploadUrlOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o ApiContactOutput) Url() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApiContact) *string { return v.Url }).(pulumi.StringPtrOutput)\n}", "func (o TimelineOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Timeline) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (i *instance) url() string {\n\treturn i.apiURL\n}", "func (o GroupContainerVolumeGitRepoOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GroupContainerVolumeGitRepo) string { return v.Url }).(pulumi.StringOutput)\n}", "func (o *MockOrderer) URL() string {\n\treturn o.OrdererURL\n}", "func (o BuildSpecSourceOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BuildSpecSource) string { return v.Url }).(pulumi.StringOutput)\n}", "func (o CatalogOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Catalog) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (s GetQueueUrlOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o *MockGrpcOrderer) URL() string {\n\treturn o.OrdererURL\n}", "func (w *KeystoreWallet) URL() accounts.URL {\n\treturn w.Account.URL\n}", "func (s GetQueueUrlInput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (a Asset) String() (result string, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tmsg := fmt.Sprintf(\"failed to build URL: %v\", r)\n\t\t\ta.logger.Error(msg)\n\t\t\tresult = \"\"\n\t\t\terr = errors.New(msg)\n\t\t}\n\t}()\n\n\tassetURL := joinUrl([]interface{}{a.distribution(), a.assetType(), a.signature(), a.Transformation, a.version(), a.source()})\n\tquery := a.query()\n\n\treturn joinNonEmpty([]interface{}{assetURL, query}, \"?\"), nil\n}", "func (s ServiceInfo) Url() string {\n\turl := fmt.Sprintf(\"%s://%s:%v\", DefaultHttpProtocol, s.Host, s.Port)\n\treturn url\n}", "func (f *FileBlob) Url() *url.URL {\n\treturn f.url\n}", "func (s CreateUploadUrlInput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (this *DynMap) urlEncode(vals *url.Values, key string, value interface{}) error {\n\n\tif DynMapConvertable(value) {\n\t\tmp, ok := ToDynMap(value)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Unable to convert %s\", mp)\n\t\t}\n\t\tfor k, v := range mp.Map {\n\t\t\t//encode in rails style key[key2]=value\n\t\t\tthis.urlEncode(vals, fmt.Sprintf(\"%s[%s]\", key, k), v)\n\t\t}\n\t\treturn nil\n\t}\n\tr := reflect.ValueOf(value)\n\t//now test if it is an array\n\tif r.Kind() == reflect.Array || r.Kind() == reflect.Slice {\n\t\tfor i :=0; i < r.Len(); i++ {\n\t\t\tthis.urlEncode(vals, key, r.Index(i).Interface())\n\t\t}\n\t}\n\n\tvals.Add(key, ToString(value))\n\treturn nil\n}", "func (o StudioOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Studio) pulumi.StringOutput { return v.Url }).(pulumi.StringOutput)\n}", "func (ep *Endpoint) URL() (string, error) {\n\tbaseURL, err := deploys.GetDownloadURL(ep.Version)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn baseURL + \"/\" + ep.Resource + \".json\", nil\n}", "func (v UrlResolve) MarshalJSON() ([]byte, error) {\n\tw := jwriter.Writer{}\n\teasyjsonD3b49167EncodeContentApiModelUrlV2(&w, v)\n\treturn w.Buffer.BuildBytes(), w.Error\n}", "func (u URI) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(string(u))\n}", "func URL(url *url.URL) zapcore.Field {\n\treturn zap.Object(\"url\", &URLField{URL: url})\n}", "func (o ApplicationSpecRolloutplanRolloutbatchesBatchrolloutwebhooksOutput) Url() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ApplicationSpecRolloutplanRolloutbatchesBatchrolloutwebhooks) string { return v.Url }).(pulumi.StringOutput)\n}", "func Serialize(val interface{}) (string, error) {\n\tb := bytes.Buffer{}\n\terr := gob.NewEncoder(&b).Encode(val)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn base64.StdEncoding.EncodeToString(b.Bytes()), nil\n}", "func (url NodeURL) String() string {\n\tif url.ID.IsZero() {\n\t\treturn url.Address\n\t}\n\treturn url.ID.String() + \"@\" + url.Address\n}", "func (v UrlResolve) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD3b49167EncodeContentApiModelUrlV2(w, v)\n}", "func (c *Client) Url(method string, e ...Endpoint) Modifier {\n\t// TODO Create composite URLs? Add().Add().. etc? Easier to modify on the fly..\n\treturn func(r *http.Request) error {\n\t\tu := c.createURL(e...)\n\t\tr.URL = u\n\t\tr.Method = method\n\t\treturn nil\n\t}\n}" ]
[ "0.7404191", "0.6716941", "0.63445586", "0.6165448", "0.60160846", "0.5903363", "0.589787", "0.5830765", "0.5797892", "0.57532245", "0.571518", "0.5711831", "0.5668135", "0.56397814", "0.5626903", "0.5581893", "0.5565815", "0.55203366", "0.5503169", "0.54993176", "0.54848033", "0.5469571", "0.5461246", "0.5456887", "0.5445935", "0.5431772", "0.54203606", "0.54102135", "0.5394584", "0.53906584", "0.5369961", "0.53679705", "0.5312194", "0.52989185", "0.5297443", "0.5295674", "0.5293192", "0.5287788", "0.5280032", "0.52744234", "0.5261624", "0.52479124", "0.5246755", "0.5244825", "0.5244624", "0.5239935", "0.5235557", "0.5228013", "0.5221468", "0.52115726", "0.5211237", "0.5210566", "0.52059335", "0.5200339", "0.51760304", "0.5168129", "0.5166946", "0.5166577", "0.5164844", "0.5158304", "0.5158031", "0.5156814", "0.5148718", "0.51388395", "0.5132773", "0.5131581", "0.51230997", "0.5122288", "0.5116939", "0.5109665", "0.5108061", "0.5106463", "0.5103126", "0.5094309", "0.50937206", "0.5093216", "0.5087792", "0.5085335", "0.50841653", "0.50796807", "0.5074789", "0.5066647", "0.5066318", "0.505772", "0.5057234", "0.5053715", "0.50428396", "0.5038124", "0.5034858", "0.50340825", "0.50294137", "0.50264406", "0.5023082", "0.5018132", "0.5017323", "0.5017079", "0.501677", "0.5016057", "0.49977913", "0.49938023" ]
0.6264516
3
GetArticles returns all the articles in given a request, a keyword can be anything
func (a *Api) GetArticles(keyword string) (*Response, error) { req := ReqArticles{baseUrl: a.baseUrl, q: keyword} return a.do(req) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetArticles(w http.ResponseWriter, r *http.Request) {\n\tarticles, err := dao.findAll()\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\trespondWithJSON(w, http.StatusOK, articles)\n}", "func (c *Client) GetArticles(since int) (*RetrieveResult, error) {\n\treq := RetrieveOption{\n\t\tSort: SortOldest,\n\t\tDetailType: \"complete\",\n\t\tContentType: \"article\",\n\t\tState: \"all\",\n\t\tAccessToken: c.authedUser.AccessToken,\n\t\tConsumerKey: c.consumerID,\n\t\tSince: since,\n\t}\n\n\tlog.Debugf(\"Params to send %+v\", req)\n\n\tvar resp RetrieveResult\n\n\tif err := c.call(\"/get\", req, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &resp, nil\n}", "func getArticles(wg *sync.WaitGroup) {\n\n\tclient := &http.Client{}\n\treq, err := http.NewRequest(\"GET\", articlesURL, nil)\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\tdefer func() {\n\t\tresp.Body.Close()\n\t\twg.Done()\n\t}()\n\n\terr = json.NewDecoder(resp.Body).Decode(&articles)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n}", "func (p *Parser) GetArticles(page int, tag string) ([]model.ArticleItem, int, error) {\n\tq := map[string]interface{}{\"p\": page}\n\tdir := []interface{}{\"featured\"}\n\tif tag != \"\" {\n\t\tdir = append(dir, \"tag\", tag)\n\t}\n\tdoc, code, err := p.getDoc(utils.BuildURLWithQuery(q, malURL, dir...), \".content-left\")\n\tif err != nil {\n\t\treturn nil, code, err\n\t}\n\treturn p.article.GetList(doc), http.StatusOK, nil\n}", "func getArticlesHandler(c *gin.Context) {\n\n\tvar wg sync.WaitGroup\n\n\twg.Add(2)\n\tgo getArticles(&wg)\n\tgo getContentMarketing(&wg)\n\n\twg.Wait()\n\n\terr := resultMapper()\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, err)\n\t}\n\n\tc.JSON(http.StatusOK, resultContent)\n}", "func (service *RssService) GetArticles(id int64, userID int64, page int) *models.ArticlesJSON {\n\tvar articles []models.Articles\n\tvar count int64\n\toffset := service.config.PageSize * (page - 1)\n\twhereObject := models.Articles{FeedId: id}\n\n\tquery := service.db.Where(&whereObject).\n\t\tSelect(\"Id, Title, IsBookmark, IsRead, Link, FeedId\").\n\t\tLimit(service.config.PageSize).\n\t\tOffset(offset).\n\t\tOrder(\"Id desc\")\n\tqueryCount := service.db.Model(&whereObject).Where(&whereObject)\n\n\tvar settings models.Settings\n\tservice.db.Where(models.Settings{UserId: userID}).Find(&settings)\n\n\tif settings.UnreadOnly {\n\t\twhereNotObject := models.Articles{IsRead: true}\n\t\tquery = query.Not(&whereNotObject)\n\t\tqueryCount = queryCount.Not(&whereNotObject)\n\t}\n\n\tquery.Find(&articles)\n\tqueryCount.Count(&count)\n\n\treturn &models.ArticlesJSON{Articles: articles, Count: count}\n}", "func (c Controller) Articles(categoryID, page int) ([]*model.Article, error) {\n\treturn c.ArticlesRepository.ListByCategory(categoryID, page, \"tags,categories\")\n}", "func (service *RssService) GetArticles(id uint, page int) *models.ArticlesJSON {\n\tvar articles []models.Articles\n\tvar count int\n\toffset := service.config.PageSize * (page - 1)\n\twhereObject := models.Articles{FeedId: id}\n\n\tquery := service.dbp().Where(&whereObject).\n\t\tSelect(\"Id, Title, IsBookmark, IsRead\").\n\t\tLimit(service.config.PageSize).\n\t\tOffset(offset).\n\t\tOrder(\"Id desc\")\n\tqueryCount := service.dbp().Model(&whereObject).Where(&whereObject)\n\n\tif service.AppSettings.UnreadOnly {\n\t\twhereNotObject := models.Articles{IsRead: true}\n\t\tquery = query.Not(&whereNotObject)\n\t\tqueryCount = queryCount.Not(&whereNotObject)\n\t}\n\n\tquery.Find(&articles)\n\tqueryCount.Count(&count)\n\n\treturn &models.ArticlesJSON{Articles: articles, Count: count}\n}", "func getArticle(w http.ResponseWriter, r *http.Request) {\r\n\tw.Header().Set(\"Content-Type\", \"application/json\")\r\n\tparams := mux.Vars(r) // Gets params\r\n\t// Looping through articles and find one with the id from the params\r\n\tfor _, item := range Articles {\r\n\t\tif item.Name == params[\"Id\"] {\r\n\t\t\tjson.NewEncoder(w).Encode(item)\r\n\t\t\treturn\r\n\t\t}\r\n\t}\r\n\tjson.NewEncoder(w).Encode(&Article{})\r\n}", "func getAllArticles() []article {\n\treturn articleList\n}", "func (*server) GetAllArticles(ctx context.Context, req *web_log_pb.GetAllArticlesRequest) (*web_log_pb.GetAllArticlesResponse, error) {\n\tfmt.Println(\"GetArticles function was invoked with a streaming request\")\n\taccessWebLogger.ClientIP = getClientIP(ctx)\n\terrorWebLogger.ClientIP = getClientIP(ctx)\n\tpc, _, _, _ := runtime.Caller(0)\n\n\tjsonData := getJSONData()\n\t// current articles in the json file\n\tcurrentArticles := getCurrentArticles(jsonData)\n\n\tvar result bytes.Buffer // server response (using string buffer to concate strings)\n\tif len(currentArticles) == 0 {\n\t\tpc, _, _, _ := runtime.Caller(0)\n\t\terrorWebLogger.ErrorPrintln(getCurrentRPCmethod(pc), \"No article is available now.\")\n\t\tresult.WriteString(\"No article is available now.\")\n\t} else {\n\t\tfor _, article := range currentArticles {\n\t\t\tresult.WriteString(\"\\narticleID: \" + article.ArticleID + \"\\ntitle: \" + article.Title + \"\\n\")\n\t\t}\n\t}\n\n\tres := &web_log_pb.GetAllArticlesResponse{\n\t\tResult: result.String(),\n\t}\n\taccessWebLogger.AccessPrintln(getCurrentRPCmethod(pc), \"\")\n\treturn res, nil\n}", "func AllArticles(w http.ResponseWriter, r *http.Request) {\n\tarticles := Articles{\n\t\tArticle{Title:\"Test Title\", Desc: \"Test Description\", Content: \"Hello World\"},\n\t}\n\n\tfmt.Fprintf(w, \"Endpoint Hit: All Articles Endpoint\")\n\tjson.NewEncoder(w).Encode(articles)\n}", "func getAllArticles(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(articles)\n\tw.WriteHeader(http.StatusOK)\n}", "func (repo *SQLRepository) GetArticles(id int64) ([]model.ArticleModel, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), repo.timeout)\n\tdefer cancel()\n\n\tproc := \"[dbo].[spGetArticles]\"\n\tcmd := fmt.Sprintf(\"EXEC %s %d\", proc, id)\n\tarticles := make([]model.ArticleModel, 0)\n\trows, _, err := repo.queryContext(ctx, cmd)\n\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to query for GetArticles(%d) method: %v\", id, err)\n\t\treturn nil, err\n\t}\n\n\tfor rows.Next() {\n\t\tarticle := model.ArticleModel{}\n\n\t\tscanErr := rows.Scan(\n\t\t\t&article.ID,\n\t\t\t&article.Title,\n\t\t\t&article.DateTime,\n\t\t\t&article.Body,\n\t\t\t&article.TagsString,\n\t\t)\n\t\tarticle.Date = article.DateTime.Format(\"2006-01-02\")\n\t\tarticle.Tags = strings.Split(article.TagsString, \",\")\n\n\t\tif scanErr != nil {\n\t\t\tlog.Errorf(\"Failed to scan row cells: %v\", scanErr)\n\t\t\treturn nil, scanErr\n\t\t}\n\n\t\tarticles = append(articles, article)\n\t}\n\n\treturn articles, nil\n}", "func ArticleList(c *gin.Context) {\n\t//condition := ArticleModel{}\n\t// tag := c.Query(\"tag\")\n\t// author := c.Query(\"author\")\n\t// favorited := c.Query(\"favorited\")\n\t// limit := c.Query(\"limit\")\n\t// offset := c.Query(\"offset\")\n\t// articleModels, modelCount, _ := FindManyArticle(tag, author, limit, offset, favorited)\n\tarticleModels, modelCount, _ := FindArticleList()\n\t// if err != nil {\n\t// \tc.JSON(http.StatusNotFound, common.NewError(\"articles\", errors.New(\"Invalid param\")))\n\t// \treturn\n\t// }\n\tserializer := ArticleListSerializer{c, articleModels}\n\tlogger.Trace(\"ArticleList serializer\", serializer)\n\tc.JSON(http.StatusOK, gin.H{\"articles\": serializer.Response(), \"articlesCount\": modelCount})\n}", "func getArticles(p int) {\n\tdb, err := bolt.Open(\"../.db\", 0600, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer db.Close()\n\n\t//display 10 articles per page\n\tIdIndex := (p-1)*10 + 1\n\tvar articles ArticlesResponse\n\tvar article Article\n\terr = db.View(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(\"Article\"))\n\t\tif b != nil {\n\t\t\tc := b.Cursor()\n\t\t\tk, v := c.Seek(itob(IdIndex))\n\t\t\tif k == nil {\n\t\t\t\tfmt.Println(\"Page is out of index\")\n\t\t\t\treturn errors.New(\"Page is out of index\")\n\t\t\t}\n\t\t\tkey := binary.BigEndian.Uint64(k)\n\t\t\tfmt.Print(key)\n\t\t\tif int(key) != IdIndex {\n\t\t\t\tfmt.Println(\"Page is out of index\")\n\t\t\t\treturn errors.New(\"Page is out of index\")\n\t\t\t}\n\t\t\tcount := 0\n\t\t\tvar ori_artc Article\n\t\t\tfor ; k != nil && count < 10; k, v = c.Next() {\n\t\t\t\terr = json.Unmarshal(v, &ori_artc)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tarticle.Id = ori_artc.Id\n\t\t\t\tarticle.Name = ori_artc.Name\n\t\t\t\tarticles.Articles = append(articles.Articles, article)\n\t\t\t\tcount = count + 1\n\t\t\t}\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn errors.New(\"Article Not Exists\")\n\t\t}\n\t})\n\tfor i := 0; i < len(articles.Articles); i++ {\n\t\tfmt.Println(articles.Articles[i])\n\t}\n}", "func GetAllArticles(db *sqlx.DB) httprouter.Handle {\n\treturn func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t\tvar article models.Article\n\t\tarticles, err := article.GetArticles(db)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset= UTF-8\")\n\t\tw.WriteHeader(http.StatusOK)\n\n\t\tif err := json.NewEncoder(w).Encode(articles); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t}\n\n}", "func GetFeedArticles(c *gin.Context) {\n\tclient, ctx, cancel := utils.GetConnection()\n\tdefer cancel()\n\tarticleCollection := client.Database(\"conduit\").Collection(\"articles\")\n\tuserCollection := client.Database(\"conduit\").Collection(\"users\")\n\n\tvar loginUser models.User\n\tclaims, err := middlewares.Authenticate(c)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tid, err := primitive.ObjectIDFromHex(claims.UserID)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t}\n\terr = userCollection.FindOne(ctx, bson.M{\n\t\t\"_id\": id,\n\t}).Decode(&loginUser)\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tvar args GetFeedArgs\n\targs.Limit = 20\n\targs.Offset = 0\n\n\tif err := c.ShouldBindQuery(&args); err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tvar query bson.M = make(primitive.M)\n\tquery[\"author\"] = bson.M{\n\t\t\"$in\": loginUser.Following,\n\t}\n\n\tmatchStage := bson.D{{Key: \"$match\", Value: query}}\n\tlookupStage := bson.D{{Key: \"$lookup\", Value: bson.D{{Key: \"from\", Value: \"users\"}, {Key: \"localField\", Value: \"author\"}, {Key: \"foreignField\", Value: \"_id\"}, {Key: \"as\", Value: \"author\"}}}}\n\tunwindStage := bson.D{{Key: \"$unwind\", Value: bson.D{{Key: \"path\", Value: \"$author\"}, {Key: \"preserveNullAndEmptyArrays\", Value: false}}}}\n\tskipStage := bson.D{{Key: \"$skip\", Value: args.Offset}}\n\tlimitStage := bson.D{{Key: \"$limit\", Value: args.Limit}}\n\tcursor, err := articleCollection.Aggregate(ctx, mongo.Pipeline{matchStage, lookupStage, unwindStage, skipStage, limitStage})\n\tcounts, err := articleCollection.CountDocuments(ctx, query)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\tvar articles []models.ArticleWithAuthor\n\terr = cursor.All(ctx, &articles)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tvar articlesJSON []models.ArticleJSON = make([]models.ArticleJSON, len(articles))\n\tfor i, article := range articles {\n\t\tarticlesJSON[i].ArticleBase = article.ArticleBase\n\t\tarticlesJSON[i].Author = article.Author.ToProfile(&loginUser)\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"articles\": articlesJSON,\n\t\t\"articlesCount\": counts,\n\t})\n}", "func (ArticleController) GetAll(c *gin.Context) {\n\tarticles, err := models.GetAllArticles()\n\n\tif err != nil {\n\t\tc.JSON(err.Code(), gin.H{\n\t\t\t\"message\": err.Error(),\n\t\t})\n\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, articles)\n}", "func (x *ArticleHandler) SearchArticles() http.HandlerFunc {\n\treturn func(res http.ResponseWriter, req *http.Request) {\n\n\t\tvar payload models.ArticleFromClient\n\n\t\terr := json.NewDecoder(req.Body).Decode(&payload)\n\t\tif err != nil {\n\t\t\tutils.ResErr(&res, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tarticles, err := driver.DBArticleSearch(x.db, &payload)\n\t\tif err != nil {\n\t\t\tutils.ResErr(&res, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tresponse := models.ArticleFromServer{\n\t\t\tArticlesFromServer: articles,\n\t\t}\n\n\t\terr = json.NewEncoder(res).Encode(&response)\n\t\tif err != nil {\n\t\t\tutils.ResErr(&res, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (c *Client) GetArticles(pageID int) *types.ArticleList {\n\tarticles := &types.ArticleList{}\n\tc.Client.Where(\"id >= ?\", pageID).Order(\"id\").Limit(pageSize + 1).Find(&articles.Items)\n\tif len(articles.Items) == pageSize+1 {\n\t\tarticles.NextPageID = articles.Items[len(articles.Items)-1].ID\n\t\tarticles.Items = articles.Items[:pageSize]\n\t}\n\treturn articles\n}", "func (c *ArticlesController) Articles(ctx *app.ArticlesArticlesContext) error {\n\t// ArticlesController_Articles: start_implement\n\n\t// Put your logic here\n\tarticleTable := models.NewArticleDB(c.db)\n\tarticles := articleTable.ListGoaNewsAPIArticle(ctx.Context)\n\n\t// ArticlesController_Articles: end_implement\n\tres := app.GoaNewsAPIArticleCollection{}\n\tres = articles\n\treturn ctx.OK(res)\n}", "func (s *Service) Articles(id int) ([]*Article, error) {\n\tbody, err := s.requestCourseArticles(id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer body.Close()\n\n\tarticleResult := &articleResult{}\n\tif err := handleJSONParse(body, articleResult); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn articleResult.Articles, nil\n}", "func (d *DB) Articles(categoryID uint16, count int, user *User) ([]*Article, error) {\n\tresults := []*Article{}\n\tquery := bson.M{\"categoryid\": categoryID}\n\n\tvar iter *mgo.Iter\n\tswitch count {\n\tcase 0:\n\t\titer = d.Items.Find(query).Iter()\n\tdefault:\n\t\titer = d.Items.Find(bson.M{\"categoryid\": categoryID}).Limit(count).Iter()\n\t}\n\terr := iter.All(&results)\n\treturn results, err\n}", "func (s *ArticlesService) GetAll() ([]models.Article, error) {\n\tvar articles []models.Article\n\terr := s.db.Find(&articles).Error\n\treturn articles, err\n}", "func (handler Handler) GetArticlesByTagHandler(w http.ResponseWriter, r *http.Request) {\n\n\ttagName := mux.Vars(r)[\"tagName\"]\n\tdate := mux.Vars(r)[\"date\"]\n\n\tdateFormat := \"20060102\"\n\tnewDate, dateErr := time.Parse(dateFormat, date)\n\n\tif dateErr != nil {\n\t\tlog.Printf(\"date error: %s\", dateErr)\n\t\thandler.BadRequestHandler(w, r)\n\t\treturn\n\t}\n\n\tdate = newDate.Format(\"2006-01-02\")\n\n\tresp := usecases.ResponseCollector{}\n\n\tuc := usecases.GetArticlesByTag{\n\t\tArticleRepository: handler.ArticleRepository,\n\t\tTagName: tagName,\n\t\tDate: date,\n\t\tResponse: &resp,\n\t}\n\n\tuc.Execute()\n\n\tlog.Printf(\"handler GetArticlesByTagHandler var tagName: %s, date: %s\", tagName, date)\n\n\tif resp.Error != nil {\n\t\tlog.Printf(\"response error %s (%s)\", resp.Error.Name, resp.Error.Description)\n\t\thandler.BadRequestHandler(w, r)\n\t\treturn\n\t}\n\n\tfmt.Fprintf(w, handler.Presenter.GetArticlesByTag(tagName, resp.Response.Body[\"articles\"].([]entities.Article)))\n}", "func getAllArticles() []article {\n\tclient, clierr := mongo.NewClient(options.Client().ApplyURI(dbConfig.dburi))\n\tif clierr != nil {\n\t\tlog.Fatal(clierr)\n\t}\n\tctx, _ := context.WithTimeout(context.Background(), 10*time.Second)\n\tconnerr := client.Connect(ctx)\n\tif connerr != nil {\n\t\tlog.Fatal(connerr)\n\t}\n\tdefer client.Disconnect(ctx)\n\tdb := client.Database(dbConfig.dbName).Collection(dbConfig.articleColName)\n\n\tcursor, err := db.Find(ctx, bson.D{})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tvar articleList []article\n\tif err := cursor.All(ctx, &articleList); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(articleList)\n\treturn articleList\n}", "func (a *ArticleHandler) FetchArticle(c *gin.Context) {\n\tn := c.Query(\"num\")\n\tnum, _ := strconv.Atoi(n)\n\n\tcursor := c.Query(\"cursor\")\n\n\tctx, cancel := context.WithCancel(c)\n\tdefer cancel()\n\n\tlistAr, nextCursor, err := a.ArticleUsecase.Fetch(ctx, cursor, int64(num))\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(getStatusCode(err), ResponseError{Message: err.Error()})\n\t\treturn\n\t}\n\n\tc.Header(\"X-Cursor\", nextCursor)\n\tc.JSON(http.StatusOK, listAr)\n}", "func getAllArticles() []article {\n\tarticleList = nil\n\tprintarticle()\n\treturn articleList\n}", "func getAnArticle(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r)\n\tfor _, article := range articles {\n\t\tif article.ID == params[\"id\"] {\n\t\t\tjson.NewEncoder(w).Encode(article)\n\t\t\treturn\t\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(&article{})\n\tw.WriteHeader(http.StatusOK)\n}", "func (m *Vulnerability) GetArticles()([]Articleable) {\n val, err := m.GetBackingStore().Get(\"articles\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]Articleable)\n }\n return nil\n}", "func Article(next http.Handler) http.Handler {\r\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\r\n\t\tvar article *types.Article\r\n\r\n\t\tif id := chi.URLParam(r, \"id\"); id != \"\" {\r\n\t\t\tintID, err := strconv.Atoi(id)\r\n\t\t\tif err != nil {\r\n\t\t\t\t_ = render.Render(w, r, types.ErrInvalidRequest(err))\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tarticle = DBClient.GetArticleByID(intID)\r\n\t\t} else {\r\n\t\t\t_ = render.Render(w, r, types.ErrNotFound())\r\n\t\t\treturn\r\n\t\t}\r\n\t\tif article == nil {\r\n\t\t\t_ = render.Render(w, r, types.ErrNotFound())\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tctx := context.WithValue(r.Context(), ArticleCtxKey, article)\r\n\t\tnext.ServeHTTP(w, r.WithContext(ctx))\r\n\t})\r\n}", "func ListArticles(c *gin.Context) {\n\tarticles := []models.Article{}\n\tif err := database.Db.Find(&articles).Error; err != nil {\n\t\tc.String(http.StatusInternalServerError, \"Error listing articles\")\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, &articles)\n}", "func GetArticle(c *gin.Context) {\n\tvar loginUser models.User\n\tclaims, err := middlewares.Authenticate(c)\n\n\tclient, ctx, cancel := utils.GetConnection()\n\tdefer cancel()\n\tuserCollection := client.Database(\"conduit\").Collection(\"users\")\n\tarticleCollection := client.Database(\"conduit\").Collection(\"articles\")\n\n\tid, err := primitive.ObjectIDFromHex(claims.UserID)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\terr = userCollection.FindOne(ctx, bson.M{\n\t\t\"_id\": id,\n\t}).Decode(&loginUser)\n\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tslug := c.Param(\"slug\")\n\n\tvar article models.ArticleWithAuthor\n\tmatchStage := bson.D{{Key: \"$match\", Value: bson.D{{Key: \"slug\", Value: slug}}}}\n\tlookupStage := bson.D{{Key: \"$lookup\", Value: bson.D{{Key: \"from\", Value: \"users\"}, {Key: \"localField\", Value: \"author\"}, {Key: \"foreignField\", Value: \"_id\"}, {Key: \"as\", Value: \"author\"}}}}\n\tcursor, err := articleCollection.Aggregate(ctx, mongo.Pipeline{matchStage, lookupStage})\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\tfor cursor.Next(ctx) {\n\t\terr := cursor.Decode(&article)\n\t\tif err != nil {\n\t\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\t\"error\": err.Error(),\n\t\t\t})\n\t\t\treturn\n\t\t}\n\t\tbreak\n\t}\n\tvar articleJSON = models.ArticleJSON{ArticleBase: article.ArticleBase, Author: article.Author.ToProfile(&loginUser)}\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"article\": articleJSON,\n\t})\n}", "func (x *ArticleHandler) GetArticles() http.HandlerFunc {\n\treturn func(res http.ResponseWriter, req *http.Request) {\n\n\t\tvar payload models.ArticleFromClient\n\n\t\terr := json.NewDecoder(req.Body).Decode(&payload)\n\t\tif err != nil {\n\t\t\tutils.ResErr(&res, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tarticles, err := driver.DBArticleGetAll(x.db, &payload)\n\t\tif err != nil {\n\t\t\tutils.ResErr(&res, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tresponse := models.ArticleFromServer{\n\t\t\tArticlesFromServer: articles,\n\t\t}\n\n\t\terr = json.NewEncoder(res).Encode(&response)\n\t\tif err != nil {\n\t\t\tutils.ResErr(&res, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\t}\n}", "func ArticleRetrieve(c *gin.Context) {\n\tslug := c.Param(\"slug\")\n\t// if slug == \"feed\" {\n\t// \tArticleFeed(c)\n\t// \treturn\n\t// }\n\tarticleModel, _ := FindOneArticle(&ArticleModel{Slug: slug})\n\t// if err != nil {\n\t// \tc.JSON(http.StatusNotFound, common.NewError(\"articles\", errors.New(\"Invalid slug\")))\n\t// \treturn\n\t// }\n\tserializer := ArticleSerializer{c, articleModel}\n\tc.JSON(http.StatusOK, gin.H{\"article\": serializer.Response()})\n}", "func (m *MockHandler) GetArticles(username string, limit, offset int, filters []domain.ArticleFilter) (*domain.User, domain.ArticleCollection, int, error) {\n\tret := m.ctrl.Call(m, \"GetArticles\", username, limit, offset, filters)\n\tret0, _ := ret[0].(*domain.User)\n\tret1, _ := ret[1].(domain.ArticleCollection)\n\tret2, _ := ret[2].(int)\n\tret3, _ := ret[3].(error)\n\treturn ret0, ret1, ret2, ret3\n}", "func (k *KnowledgebaseService) Search(ctx context.Context, query string, highlight bool, start, limit int) (result *ArticlePageScheme, response *Response, err error) {\n\n\tif len(query) == 0 {\n\t\treturn nil, nil, fmt.Errorf(\"error, please provide a valid query value\")\n\t}\n\n\tparams := url.Values{}\n\tparams.Add(\"start\", strconv.Itoa(start))\n\tparams.Add(\"limit\", strconv.Itoa(limit))\n\tparams.Add(\"query\", query)\n\n\tif !highlight {\n\t\tparams.Add(\"highlight\", \"false\")\n\t}\n\n\tvar endpoint = fmt.Sprintf(\"rest/servicedeskapi/knowledgebase/article?%v\", params.Encode())\n\n\trequest, err := k.client.newRequest(ctx, http.MethodGet, endpoint, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\trequest.Header.Set(\"Accept\", \"application/json\")\n\trequest.Header.Set(\"X-ExperimentalApi\", \"opt-in\")\n\n\tresponse, err = k.client.Do(request)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresult = new(ArticlePageScheme)\n\tif err = json.Unmarshal(response.BodyAsBytes, &result); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (m *MockArticlesLogic) GetArticles(username string, limit, offset int, filters []domain.ArticleFilter) (*domain.User, domain.ArticleCollection, int, error) {\n\tret := m.ctrl.Call(m, \"GetArticles\", username, limit, offset, filters)\n\tret0, _ := ret[0].(*domain.User)\n\tret1, _ := ret[1].(domain.ArticleCollection)\n\tret2, _ := ret[2].(int)\n\tret3, _ := ret[3].(error)\n\treturn ret0, ret1, ret2, ret3\n}", "func (_m *ArticleUsecase) GetArticles(ctx context.Context, payload domain.ArticleSearchPayload) ([]domain.Article, error) {\n\tret := _m.Called(ctx, payload)\n\n\tvar r0 []domain.Article\n\tif rf, ok := ret.Get(0).(func(context.Context, domain.ArticleSearchPayload) []domain.Article); ok {\n\t\tr0 = rf(ctx, payload)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).([]domain.Article)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, domain.ArticleSearchPayload) error); ok {\n\t\tr1 = rf(ctx, payload)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (_m *ArticleUsecase) GetArticles(ctx context.Context, author string, query string) ([]domain.Article, error) {\n\tret := _m.Called(ctx, author, query)\n\n\tvar r0 []domain.Article\n\tif rf, ok := ret.Get(0).(func(context.Context, string, string) []domain.Article); ok {\n\t\tr0 = rf(ctx, author, query)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).([]domain.Article)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {\n\t\tr1 = rf(ctx, author, query)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func getEverything(endpoint string) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\n\t\t//Read text box from HTML and assign it to search.Query\n\t\tsearch := &Search{\n\t\t\tQuery: c.Query(\"q\"),\n\t\t}\n\n\t\tr.LoadHTMLGlob(\"templates/*\")\n\n\t\tif search.Query == \"\" {\n\t\t\tc.HTML(http.StatusOK, \"header_everything.tmpl.html\", gin.H{\n\t\t\t\t\"title\": \"News Aggregation\",\n\t\t\t\t\"query\": search.Query,\n\t\t\t})\n\t\t\tc.HTML(http.StatusOK, \"footer.tmpl.html\", gin.H{})\n\n\t\t} else {\n\n\t\t\turl := endpoint + search.Query + apiKey\n\n\t\t\tclient := http.Client{\n\t\t\t\tTimeout: time.Second * 10,\n\t\t\t}\n\n\t\t\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tres, err := client.Do(req)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tif res.Body != nil {\n\t\t\t\tdefer res.Body.Close()\n\t\t\t}\n\n\t\t\tbody, err := ioutil.ReadAll(res.Body)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tjsonErr := json.Unmarshal(body, &NewsResultsVar)\n\t\t\tif jsonErr != nil {\n\t\t\t\tpanic(jsonErr)\n\t\t\t}\n\n\t\t\tc.HTML(http.StatusOK, \"header_everything.tmpl.html\", gin.H{\n\t\t\t\t\"title\": \"News Aggregation | \" + search.Query,\n\t\t\t\t\"query\": search.Query,\n\t\t\t\t\"status\": NewsResultsVar.Status,\n\t\t\t\t\"code\": NewsResultsVar.Code,\n\t\t\t\t\"message\": NewsResultsVar.Message,\n\t\t\t})\n\t\t\tc.HTML(http.StatusOK, \"articles_container.tmpl.html\", gin.H{})\n\t\t\tfor _, article := range NewsResultsVar.Articles {\n\t\t\t\tc.HTML(http.StatusOK, \"articles.tmpl.html\", gin.H{\n\t\t\t\t\t\"articleSource\": article.Source.Name,\n\t\t\t\t\t\"articlePubDate\": article.PublishedAt.Format(\"January 2, 2006\"),\n\t\t\t\t\t\"articleTitle\": article.Title,\n\t\t\t\t\t\"articleDescription\": article.Description,\n\t\t\t\t\t\"articleImage\": article.UrlToImage,\n\t\t\t\t\t\"articleUrl\": article.Url,\n\t\t\t\t})\n\t\t\t}\n\t\t\tc.HTML(http.StatusOK, \"footer.tmpl.html\", gin.H{})\n\t\t}\n\t}\n}", "func (mdb *MockDynamo) GetAllArticles() ([]models.Article, error) {\n\tvar articles []models.Article\n\tfor _, v := range mdb.ArticlesTable {\n\t\tarticles = append(articles, v)\n\t}\n\treturn articles, nil\n}", "func GetArticle(w http.ResponseWriter, r *http.Request) {\n params := mux.Vars(r)\n for _, item := range article {\n if item.ID == params[\"id\"] {\n item.ShortText = \"\"\n json.NewEncoder(w).Encode(item)\n return\n }\n }\n json.NewEncoder(w).Encode(&Article{})\n}", "func CrawlArticles(w http.ResponseWriter, r *http.Request) {\n\t// TODO: could this happen in parallel? save the articles while getting the next news source...\n\tarticles := getHackerNewsArticles()\n\tarticles = append(articles, getTechCrunchArticles()...)\n\tarticles = append(articles, getNYTArticles()...)\n\tcount, err := insertArticles(articles)\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\trespondWithJSON(w, http.StatusOK, count)\n}", "func (ArticleController) GetTopArticles(c *gin.Context) {\n\tlimit, err := strconv.Atoi(c.Query(\"limit\"))\n\tif err != nil {\n\t\tc.JSON(http.StatusUnprocessableEntity, gin.H{\n\t\t\t\"message\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tarticles, dbErr := models.GetTopArticles(limit)\n\tif dbErr != nil {\n\t\tc.JSON(dbErr.Code(), gin.H{\n\t\t\t\"message\": dbErr.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, articles)\n}", "func Articles(w http.ResponseWriter, r *http.Request) {\n\tAuthorised(r)\n\tWow.Data = data.GetAll(Wow.ID)\n\ttmpl, _ := template.ParseFiles(\"./public/html/articles.html\")\n\ttmpl.Execute(w, Wow)\n}", "func (delivery *Delivery) getBoardArticles(w http.ResponseWriter, r *http.Request, boardID string) {\n\tdelivery.logger.Debugf(\"getBoardArticles: %v\", r)\n\ttoken := delivery.getTokenFromRequest(r)\n\t// Check permission for board\n\terr := delivery.usecase.CheckPermission(token,\n\t\t[]usecase.Permission{usecase.PermissionReadBoardInformation},\n\t\tmap[string]string{\n\t\t\t\"board_id\": boardID,\n\t\t})\n\n\tif err != nil {\n\t\t// TODO: record unauthorized access\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tvar recommendCountGreaterEqual, recommendCountLessEqual int\n\tvar recommendCountGreaterEqualIsSet, recommendCountLessEqualIsSet bool\n\tqueryParam := r.URL.Query()\n\trecommendCountGreaterEqualParam := queryParam.Get(\"recommend_count_ge\")\n\trecommendCountGreaterEqualIsSet = recommendCountGreaterEqualParam != \"\"\n\trecommendCountGreaterEqual, err = strconv.Atoi(recommendCountGreaterEqualParam)\n\n\tif err != nil && recommendCountGreaterEqualIsSet {\n\t\tdelivery.logger.Errorf(\"recommend_count_ge should be integer\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\trecommendCountLessEqualParam := queryParam.Get(\"recommend_count_le\")\n\trecommendCountLessEqualIsSet = recommendCountLessEqualParam != \"\"\n\trecommendCountLessEqual, err = strconv.Atoi(recommendCountLessEqualParam)\n\tif err != nil && recommendCountLessEqualIsSet {\n\t\tdelivery.logger.Errorf(\"recommend_count_le should be integer\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tsearchCond := &usecase.ArticleSearchCond{\n\t\tTitle: queryParam.Get(\"title_contain\"),\n\t\tAuthor: queryParam.Get(\"author\"),\n\t\tRecommendCountGreaterEqual: recommendCountGreaterEqual,\n\t\tRecommendCountLessEqual: recommendCountLessEqual,\n\t\tRecommendCountGreaterEqualIsSet: recommendCountGreaterEqualIsSet,\n\t\tRecommendCountLessEqualIsSet: recommendCountLessEqualIsSet,\n\t}\n\n\tresponseMap := map[string]interface{}{\n\t\t\"data\": map[string]interface{}{\n\t\t\t\"items\": delivery.usecase.GetBoardArticles(context.Background(), boardID, searchCond),\n\t\t},\n\t}\n\n\tb, _ := json.MarshalIndent(responseMap, \"\", \" \")\n\t_, err = w.Write(b)\n\tif err != nil {\n\t\tdelivery.logger.Errorf(\"getBoardArticles write success response err: %w\", err)\n\t}\n}", "func ScrapeArticle(url string, client *http.Client) (*ArticleResponse, error) {\n\treq, err := http.NewRequest(http.MethodGet, MercuryURL+url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Add(\"x-api-key\", MercuryToken)\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tartResp := ArticleResponse{}\n\n\terr = json.Unmarshal(bodyBytes, &artResp)\n\treturn &artResp, err\n}", "func (_m *API) GetArticles(page int, tag string) ([]model.ArticleItem, int, error) {\n\tret := _m.Called(page, tag)\n\n\tvar r0 []model.ArticleItem\n\tif rf, ok := ret.Get(0).(func(int, string) []model.ArticleItem); ok {\n\t\tr0 = rf(page, tag)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).([]model.ArticleItem)\n\t\t}\n\t}\n\n\tvar r1 int\n\tif rf, ok := ret.Get(1).(func(int, string) int); ok {\n\t\tr1 = rf(page, tag)\n\t} else {\n\t\tr1 = ret.Get(1).(int)\n\t}\n\n\tvar r2 error\n\tif rf, ok := ret.Get(2).(func(int, string) error); ok {\n\t\tr2 = rf(page, tag)\n\t} else {\n\t\tr2 = ret.Error(2)\n\t}\n\n\treturn r0, r1, r2\n}", "func GetArticleTags(tags ArrayFlags, input *bufio.Scanner) {\n\tallTags := struct {\n\t\tCode int\n\t\tText string\n\t\tBody []util.Tag\n\t}{}\n\t// get the request from api to get all tags\n\treq, err := http.Get(\"http://localhost:8080/tags\")\n\tutil.CheckError(err)\n\n\tdefer req.Body.Close()\n\n\t// decode the response json and display it to the user\n\tjson.NewDecoder(req.Body).Decode(&allTags)\n\tfmt.Fprintln(os.Stdout, \"Please choose whatever tag you like(just enter if nothing):\")\n\n\tfor _, i := range allTags.Body {\n\t\tfmt.Fprintf(os.Stdout, \" %-5d%s\\n\", i.Id, i.Name)\n\t}\n\n\t// get the input\n\tinput.Scan()\n\tchose := input.Text()\n\n\t// and split it into []string\n\tw := strings.FieldsFunc(chose, func(r rune) bool {\n\t\tswitch r {\n\t\tcase ',', ';', ' ', '\\t', '.', '\\n':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t\t}\n\t})\n\n\t// convert it into []int and complete the tags\n\tfor _, i := range w {\n\t\tn, err := strconv.Atoi(i)\n\t\tutil.CheckError(err)\n\t\ttags = append(tags, n)\n\t}\n\n}", "func ListArticlesWithPage(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tvar lim_int int\n\tvar off_int int\n\tvar articles []*models.Posts\n\n\tlimit := chi.URLParam(r, \"limit\")\n\toffset := chi.URLParam(r, \"offset\")\n\n\tlim_int, err = strconv.Atoi(limit)\n\tif err != nil {\n\t\trender.Render(w, r, ErrNotFound)\n\t\treturn\n\t}\n\n\toff_int, err = strconv.Atoi(offset)\n\tif err != nil {\n\t\trender.Render(w, r, ErrNotFound)\n\t\treturn\n\t}\n\n\tarticles, err = dbListArticlePage(&lim_int, &off_int)\n\tif err != nil {\n\t\trender.Render(w, r, ErrNotFound)\n\t\treturn\n\t}\n\n\n\tif err := render.RenderList(w, r, NewArticleListResponse(articles)); err != nil {\n\t\trender.Render(w, r, ErrRender(err))\n\t\treturn\n\t}\n}", "func SearchArticle(db *sql.DB, words string) ([]blogmodel.Summary, error) {\n\tql := fmt.Sprintf(\"SELECT id, title, abstract, created_time FROM summary WHERE id in (SELECT id FROM content WHERE MATCH(substance) AGAINST('%s' IN BOOLEAN MODE));\", words)\n\trows, err := db.Query(ql)\n\tdefer func() {\n\t\tif rows != nil {\n\t\t\t// 可以关闭掉未scan连接一直占用\n\t\t\trows.Close()\n\t\t}\n\t}()\n\tif err != nil {\n\t\tlog.Error(\"query all err \", err)\n\t\treturn []blogmodel.Summary{}, err\n\t}\n\tvar res []blogmodel.Summary\n\tvar summary blogmodel.Summary\n\tfor rows.Next() {\n\t\terr = rows.Scan(&summary.SId, &summary.Title, &summary.Abstract, &summary.CreatedTime)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"search Article error\", err)\n\t\t}\n\t\ttimeParse, terr := time.Parse(\"2006-01-02 15:04:05\", summary.CreatedTime)\n\t\tif terr != nil {\n\t\t\tlog.Error(\"Parser time error \")\n\t\t}\n\t\tsummary.CreatedTime = fmt.Sprint(timeParse.Format(\"02 Jan 06\"))\n\t\tres = append(res, summary)\n\t}\n\ttimeParse, terr := time.Parse(\"2006-01-02 15:04:05\", summary.CreatedTime)\n\tif terr != nil {\n\t\tlog.Error(\"Parser time error \")\n\t}\n\tsummary.CreatedTime = fmt.Sprint(timeParse.Format(\"02 Jan 06\"))\n\tlog.Print(\"Search article by words:\", words)\n\treturn res, nil\n}", "func (s *Server) Article(ctx context.Context, in *pb.ArticleRequest) (*pb.ArticleReply, error) {\n\ta, err := s.db.Get(ctx, in.Id)\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, fmt.Sprintf(\"failed to get article: %v\", err))\n\t}\n\treturn &pb.ArticleReply{Article: a}, nil\n}", "func GetArticle(w http.ResponseWriter, r *http.Request) {\n\n\tarticle := r.Context().Value(\"article\").(*models.Posts)\n\n\tif err := render.Render(w, r, NewArticleResponse(article)); err != nil {\n\t\trender.Render(w, r, ErrRender(err))\n\t\treturn\n\t}\n}", "func AllArticles() (articles []Article, err error) {\n\terr = DB.Select(&articles, \"SELECT COALESCE(articles.text, '') AS text, articles.id, articles.title, articles.created_at, articles.updated_at FROM articles\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\treturn articles, nil\n}", "func (s *Service) ListArticles(c context.Context, id, mid int64) (res *model.ListArticles, err error) {\n\tif id <= 0 {\n\t\treturn\n\t}\n\tres = &model.ListArticles{}\n\tres.List, err = s.List(c, id)\n\tif err != nil {\n\t\treturn\n\t}\n\tif res.List == nil {\n\t\terr = ecode.NothingFound\n\t\treturn\n\t}\n\tvar lastID int64\n\tgroup := &errgroup.Group{}\n\tgroup.Go(func() (err error) {\n\t\tarts, err := s.dao.ListArts(c, id)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tfor _, a := range arts {\n\t\t\tif a.IsNormal() {\n\t\t\t\tres.Articles = append(res.Articles, a)\n\t\t\t}\n\t\t}\n\t\treturn\n\t})\n\tgroup.Go(func() (err error) {\n\t\tres.Author, err = s.author(c, res.List.Mid)\n\t\treturn\n\t})\n\tgroup.Go(func() (err error) {\n\t\tres.List.Read, err = s.dao.CacheListReadCount(c, id)\n\t\treturn\n\t})\n\tgroup.Go(func() (err error) {\n\t\tif mid > 0 {\n\t\t\tres.Attention, _ = s.isAttention(c, mid, res.List.Mid)\n\t\t}\n\t\treturn\n\t})\n\tgroup.Go(func() (err error) {\n\t\tif mid == 0 {\n\t\t\treturn\n\t\t}\n\t\tlastID, _ = s.historyPosition(c, mid, res.List.ID)\n\t\treturn\n\t})\n\terr = group.Wait()\n\tif res.Articles == nil {\n\t\tres.Articles = []*model.ListArtMeta{}\n\t}\n\tres.List.ArticlesCount = int64(len(res.Articles))\n\tres.Last.Strong()\n\tif lastID == 0 {\n\t\treturn\n\t}\n\tfor _, a := range res.Articles {\n\t\tif a.ID == lastID {\n\t\t\tres.Last = *a\n\t\t\tbreak\n\t\t}\n\t}\n\treturn\n}", "func allArticles(w http.ResponseWriter, r *http.Request) {\n w.Header().Set(\"Content-Type\", \"application/json\")\n json.NewEncoder(w).Encode(articles)\n}", "func (handler Handler) GetArticleHandler(w http.ResponseWriter, r *http.Request) {\n\n\tid := mux.Vars(r)[\"id\"]\n\n\tresp := usecases.ResponseCollector{}\n\n\tuc := usecases.GetArticle{\n\t\tArticleRepository: handler.ArticleRepository,\n\t\tArticleID: id,\n\t\tResponse: &resp,\n\t}\n\n\tuc.Execute()\n\n\tlog.Printf(\"handler GetArticleHandler var id: %s\", id)\n\tlog.Printf(\"response collector received %s\", resp.Response)\n\n\tif resp.Error != nil {\n\t\tlog.Printf(\"response error %s (%s)\", resp.Error.Name, resp.Error.Description)\n\t\thandler.NotFoundHandler(w, r)\n\t\treturn\n\t}\n\n\tfmt.Fprintf(w, handler.Presenter.GetArticle(resp.Response.Body[\"article\"].(entities.Article)))\n}", "func (as *ArticleService) Articles() ([]entities.Article, []error) {\n\tarticles, errs := as.articleRepo.Articles()\n\tif len(errs) > 0 {\n\t\treturn nil, errs\n\t}\n\n\treturn articles, nil\n}", "func (s ArticleService) Get(ctx context.Context, id string) (*Article, error) {\n\tstat := `SELECT id, title, description, content FROM articles WHERE id = ?;`\n\tif s.DB == nil {\n\t\tpanic(\"no existing database\")\n\t}\n\trows, err := s.DB.QueryContext(ctx, stat, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tvar article Article\n\tif rows.Next() {\n\t\terr := rows.Scan(&article.ID, &article.Title, &article.Desc, &article.Content)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn &article, err\n}", "func (dao *ArticleDAO) Query(rs app.RequestScope, offset, limit, categoryId int, sorting, filter string) ([]models.Article, error) {\n\tarticles := []models.Article{}\n\tq := rs.Tx().Select().OrderBy(\"id\")\n\tif categoryId != 0 {\n\t\tq.Where(dbx.HashExp{\"category_id\": categoryId})\n\t}\n\tif filter != \"\" {\n\t\tq.AndWhere(dbx.Like(\"title\", filter))\n\t}\n\tif sorting == \"asc\" {\n\t\tq.OrderBy(\"id ASC\")\n\t} else {\n\t\tq.OrderBy(\"id DESC\")\n\t}\n\terr := q.Offset(int64(offset)).Limit(int64(limit)).All(&articles)\n\treturn articles, err\n}", "func fetchAllArticleList() {\n\t// loop over the articleList jumping 16 items\n\tfor i := 0; i < articleL; i++ {\n\t\t// go routine to fetch data\n\t\tgo func(url string, index int) {\n\t\t\tfetchDoc(url, func(doc *goquery.Document) {\n\t\t\t\t// check blank URLs\n\t\t\t\tif url == \"\" {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tvar text string\n\t\t\t\tat := new(artText)\n\n\t\t\t\t// set the index of artText for proper synchronization of the data\n\t\t\t\tat.I = index\n\n\t\t\t\t// query the article element\n\t\t\t\tq := doc.Find(paraSelector)\n\n\t\t\t\t// check the no. of elements\n\t\t\t\tif q.Length() <= 0 {\n\t\t\t\t\t// create an error msg\n\t\t\t\t\tat.Text = fmt.Sprintf(\n\t\t\t\t\t\t\"error: %v: 0 result from \\\"%v \\\"(selector) \",\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tparaSelector)\n\t\t\t\t\t// send the error msg\n\t\t\t\t\tch <- *at\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// scrap the data\n\t\t\t\tq.Each(func(j int, t *goquery.Selection) {\n\t\t\t\t\ttext = strings.TrimSpace(t.Text())\n\t\t\t\t\t// add the text to the final text\n\t\t\t\t\t// if the text is not blank\n\t\t\t\t\tif text != \"\" {\n\t\t\t\t\t\t// add extra space if the no the 1st element\n\t\t\t\t\t\tif j != 0 {\n\t\t\t\t\t\t\tat.Text += (\"\\n\\n\" + text)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tat.Text += text\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\t// send data back to the channel\n\t\t\t\tch <- *at\n\t\t\t})\n\t\t}(articleList[i].URL, i)\n\n\t\t// sleep for 2 seconds to avoid rejection from the website\n\t\tif i%16 == 0 {\n\t\t\ttime.Sleep(2 * time.Second)\n\t\t}\n\t}\n}", "func (s *Service) FindAll(ctx context.Context, req FindRequest) ([]*Article, error) {\n\trecorder := timeutil.NewRecorder(\"find all articles\")\n\tdefer log.WithContext(ctx).Info(recorder)\n\tif err := validator.Validate(req); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid find request: %w\", err)\n\t}\n\tif req.Limit > s.conf.MaxPageSize {\n\t\treq.Limit = s.conf.MaxPageSize\n\t}\n\tarticles, err := s.repo.FindAll(ctx, req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to find articles: %w\", err)\n\t}\n\treturn articles, nil\n}", "func FindArticlesBy(field string, val interface{}) (_articles []Article, err error) {\n\tsqlFmt := `SELECT COALESCE(articles.text, '') AS text, articles.id, articles.title, articles.created_at, articles.updated_at FROM articles WHERE %s = ?`\n\tsqlStr := fmt.Sprintf(sqlFmt, field)\n\terr = DB.Select(&_articles, DB.Rebind(sqlStr), val)\n\tif err != nil {\n\t\tlog.Printf(\"Error: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\treturn _articles, nil\n}", "func ListArticles(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\tvar articles []*models.Posts\n\n\tarticles, err = dbListArticle()\n\tif err != nil {\n\t\trender.Render(w, r, ErrNotFound)\n\t\treturn\n\t}\n\n\n\tif err := render.RenderList(w, r, NewArticleListResponse(articles)); err != nil {\n\t\trender.Render(w, r, ErrRender(err))\n\t\treturn\n\t}\n}", "func AllArticles() []Article {\n\tvar articles []Article\n\tfiles, err := ioutil.ReadDir(\"./articles\")\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tfor _, f := range files {\n\t\ta, _ := parseArticle(f.Name())\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\tarticles = append(articles, a)\n\t}\n\n\treturn articles\n}", "func (c *Client) ListArticles(feedID string) ([]Article, error) {\n\tarticles := []Article{}\n\t_, err := c.sling.Get(fmt.Sprintf(\"feeds/%s/articles\", feedID)).ReceiveSuccess(&articles)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn articles, nil\n}", "func GetAllArticleList(w http.ResponseWriter, r *http.Request) {\n var articlesWithoutFullText []Article\n for _, item := range article {\n item.FullText = \"\"\n articlesWithoutFullText = append(articlesWithoutFullText, item)\n }\n json.NewEncoder(w).Encode(articlesWithoutFullText)\n}", "func (s *Service) article(c context.Context, mid, zoneid int64, highlight int, keyword, mobiApp, device, platform, buvid, filtered, order, sType string, plat int8, categoryID, build, pn, ps int, now time.Time) (res *search.TypeSearch, err error) {\n\tif res, err = s.srchDao.ArticleByType(c, mid, zoneid, keyword, mobiApp, device, platform, buvid, filtered, order, sType, plat, categoryID, build, highlight, pn, ps, now); err != nil {\n\t\tlog.Error(\"%+v\", err)\n\t\treturn\n\t}\n\tif res != nil && len(res.Items) > 0 {\n\t\tvar mids []int64\n\t\tfor _, v := range res.Items {\n\t\t\tmids = append(mids, v.Mid)\n\t\t}\n\t\tvar infom map[int64]*account.Info\n\t\tif infom, err = s.accDao.Infos3(c, mids); err != nil {\n\t\t\tlog.Error(\"%+v\", err)\n\t\t\terr = nil\n\t\t\treturn\n\t\t}\n\t\tfor _, item := range res.Items {\n\t\t\tif info, ok := infom[item.Mid]; ok {\n\t\t\t\titem.Name = info.Name\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (JSONPresenter) GetArticlesByTag(tagName string, articles []entities.Article) string {\n\n\tids, relatedTags := []string{}, []string{}\n\n\ttagSet := map[string]bool{}\n\n\tfor _, a := range articles {\n\t\tids = append(ids, a.GetID())\n\t\tfor _, tag := range a.GetTags() {\n\t\t\ttagSet[tag] = true\n\t\t}\n\t}\n\n\tfor tag := range tagSet {\n\t\tif tag != tagName {\n\t\t\trelatedTags = append(relatedTags, tag)\n\t\t}\n\t}\n\n\n\tvar limitedIDs []string \n\t\n\tlimitedIDs = ids\n\n\tif len(ids) >= 10 {\n\t\tlimitedIDs = ids[:10]\n\t}\n\n\tformatted := map[string]interface{}{\n\t\t\"tag\": tagName,\n\t\t\"count\": len(articles),\n\t\t\"articles\": limitedIDs,\n\t\t\"related_tags\": relatedTags,\n\t}\n\n\tjson, err := json.Marshal(formatted)\n\n\tif err != nil {\n\t\tlog.Printf(\"error serializing articles: %s\", err)\n\t\treturn \"\"\n\t}\n\n\tlog.Printf(\"presenter %s\", json)\n\n\treturn string(json)\n}", "func (s Store) ListArticles() ([]string, error) {\n\tdir, err := os.Open(s.basePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer dir.Close()\n\treturn dir.Readdirnames(0)\n}", "func (ac *ArticleController) List(w http.ResponseWriter, r *http.Request) {\n\t// by get params:\n\t// - n: number of articles to fetch (max 10), default 5\n\t// - likes: {true/false} count likes for article\n\t// - comments: {true/false} count comments for article\n\n\t// by htttreemux params\n\t// year, month, day\n\n\tp := httptreemux.ContextParams(r.Context())\n\tanswer := []map[string]interface{}{}\n\tvar date time.Time\n\n\tyear, err := strconv.Atoi(p[\"year\"])\n\tif err != nil {\n\t\t// year it's unreadable\n\t\tdate = time.Now()\n\t} else {\n\t\tmonth, err := strconv.Atoi(p[\"month\"])\n\t\tif err != nil {\n\t\t\t// month ureadable, default\n\t\t\tmonth = 12 // December\n\t\t} else {\n\t\t\t// dates are in input in js format\n\t\t\t// so month starts from 0\n\t\t\t// but go internal dates start from 1\n\t\t\t// so we need to increment the input\n\t\t\tmonth++\n\t\t}\n\t\tday, err := strconv.Atoi(p[\"day\"])\n\t\tif err != nil {\n\t\t\t// day unreadable, default\n\t\t\t// from godoc.org/time\n\t\t\t// The month, day, hour, min, sec, and nsec values may be outside their usual ranges\n\t\t\t// and will be normalized during the conversion. For example, October 32 converts to November 1.\n\t\t\tmonth++\n\t\t\tday = 1\n\t\t}\n\t\t// set date with given inputsex\n\t\tdate = time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.Local)\n\t}\n\n\t// get parameters handling\n\tn := 5\n\tnPar, err := strconv.Atoi(r.FormValue(\"n\"))\n\tif err == nil && nPar > 0 && nPar < 10 { //if n is too great or not valid, fall to default\n\t\tn = nPar\n\t}\n\n\tlFlag := r.FormValue(\"likes\") == \"true\"\n\tcFlag := r.FormValue(\"comments\") == \"true\"\n\n\txa := models.Articles(n, date)\n\tfor _, ar := range xa {\n\t\tsingle := map[string]interface{}{}\n\t\tsingle[\"article\"] = ar\n\t\tif lFlag { // get likes count\n\t\t\tsingle[\"likes\"] = models.LikesCount(ar.ID)\n\t\t}\n\t\tif cFlag {\n\t\t\tsingle[\"comments\"] = models.CommentsCount(ar.ID)\n\t\t}\n\t\tanswer = append(answer, single)\n\t}\n\tif len(answer) == 0 {\n\t\tsendJSON(answer, http.StatusNotFound, w)\n\t} else {\n\t\tsendJSON(answer, http.StatusOK, w)\n\t}\n}", "func article(g *echo.Group, db *sqlx.DB) {\n\tarticleModel := model.NewArticleModel(*db, viper.GetString(\"schema.article\"))\n\ttagModel := model.NewTagModel(*db, viper.GetString(\"schema.tag\"))\n\n\tarticleLogic := articlelogic.NewArticleLogic(articleModel, tagModel)\n\troutes := articleRouter(articleLogic)\n\tAddRoutes(g, routes)\n}", "func (s ArticleService) List(ctx context.Context) ([]Article, error) {\n\tstat := `SELECT id, title, description, content FROM articles;`\n\tif s.DB == nil {\n\t\tpanic(\"no existing database\")\n\t}\n\trows, err := s.DB.QueryContext(ctx, stat)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tret := make([]Article, 0, 20)\n\tfor rows.Next() {\n\t\tfmt.Println(\"got 1 record\")\n\t\tvar article Article\n\t\terr := rows.Scan(&article.ID, &article.Title, &article.Desc, &article.Content)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, article)\n\t}\n\treturn ret, err\n\n}", "func (self PostgresDatabase) GetAllArticles() (articles []ArticleEntry) {\n rows, err := self.conn.Query(\"SELECT message_id, newsgroup FROM ArticlePosts\")\n if err == nil {\n for rows.Next() {\n var entry ArticleEntry\n rows.Scan(&entry[0], &entry[1])\n articles = append(articles, entry)\n }\n rows.Close()\n } else {\n log.Println(\"failed to get all articles\", err)\n }\n return articles\n}", "func (handler WebserviceHandler) GetKeywords(res http.ResponseWriter, req *http.Request) {\n\thandler.Logger.Info(\"Received \" + req.Method + \" request at path: \" + req.URL.Path)\n\n\t// Setting headers for CORS\n\tres.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tres.Header().Set(\"Access-Control-Allow-Headers\", \"Authorization\")\n\tif req.Method == http.MethodOptions {\n\t\treturn\n\t}\n\n\thandler.Logger.Debug(\"Starting to retrieve keywords\")\n\tkeywordsUseCase, err := handler.KeywordsInteractor.Keywords()\n\tif err != nil {\n\t\tres.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\thandler.Logger.Debug(\"Keywords retrieved\")\n\n\thandler.Logger.Debug(\"Transforming data for presentation\")\n\tvar keywords []Keyword\n\tfor _, keyword := range keywordsUseCase {\n\t\tkeywords = append(keywords, Keyword{keyword.ID, keyword.DisplayText})\n\t}\n\tkb := Keywords{keywords}\n\thandler.Logger.Debug(\"Data transformed\")\n\n\thandler.Logger.Debug(\"Starting writing body\")\n\tvar body []byte\n\tif body, err = json.Marshal(kb); err != nil {\n\t\tres.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\thandler.Logger.Debug(\"Body written\")\n\n\tres.Header().Add(\"Content-Type\", \"application/json\")\n\n\tres.WriteHeader(200)\n\t_, err = res.Write(body)\n\tif err != nil {\n\t\treturn\n\t}\n\thandler.Logger.Info(\"Returning response\")\n\treturn\n}", "func getEntries(URL string, page, limit int) ([]model.Entry, error) {\n\tentries := make([]model.Entry, 0)\n\n\tfor {\n\t\tresp, err := http.Get(URL + strconv.Itoa(page))\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"ERROR: internet bağlantınızı kontrol edin\")\n\t\t}\n\n\t\troot, err := html.Parse(resp.Body)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"ERROR: An error occured while parsing body\")\n\t\t}\n\t\tdefer resp.Body.Close()\n\n\t\tif _, ok := scrape.Find(root, isTopicFoundMatcher); !ok {\n\t\t\treturn nil, errors.New(\"ERROR: \" + strconv.Itoa(page) + \". sayfa yok\")\n\t\t}\n\n\t\tentryList, ok := scrape.Find(root, entryListMatcher)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"ERROR: Site layoutu değişmiş olabilir | Report: github.com/mucanyu/eksisozluk-go/issues\")\n\t\t}\n\n\t\tentryNodeList := scrape.FindAll(entryList, entryMatcher)\n\n\t\tfor _, enode := range entryNodeList {\n\t\t\tentry := model.Entry{}\n\t\t\tentry.Text = scrape.Text(enode)\n\n\t\t\tautNode, ok := scrape.Find(enode.Parent, authorMatcher)\n\t\t\tif ok {\n\t\t\t\tentry.Author = scrape.Text(autNode)\n\t\t\t}\n\n\t\t\tdateNode, ok := scrape.Find(enode.Parent, dateMatcher)\n\t\t\tif ok {\n\t\t\t\tentry.Date = scrape.Text(dateNode)\n\t\t\t}\n\n\t\t\tentries = append(entries, entry)\n\t\t\tlimit--\n\t\t\tif limit == 0 {\n\t\t\t\treturn entries, nil\n\t\t\t}\n\t\t}\n\t\tif len(entries)%10 != 0 {\n\t\t\treturn entries, nil\n\t\t}\n\t\tpage++\n\t}\n}", "func (s *Service) Article(id alarmquote.ArticleID) (*alarmquote.Article, error) {\n\treturn s.repo.Retrieve(id)\n}", "func (service *RssService) Search(searchString string, isBookmark bool, feedID int64, userID int64) *models.ArticlesJSON {\n\tvar articles []models.Articles\n\tquery := service.db.\n\t\tJoins(\"join feeds on articles.FeedId = feeds.Id\").\n\t\tSelect(\"articles.Id, articles.Title, articles.IsBookmark, articles.IsRead, articles.Link\").\n\t\tWhere(\"(articles.Title LIKE ? OR articles.Body LIKE ?) and feeds.UserId = ?\", \"%\"+searchString+\"%\", \"%\"+searchString+\"%\", userID)\n\n\tif feedID != 0 {\n\t\tquery = query.Where(&models.Articles{Id: feedID})\n\t}\n\tif isBookmark {\n\t\tquery = query.Where(\"articles.IsBookmark = 1\")\n\t}\n\n\tquery.Find(&articles)\n\n\treturn &models.ArticlesJSON{Articles: articles}\n}", "func (ads *ArticleDS) Get(idS string) (*articles.Article, error) {\n\tid, err := strconv.Atoi(idS)\n\tif err != nil {\n\t\treturn nil, status.ErrBadRequest.WithMessage(err.Error())\n\t}\n\tdb := ads.db\n\ta := articles.Article{}\n\tfindStmt := `SELECT id, title, publish_date, body, tags FROM ARTICLES.ARTICLE WHERE id = $1`\n\terr = db.QueryRow(\n\t\tfindStmt,\n\t\tid).Scan(&a.ID, &a.Title, &a.Date, &a.Body, pq.Array(&a.Tags))\n\tif err == sql.ErrNoRows {\n\t\treturn nil, status.ErrNotFound.WithMessage(err.Error())\n\t}\n\treturn &a, nil\n}", "func Article(w http.ResponseWriter, r *http.Request) {\n\t// Get the ID\n\tid := mux.Vars(r)[\"id\"]\n\n\t// Check auth filter\n\t_, err := user.FromSession(r)\n\t// Define an article variable\n\tvar a article.Article\n\tif err == nil {\n\t\t// Attempt to find the article (no filter for published status due to authed user)\n\t\ta, err = article.Get(id, nil)\n\t} else {\n\t\t// Request a the published article\n\t\tpublished := true\n\t\ta, err = article.Get(id, &published)\n\t}\n\n\tif err != nil {\n\t\t// Not found, return 404\n\t\tHandleNotFound(w, r)\n\t\treturn\n\t}\n\n\t// Build the markup\n\ta.ParseHTML()\n\ta.FormatTimestamp()\n\n\t// Prepare the view\n\tdata := viewmodels.Article()\n\tdata.Article = a\n\tdata.Layout.Meta.Title = a.Title + \" - ESA Marathon\"\n\n\tRenderer.HTML(w, http.StatusOK, \"article.html\", data)\n}", "func (r *Resolver) ArticleFindList() runtime.ArticleFindListResolver {\n\treturn &articleFindListResolver{r}\n}", "func (as *ArticleService) GetArticle(id string) (*entities.Article, []error) {\n\tarticle, errs := as.articleRepo.GetArticle(id) // here article is pointer btw, it is accesing from the one we did in the repository layer\n\n\tif len(errs) > 0 {\n\t\treturn nil, errs\n\t}\n\treturn article, nil\n}", "func FindArticles(ids ...int64) ([]Article, error) {\n\tif len(ids) == 0 {\n\t\tmsg := \"At least one or more ids needed\"\n\t\tlog.Println(msg)\n\t\treturn nil, errors.New(msg)\n\t}\n\t_articles := []Article{}\n\tidsHolder := strings.Repeat(\",?\", len(ids)-1)\n\tsql := DB.Rebind(fmt.Sprintf(`SELECT COALESCE(articles.text, '') AS text, articles.id, articles.title, articles.created_at, articles.updated_at FROM articles WHERE articles.id IN (?%s)`, idsHolder))\n\tidsT := []interface{}{}\n\tfor _,id := range ids {\n\t\tidsT = append(idsT, interface{}(id))\n\t}\n\terr := DB.Select(&_articles, sql, idsT...)\n\tif err != nil {\n\t\tlog.Printf(\"Error: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\treturn _articles, nil\n}", "func (d *DB) All() []Article {\n\tst, err := d.db.Prepare(\"select id,feed,title,content,published,link,read,display_name from articles where deleted = false order by id\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil\n\t}\n\tdefer st.Close()\n\n\trows, err := st.Query()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil\n\t}\n\tdefer rows.Close()\n\n\tvar (\n\t\tid int\n\t\ttitle string\n\t\tcontent string\n\t\tfeed string\n\t\tlink string\n\t\tread bool\n\t\tdisplay string\n\t\tpublished time.Time\n\t)\n\n\tarticles := []Article{}\n\n\tfor rows.Next() {\n\t\terr = rows.Scan(&id, &feed, &title, &content, &published, &link, &read, &display)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\n\t\t// Check if we should higlight it\n\t\tfields := strings.Fields(title)\n\t\thighlight := false\n\t\tfor _, f := range fields {\n\t\t\tfor _, h := range d.c.conf.Highlights {\n\t\t\t\tif strings.Contains(strings.ToLower(f), strings.ToLower(h)) {\n\t\t\t\t\thighlight = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif highlight {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tarticles = append(articles, Article{id: id, highlight: highlight, feed: feed, title: title, content: content, published: published, link: link, read: read, feedDisplay: display})\n\t}\n\treturn articles\n}", "func (service *RssService) Search(searchString string, isBookmark bool, feedID uint) *models.ArticlesJSON {\n\t// fixme\n\tbm := 0\n\n\tif isBookmark {\n\t\tbm = 1\n\t}\n\n\tvar articles []models.Articles\n\tquery := service.dbp().\n\t\tSelect(\"Id, Title, IsBookmark, IsRead\").\n\t\tWhere(\"IsBookmark = ? AND (Title LIKE ? OR Body LIKE ?)\", bm, \"%\"+searchString+\"%\", \"%\"+searchString+\"%\")\n\n\tif feedID != 0 {\n\t\tquery = query.Where(&models.Articles{Id: feedID})\n\t}\n\n\tquery.Find(&articles)\n\n\treturn &models.ArticlesJSON{Articles: articles}\n}", "func (i Index) HandleRequest(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tpage := 1\n\tkeys, ok := r.URL.Query()[\"page\"]\n\tif ok && len(keys[0]) > 0 {\n\t\ti, err := strconv.Atoi(keys[0])\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t}\n\t\tpage = i\n\t}\n\tarticles, err := i.Repository.Fetch(100, page)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n\tjson.NewEncoder(w).Encode(articles)\n}", "func (c *ArticlesController) Article(ctx *app.ArticleArticlesContext) error {\n\t// ArticlesController_Article: start_implement\n\n\t// Put your logic here\n\tarticleTable := models.NewArticleDB(c.db)\n\tarticle, err := articleTable.OneGoaNewsAPIArticle(ctx.Context, ctx.ID)\n\n\tif err != nil {\n\t\treturn ctx.NotFound()\n\t}\n\n\t// ArticlesController_Article: end_implement\n\tres := &app.GoaNewsAPIArticle{}\n\tres = article\n\treturn ctx.OK(res)\n}", "func (p *Parser) GetArticle(id int) (*model.Article, int, error) {\n\tdoc, code, err := p.getDoc(utils.BuildURL(malURL, \"featured\", id), \".content-left\")\n\tif err != nil {\n\t\treturn nil, code, err\n\t}\n\treturn p.article.GetDetails(doc), http.StatusOK, nil\n}", "func FindArticlesWhere(where string, args ...interface{}) (articles []Article, err error) {\n\tsql := \"SELECT COALESCE(articles.text, '') AS text, articles.id, articles.title, articles.created_at, articles.updated_at FROM articles\"\n\tif len(where) > 0 {\n\t\tsql = sql + \" WHERE \" + where\n\t}\n\tstmt, err := DB.Preparex(DB.Rebind(sql))\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\terr = stmt.Select(&articles, args...)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\treturn articles, nil\n}", "func (s *searcher) Keyword(resp http.ResponseWriter, req *http.Request) {\n\tsearchTerms := mux.Vars(req)\n\n\tkey := searchTerms[\"keyword\"]\n\tif len(key) == 0 {\n\t\tresp.WriteHeader(http.StatusBadRequest)\n\t\tresp.Write([]byte(\"keyword is empty\"))\n\t\treturn\n\t}\n\n\tsearchPaths, err := s.searchIndex.GetTransactionPathsByKeyword(key)\n\tif err != nil {\n\t\tresp.WriteHeader(http.StatusInternalServerError)\n\t\tresp.Write([]byte(fmt.Sprintf(\"error finding transactions: %s\", err.Error())))\n\t\treturn\n\t}\n\n\ttransactions, err := s.searchIndex.GetTransactionsFromFiles(searchPaths)\n\tif err != nil {\n\t\tresp.WriteHeader(http.StatusInternalServerError)\n\t\tresp.Write([]byte(fmt.Sprintf(\"error finding transactions: %s\", err.Error())))\n\t\treturn\n\t}\n\n\tresultBytes, err := json.Marshal(transactions)\n\tif err != nil {\n\t\tresp.WriteHeader(http.StatusInternalServerError)\n\t\tresp.Write([]byte(fmt.Sprintf(\"error marshallig transactions to json: %s\", err.Error())))\n\t\treturn\n\t}\n\n\tresp.WriteHeader(http.StatusOK)\n\tresp.Write(resultBytes)\n}", "func (mr *MockHandlerMockRecorder) GetArticles(username, limit, offset, filters interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetArticles\", reflect.TypeOf((*MockHandler)(nil).GetArticles), username, limit, offset, filters)\n}", "func (s *Server) LatestArticles(ctx context.Context, in *pb.LatestArticlesRequest) (*pb.ArticlesReply, error) {\n\tif in.Count == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"count cannot be 0\")\n\t}\n\tif in.Count > 50 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"count cannot be greater than 50\")\n\t}\n\tres, err := s.db.Latest(ctx, in.Category, in.Count, in.Status)\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, fmt.Sprintf(\"failed to get latest articles: %v\", err))\n\t}\n\n\treturn &pb.ArticlesReply{Articles: res}, nil\n}", "func GenArticlesFromRssFeed(rssURI string) ([]Article, error) {\n\n\titems, err := services.RetrieveItemsFromRss(rssURI)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar listOfArticles []Article\n\tfor i, v := range items {\n\t\tarticle := Article{ID: i, Title: v.Title, Desc: v.Description, Link: v.Link}\n\n\t\tlistOfArticles = append(listOfArticles, article)\n\t}\n\n\treturn listOfArticles, nil\n}", "func (mr *MockArticlesLogicMockRecorder) GetArticles(username, limit, offset, filters interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetArticles\", reflect.TypeOf((*MockArticlesLogic)(nil).GetArticles), username, limit, offset, filters)\n}", "func GetArticleDetail(c *gin.Context) {\n\twebapp := app.GinCtx{C: c}\n\taid, err := utils.Str(c.DefaultQuery(\"aid\", \"0\")).Int64()\n\tif err != nil {\n\t\tlog.Info(c, \"invalid param aid,\", err.Error())\n\t\twebapp.MakeFailedJsonRes(http.StatusOK, err)\n\t\treturn\n\t}\n\n\tsrv := NewArticleService(&Article{}, &ArticleModelImpl{})\n\tsrv.Data.Aid = aid\n\terr = srv.DetailArticle(c)\n\tif err != nil {\n\t\twebapp.MakeFailedJsonRes(0, err)\n\t\treturn\n\t}\n\twebapp.MakeSuccessJsonRes(http.StatusOK, srv.Data)\n}", "func FetchArticle(ctx context.Context, url string) (*model.Article, error) {\n\t// Validate URL\n\t_, err := nurl.ParseRequestURI(url)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid URL: %v\", err)\n\t}\n\n\t// Get URL content type\n\tcontentType, err := getContentType(ctx, url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !strings.HasPrefix(contentType, \"text/html\") {\n\t\treturn nil, fmt.Errorf(\"invalid content-type: %s\", contentType)\n\t}\n\n\t// Get URL content\n\tres, err := get(ctx, url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer res.Body.Close()\n\tbody, err := charset.NewReader(res.Body, contentType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Extract metas\n\tmetas, err := ExtractMetas(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create article with Open Graph atributes\n\tresult := &model.Article{\n\t\tText: metas.GetContent(\"og:description\", \"twitter:description\", \"description\"),\n\t\tImage: metas.GetContent(\"og:image\", \"twitter:image\"),\n\t}\n\ttitle := metas.GetContent(\"og:title\")\n\tif title != nil {\n\t\tresult.Title = *title\n\t}\n\n\tvar buffer bytes.Buffer\n\ttee := io.TeeReader(body, &buffer)\n\n\t// Test if the HTML page is readable by Shiori readability\n\tif !read.IsReadable(tee) {\n\t\treturn result, fmt.Errorf(\"unable to extract content from HTML page\")\n\t}\n\n\t// Extract content from the HTML page\n\tarticle, err := read.FromReader(&buffer, url)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\t// Complete result with extracted properties\n\tresult.HTML = &article.Content\n\tif result.Title == \"\" {\n\t\tresult.Title = article.Title\n\t}\n\tif result.Text == nil {\n\t\t// FIXME: readability excerpt don't well support UTF8\n\t\ttext := tooling.ToUTF8(article.Excerpt)\n\t\tresult.Text = &text\n\t}\n\tif result.Image == nil {\n\t\tresult.Image = &article.Image\n\t}\n\n\t// TODO: add other properties to the result\n\t// article.Favicon\n\t// article.Length\n\t// article.SiteName\n\n\treturn result, nil\n}", "func (a *ArticleController) Get() {\n\n\to := orm.NewOrm()\n\tid, _ := strconv.Atoi(a.Ctx.Input.Param(\":id\"))\n\tarticle := m.Article{Id: id}\n\terr := o.Read(&article)\n\tif err == orm.ErrNoRows {\n\t\tfmt.Println(\"查询不到\")\n\t} else if err == orm.ErrMissPK {\n\t\tfmt.Println(\"找不到主键\")\n\t} else {\n\t\ta.Data[\"model\"] = article\n\t}\n\ta.Data[\"test\"] = err\n\ta.Data[\"id\"] = id\n\ta.Data[\"title\"] = article.Title\n\ta.Layout = \"nimda/layout.tpl\"\n\n}", "func (m *MockArticleLogic) ArticleGet(slug, username string) (*domain.User, *domain.Article, error) {\n\tret := m.ctrl.Call(m, \"ArticleGet\", slug, username)\n\tret0, _ := ret[0].(*domain.User)\n\tret1, _ := ret[1].(*domain.Article)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}" ]
[ "0.6451116", "0.63958263", "0.6380423", "0.6260228", "0.61972106", "0.6151694", "0.6122455", "0.60833824", "0.5931939", "0.59121436", "0.5874952", "0.5871982", "0.58573645", "0.5850068", "0.5837676", "0.5773559", "0.5768707", "0.571975", "0.57004565", "0.56893593", "0.5687668", "0.56810594", "0.5645666", "0.55635303", "0.55402935", "0.55098957", "0.54944205", "0.5494108", "0.54911107", "0.54864705", "0.5477424", "0.53693545", "0.5367812", "0.5363106", "0.5343049", "0.53192896", "0.53076375", "0.5298064", "0.5294353", "0.5280671", "0.52694476", "0.52545863", "0.5240173", "0.5194432", "0.51905954", "0.5145675", "0.5130221", "0.5118294", "0.51035583", "0.5082818", "0.5081674", "0.50735474", "0.50698525", "0.50629085", "0.50526005", "0.50523955", "0.50409985", "0.5039865", "0.5034776", "0.501248", "0.49983743", "0.49946928", "0.4981023", "0.4964531", "0.49588358", "0.495326", "0.49434718", "0.49277127", "0.49173638", "0.49132973", "0.48992592", "0.48951957", "0.48837405", "0.48831713", "0.48620725", "0.485008", "0.4839419", "0.4838001", "0.4836838", "0.48324326", "0.48307952", "0.48215064", "0.48054048", "0.4779261", "0.47704297", "0.47451863", "0.47405308", "0.4734675", "0.47276872", "0.47231078", "0.46826795", "0.466929", "0.4661435", "0.4660469", "0.4650532", "0.46364346", "0.46321592", "0.46320152", "0.4600879", "0.45969057" ]
0.7885638
0
GetHeadlines returns all the articles in given a request, a category can be one of the following: entertainement, general, health, science, sports, technology, business
func (a *Api) GetHeadlines(category string) (*Response, error) { req := ReqHeadlines{baseUrl: a.baseUrl, category: category} return a.do(req) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t *NewsService) Headlines(request *HeadlinesRequest) (*HeadlinesResponse, error) {\n\n\trsp := &HeadlinesResponse{}\n\treturn rsp, t.client.Call(\"news\", \"Headlines\", request, rsp)\n\n}", "func TopHeadlines(ctx context.Context, _ store.Store, r *http.Request) (*SuccessResponse, error) {\n\tr.ParseForm()\n\n\tclient = newsclient.New(headlinesEndpoint)\n\tparams := new(headlines.Params)\n\terr := schema.NewDecoder().Decode(params, r.Form)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error decoding params: %v\", err)\n\t}\n\n\tif params.Page == 0 {\n\t\tparams.Page = 1\n\t}\n\n\t// Requests to external services should have timeouts.\n\treqCtx, cancel := context.WithTimeout(ctx, defaultDuration)\n\tdefer cancel()\n\n\tres, err := fetch(reqCtx, params)\n\tif err != nil {\n\t\treturn nil, &httperror.HTTPError{\n\t\t\tCode: http.StatusBadRequest,\n\t\t\tMessage: err.Error(),\n\t\t\tRequestURL: r.RequestURI,\n\t\t\tDocsURL: headlinesEndpoint.DocsURL,\n\t\t}\n\t}\n\n\treturn &SuccessResponse{\n\t\tCode: http.StatusOK,\n\t\tRequestURL: r.RequestURI,\n\t\tCount: len(res.Articles),\n\t\tPage: params.Page,\n\t\tTotalCount: res.TotalResults,\n\t\tData: res.Articles,\n\t}, nil\n}", "func getTopHeadlines(endpoint string) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\t//Assign search to an instance of Search struct from HTML selection box form value.\n\t\tsearch := &Search{\n\t\t\tQuery: c.Request.FormValue(\"c\"),\n\t\t\tCountry: \"\",\n\t\t}\n\n\t\t//Load HTML templates from folder\n\t\tr.LoadHTMLGlob(\"templates/*\")\n\n\t\t//First time load to avoid empty API call\n\t\tif search.Query == \"\" {\n\t\t\tc.HTML(http.StatusOK, \"header_headlines.tmpl.html\", gin.H{\n\t\t\t\t\"title\": \"News Aggregation\",\n\t\t\t\t\"country\": search.Country,\n\t\t\t\t\"query\": search.Query,\n\t\t\t})\n\n\t\t\t//Build footer HTML\n\t\t\tc.HTML(http.StatusOK, \"footer.tmpl.html\", gin.H{})\n\t\t} else {\n\t\t\t//Switch title based on selection box query.\n\t\t\tswitch search.Query {\n\t\t\tcase \"za\":\n\t\t\t\tsearch.Country = \"South Africa\"\n\t\t\tcase \"ae\":\n\t\t\t\tsearch.Country = \"United Arab Emirates\"\n\t\t\tcase \"ar\":\n\t\t\t\tsearch.Country = \"Argentina\"\n\t\t\tcase \"at\":\n\t\t\t\tsearch.Country = \"Austria\"\n\t\t\tcase \"au\":\n\t\t\t\tsearch.Country = \"Australia\"\n\t\t\tcase \"be\":\n\t\t\t\tsearch.Country = \"Belgium\"\n\t\t\tcase \"bg\":\n\t\t\t\tsearch.Country = \"Bulgaria\"\n\t\t\tcase \"ca\":\n\t\t\t\tsearch.Country = \"Canada\"\n\t\t\tcase \"ch\":\n\t\t\t\tsearch.Country = \"Switzerland\"\n\t\t\tcase \"cn\":\n\t\t\t\tsearch.Country = \"China\"\n\t\t\tcase \"co\":\n\t\t\t\tsearch.Country = \"Colombia\"\n\t\t\tcase \"cu\":\n\t\t\t\tsearch.Country = \"Cuba\"\n\t\t\tcase \"cz\":\n\t\t\t\tsearch.Country = \"Czechia\"\n\t\t\tcase \"de\":\n\t\t\t\tsearch.Country = \"Germany\"\n\t\t\tcase \"eg\":\n\t\t\t\tsearch.Country = \"Egypt\"\n\t\t\tcase \"fr\":\n\t\t\t\tsearch.Country = \"France\"\n\t\t\tcase \"gb\":\n\t\t\t\tsearch.Country = \"United Kingdom\"\n\t\t\tcase \"gr\":\n\t\t\t\tsearch.Country = \"Greece\"\n\t\t\tcase \"hk\":\n\t\t\t\tsearch.Country = \"Hong Kong\"\n\t\t\tcase \"hu\":\n\t\t\t\tsearch.Country = \"Hungary\"\n\t\t\tcase \"id\":\n\t\t\t\tsearch.Country = \"Indonesia\"\n\t\t\tcase \"ru\":\n\t\t\t\tsearch.Country = \"Russian Federation\"\n\t\t\tcase \"us\":\n\t\t\t\tsearch.Country = \"United States of America\"\n\t\t\tdefault:\n\t\t\t\tsearch.Country = \"\"\n\t\t\t}\n\n\t\t\t/*Construct the URL using the hard coded endpoint, user input query, and file read API key.\n\t\t\tThe net/http package creates a client and fetches the API's news response body in JSON format.\n\t\t\tThen we assign it to our NewsResults struct.\n\t\t\t*/\n\t\t\turl := endpoint + search.Query + apiKey\n\n\t\t\tclient := http.Client{\n\t\t\t\tTimeout: time.Second * 10,\n\t\t\t}\n\n\t\t\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tres, err := client.Do(req)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\t//Execute res.Body.Close() at the end of the function to avoid memory leak.\n\t\t\tif res.Body != nil {\n\t\t\t\tdefer res.Body.Close()\n\t\t\t}\n\n\t\t\t//Read body response from client\n\t\t\tbody, err := ioutil.ReadAll(res.Body)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tjsonErr := json.Unmarshal(body, &NewsResultsVar)\n\t\t\tif jsonErr != nil {\n\t\t\t\tpanic(jsonErr)\n\t\t\t}\n\n\t\t\t//Call HTML for /topheadlines using mutliple templates\n\t\t\t//Call head & header of HTML\n\t\t\tc.HTML(http.StatusOK, \"header_headlines.tmpl.html\", gin.H{\n\t\t\t\t\"title\": \"News Aggregation | \" + search.Country,\n\t\t\t\t\"country\": search.Country,\n\t\t\t\t\"query\": search.Query,\n\t\t\t\t\"status\": NewsResultsVar.Status,\n\t\t\t\t\"code\": NewsResultsVar.Code,\n\t\t\t\t\"message\": NewsResultsVar.Message,\n\t\t\t})\n\t\t\t//Call and duplicate article format based on the amount of articles pulled fomr the API\n\t\t\tc.HTML(http.StatusOK, \"articles_container.tmpl.html\", gin.H{})\n\t\t\tfor _, article := range NewsResultsVar.Articles {\n\t\t\t\tc.HTML(http.StatusOK, \"articles.tmpl.html\", gin.H{\n\t\t\t\t\t//Send JSON data to HTML\n\t\t\t\t\t\"articleSource\": article.Source.Name,\n\t\t\t\t\t\"articlePubDate\": article.PublishedAt.Format(\"January 2, 2006\"),\n\t\t\t\t\t\"articleTitle\": article.Title,\n\t\t\t\t\t\"articleDescription\": article.Description,\n\t\t\t\t\t\"articleImage\": article.UrlToImage,\n\t\t\t\t\t\"articleUrl\": article.Url,\n\t\t\t\t})\n\t\t\t}\n\t\t\t//Call footer HTML\n\t\t\tc.HTML(http.StatusOK, \"footer.tmpl.html\", gin.H{})\n\t\t}\n\t}\n}", "func HeadlinesGetter() (AggregatedNews, error) {\n\tfmt.Println(\"retreiving news headline cached\")\n\t// RetrieveCachedNews(key string, redisPool *redis.Pool)\n\tkey := cache.RedisKeyGen(headLines...)\n\n\tobjID, err := cache.RetrieveCachedNews(key, RedisPool)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tvar x AggregatedNews\n\t\treturn x, err\n\t}\n\n\tresults, err := NewsMainIndexNewsCached(objID...)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn results, err\n\t}\n\n\treturn results, nil\n}", "func (s WashingtonPostScraper) ScrapeHeadlines() (*[]*Headline, error) {\n\theadlines := make([]*Headline, 0)\n\tvar parseErr error\n\ts.collector.OnHTML(\"#main-content\", func(e *colly.HTMLElement) {\n\t\te.ForEach(\"div.flex-item\", func(ndx int, flex *colly.HTMLElement) {\n\t\t\turl := flex.ChildAttr(\"div.headline > a\", \"href\")\n\t\t\tif url != \"\" {\n\t\t\t\ttitle := flex.ChildText(\"div.headline > a\")\n\t\t\t\tblurb := flex.ChildText(\"div.blurb\")\n\t\t\t\tnewHeadline := &Headline{\n\t\t\t\t\tURL: &url,\n\t\t\t\t\tTitle: &title,\n\t\t\t\t}\n\t\t\t\tif blurb != \"\" {\n\t\t\t\t\tnewHeadline.Blurb = &blurb\n\t\t\t\t}\n\n\t\t\t\theadlines = append(headlines, newHeadline)\n\t\t\t}\n\t\t})\n\t})\n\n\t// Set error handler\n\ts.collector.OnError(func(r *colly.Response, err error) {\n\t\tparseErr = err\n\t})\n\n\ts.collector.Visit(s.URL())\n\treturn &headlines, parseErr\n}", "func headlines(w, h openvg.VGfloat, section string) {\n\tr, err := netread(fmt.Sprintf(NYTfmt, section, NYTAPIkey))\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"headline read error: %v\\n\", err)\n\t\tgerror(0, 0, w, h*0.5, \"no headlines\")\n\t\treturn\n\t}\n\tdefer r.Close()\n\tvar data NYTHeadlines\n\terr = json.NewDecoder(r).Decode(&data)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"decode: %v\\n\", err)\n\t\tgerror(0, 0, w, h*0.5, \"no headlines\")\n\t\treturn\n\t}\n\tx := w * 0.50\n\ty := h * 0.10\n\tregionFill(0, 0, w, h*.50, bgcolor)\n\theadsize := w / 70\n\tspacing := headsize * 2.0\n\tfor i := len(data.Results) - 1; i >= 0; i-- {\n\t\topenvg.TextMid(x, y, fromHTML.Replace(data.Results[i].Title), \"sans\", int(headsize))\n\t\ty = y + spacing\n\t}\n\topenvg.Image(w*0.05, 15, 30, 30, \"poweredby_nytimes_30a.png\")\n\topenvg.End()\n}", "func (c Client) GetHeadends(postalCode string) ([]Headend, error) {\n\turl := fmt.Sprint(DefaultBaseURL, APIVersion,\n\t\t\"/headends?country=USA&postalcode=\", postalCode)\n\tfmt.Println(\"URL:>\", url)\n\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\treq.Header.Set(\"token\", c.Token)\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\tlog.Fatal(resp.Status)\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close() //resp.Body.Close() will run when we're finished.\n\n\t// make the slice of headends\n\th := []Headend{}\n \n\t//body, _ := ioutil.ReadAll(resp.Body)\n\t//fmt.Println(\"PostalResponse Body:\", string(body))\n\n\t// decode the body\n\terr = json.NewDecoder(resp.Body).Decode(&h)\n\tif err != nil {\n\t\tfmt.Println(\"Error parsing headend responseline\")\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\treturn h, nil\n}", "func getIndustryOverview(date, link string) ([]Industry, error) {\n\n\tvar result []Industry\n\n\tres, err := http.Get(link)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer res.Body.Close()\n\tif res.StatusCode != 200 {\n\t\tlog.Fatalf(\"status code error: %d %s\", res.StatusCode, res.Status)\n\t}\n\n\tdoc, err := goquery.NewDocumentFromReader(res.Body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Title\n\tvar (\n\t\tsector string // Industry sectors, e.g. Materials\n\t\tindustry string // Industry, e.g. Chemical Products\n\t\tcode string\n\t\tclose float64\n\t\tchange float64\n\t\tchangePct float64\n\t\tvolume int\n\t\tturnover int\n\t\tpe float64\n\t\tpb float64\n\t\tyield float64\n\t\tmarketCap int\n\t)\n\tdoc.Find(\"h1\").Each(func(i int, s *goquery.Selection) {\n\t\ttext := s.Text() // e.g. Industry Details - Materials - Chemical Products\n\t\ttexts := strings.Split(text, \"-\")\n\t\tif len(texts) == 3 {\n\t\t\tsector = strings.TrimSpace(texts[1]) // e.g. Materials\n\t\t\tindustry = strings.TrimSpace(texts[2]) // e.g. Chemical Products\n\t\t\tfmt.Printf(\"Getting [%s] - [%s]\\n\", sector, industry)\n\t\t}\n\t})\n\n\t// For each code inside a sector, gets the details\n\tdoc.Find(\"span.float_l\").Each(func(i int, s *goquery.Selection) {\n\t\tcode = strings.TrimSpace(s.Text()) // e.g. 00301.HK\n\t\tif strings.Contains(code, \"0\") { // Check starts with 0\n\t\t\tcode = strings.ReplaceAll(code, \".HK\", \"\") // 00301.HK -> 00301\n\t\t\tss := s.ParentsUntil(\"tbody\")\n\t\t\tvar values []string\n\n\t\t\tss.Each(func(j int, tb *goquery.Selection) {\n\t\t\t\ttb.Find(\"td.cls.txt_r.pad3\").Each(func(i int, td *goquery.Selection) {\n\t\t\t\t\t// fmt.Println(td.Text())\n\t\t\t\t\tvalues = append(values, td.Text())\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tif len(values) == 10 {\n\t\t\t\t_ = values[0] // Some empty string\n\t\t\t\tclose, _ = util.ParseF(values[1])\n\t\t\t\tchange, _ = util.ParseF(values[2])\n\t\t\t\tchangePct, _ = util.ParseF(values[3])\n\t\t\t\tvolume, _ = util.ParseI(values[4])\n\t\t\t\tturnover, _ = util.ParseI(values[5])\n\t\t\t\tpe, _ = util.ParseF(values[6])\n\t\t\t\tpb, _ = util.ParseF(values[7])\n\t\t\t\tyield, _ = util.ParseF(values[8])\n\t\t\t\tmarketCap, _ = util.ParseI(values[9])\n\n\t\t\t\trec := Industry{\n\t\t\t\t\tDate: date,\n\t\t\t\t\tSector: sector,\n\t\t\t\t\tIndustry: industry,\n\t\t\t\t\tCodeF: code,\n\t\t\t\t\tClose: close,\n\t\t\t\t\tChange: change,\n\t\t\t\t\tChangePct: changePct,\n\t\t\t\t\tVolume: volume,\n\t\t\t\t\tTurnover: turnover,\n\t\t\t\t\tPE: pe,\n\t\t\t\t\tPB: pb,\n\t\t\t\t\tYieldPct: yield,\n\t\t\t\t\tMarketCap: marketCap,\n\t\t\t\t}\n\t\t\t\tresult = append(result, rec)\n\t\t\t}\n\t\t}\n\t})\n\n\treturn result, nil\n}", "func (a *Api) GetArticles(keyword string) (*Response, error) {\n\treq := ReqArticles{baseUrl: a.baseUrl, q: keyword}\n\treturn a.do(req)\n}", "func GetNews(ctx *bot.Context) string {\n\tvar (\n\t\tresult NewsResponseData\n\t\tcategory string\n\t)\n\tif len(ctx.Args) > 0 {\n\t\tcategory = ctx.Args[0]\n\t}\n\tresp, err := http.Get(fmt.Sprintf(\"https://newsapi.org/v2/top-headlines?country=%v&category=%v&apiKey=%v\", ctx.Conf.News.Country, category, ctx.Conf.News.APIKey))\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Get news error: %v\", err)\n\t}\n\n\terr = json.NewDecoder(resp.Body).Decode(&result)\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Parse news error: %v\", err)\n\t}\n\n\tif result.Status == \"ok\" {\n\t\tif len(result.Articles) > 0 {\n\t\t\tvar news []string\n\t\t\tfor i := 0; i < ctx.Conf.News.Articles; i++ {\n\t\t\t\tnews = append(news, fmt.Sprintf(\"```%v\\n\\n%v\\nLink: %v```\", result.Articles[i].Title, result.Articles[i].Description, result.Articles[i].URL))\n\t\t\t}\n\n\t\t\treturn strings.Join(news, \"\\n\")\n\t\t} else {\n\t\t\treturn ctx.Loc(\"news_404\")\n\t\t}\n\t} else {\n\t\treturn ctx.Loc(\"news_api_error\")\n\t}\n}", "func (e *Education) GetAllByCategory(ctx context.Context) interface{} {\n\treturn e.GetAll(ctx)\n}", "func (*server) GetAllArticles(ctx context.Context, req *web_log_pb.GetAllArticlesRequest) (*web_log_pb.GetAllArticlesResponse, error) {\n\tfmt.Println(\"GetArticles function was invoked with a streaming request\")\n\taccessWebLogger.ClientIP = getClientIP(ctx)\n\terrorWebLogger.ClientIP = getClientIP(ctx)\n\tpc, _, _, _ := runtime.Caller(0)\n\n\tjsonData := getJSONData()\n\t// current articles in the json file\n\tcurrentArticles := getCurrentArticles(jsonData)\n\n\tvar result bytes.Buffer // server response (using string buffer to concate strings)\n\tif len(currentArticles) == 0 {\n\t\tpc, _, _, _ := runtime.Caller(0)\n\t\terrorWebLogger.ErrorPrintln(getCurrentRPCmethod(pc), \"No article is available now.\")\n\t\tresult.WriteString(\"No article is available now.\")\n\t} else {\n\t\tfor _, article := range currentArticles {\n\t\t\tresult.WriteString(\"\\narticleID: \" + article.ArticleID + \"\\ntitle: \" + article.Title + \"\\n\")\n\t\t}\n\t}\n\n\tres := &web_log_pb.GetAllArticlesResponse{\n\t\tResult: result.String(),\n\t}\n\taccessWebLogger.AccessPrintln(getCurrentRPCmethod(pc), \"\")\n\treturn res, nil\n}", "func (r ReqHeadlines) SerializeUrl() string {\n\treturn r.baseUrl + \"top-headlines?category=\" + r.category + \"&pageSize=\" + strconv.Itoa(r.pageSize) + \"&country=\" + r.country\n}", "func LoadExistingHeadlines() {\n\tvar headlines []string\n\n\tfile, err := os.Open(savedHeadlinesFileName)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdefer file.Close()\n\n\tdecoder := json.NewDecoder(file)\n\n\terr = decoder.Decode(&headlines)\n\n\tif err != nil {\n\t\tLogger.Errorln(err)\n\t\treturn\n\t}\n\n\tChainLock.Lock()\n\tFetchedHeadlinesLock.Lock()\n\tdefer ChainLock.Unlock()\n\tdefer FetchedHeadlinesLock.Unlock()\n\n\tfor _, line := range headlines {\n\t\treader := strings.NewReader(line)\n\t\tFetchedHeadlines = append(FetchedHeadlines, line)\n\t\tHeadlineChain.Build(reader)\n\t}\n}", "func (c *Client) GetArticles(since int) (*RetrieveResult, error) {\n\treq := RetrieveOption{\n\t\tSort: SortOldest,\n\t\tDetailType: \"complete\",\n\t\tContentType: \"article\",\n\t\tState: \"all\",\n\t\tAccessToken: c.authedUser.AccessToken,\n\t\tConsumerKey: c.consumerID,\n\t\tSince: since,\n\t}\n\n\tlog.Debugf(\"Params to send %+v\", req)\n\n\tvar resp RetrieveResult\n\n\tif err := c.call(\"/get\", req, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &resp, nil\n}", "func (k *KnowledgebaseService) Search(ctx context.Context, query string, highlight bool, start, limit int) (result *ArticlePageScheme, response *Response, err error) {\n\n\tif len(query) == 0 {\n\t\treturn nil, nil, fmt.Errorf(\"error, please provide a valid query value\")\n\t}\n\n\tparams := url.Values{}\n\tparams.Add(\"start\", strconv.Itoa(start))\n\tparams.Add(\"limit\", strconv.Itoa(limit))\n\tparams.Add(\"query\", query)\n\n\tif !highlight {\n\t\tparams.Add(\"highlight\", \"false\")\n\t}\n\n\tvar endpoint = fmt.Sprintf(\"rest/servicedeskapi/knowledgebase/article?%v\", params.Encode())\n\n\trequest, err := k.client.newRequest(ctx, http.MethodGet, endpoint, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\trequest.Header.Set(\"Accept\", \"application/json\")\n\trequest.Header.Set(\"X-ExperimentalApi\", \"opt-in\")\n\n\tresponse, err = k.client.Do(request)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresult = new(ArticlePageScheme)\n\tif err = json.Unmarshal(response.BodyAsBytes, &result); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func getArticles(wg *sync.WaitGroup) {\n\n\tclient := &http.Client{}\n\treq, err := http.NewRequest(\"GET\", articlesURL, nil)\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\tdefer func() {\n\t\tresp.Body.Close()\n\t\twg.Done()\n\t}()\n\n\terr = json.NewDecoder(resp.Body).Decode(&articles)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n}", "func (c *CseListCall) Hl(hl string) *CseListCall {\n\tc.urlParams_.Set(\"hl\", hl)\n\treturn c\n}", "func AllArticles(w http.ResponseWriter, r *http.Request) {\n\tarticles := Articles{\n\t\tArticle{Title:\"Test Title\", Desc: \"Test Description\", Content: \"Hello World\"},\n\t}\n\n\tfmt.Fprintf(w, \"Endpoint Hit: All Articles Endpoint\")\n\tjson.NewEncoder(w).Encode(articles)\n}", "func MakeArticlesOfCategory(amount int, now time.Time, category string) []Article {\n\tret := []Article{}\n\tfor i := 0; i < amount; i++ {\n\t\tnowOffset := myTimeToString(now.Add(time.Hour * -1).Add(time.Second * time.Duration(i)))\n\t\tart := Article{\n\t\t\tTitle: category + \" Article \" + strconv.Itoa(i),\n\t\t\tPreview: \"This is the preview for \" + category + \" Article \" + strconv.Itoa(i),\n\t\t\tBody: \"Test Article \" + strconv.Itoa(i),\n\t\t\tSlug: strings.ToLower(category) + \"-article-\" + strconv.Itoa(i),\n\t\t\tPublished: nowOffset,\n\t\t\tEdited: nowOffset,\n\t\t\tCategory: category,\n\t\t}\n\t\tret = append(ret, art)\n\t}\n\treturn ret\n}", "func (dao *ArticleDAO) Query(rs app.RequestScope, offset, limit, categoryId int, sorting, filter string) ([]models.Article, error) {\n\tarticles := []models.Article{}\n\tq := rs.Tx().Select().OrderBy(\"id\")\n\tif categoryId != 0 {\n\t\tq.Where(dbx.HashExp{\"category_id\": categoryId})\n\t}\n\tif filter != \"\" {\n\t\tq.AndWhere(dbx.Like(\"title\", filter))\n\t}\n\tif sorting == \"asc\" {\n\t\tq.OrderBy(\"id ASC\")\n\t} else {\n\t\tq.OrderBy(\"id DESC\")\n\t}\n\terr := q.Offset(int64(offset)).Limit(int64(limit)).All(&articles)\n\treturn articles, err\n}", "func getAllArticles(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(articles)\n\tw.WriteHeader(http.StatusOK)\n}", "func (c Controller) Articles(categoryID, page int) ([]*model.Article, error) {\n\treturn c.ArticlesRepository.ListByCategory(categoryID, page, \"tags,categories\")\n}", "func getAllArticles() []article {\n\treturn articleList\n}", "func GetArticles(w http.ResponseWriter, r *http.Request) {\n\tarticles, err := dao.findAll()\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\trespondWithJSON(w, http.StatusOK, articles)\n}", "func getIndustryLinks(date string, tab int) ([]string, error) {\n\t// tab reference\n\t// 1 - Overview\n\t// 2 - Range\n\t// 3 - Performance\n\t// 4 - Financial Ratio\n\t// 5 - Banking Ratio (Blank)\n\t// 6 - Earnings\n\n\tvar links []string\n\n\t// Check if data is ready\n\tdataReady := util.CheckWebsiteDate(date)\n\tif !dataReady {\n\t\treturn links, fmt.Errorf(\"data not ready - %s\", date)\n\t}\n\n\tres, err := http.Get(\"http://www.aastocks.com/en/stocks/market/industry/sector-industry-details.aspx\")\n\tif err != nil {\n\t\treturn links, err\n\t}\n\tdefer res.Body.Close()\n\tif res.StatusCode != 200 {\n\t\treturn links, fmt.Errorf(\"status code error: %d %s\", res.StatusCode, res.Status)\n\t}\n\tbody, err := ioutil.ReadAll(res.Body)\n\n\tr := regexp.MustCompile(\"gotoindustry\\\\(\\\\'(\\\\d{4})\\\\'\\\\)\")\n\tmatches := r.FindAllStringSubmatch(string(body), -1)\n\tfor _, match := range matches {\n\t\tif len(match) >= 2 {\n\t\t\tindustryCode := match[1]\n\t\t\tlink := fmt.Sprintf(\"http://www.aastocks.com/en/stocks/market/industry/sector-industry-details.aspx?industrysymbol=%s&t=%d&s=&o=&p=\", industryCode, tab)\n\n\t\t\tlinks = append(links, link)\n\t\t}\n\t}\n\treturn links, nil\n}", "func formatArticleGroups(articles []Article, categoryInfo CategoryInfo, onlyCategory string, headlines int) ([]ArticleGroup) {\n\t//rowsPerCategory := ternary_int(onlyCategory == \"\", kRowsPerCategory, kMaxArticles)\n\n\tpr(\"formatArticleGroups\")\n\n\tvar categoryOrder []string\n\tif onlyCategory != \"\" {\n\t\t//prVal(\"headlines\", headlines)\n\t\tarticlesPerCategoryGroup :=\n\t\t\tswitch_int(headlines,\n\t\t\t\tkNoHeadlines,\t\t kRowsPerCategory * kNumCols,\n\t\t\t\tkAlternateHeadlines, kRowsPerCategory + 1,\n\t\t\t\tkAllHeadlines, \t\t 2)\n\t\t//prVal(\"articlesPerCategoryGroup\", articlesPerCategoryGroup)\n\n\t\tassert(articlesPerCategoryGroup != -1)\n\n\t\tnumCategoryGroups := kMaxArticles / articlesPerCategoryGroup\n\n\t\tcategoryOrder = make([]string, numCategoryGroups)\n\t\tfor i := range categoryOrder {\n\t\t\tcategoryOrder[i] = onlyCategory\n\t\t}\n\t} else {\n\t\tcategoryOrder = categoryInfo.CategoryOrder\n\t}\n\n\n\tarticleGroups := make([]ArticleGroup, len(categoryOrder))\n\n\tcat := 0\n\theadlineSide := 0 // The side that has the headline (large article).\n\tcurrArticle := 0\n\tfor ccc, category := range categoryOrder {\n\t\trow := 0\n\t\tcol := 0\n\t\tfilled := false\n\n\n\t\t// Set category header text and background color.\n\t\tif onlyCategory == \"\" { // Mixed categories\n\t\t\tarticleGroups[cat].Category = category\n\t\t\tarticleGroups[cat].More = category\n\t\t} else { \t\t\t // Single category\n\t\t\tcategory = onlyCategory // Make all categories the same\n\t\t\t// Only the first articleGroup has a category name, the rest have \"\",\n\t\t\t// which is a flag to have no category header.\n\t\t\tif ccc == 0 {\n\t\t\t\tarticleGroups[cat].Category = category\n\t\t\t} else {\n\t\t\t\tarticleGroups[cat].Category = \"\"\n\t\t\t}\n\t\t\tarticleGroups[cat].More = \"\"\n\t\t}\n\n\t\tarticleGroups[cat].HeaderColor = categoryInfo.HeaderColors[category]\n\t\tarticleGroups[cat].HeadlineSide = headlineSide\n\n\t\t// Mixed categories - causing all articles to reiterate, but it will test against the category later.\n\t\tif onlyCategory == \"\" {\n\t\t\tcurrArticle = 0\n\t\t}\n\n\t\t// TODO: if a single category, with headlines, either large image should be set to always\n\t\t// 4 article height, or all articles should stack verticlally in each column.\n\t\t// (I prefer the second idea, because it might look nicer.)\n\n\t\tfor currArticle < len(articles) {\n\t\t\tarticle := articles[currArticle]\n\t\t\tcurrArticle++\n\n\n\t\t\tformatArticle(&article)\n\n\n\t\t\t// This works since we've sorted by bucket/category.\n\t\t\tif coalesce_str(article.Bucket, article.Category) == category {\n\n\t\t\t\tif row == 0 {\n\t\t\t\t\t// Allocate a new column of categories\n\t\t\t\t\tarticleGroups[cat].Articles = append(articleGroups[cat].Articles,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t make([]Article, kRowsPerCategory))\n\t\t\t\t}\n\n\t\t\t\t// The first article is always the headline. Articles after the headline get skipped.\n\t\t\t\tsize := 0\n\n\n\t\t\t\tif headlines != kNoHeadlines {\n\t\t\t\t\tif col == 0 || headlines == kAllHeadlines {\n\t\t\t\t\t\tif row == 0 { // first article is the headline, i.e. big\n\t\t\t\t\t\t\tsize = 1 // 1 means large article (headline)\n\t\t\t\t\t\t} else { // the rest of the articles get skipped, since the headline takes all the space.\n\t\t\t\t\t\t\tsize = -1 // -1 means skip the article\n\t\t\t\t\t\t\tcurrArticle-- // don't skip the article, since the slot is skipped\n\t\t\t\t\t\t\t\t\t\t // TODO: there's a bug where a headline article gets displayed twice, if we're in a specific category!!!\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Assign this slot the next article, as long as this is not an empty slot. Make sure size gets assigned!\n\t\t\t\tif size == -1 {\n\t\t\t\t\tarticleGroups[cat].Articles[col][row].Size = -1\n\t\t\t\t} else {\n\t\t\t\t\tarticleGroups[cat].Articles[col][row] = article\n\t\t\t\t\tarticleGroups[cat].Articles[col][row].Size = size\n\n\t\t\t\t\t//articleGroups[cat].Articles[col][row].Title =\n\t\t\t\t\t//\tarticleGroups[cat].Articles[col][row].Title[0:29] + \" \" + strconv.Itoa(row) + \" \" + strconv.Itoa(col) + \" \" + strconv.Itoa(currArticle)\n\t\t\t\t}\n\n\t\t\t\t// Inc row, col\n\t\t\t\tcol++\n\t\t\t\tif col == kNumCols {\n\t\t\t\t\tcol = 0\n\t\t\t\t\trow++\n\n\t\t\t\t\tif row == kRowsPerCategory {\n\t\t\t\t\t\tfilled = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If we ran out of articles, skip the rest\n\t\tfor !filled {\n\t\t\tif row == 0 {\n\t\t\t\t// Make room for new row\n\t\t\t\tarticleGroups[cat].Articles = append(articleGroups[cat].Articles,\n\t\t\t\t\t\t\t\t\t\t\t\t\t make([]Article, kRowsPerCategory))\n\t\t\t}\n\n\t\t\tarticleGroups[cat].Articles[col][row].Size = -1 // -1 means skip the article\n\n\t\t\t// Inc row, col\n\t\t\tcol++\n\t\t\tif col == kNumCols {\n\t\t\t\tcol = 0\n\t\t\t\trow++\n\n\t\t\t\tif row == kRowsPerCategory {\n\t\t\t\t\tfilled = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tcat++\n\n\t\tif headlines == kAlternateHeadlines {\n\t\t\theadlineSide = (headlineSide + 1) % 2 // The side with the headline switches each time, to look nice.\n\t\t}\n\t}\n\n\t// If a single category, only the last articleGroup should have a \"More...\" link.\n\tif onlyCategory != \"\" {\n\t\tarticleGroups[cat - 1].More = onlyCategory\n\t}\n\n\treturn articleGroups\n}", "func (s *Scraper) ScrapeArticle(r io.Reader) error {\n\tdoc, err := html.Parse(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//first find body and head\n\thead := findFirst(doc, atom.Head)\n\tif head == nil {\n\t\treturn errors.New(\"Could not find a head tag, perhaps this is invalid html\")\n\t}\n\tbody := findFirst(doc, atom.Body)\n\tif body == nil {\n\t\treturn errors.New(\"Could not find a body tag, perhaps this is invalid html\")\n\t}\n\n\theaders := findAll(doc, atom.H1, atom.H2, atom.H3, atom.H4, atom.H5)\n\tif headers == nil {\n\t\treturn errors.New(\"Could not find any header tags\")\n\t}\n\tfmt.Println(\" FOUND HEADERS\")\n\tfor _, h := range headers {\n\t\ttext, err := getInnerText(h)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfmt.Printf(\"%v: %s\\n\", h.DataAtom, text)\n\t}\n\treturn nil\n}", "func (doc Document) Headings() []string {\n\tvar headings []string\n\tfields := strings.FieldsFunc(doc.Descriptors, func(r rune) bool {\n\t\treturn r == ';' || r == '/'\n\t})\n\tfor _, f := range fields {\n\t\theadings = append(headings, strings.TrimSpace(f))\n\t}\n\treturn headings\n}", "func TestGetAllCategories(t *testing.T) {\n\t//Create a request to pass to the handler\n\treq, err := http.NewRequest(\"GET\", \"/categories\", nil)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t//Create a ResponseRecorder to record the response\n\trr := httptest.NewRecorder()\n\thandler := http.HandlerFunc(GetAllCategories)\n\n\thandler.ServeHTTP(rr, req)\n\n\t// Check the response status code is what we expect\n\tassert.Equal(t, 200, rr.Code, \"OK response is expected\")\n\t// Check the response body is what we expect\n\texpected := `[{\"CategoryID\":\"bq4fasj7jhfi127rimlg\",\"CategoryName\":\"Shopping Products\",\"CategoryDescription\":\"Products consumers purchase and consume on a less frequent schedule compared to convenience products.\"},{\"CategoryID\":\"bq4fb3b7jhfi7v7uo39g\",\"CategoryName\":\"Specialty Products\",\"CategoryDescription\":\"Products that are more expensive relative to convenience and shopping products.\"}]`\n\tassert.JSONEq(t, expected, rr.Body.String(), \"Expected response body to be the same\")\n}", "func (p *Parser) GetArticles(page int, tag string) ([]model.ArticleItem, int, error) {\n\tq := map[string]interface{}{\"p\": page}\n\tdir := []interface{}{\"featured\"}\n\tif tag != \"\" {\n\t\tdir = append(dir, \"tag\", tag)\n\t}\n\tdoc, code, err := p.getDoc(utils.BuildURLWithQuery(q, malURL, dir...), \".content-left\")\n\tif err != nil {\n\t\treturn nil, code, err\n\t}\n\treturn p.article.GetList(doc), http.StatusOK, nil\n}", "func getArticles(p int) {\n\tdb, err := bolt.Open(\"../.db\", 0600, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer db.Close()\n\n\t//display 10 articles per page\n\tIdIndex := (p-1)*10 + 1\n\tvar articles ArticlesResponse\n\tvar article Article\n\terr = db.View(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(\"Article\"))\n\t\tif b != nil {\n\t\t\tc := b.Cursor()\n\t\t\tk, v := c.Seek(itob(IdIndex))\n\t\t\tif k == nil {\n\t\t\t\tfmt.Println(\"Page is out of index\")\n\t\t\t\treturn errors.New(\"Page is out of index\")\n\t\t\t}\n\t\t\tkey := binary.BigEndian.Uint64(k)\n\t\t\tfmt.Print(key)\n\t\t\tif int(key) != IdIndex {\n\t\t\t\tfmt.Println(\"Page is out of index\")\n\t\t\t\treturn errors.New(\"Page is out of index\")\n\t\t\t}\n\t\t\tcount := 0\n\t\t\tvar ori_artc Article\n\t\t\tfor ; k != nil && count < 10; k, v = c.Next() {\n\t\t\t\terr = json.Unmarshal(v, &ori_artc)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tarticle.Id = ori_artc.Id\n\t\t\t\tarticle.Name = ori_artc.Name\n\t\t\t\tarticles.Articles = append(articles.Articles, article)\n\t\t\t\tcount = count + 1\n\t\t\t}\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn errors.New(\"Article Not Exists\")\n\t\t}\n\t})\n\tfor i := 0; i < len(articles.Articles); i++ {\n\t\tfmt.Println(articles.Articles[i])\n\t}\n}", "func CrawlArticles(w http.ResponseWriter, r *http.Request) {\n\t// TODO: could this happen in parallel? save the articles while getting the next news source...\n\tarticles := getHackerNewsArticles()\n\tarticles = append(articles, getTechCrunchArticles()...)\n\tarticles = append(articles, getNYTArticles()...)\n\tcount, err := insertArticles(articles)\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\trespondWithJSON(w, http.StatusOK, count)\n}", "func (client ModelClient) ListHierarchicalEntitiesPreparer(ctx context.Context, appID uuid.UUID, versionID string, skip *int32, take *int32) (*http.Request, error) {\n\turlParameters := map[string]interface{}{\n\t\t\"Endpoint\": client.Endpoint,\n\t}\n\n\tpathParameters := map[string]interface{}{\n\t\t\"appId\": autorest.Encode(\"path\", appID),\n\t\t\"versionId\": autorest.Encode(\"path\", versionID),\n\t}\n\n\tqueryParameters := map[string]interface{}{}\n\tif skip != nil {\n\t\tqueryParameters[\"skip\"] = autorest.Encode(\"query\", *skip)\n\t} else {\n\t\tqueryParameters[\"skip\"] = autorest.Encode(\"query\", 0)\n\t}\n\tif take != nil {\n\t\tqueryParameters[\"take\"] = autorest.Encode(\"query\", *take)\n\t} else {\n\t\tqueryParameters[\"take\"] = autorest.Encode(\"query\", 100)\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsGet(),\n\t\tautorest.WithCustomBaseURL(\"{Endpoint}/luis/api/v2.0\", urlParameters),\n\t\tautorest.WithPathParameters(\"/apps/{appId}/versions/{versionId}/hierarchicalentities\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (worker *WebsiteCategorizationWorker) RequestCategoriesForWebsite(websiteAddress string) ([]string, error) {\n\tbase64String := b64.StdEncoding.EncodeToString([]byte(websiteAddress))\n\tclient := http.Client{}\n\n\trequestUrl := Endpoint + base64String\n\treq, _ := http.NewRequest(\"GET\", requestUrl, nil)\n\n\treq.SetBasicAuth(AccessKey, AccessSecret)\n\treq.Header.Add(\"Host\", \"api.webshrinker.com\")\n\n\tresponse, err := client.Do(req)\n\tif err != nil {\n\t\tfmt.Printf(\"%s\", err)\n\t\treturn nil, err\n\t} else {\n\t\tdefer response.Body.Close()\n\n\t\tif response.StatusCode >= 400 {\n\t\t\tfmt.Println(response.Header)\n\t\t\treturn nil, err\n\t\t}\n\t\tcontents, err := ioutil.ReadAll(response.Body)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"%s\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tfmt.Println(string(contents))\n\t\tvar jsonData map[string]interface{}\n\t\tif err := json.Unmarshal(contents, &jsonData); err != nil {\n\t\t\tfmt.Printf(\"%s\", err)\n\t\t}\n\t\tdata := jsonData[\"data\"].([]interface{})\n\t\tinnerDict := data[0].(map[string]interface{})\n\t\tcategoryArray := innerDict[\"categories\"].([]interface{})\n\n\t\tcategories := make([]string, len(categoryArray))\n\t\tfor index, category := range categoryArray {\n\t\t\tcategories[index] = category.(string)\n\t\t}\n\t\treturn categories, nil\n\t}\n}", "func Head_(children ...HTML) HTML {\n return Head(nil, children...)\n}", "func (s *Service) Articles(id int) ([]*Article, error) {\n\tbody, err := s.requestCourseArticles(id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer body.Close()\n\n\tarticleResult := &articleResult{}\n\tif err := handleJSONParse(body, articleResult); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn articleResult.Articles, nil\n}", "func CategoryGet(c *gin.Context) {\n\tCategory, err := models.GetCategory(c.Param(\"name\"))\n\tif err != nil {\n\t\tc.HTML(http.StatusNotFound, \"errors/404\", nil)\n\t\treturn\n\t}\n\tvar filter models.DaoFilter\n\tfilter.Category.Name = Category.Name\n\tcount,_ := filter.GetPostsCount()\n\tcurrentPage, _ := strconv.Atoi(c.DefaultQuery(\"p\",\"1\"))\n\tlimit := 10\n\tPagination := helpers.NewPaginator(c,limit,count)\n\tlist, err := filter.GetPostsByPage(currentPage,limit)\n\tif err != nil {\n\t\tc.HTML(http.StatusNotFound, \"errors/404\", nil)\n\t\treturn\n\t}\n\n\th := helpers.DefaultH(c)\n\th[\"Title\"] = Category.Name\n\th[\"Category\"] = Category\n\th[\"Active\"] = \"categories\"\n\th[\"List\"] = list\n\th[\"Pagination\"] = Pagination\n\tc.HTML(http.StatusOK, \"categories/show\", h)\n}", "func (c Category) GetAll(ctx iris.Context) {\n\n\tpage := middleware.GetPage(ctx)\n\n\tdatas, err := models.Category{}.GetAll(&page)\n\tif err != nil {\n\t\tresponse.JSONError(ctx, err.Error())\n\t\treturn\n\t}\n\n\tresponse.JSONPage(ctx, datas, page)\n}", "func getEntries(URL string, page, limit int) ([]model.Entry, error) {\n\tentries := make([]model.Entry, 0)\n\n\tfor {\n\t\tresp, err := http.Get(URL + strconv.Itoa(page))\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"ERROR: internet bağlantınızı kontrol edin\")\n\t\t}\n\n\t\troot, err := html.Parse(resp.Body)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"ERROR: An error occured while parsing body\")\n\t\t}\n\t\tdefer resp.Body.Close()\n\n\t\tif _, ok := scrape.Find(root, isTopicFoundMatcher); !ok {\n\t\t\treturn nil, errors.New(\"ERROR: \" + strconv.Itoa(page) + \". sayfa yok\")\n\t\t}\n\n\t\tentryList, ok := scrape.Find(root, entryListMatcher)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"ERROR: Site layoutu değişmiş olabilir | Report: github.com/mucanyu/eksisozluk-go/issues\")\n\t\t}\n\n\t\tentryNodeList := scrape.FindAll(entryList, entryMatcher)\n\n\t\tfor _, enode := range entryNodeList {\n\t\t\tentry := model.Entry{}\n\t\t\tentry.Text = scrape.Text(enode)\n\n\t\t\tautNode, ok := scrape.Find(enode.Parent, authorMatcher)\n\t\t\tif ok {\n\t\t\t\tentry.Author = scrape.Text(autNode)\n\t\t\t}\n\n\t\t\tdateNode, ok := scrape.Find(enode.Parent, dateMatcher)\n\t\t\tif ok {\n\t\t\t\tentry.Date = scrape.Text(dateNode)\n\t\t\t}\n\n\t\t\tentries = append(entries, entry)\n\t\t\tlimit--\n\t\t\tif limit == 0 {\n\t\t\t\treturn entries, nil\n\t\t\t}\n\t\t}\n\t\tif len(entries)%10 != 0 {\n\t\t\treturn entries, nil\n\t\t}\n\t\tpage++\n\t}\n}", "func getCategoriesList(lister listing.Service) http.HandlerFunc {\n\treturn func(rw http.ResponseWriter, r *http.Request) {\n\t\trw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tvar list *listing.CategoriesResponse\n\n\t\tlimit := r.FormValue(\"limit\")\n\t\ttop := r.FormValue(\"top\")\n\n\t\tl, err := strconv.ParseInt(limit, 10, 2)\n\t\tif err != nil {\n\t\t\tl = 100\n\t\t}\n\t\tif top == \"true\" {\n\t\t\tlist, err = lister.TopCategories(r.Context(), int(l))\n\t\t} else {\n\t\t\tlist, err = lister.Categories(r.Context())\n\t\t}\n\n\t\tif err != nil {\n\t\t\t// server problem while answering the request\n\t\t\tr := constructError(http.StatusInternalServerError,\n\t\t\t\t\"unable to process request\",\n\t\t\t\t\"A problem occurs while processing the request\")\n\n\t\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\t\tjson.NewEncoder(rw).Encode(r)\n\t\t\treturn\n\t\t}\n\n\t\trw.WriteHeader(http.StatusOK)\n\t\terr = json.NewEncoder(rw).Encode(list)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\t}\n}", "func getCategorias(w http.ResponseWriter, r *http.Request) { //esto sirve para mostar todos los datos\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tvar categorias = allcategorias{}\n\n\tvar Cat categoria\n\tpol := newCn()\n\tpol.abrir()\n\trows, err := pol.db.Query(\"select * from categoria\")\n\tif err != nil {\n\t\tfmt.Println(\"Error running query\")\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\terr := rows.Scan(&Cat.ID, &Cat.CATEGORIA)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\t\tcategorias = append(categorias, Cat)\n\t}\n\n\tjson.NewEncoder(w).Encode(categorias)\n\tpol.cerrar()\n}", "func ArticleList(c *gin.Context) {\n\t//condition := ArticleModel{}\n\t// tag := c.Query(\"tag\")\n\t// author := c.Query(\"author\")\n\t// favorited := c.Query(\"favorited\")\n\t// limit := c.Query(\"limit\")\n\t// offset := c.Query(\"offset\")\n\t// articleModels, modelCount, _ := FindManyArticle(tag, author, limit, offset, favorited)\n\tarticleModels, modelCount, _ := FindArticleList()\n\t// if err != nil {\n\t// \tc.JSON(http.StatusNotFound, common.NewError(\"articles\", errors.New(\"Invalid param\")))\n\t// \treturn\n\t// }\n\tserializer := ArticleListSerializer{c, articleModels}\n\tlogger.Trace(\"ArticleList serializer\", serializer)\n\tc.JSON(http.StatusOK, gin.H{\"articles\": serializer.Response(), \"articlesCount\": modelCount})\n}", "func GetAllCategory(c * gin.Context){\n\tdb := database.DBConn()\n\trows, err := db.Query(\"SELECT * FROM category\")\n\tif err != nil{\n\t\tc.JSON(500, gin.H{\n\t\t\t\"messages\" : \"Story not found\",\n\t\t});\n\t}\n\tpost := DTO.CategoryDTO{}\n\tlist := [] DTO.CategoryDTO{}\n\tfor rows.Next(){\n\t\tvar id, types int\n\t\tvar name string\n\t\terr = rows.Scan(&id, &name, &types)\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\tpost.Id = id\n\t\tpost.Name = name\n\t\tpost.Type = types\n\t\tlist = append(list,post);\n\t}\n\tc.JSON(200, list)\n\tdefer db.Close()\n}", "func getAllArticles() []article {\n\tarticleList = nil\n\tprintarticle()\n\treturn articleList\n}", "func (cia *chainInfoAPI) ChainSetHead(ctx context.Context, key types.TipSetKey) error {\n\tts, err := cia.chain.ChainReader.GetTipSet(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn cia.chain.ChainReader.SetHead(ctx, ts)\n}", "func (ArticleController) GetAll(c *gin.Context) {\n\tarticles, err := models.GetAllArticles()\n\n\tif err != nil {\n\t\tc.JSON(err.Code(), gin.H{\n\t\t\t\"message\": err.Error(),\n\t\t})\n\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, articles)\n}", "func (c *Client) Head(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodHead, url, data...)\n}", "func (a *ArticleHandler) FetchArticle(c *gin.Context) {\n\tn := c.Query(\"num\")\n\tnum, _ := strconv.Atoi(n)\n\n\tcursor := c.Query(\"cursor\")\n\n\tctx, cancel := context.WithCancel(c)\n\tdefer cancel()\n\n\tlistAr, nextCursor, err := a.ArticleUsecase.Fetch(ctx, cursor, int64(num))\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(getStatusCode(err), ResponseError{Message: err.Error()})\n\t\treturn\n\t}\n\n\tc.Header(\"X-Cursor\", nextCursor)\n\tc.JSON(http.StatusOK, listAr)\n}", "func GetIndustryOverview(date string) ([]Industry, error) {\n\tvar results []Industry\n\n\texist := db.RecordExists(\"industry\", date)\n\tif exist {\n\t\treturn results, fmt.Errorf(\"records exists in db - %s\", date)\n\t}\n\n\tlinks, err := getIndustryLinks(date, 1) // check dates\n\tif err != nil {\n\t\treturn results, err\n\t}\n\n\tfor _, link := range links {\n\t\tindustry, _ := getIndustryOverview(date, link)\n\t\tresults = append(results, industry...)\n\t}\n\treturn results, nil\n}", "func GetWareByCategory(c *server.Context) error {\n\tvar (\n\t\tres []ware.BriefInfo\n\t\tcidReq struct {\n\t\t\tParentCID uint32 `json:\"parent_cid\" validate:\"required\"`\n\t\t\tCID uint32 `json:\"cid\"`\n\t\t}\n\t)\n\n\terr := c.JSONBody(&cidReq)\n\tif err != nil {\n\t\tlogger.Error(err)\n\t\treturn core.WriteStatusAndDataJSON(c, constants.ErrInvalidParam, nil)\n\t}\n\n\terr = c.Validate(cidReq)\n\tif err != nil {\n\t\tlogger.Error(err)\n\t\treturn core.WriteStatusAndDataJSON(c, constants.ErrInvalidParam, nil)\n\t}\n\n\tconn, err := mysql.Pool.Get()\n\tdefer mysql.Pool.Release(conn)\n\tif err != nil {\n\t\tlogger.Error(err)\n\t\treturn core.WriteStatusAndDataJSON(c, constants.ErrMysql, nil)\n\t}\n\n\tif cidReq.CID == 0 {\n\t\tres, err = ware.Service.GetByParentCID(conn, cidReq.ParentCID)\n\t\tif err != nil {\n\t\t\tlogger.Error(err)\n\t\t\treturn core.WriteStatusAndDataJSON(c, constants.ErrMysql, nil)\n\t\t}\n\t} else {\n\t\tres, err = ware.Service.GetByCID(conn, cidReq.CID)\n\t\tif err != nil {\n\t\t\tlogger.Error(err)\n\t\t\treturn core.WriteStatusAndDataJSON(c, constants.ErrMysql, nil)\n\t\t}\n\t}\n\n\treturn core.WriteStatusAndDataJSON(c, constants.ErrSucceed, res)\n}", "func (cs ThingsService) GetByCategoryAndQuery(ctx context.Context, category string, q string) (ThingListResponse, error) {\n\tlog.Println(\"Getting by category and query\", category, q)\n\treturn ThingListResponse{}, nil\n}", "func (h HospitalityResource) HospitalityGetByRequest(request *restful.Request, response *restful.Response) {\n\thr := &hospitality.Request{}\n\terr := request.ReadEntity(&hr)\n\n\tif err != nil {\n\t\tresponse.AddHeader(\"Content-Type\", \"text/plain\")\n\t\tresponse.WriteErrorString(http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\tlog.Infof(\"Try to get hospitality score by %v\", hr)\n\tscore := &hospitality.Hospitality{}\n\te := score.GetByRequest(hr)\n\tif e != nil {\n\t\terr := e.(*rmderror.AppError)\n\t\tresponse.WriteErrorString(err.Code, err.Error())\n\t\treturn\n\t}\n\tresponse.WriteEntity(score)\n}", "func FirstArticles(n uint32) ([]Article, error) {\n\t_articles := []Article{}\n\tsql := fmt.Sprintf(\"SELECT COALESCE(articles.text, '') AS text, articles.id, articles.title, articles.created_at, articles.updated_at FROM articles ORDER BY articles.id ASC LIMIT %v\", n)\n\terr := DB.Select(&_articles, DB.Rebind(sql))\n\tif err != nil {\n\t\tlog.Printf(\"Error: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\treturn _articles, nil\n}", "func (c *CseSiterestrictListCall) Hl(hl string) *CseSiterestrictListCall {\n\tc.urlParams_.Set(\"hl\", hl)\n\treturn c\n}", "func (e *Education) GetAll(ctx context.Context) interface{} {\n\tq := datastore.NewQuery(\"education\")\n\n\t// Get All educations\n\tvar entities Educations\n\tGetAll(ctx, q, &entities, \"year_in\", true)\n\n\te.GetImages(ctx, entities)\n\n\treturn entities\n}", "func GetAllArticles(db *sqlx.DB) httprouter.Handle {\n\treturn func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t\tvar article models.Article\n\t\tarticles, err := article.GetArticles(db)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset= UTF-8\")\n\t\tw.WriteHeader(http.StatusOK)\n\n\t\tif err := json.NewEncoder(w).Encode(articles); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t}\n\n}", "func getArticlesHandler(c *gin.Context) {\n\n\tvar wg sync.WaitGroup\n\n\twg.Add(2)\n\tgo getArticles(&wg)\n\tgo getContentMarketing(&wg)\n\n\twg.Wait()\n\n\terr := resultMapper()\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, err)\n\t}\n\n\tc.JSON(http.StatusOK, resultContent)\n}", "func allArticles(w http.ResponseWriter, r *http.Request) {\n w.Header().Set(\"Content-Type\", \"application/json\")\n json.NewEncoder(w).Encode(articles)\n}", "func NewHeadline() *Headline {\n\treturn &Headline{}\n}", "func TestGetCategoryById(t *testing.T) {\n\tfor _, p := range categoryByIdTest {\n\t\t//request url\n\t\tpath := \"/categories/\" + p.categoryId\n\t\treq, err := http.NewRequest(\"GET\", path, nil)\n\t\t//passing the {id} var as it was not recognizable for some reason\n\t\treq = mux.SetURLVars(req, map[string]string{\"id\": p.categoryId})\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\trr := httptest.NewRecorder()\n\t\thandler := http.HandlerFunc(GetCategoryById)\n\n\t\thandler.ServeHTTP(rr, req)\n\n\t\tassert.Equal(t, p.expectedCode, rr.Code, \"OK response is expected\")\n\t\tassert.Equal(t, p.expected, strings.TrimSuffix(rr.Body.String(),\"\\n\"), \"Response body is expected to be equal to expected value\")\n\t}\n}", "func (v *Kounta) GetCategories(token string, company string) (Categories, error) {\n\tclient := &http.Client{}\n\tclient.CheckRedirect = checkRedirectFunc\n\n\tu, _ := url.ParseRequestURI(baseURL)\n\tu.Path = fmt.Sprintf(categoriesURL, company)\n\turlStr := fmt.Sprintf(\"%v\", u)\n\n\tr, err := http.NewRequest(\"GET\", urlStr, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tr.Header = http.Header(make(map[string][]string))\n\tr.Header.Set(\"Accept\", \"application/json\")\n\tr.Header.Set(\"Authorization\", \"Bearer \"+token)\n\n\tres, err := client.Do(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trawResBody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif res.StatusCode == 200 {\n\t\tvar resp []Category\n\n\t\terr = json.Unmarshal(rawResBody, &resp)\n\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn resp, nil\n\t}\n\treturn nil, fmt.Errorf(\"Failed to get Kounta Categories %s\", res.Status)\n\n}", "func FetchArticle(ctx context.Context, url string) (*model.Article, error) {\n\t// Validate URL\n\t_, err := nurl.ParseRequestURI(url)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid URL: %v\", err)\n\t}\n\n\t// Get URL content type\n\tcontentType, err := getContentType(ctx, url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !strings.HasPrefix(contentType, \"text/html\") {\n\t\treturn nil, fmt.Errorf(\"invalid content-type: %s\", contentType)\n\t}\n\n\t// Get URL content\n\tres, err := get(ctx, url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer res.Body.Close()\n\tbody, err := charset.NewReader(res.Body, contentType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Extract metas\n\tmetas, err := ExtractMetas(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create article with Open Graph atributes\n\tresult := &model.Article{\n\t\tText: metas.GetContent(\"og:description\", \"twitter:description\", \"description\"),\n\t\tImage: metas.GetContent(\"og:image\", \"twitter:image\"),\n\t}\n\ttitle := metas.GetContent(\"og:title\")\n\tif title != nil {\n\t\tresult.Title = *title\n\t}\n\n\tvar buffer bytes.Buffer\n\ttee := io.TeeReader(body, &buffer)\n\n\t// Test if the HTML page is readable by Shiori readability\n\tif !read.IsReadable(tee) {\n\t\treturn result, fmt.Errorf(\"unable to extract content from HTML page\")\n\t}\n\n\t// Extract content from the HTML page\n\tarticle, err := read.FromReader(&buffer, url)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\t// Complete result with extracted properties\n\tresult.HTML = &article.Content\n\tif result.Title == \"\" {\n\t\tresult.Title = article.Title\n\t}\n\tif result.Text == nil {\n\t\t// FIXME: readability excerpt don't well support UTF8\n\t\ttext := tooling.ToUTF8(article.Excerpt)\n\t\tresult.Text = &text\n\t}\n\tif result.Image == nil {\n\t\tresult.Image = &article.Image\n\t}\n\n\t// TODO: add other properties to the result\n\t// article.Favicon\n\t// article.Length\n\t// article.SiteName\n\n\treturn result, nil\n}", "func (obj *Doc) GetLineage(ctx context.Context) ([]*LineageInfo, error) {\n\tresult := &struct {\n\t\tLineage []*LineageInfo `json:\"qLineage\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetLineage\", result)\n\treturn result.Lineage, err\n}", "func GetLVMainCategories(url string) []string {\n\t// Slice to hold category names\n\tvar mainCategories []string\n\t// Init colly collector\n\tc := createCollyCollector()\n\t// Find within the children of each li tag anything with class .lv-header-main-nav__item\n\t// Append the text of that span to categories array\n\tc.OnHTML(\"li\", func(e *colly.HTMLElement) {\n\t\tpageDom := e.DOM\n\t\tpageDom.Find(\".lv-header-main-nav__item\").Each(func(i int, s *goquery.Selection) {\n\t\t\tmainCategories = append(mainCategories, s.Find(\"span\").Text())\n\t\t})\n\t})\n\t// Request Handler\n\tc.OnRequest(func(r *colly.Request) {\n\t\tfmt.Println(\"Visiting\", r.URL.String())\n\t})\n\t// Error Handler\n\tc.OnError(func(r *colly.Response, err error) {\n\t\tlog.Println(\"Request URL:\", r.Request.URL, \"failed with response:\", r, \"\\nError:\", err)\n\t})\n\t// Response Handler\n\tc.OnResponse(func(r *colly.Response) {\n\t\t//fmt.Println(r.Body)\n\t})\n\t// Send visit request to colly collector\n\tc.Visit(url)\n\treturn mainCategories\n}", "func (m *Vulnerability) GetArticles()([]Articleable) {\n val, err := m.GetBackingStore().Get(\"articles\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]Articleable)\n }\n return nil\n}", "func (r *CompanyJournalLinesCollectionRequest) Get(ctx context.Context) ([]JournalLine, error) {\n\treturn r.GetN(ctx, 0)\n}", "func GetArticleTags(tags ArrayFlags, input *bufio.Scanner) {\n\tallTags := struct {\n\t\tCode int\n\t\tText string\n\t\tBody []util.Tag\n\t}{}\n\t// get the request from api to get all tags\n\treq, err := http.Get(\"http://localhost:8080/tags\")\n\tutil.CheckError(err)\n\n\tdefer req.Body.Close()\n\n\t// decode the response json and display it to the user\n\tjson.NewDecoder(req.Body).Decode(&allTags)\n\tfmt.Fprintln(os.Stdout, \"Please choose whatever tag you like(just enter if nothing):\")\n\n\tfor _, i := range allTags.Body {\n\t\tfmt.Fprintf(os.Stdout, \" %-5d%s\\n\", i.Id, i.Name)\n\t}\n\n\t// get the input\n\tinput.Scan()\n\tchose := input.Text()\n\n\t// and split it into []string\n\tw := strings.FieldsFunc(chose, func(r rune) bool {\n\t\tswitch r {\n\t\tcase ',', ';', ' ', '\\t', '.', '\\n':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t\t}\n\t})\n\n\t// convert it into []int and complete the tags\n\tfor _, i := range w {\n\t\tn, err := strconv.Atoi(i)\n\t\tutil.CheckError(err)\n\t\ttags = append(tags, n)\n\t}\n\n}", "func GetCategory(response http.ResponseWriter, request *http.Request) {\n\t//var results TCategory\n\tvar errorResponse = ErrorResponse{\n\t\tCode: http.StatusInternalServerError, Message: \"Internal Server Error.\",\n\t}\n\n\tcollection := Client.Database(\"msdb\").Collection(\"t_cat_mg\")\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tcursor, err := collection.Find(ctx, bson.M{})\n\tvar results []bson.M\n\terr = cursor.All(ctx, &results)\n\n\tdefer cancel()\n\n\tif err != nil {\n\t\terrorResponse.Message = \"Document not found\"\n\t\treturnErrorResponse(response, request, errorResponse)\n\t} else {\n\t\tvar successResponse = SuccessResponse{\n\t\t\tCode: http.StatusOK,\n\t\t\tMessage: \"Success\",\n\t\t\tResponse: results,\n\t\t}\n\n\t\tsuccessJSONResponse, jsonError := json.Marshal(successResponse)\n\n\t\tif jsonError != nil {\n\t\t\treturnErrorResponse(response, request, errorResponse)\n\t\t}\n\t\tresponse.Header().Set(\"Content-Type\", \"application/json\")\n\t\tresponse.Write(successJSONResponse)\n\t}\n\n}", "func (c *Client) GetArticles(pageID int) *types.ArticleList {\n\tarticles := &types.ArticleList{}\n\tc.Client.Where(\"id >= ?\", pageID).Order(\"id\").Limit(pageSize + 1).Find(&articles.Items)\n\tif len(articles.Items) == pageSize+1 {\n\t\tarticles.NextPageID = articles.Items[len(articles.Items)-1].ID\n\t\tarticles.Items = articles.Items[:pageSize]\n\t}\n\treturn articles\n}", "func (h Headline) ValidateHeadlineCreation() error {\n\tif h.Title == \"\" {\n\t\treturn errors.New(\"The title is mandatory\")\n\t}\n\n\tif h.Content == \"\" {\n\t\treturn errors.New(\"The content is mandatory\")\n\t}\n\n\tif h.VisaType == \"\" {\n\t\treturn errors.New(\"The visatype is mandatory\")\n\t}\n\n\tif h.CountryID == 0 {\n\t\treturn errors.New(\"The country_id is mandatory\")\n\t}\n\n\tif h.CategoryID == 0 {\n\t\treturn errors.New(\"The category_id is mandatory\")\n\t}\n\n\treturn nil\n}", "func HorizonGet(urlSuffix string, goodHttpCodes []int, structure interface{}, quiet bool) (httpCode int, retError error) {\n\tretError = nil\n\n\t// get message printer\n\tmsgPrinter := i18n.GetMessagePrinter()\n\n\thttpClient := GetHTTPClient(0)\n\n\turl := GetHorizonUrlBase() + \"/\" + urlSuffix\n\tapiMsg := http.MethodGet + \" \" + url\n\tVerbose(apiMsg)\n\t// Create the request and run it\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\tFatal(HTTP_ERROR, msgPrinter.Sprintf(\"%s new request failed: %v\", apiMsg, err))\n\t}\n\treq.Close = true\n\treq.Header.Add(\"Accept\", \"application/json\")\n\n\t// add the language request to the http header\n\tlocaleTag, err := i18n.GetLocale()\n\tif err != nil {\n\t\tlocaleTag = language.English\n\t}\n\treq.Header.Add(\"Accept-Language\", localeTag.String())\n\n\tresp, err := httpClient.Do(req)\n\tif resp != nil && resp.Body != nil {\n\t\tdefer resp.Body.Close()\n\t}\n\tif err != nil {\n\t\tif quiet {\n\t\t\tif os.Getenv(\"HORIZON_URL\") == \"\" {\n\t\t\t\tstatusCommand := \"systemctl status horizon\"\n\t\t\t\tstatusURL := \"curl \" + HZN_API + \"/status\"\n\t\t\t\tif runtime.GOOS == \"darwin\" {\n\t\t\t\t\tstatusCommand = \"docker ps | grep horizon\"\n\t\t\t\t\tstatusURL = \"curl \" + HZN_API_MAC + \"/status\"\n\t\t\t\t}\n\t\t\t\tretError = fmt.Errorf(msgPrinter.Sprintf(\"Can't connect to the Horizon REST API to run %s. Run '%s' to check if the Horizon agent is running. Or run '%s' to check the Horizon agent status. Or set HORIZON_URL to connect to another local port that is connected to a remote Horizon agent via a ssh tunnel. Specific error is: %v\", apiMsg, statusCommand, statusURL, err))\n\t\t\t} else {\n\t\t\t\tretError = fmt.Errorf(msgPrinter.Sprintf(\"Can't connect to the Horizon REST API to run %s. Maybe the ssh tunnel associated with that port is down? Or maybe the remote Horizon agent at the other end of that tunnel is down. Specific error is: %v\", apiMsg, err))\n\t\t\t}\n\t\t\treturn\n\t\t} else {\n\t\t\tprintHorizonRestError(apiMsg, err)\n\t\t}\n\t}\n\thttpCode = resp.StatusCode\n\tVerbose(msgPrinter.Sprintf(\"HTTP code: %d\", httpCode))\n\tif !isGoodCode(httpCode, goodHttpCodes) {\n\t\tif quiet {\n\t\t\tretError = fmt.Errorf(msgPrinter.Sprintf(\"Bad HTTP code from %s: %d\", apiMsg, httpCode))\n\t\t\treturn\n\t\t} else {\n\t\t\tFatal(HTTP_ERROR, msgPrinter.Sprintf(\"bad HTTP code from %s: %d\", apiMsg, httpCode))\n\t\t}\n\t}\n\tif httpCode == goodHttpCodes[0] {\n\t\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tif quiet {\n\t\t\t\tretError = fmt.Errorf(msgPrinter.Sprintf(\"Failed to read body response from %s: %v\", apiMsg, err))\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tFatal(HTTP_ERROR, msgPrinter.Sprintf(\"failed to read body response from %s: %v\", apiMsg, err))\n\t\t\t}\n\t\t}\n\t\tswitch s := structure.(type) {\n\t\tcase *string:\n\t\t\t// Just return the unprocessed response body\n\t\t\t*s = string(bodyBytes)\n\t\tdefault:\n\t\t\t// Put the response body in the specified struct\n\t\t\terr = json.Unmarshal(bodyBytes, structure)\n\t\t\tif err != nil {\n\t\t\t\tif quiet {\n\t\t\t\t\tretError = fmt.Errorf(msgPrinter.Sprintf(\"Failed to unmarshal body response from %s: %v\", apiMsg, err))\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\tFatal(JSON_PARSING_ERROR, msgPrinter.Sprintf(\"failed to unmarshal body response from %s: %v\", apiMsg, err))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (m *CompaniesItemJournalsItemJournalLinesJournalLineItemRequestBuilder) Get(ctx context.Context, requestConfiguration *CompaniesItemJournalsItemJournalLinesJournalLineItemRequestBuilderGetRequestConfiguration)(ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.JournalLineable, error) {\n requestInfo, err := m.ToGetRequestInformation(ctx, requestConfiguration);\n if err != nil {\n return nil, err\n }\n errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings {\n \"4XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n \"5XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n }\n res, err := m.BaseRequestBuilder.RequestAdapter.Send(ctx, requestInfo, ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.CreateJournalLineFromDiscriminatorValue, errorMapping)\n if err != nil {\n return nil, err\n }\n if res == nil {\n return nil, nil\n }\n return res.(ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.JournalLineable), nil\n}", "func (h *Headline) Merge(override *Headline) {\n\tif override.Title != \"\" && h.Title != override.Title {\n\t\th.Title = override.Title\n\t}\n\n\tif override.Content != \"\" && h.Content != override.Content {\n\t\th.Content = override.Content\n\t}\n\n\tif override.Hash != \"\" && h.Hash != override.Hash {\n\t\th.Hash = override.Hash\n\t}\n\n\tif override.Url != \"\" && h.Url != override.Url {\n\t\th.Url = override.Url\n\t}\n\n\tif override.VisaType != \"\" && h.VisaType != override.VisaType {\n\t\th.VisaType = override.VisaType\n\t}\n\n\tif override.CategoryID != 0 && h.CategoryID != override.CategoryID {\n\t\th.CategoryID = override.CategoryID\n\t}\n\n\tif override.CountryID != 0 && h.CountryID != override.CountryID {\n\t\th.CountryID = override.CountryID\n\t}\n}", "func GetAllCategories (w http.ResponseWriter, r *http.Request) {\n\t//define new encoder that writes to the w\n\t//or report an error\n\tif err := json.NewEncoder(w).Encode(Categories); err != nil {\n\t\tlog.Printf(err.Error())\n\t\tw.WriteHeader(500)\n\t}\n}", "func (c *_Crawler) parseCategoryProducts(ctx context.Context, resp *http.Response, yield func(context.Context, interface{}) error) error {\n\tif c == nil || yield == nil {\n\t\treturn nil\n\t}\n\n\trespBody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tc.logger.Debug(err)\n\t\treturn err\n\t}\n\n\tdoc, err := goquery.NewDocumentFromReader(bytes.NewReader(respBody))\n\tif err != nil {\n\t\treturn err\n\t}\n\tlastIndex := nextIndex(ctx)\n\n\tsel := doc.Find(`.name-link`)\n\n\tfor i := range sel.Nodes {\n\t\tnode := sel.Eq(i)\n\t\tif href, _ := node.Attr(\"href\"); href != \"\" {\n\n\t\t\treq, err := http.NewRequest(http.MethodGet, href, nil)\n\t\t\tif err != nil {\n\t\t\t\tc.logger.Error(err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlastIndex += 1\n\t\t\tnctx := context.WithValue(ctx, \"item.index\", lastIndex)\n\t\t\tif err := yield(nctx, req); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t//special category link\n\tif len(sel.Nodes) == 0 {\n\t\tif len(doc.Find(`.pt_categorylanding`).Nodes) > 0 {\n\t\t\tcategoryName := strings.Split(strings.TrimSuffix(resp.Request.URL.Path, \"/\"), `/`)\n\t\t\trequestURL := \"https://www.res-x.com/ws/r2/Resonance.aspx?appid=bareminerals01&tk=958677643273121&pg=525672038920870&sg=1&ev=content&ei=&bx=true&sc=campaign1_rr&sc=campaign2_rr&no=20&AllCategories=\" + categoryName[len(categoryName)-1] + \"&ccb=certonaRecommendations&vr=5.11x&ref=&url=\" + resp.Request.URL.String()\n\t\t\trespBodyV, err := c.variationRequest(ctx, requestURL, resp.Request.URL.String())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar viewData categoryStructure\n\t\t\t{\n\t\t\t\tmatched := categoryProductReg.FindSubmatch(respBodyV)\n\t\t\t\tif len(matched) > 1 {\n\t\t\t\t\tif err := json.Unmarshal(matched[1], &viewData); err != nil {\n\t\t\t\t\t\tc.logger.Errorf(\"unmarshal category detail data fialed, error=%s\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor _, item := range viewData.Resonance.Schemes {\n\t\t\t\tfor _, itemDetail := range item.Items {\n\n\t\t\t\t\tif href := itemDetail.ProductDetailURL; href != \"\" {\n\t\t\t\t\t\tcanonicalHref, err := c.CanonicalUrl(href)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tc.logger.Error(err)\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif i := strings.Index(canonicalHref, \"&\"); i != -1 {\n\t\t\t\t\t\t\tcanonicalHref = canonicalHref[0:i]\n\t\t\t\t\t\t}\n\t\t\t\t\t\treq, err := http.NewRequest(http.MethodGet, canonicalHref, nil)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tc.logger.Error(err)\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlastIndex += 1\n\t\t\t\t\t\tnctx := context.WithValue(ctx, \"item.index\", lastIndex)\n\t\t\t\t\t\tif err := yield(nctx, req); err != nil {\n\t\t\t\t\t\t\treturn err\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\tnextUrl := doc.Find(`.infinite-scroll-placeholder`).AttrOr(\"data-grid-url\", \"\")\n\tif nextUrl == \"\" {\n\t\treturn nil\n\t}\n\tnextUrl = strings.ReplaceAll(nextUrl, \"&sz=12\", \"&sz=24\")\n\n\treq, _ := http.NewRequest(http.MethodGet, nextUrl, nil)\n\tnctx := context.WithValue(ctx, \"item.index\", lastIndex)\n\treturn yield(nctx, req)\n}", "func (ArticleController) GetTopArticles(c *gin.Context) {\n\tlimit, err := strconv.Atoi(c.Query(\"limit\"))\n\tif err != nil {\n\t\tc.JSON(http.StatusUnprocessableEntity, gin.H{\n\t\t\t\"message\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tarticles, dbErr := models.GetTopArticles(limit)\n\tif dbErr != nil {\n\t\tc.JSON(dbErr.Code(), gin.H{\n\t\t\t\"message\": dbErr.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, articles)\n}", "func getHeaders(w http.ResponseWriter, r *http.Request) {\n\t//\tObtener la información del Request.-\n\trequest := httputility.GetInfoRequest(r)\n\n\t//\tDevolver el Json con la información.-\n\thttputility.GetJsonResponse(w, request)\n}", "func clinicaltrialsFetch(w http.ResponseWriter, r *http.Request) {\n\n\t// define the query\n\tquery := `(wuhan AND (coronavirus OR corona virus OR pneumonia virus)) OR COVID19 OR COVID-19 OR COVID 19 OR coronavirus 2019 OR corona virus 2019 OR SARS-CoV-2 OR SARSCoV2 OR SARS2 OR SARS-2 OR 2019 nCoV OR ((novel coronavirus OR novel corona virus) AND 2019)`\n\n\tdta, err := clinicaltrials.Fetch(query)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\thttp.Error(w, \"could not fetch data\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\trender.PlainText(w, r, dta)\n}", "func (repo *SQLRepository) GetArticles(id int64) ([]model.ArticleModel, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), repo.timeout)\n\tdefer cancel()\n\n\tproc := \"[dbo].[spGetArticles]\"\n\tcmd := fmt.Sprintf(\"EXEC %s %d\", proc, id)\n\tarticles := make([]model.ArticleModel, 0)\n\trows, _, err := repo.queryContext(ctx, cmd)\n\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to query for GetArticles(%d) method: %v\", id, err)\n\t\treturn nil, err\n\t}\n\n\tfor rows.Next() {\n\t\tarticle := model.ArticleModel{}\n\n\t\tscanErr := rows.Scan(\n\t\t\t&article.ID,\n\t\t\t&article.Title,\n\t\t\t&article.DateTime,\n\t\t\t&article.Body,\n\t\t\t&article.TagsString,\n\t\t)\n\t\tarticle.Date = article.DateTime.Format(\"2006-01-02\")\n\t\tarticle.Tags = strings.Split(article.TagsString, \",\")\n\n\t\tif scanErr != nil {\n\t\t\tlog.Errorf(\"Failed to scan row cells: %v\", scanErr)\n\t\t\treturn nil, scanErr\n\t\t}\n\n\t\tarticles = append(articles, article)\n\t}\n\n\treturn articles, nil\n}", "func GetFeedArticles(c *gin.Context) {\n\tclient, ctx, cancel := utils.GetConnection()\n\tdefer cancel()\n\tarticleCollection := client.Database(\"conduit\").Collection(\"articles\")\n\tuserCollection := client.Database(\"conduit\").Collection(\"users\")\n\n\tvar loginUser models.User\n\tclaims, err := middlewares.Authenticate(c)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tid, err := primitive.ObjectIDFromHex(claims.UserID)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t}\n\terr = userCollection.FindOne(ctx, bson.M{\n\t\t\"_id\": id,\n\t}).Decode(&loginUser)\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tvar args GetFeedArgs\n\targs.Limit = 20\n\targs.Offset = 0\n\n\tif err := c.ShouldBindQuery(&args); err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tvar query bson.M = make(primitive.M)\n\tquery[\"author\"] = bson.M{\n\t\t\"$in\": loginUser.Following,\n\t}\n\n\tmatchStage := bson.D{{Key: \"$match\", Value: query}}\n\tlookupStage := bson.D{{Key: \"$lookup\", Value: bson.D{{Key: \"from\", Value: \"users\"}, {Key: \"localField\", Value: \"author\"}, {Key: \"foreignField\", Value: \"_id\"}, {Key: \"as\", Value: \"author\"}}}}\n\tunwindStage := bson.D{{Key: \"$unwind\", Value: bson.D{{Key: \"path\", Value: \"$author\"}, {Key: \"preserveNullAndEmptyArrays\", Value: false}}}}\n\tskipStage := bson.D{{Key: \"$skip\", Value: args.Offset}}\n\tlimitStage := bson.D{{Key: \"$limit\", Value: args.Limit}}\n\tcursor, err := articleCollection.Aggregate(ctx, mongo.Pipeline{matchStage, lookupStage, unwindStage, skipStage, limitStage})\n\tcounts, err := articleCollection.CountDocuments(ctx, query)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\tvar articles []models.ArticleWithAuthor\n\terr = cursor.All(ctx, &articles)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tvar articlesJSON []models.ArticleJSON = make([]models.ArticleJSON, len(articles))\n\tfor i, article := range articles {\n\t\tarticlesJSON[i].ArticleBase = article.ArticleBase\n\t\tarticlesJSON[i].Author = article.Author.ToProfile(&loginUser)\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"articles\": articlesJSON,\n\t\t\"articlesCount\": counts,\n\t})\n}", "func (a LearningApi) GetLearningModules(isArchived bool, types []string, pageSize int, pageNumber int, sortOrder string, sortBy string, searchTerm string, expand []string, isPublished string, statuses []string) (*Learningmodulesdomainentitylisting, *APIResponse, error) {\n\tvar httpMethod = \"GET\"\n\t// create path and map variables\n\tpath := a.Configuration.BasePath + \"/api/v2/learning/modules\"\n\tdefaultReturn := new(Learningmodulesdomainentitylisting)\n\tif true == false {\n\t\treturn defaultReturn, nil, errors.New(\"This message brought to you by the laws of physics being broken\")\n\t}\n\n\n\theaderParams := make(map[string]string)\n\tqueryParams := make(map[string]string)\n\tformParams := url.Values{}\n\tvar postBody interface{}\n\tvar postFileName string\n\tvar fileBytes []byte\n\t// authentication (PureCloud OAuth) required\n\n\t// oauth required\n\tif a.Configuration.AccessToken != \"\"{\n\t\theaderParams[\"Authorization\"] = \"Bearer \" + a.Configuration.AccessToken\n\t}\n\t// add default headers if any\n\tfor key := range a.Configuration.DefaultHeader {\n\t\theaderParams[key] = a.Configuration.DefaultHeader[key]\n\t}\n\t\n\tqueryParams[\"isArchived\"] = a.Configuration.APIClient.ParameterToString(isArchived, \"\")\n\t\n\tqueryParams[\"types\"] = a.Configuration.APIClient.ParameterToString(types, \"multi\")\n\t\n\tqueryParams[\"pageSize\"] = a.Configuration.APIClient.ParameterToString(pageSize, \"\")\n\t\n\tqueryParams[\"pageNumber\"] = a.Configuration.APIClient.ParameterToString(pageNumber, \"\")\n\t\n\tqueryParams[\"sortOrder\"] = a.Configuration.APIClient.ParameterToString(sortOrder, \"\")\n\t\n\tqueryParams[\"sortBy\"] = a.Configuration.APIClient.ParameterToString(sortBy, \"\")\n\t\n\tqueryParams[\"searchTerm\"] = a.Configuration.APIClient.ParameterToString(searchTerm, \"\")\n\t\n\tqueryParams[\"expand\"] = a.Configuration.APIClient.ParameterToString(expand, \"multi\")\n\t\n\tqueryParams[\"isPublished\"] = a.Configuration.APIClient.ParameterToString(isPublished, \"\")\n\t\n\tqueryParams[\"statuses\"] = a.Configuration.APIClient.ParameterToString(statuses, \"multi\")\n\t\n\n\t// Find an replace keys that were altered to avoid clashes with go keywords \n\tcorrectedQueryParams := make(map[string]string)\n\tfor k, v := range queryParams {\n\t\tif k == \"varType\" {\n\t\t\tcorrectedQueryParams[\"type\"] = v\n\t\t\tcontinue\n\t\t}\n\t\tcorrectedQueryParams[k] = v\n\t}\n\tqueryParams = correctedQueryParams\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{ \"application/json\", }\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\theaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/json\",\n\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\theaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tvar successPayload *Learningmodulesdomainentitylisting\n\tresponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, postFileName, fileBytes)\n\tif err != nil {\n\t\t// Nothing special to do here, but do avoid processing the response\n\t} else if err == nil && response.Error != nil {\n\t\terr = errors.New(response.ErrorMessage)\n\t} else if response.HasBody {\n\t\tif \"Learningmodulesdomainentitylisting\" == \"string\" {\n\t\t\tcopy(response.RawBody, &successPayload)\n\t\t} else {\n\t\t\terr = json.Unmarshal(response.RawBody, &successPayload)\n\t\t}\n\t}\n\treturn successPayload, response, err\n}", "func (categories *Categories) ReadCategoriesByName(categoryName, language string) ([]Category, error) {\n\n\tvariables := struct {\n\t\tCategoryName string\n\t\tLanguage string\n\t}{\n\t\tCategoryName: categoryName,\n\t\tLanguage: language}\n\n\tqueryTemplate, err := template.New(\"ReadCategoriesByName\").Parse(`{\n\t\t\t\tcategories(func: eq(categoryName@{{.Language}}, \"{{.CategoryName}}\"))\n\t\t\t\t@filter(eq(categoryIsActive, true)) {\n\t\t\t\t\tuid\n\t\t\t\t\tcategoryName: categoryName@{{.Language}}\n\t\t\t\t\tcategoryIsActive\n\t\t\t\t\tbelongs_to_company @filter(eq(companyIsActive, true)) {\n\t\t\t\t\t\tuid\n\t\t\t\t\t\tcompanyName: companyName@{{.Language}}\n\t\t\t\t\t\tcompanyIsActive\n\t\t\t\t\t\thas_category @filter(eq(categoryIsActive, true)) {\n\t\t\t\t\t\t\tuid\n\t\t\t\t\t\t\tcategoryName: categoryName@{{.Language}}\n\t\t\t\t\t\t\tcategoryIsActive\n\t\t\t\t\t\t\tbelong_to_company @filter(eq(companyIsActive, true)) {\n\t\t\t\t\t\t\t\tuid\n\t\t\t\t\t\t\t\tcompanyName: companyName@{{.Language}}\n\t\t\t\t\t\t\t\tcompanyIsActive\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thas_product @filter(eq(productIsActive, true)) {\n\t\t\t\t\t\tuid\n\t\t\t\t\t\tproductName: productName@{{.Language}}\n\t\t\t\t\t\tproductIri\n\t\t\t\t\t\tpreviewImageLink\n\t\t\t\t\t\tproductIsActive\n\t\t\t\t\t\tbelongs_to_category @filter(eq(categoryIsActive, true)) {\n\t\t\t\t\t\t\tuid\n\t\t\t\t\t\t\tcategoryName: categoryName@{{.Language}}\n\t\t\t\t\t\t\tcategoryIsActive\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbelongs_to_company @filter(eq(companyIsActive, true)) {\n\t\t\t\t\t\t\tuid\n\t\t\t\t\t\t\tcompanyName: companyName@{{.Language}}\n\t\t\t\t\t\t\tcompanyIsActive\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`)\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, ErrCategoriesByNameCanNotBeFound\n\t}\n\n\tqueryBuf := bytes.Buffer{}\n\terr = queryTemplate.Execute(&queryBuf, variables)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, ErrCategoriesByNameCanNotBeFound\n\t}\n\n\ttransaction := categories.storage.Client.NewTxn()\n\tresponse, err := transaction.Query(context.Background(), queryBuf.String())\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, ErrCategoriesByNameCanNotBeFound\n\t}\n\n\ttype categoriesInStorage struct {\n\t\tAllCategoriesFoundedByName []Category `json:\"categories\"`\n\t}\n\n\tvar foundedCategories categoriesInStorage\n\terr = json.Unmarshal(response.GetJson(), &foundedCategories)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, ErrCategoriesByNameCanNotBeFound\n\t}\n\n\tif len(foundedCategories.AllCategoriesFoundedByName) == 0 {\n\t\treturn nil, ErrCategoriesByNameNotFound\n\t}\n\n\treturn foundedCategories.AllCategoriesFoundedByName, nil\n}", "func GetArticle(c *gin.Context) {\n\tvar loginUser models.User\n\tclaims, err := middlewares.Authenticate(c)\n\n\tclient, ctx, cancel := utils.GetConnection()\n\tdefer cancel()\n\tuserCollection := client.Database(\"conduit\").Collection(\"users\")\n\tarticleCollection := client.Database(\"conduit\").Collection(\"articles\")\n\n\tid, err := primitive.ObjectIDFromHex(claims.UserID)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\terr = userCollection.FindOne(ctx, bson.M{\n\t\t\"_id\": id,\n\t}).Decode(&loginUser)\n\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tslug := c.Param(\"slug\")\n\n\tvar article models.ArticleWithAuthor\n\tmatchStage := bson.D{{Key: \"$match\", Value: bson.D{{Key: \"slug\", Value: slug}}}}\n\tlookupStage := bson.D{{Key: \"$lookup\", Value: bson.D{{Key: \"from\", Value: \"users\"}, {Key: \"localField\", Value: \"author\"}, {Key: \"foreignField\", Value: \"_id\"}, {Key: \"as\", Value: \"author\"}}}}\n\tcursor, err := articleCollection.Aggregate(ctx, mongo.Pipeline{matchStage, lookupStage})\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\tfor cursor.Next(ctx) {\n\t\terr := cursor.Decode(&article)\n\t\tif err != nil {\n\t\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\t\"error\": err.Error(),\n\t\t\t})\n\t\t\treturn\n\t\t}\n\t\tbreak\n\t}\n\tvar articleJSON = models.ArticleJSON{ArticleBase: article.ArticleBase, Author: article.Author.ToProfile(&loginUser)}\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"article\": articleJSON,\n\t})\n}", "func HomeHandler(c buffalo.Context) error {\n\ta := []models.Article{}\n\ttx := c.Value(\"tx\").(*pop.Connection)\n\n\tq := tx.PaginateFromParams(c.Params())\n\n\t// Filter tags\n\ttagParam := c.Params().Get(\"tag\")\n\tif tagParam != \"\" {\n\t\ttag := &models.Tag{}\n\n\t\texists, err := tx.Where(\"name = ?\", tagParam).Exists(tag)\n\t\tif err == nil && exists {\n\t\t\ttx.Where(\"name = ?\", tagParam).First(tag)\n\t\t\tq = q.LeftJoin(\"article_tags\", \"article_tags.article_id=articles.id\").Where(\"article_tags.tag_id = ?\", tag.ID)\n\t\t}\n\t}\n\n\terr := q.Order(\"created_at desc\").Eager(\"User\").Eager(\"ArticleFavorites\").Eager(\"ArticleTags\").Eager(\"ArticleTags.Tag\").All(&a)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\tc.Set(\"paginator\", q.Paginator)\n\tc.Set(\"articles\", a)\n\n\ttags, err := models.LoadPopularArticleTags(tx, 20)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\tc.Set(\"tags\", tags)\n\n\tc.Set(\"source_page\", c.Request().URL)\n\n\treturn c.Render(200, r.HTML(\"index.html\"))\n}", "func (service *RssService) GetArticles(id uint, page int) *models.ArticlesJSON {\n\tvar articles []models.Articles\n\tvar count int\n\toffset := service.config.PageSize * (page - 1)\n\twhereObject := models.Articles{FeedId: id}\n\n\tquery := service.dbp().Where(&whereObject).\n\t\tSelect(\"Id, Title, IsBookmark, IsRead\").\n\t\tLimit(service.config.PageSize).\n\t\tOffset(offset).\n\t\tOrder(\"Id desc\")\n\tqueryCount := service.dbp().Model(&whereObject).Where(&whereObject)\n\n\tif service.AppSettings.UnreadOnly {\n\t\twhereNotObject := models.Articles{IsRead: true}\n\t\tquery = query.Not(&whereNotObject)\n\t\tqueryCount = queryCount.Not(&whereNotObject)\n\t}\n\n\tquery.Find(&articles)\n\tqueryCount.Count(&count)\n\n\treturn &models.ArticlesJSON{Articles: articles, Count: count}\n}", "func Get(p config.Config) docs.Index {\n\n\t// Get the categories (i.e. How-to, Tutorials, etc.)\n\tvar categories comm.DiscourseCategories\n\tbody := req.RequestData(p.URL, \"categories.json\")\n\tjson.Unmarshal(body, &categories)\n\n\t// Parse each category individually.\n\tvar allDocuments docs.Index\n\tio.WriteString(os.Stdout, fmt.Sprintf(\"\\n\\033[1mDiscourse API @\\033[0m %s\\n\", p.URL))\n\tfor _, category := range categories.CategoryList.Categories {\n\t\t// Check if the category should be ignored, according to `config.yaml`.\n\t\tif !ignore.ItemExists(p.Ignore, category.Name) && category.TopicCount > 0 {\n\t\t\t// Get the documents.\n\t\t\tio.WriteString(os.Stdout, fmt.Sprintf(\"\\033[1m %s\\033[0m (%v topics)\\n\", category.Name, category.TopicCount))\n\t\t\tallDocuments = parseCategory(p, category, allDocuments)\n\t\t}\n\t}\n\treturn allDocuments\n}", "func (c *Controller) getHelmRequestDependencies(hr *v1alpha1.HelmRequest) ([]*v1alpha1.HelmRequest, error) {\n\tvar data []*v1alpha1.HelmRequest\n\tdeps := hr.Spec.Dependencies\n\tif len(deps) == 0 {\n\t\tklog.V(4).Infof(\"HelmRequest %s has no dependencies\", hr.GetName())\n\t\treturn nil, nil\n\t}\n\n\tfor _, name := range deps {\n\t\td, err := c.getHelmRequest(hr.GetNamespace(), name)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Retrieve dependency %s for %s error: %s\", name, hr.GetName(), err.Error())\n\t\t\treturn nil, err\n\t\t}\n\t\tdata = append(data, d)\n\t}\n\n\treturn data, nil\n\n}", "func GetAllArticleList(w http.ResponseWriter, r *http.Request) {\n var articlesWithoutFullText []Article\n for _, item := range article {\n item.FullText = \"\"\n articlesWithoutFullText = append(articlesWithoutFullText, item)\n }\n json.NewEncoder(w).Encode(articlesWithoutFullText)\n}", "func requestAllBookTitles(AuthorID int) (map[int]string, error) {\n\tendpointBase := \"https://www.goodreads.com/author/list.xml\"\n\tpage := 1\n\n\tmapTitles, more, err := requestPage(page, AuthorID, endpointBase)\n\tif err != nil {\n\t\treturn make(map[int]string), err\n\t}\n\n\tif more > 0 {\n\t\tfmt.Println(\"There are more books in the API.\")\n\t\tfmt.Println(\"Additional requests needed:\", more)\n\t}\n\n\t/* Make a map of channels, 1 channel per page */\n\tchannels := make(map[int]chan map[int]string)\n\tfor i := 2; i <= more+1; i++ {\n\t\tchannels[i] = make(chan map[int]string)\n\t}\n\n\t/* Make 'more' (number of) requests */\n\tfor i := 2; i <= more+1; i++ {\n\t\tgo func(i int) {\n\t\t\tmoreTitles, _, err := requestPage(i, AuthorID, endpointBase)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(\"This request failed:\", i)\n\t\t\t\tchannels[i] <- make(map[int]string)\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"Received page:\", i)\n\t\t\t\tchannels[i] <- moreTitles\n\t\t\t}\n\t\t}(i)\n\t}\n\n\t/* usually 30, but left variable in case API changes (untested) */\n\tbooksPerPage := len(mapTitles)\n\n\t/* Receive pages in order */\n\tfor i := 2; i <= more+1; i++ {\n\t\tmoreTitles := <-channels[i]\n\n\t\t/* add them to mapTitles (sequential) */\n\t\tfor j := 0; j <= booksPerPage; j++ {\n\t\t\tif moreTitles[j] != \"\" {\n\t\t\t\tmapTitles[(i-1)*booksPerPage+j] = moreTitles[j]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mapTitles, nil\n}", "func (a *Client) AllHomepageSections(params *AllHomepageSectionsParams) (*AllHomepageSectionsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewAllHomepageSectionsParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"all_homepage_sections\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/homepage_sections\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &AllHomepageSectionsReader{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\tsuccess, ok := result.(*AllHomepageSectionsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for all_homepage_sections: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func GetCategories() []*datastore.Category {\n\t// Connect to database\n\tdb := OpenPostgresDB()\n\tdefer db.Close()\n\n\t// Query database\n\trows, err := db.Query(\"SELECT * FROM category\")\n\terror_handler.Check(err)\n\n\t// Store categories for landing page in this array\n\tlandingPage := make([]*datastore.Category, 0)\n\n\t// Go through list of categories returned from db\n\tfor rows.Next() {\n\t\tvar id int\n\t\tvar name string\n\t\tvar image string\n\t\terr = rows.Scan(&id, &name, &image)\n\n\t\terror_handler.Check(err)\n\n\t\t// Store single instance of categories\n\t\tvar lpage = datastore.NewCategory(id, name, image)\n\n\t\t// Store above categories in landing page array\n\t\tlandingPage = append(landingPage, lpage)\n\t}\n\treturn landingPage\n}", "func SaveHeadlines() {\n\tfile, err := os.OpenFile(savedHeadlinesFileName, os.O_CREATE|os.O_WRONLY, 0775)\n\tif err != nil {\n\t\tLogger.Errorln(err)\n\t\treturn\n\t}\n\n\tdefer file.Close()\n\n\tencoder := json.NewEncoder(file)\n\n\tFetchedHeadlinesLock.RLock()\n\tdefer FetchedHeadlinesLock.RUnlock()\n\n\terr = encoder.Encode(FetchedHeadlines)\n\n\tif err != nil {\n\t\tLogger.Errorln(err)\n\t}\n}", "func Get(c *gin.Context){\n\tidStr := c.Query(\"id\")\n\tid, err := strconv.Atoi(idStr)\n\tif err != nil {\n\t\tresponese.Error(c, err, nil)\n\t\treturn\n\t}\n\tca := Category{ID:id}\n\terr = ca.Read()\n\tif err != nil {\n\t\tresponese.Error(c, err, nil)\n\t\treturn\n\t}\n\tresponese.Success(c, \"successed\", &ca)\n}", "func newsHandler(w http.ResponseWriter, r *http.Request) {\n\tRefreshSession(w, r)\n\n\t//prVal(\"r.URL.Query()\", r.URL.Query())\n\n\treqCategory\t\t:= parseUrlParam(r, \"category\")\n\n\treqAlert\t\t:= parseUrlParam(r, \"alert\")\n\n\t// Get the username.\n\tuserId := GetSession(r)\n\tusername := getUsername(userId)\n\n\t// TODO: cache this, fetch every minute?\n\tvar articles []Article\n\tif reqCategory == \"\" {\n\t\t// Fetch 5 articles from each category\n\t\tarticles = fetchArticlesPartitionedByCategory(kRowsPerCategory + 1, userId, kMaxArticles) // kRowsPerCategory on one side, and 1 headline on the other.\n\t} else {\n\t\t// Ensure we have a valid category (prevent SQL injection)\n\t\tif _, ok := newsCategoryInfo.HeaderColors[reqCategory]; !ok {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\t// Fetch articles in requested category\n\t\tarticles = fetchArticlesWithinCategory(reqCategory, userId, kMaxArticles)\n\t}\n\n\tarticleGroups := formatArticleGroups(articles, newsCategoryInfo, reqCategory, kAlternateHeadlines)\n\n\trenderNews(w, \"News\", username, userId, articleGroups, \"news\", \"news\", []int64{}, []int64{}, reqAlert)\n}", "func GetAll(ID string) []*Labo {\n\tconst (\n\t\tCSS string = \".product-listing .product-container > p a\"\n\t)\n\tvar (\n\t\tdoc *goquery.Document\n\t\terr error\n\t\tl []*Labo\n\t\tok bool\n\t\treq *http.Request\n\t\tres *http.Response\n\t\ts *goquery.Selection\n\t)\n\treq, err = http.NewRequest(http.MethodGet, fmt.Sprintf(\"%s%s\", storeCategoryURI, ID), nil)\n\tres, err = client.Do(req)\n\tok = (err == nil)\n\tif !ok {\n\t\treturn nil\n\t}\n\tok = (res.StatusCode == http.StatusOK)\n\tif !ok {\n\t\treturn nil\n\t}\n\tdoc, err = goquery.NewDocumentFromResponse(res)\n\tok = (err == nil)\n\tif !ok {\n\t\treturn nil\n\t}\n\ts = doc.Find(CSS)\n\tok = (s.Length() > 0)\n\tif !ok {\n\t\treturn nil\n\t}\n\ts.Each(func(i int, s *goquery.Selection) {\n\t\thref, exists := s.Attr(attrHref)\n\t\tif !exists {\n\t\t\treturn\n\t\t}\n\t\tURL, err := url.Parse(href)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tID := URL.Query().Get(uriQueryParamProductID)\n\t\tlabo := Get(ID)\n\t\tif labo == nil {\n\t\t\treturn\n\t\t}\n\t\tl = append(l, labo)\n\t})\n\treturn l\n}", "func GetJournalEntriesAll(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\tif isLoggedIn(w, req) {\n\t\tq := req.URL.Query()\n\n\t\tch := make(chan map[string]bool)\n\t\tgo model.GetLabourNames(ch)\n\n\t\tdate := q[\"date\"][0]\n\t\tproductID, err := strconv.Atoi(q[\"id\"][0])\n\t\tif err != nil {\n\t\t\tlog.Println(\"Error in GETJournal Entries all\")\n\t\t\tlog.Println(err)\n\t\t}\n\t\tje, box, packet, res := model.GetAllJournalEntry(date, productID)\n\n\t\tlabours = <-ch\n\n\t\tresult := JournalResponse{\n\t\t\tJournalEntries: je,\n\t\t\tBox: box,\n\t\t\tPacket: packet,\n\t\t\tLabours: labours,\n\t\t}\n\t\tif res {\n\t\t\tp, err := json.Marshal(result)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"Error in GetJournalEntries all in Marshalling\")\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t\tio.WriteString(w, string(p))\n\t\t}\n\t}\n}", "func GetTopics() []string {\r\n\tvar topics []string\r\n\tresp, err := http.Get(\"https://www.vauva.fi/keskustelu/alue/aihe_vapaa\")\r\n\tif err != nil {\r\n\t\t// handle error\r\n\t}\r\n\tdefer resp.Body.Close()\r\n\tdoc, err := goquery.NewDocumentFromReader(resp.Body)\r\n\tif err != nil {\r\n\t\tlog.Fatal(err)\r\n\t}\r\n\tdoc.Find(\".field-content\").Each(func(i int, s *goquery.Selection) {\r\n\t\thref, ok := s.Find(\"a\").Attr(\"href\")\r\n\t\tif ok {\r\n\t\t\ttopic = fmt.Sprintf(\"https://www.vauva.fi%s\", href)\r\n\t\t\ttopics = append(topics, topic)\r\n\t\t}\r\n\t})\r\n\r\n\treturn topics\r\n}", "func (c *Client) Category(ctx context.Context, category TorrentCategory, opts *CategoryOptions) ([]*Torrent, error) {\n\tif opts == nil {\n\t\topts = &CategoryOptions{\n\t\t\tPage: 0,\n\t\t}\n\t}\n\tquery := fmt.Sprintf(\"category:%d:%d\", category, opts.Page)\n\tv := url.Values{}\n\tv.Add(\"q\", query)\n\tpath := \"/q.php?\" + v.Encode()\n\treturn c.fetchTorrents(ctx, path)\n}", "func GetRelYt(sliceKw []string) (contacts []Contact, err error) {\n\t//\n\tfor _, keyword := range sliceKw {\n\t\tr, err := http.Get(\"http://http://ec2-54-161-234-228.compute-1.amazonaws.com:3000/search?search=\" + strings.ReplaceAll(keyword, \" \", \"+\") + \"&getallpage=true\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer r.Body.Close()\n\t\t_, err = ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn nil, nil\n}" ]
[ "0.68849087", "0.6120435", "0.58814883", "0.57775015", "0.5727307", "0.5402256", "0.51543653", "0.5129571", "0.49519652", "0.48825216", "0.48794803", "0.47898486", "0.4730368", "0.46671894", "0.46384147", "0.45988035", "0.4587881", "0.45309943", "0.44835395", "0.4472544", "0.44471937", "0.4426798", "0.44251597", "0.4417659", "0.4416654", "0.4394409", "0.43936208", "0.43845475", "0.43800178", "0.43769687", "0.4369656", "0.43492493", "0.43437958", "0.4337378", "0.4306904", "0.4298762", "0.4296789", "0.42922693", "0.4289638", "0.42827055", "0.4279814", "0.42750323", "0.42727497", "0.4260924", "0.4258524", "0.42568168", "0.42565078", "0.4249033", "0.4237805", "0.4229013", "0.4203948", "0.4188182", "0.41841885", "0.41760227", "0.4173489", "0.41719398", "0.41608375", "0.41576475", "0.41542456", "0.4149964", "0.41414317", "0.41353172", "0.41351765", "0.41231593", "0.41214132", "0.41191477", "0.41144043", "0.410714", "0.40987927", "0.4075138", "0.4070095", "0.40680894", "0.40665352", "0.40580216", "0.4055315", "0.40440202", "0.4031433", "0.4029463", "0.40293437", "0.40292808", "0.40169403", "0.40133667", "0.40090698", "0.40085942", "0.4008278", "0.40072143", "0.40057528", "0.4003479", "0.40018663", "0.40006322", "0.40003857", "0.3998417", "0.39940673", "0.39923465", "0.39896858", "0.3988057", "0.39876562", "0.39868566", "0.3981587", "0.397883" ]
0.7598716
0
CronIntervalValidator return a nil value when a valid cron string is passed used in gopkg.in/validator.v2
func CronIntervalValidator(val interface{}, param string) error { value, ok := val.(string) if !ok { return fmt.Errorf("invalid crontab entry, not a valid string") } if _, err := cron.ParseStandard(value); err != nil { return errors.Wrap(err, "invalid crontab entry") } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ValidateCronInterval(val interface{}) error {\n\treturn CronIntervalValidator(val, \"\")\n}", "func (c *CronSchedule) Validate() error {\n\tif c.entry == \"\" {\n\t\treturn ErrMissingCronEntry\n\t}\n\t_, err := cron.Parse(c.entry)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c Cron) Validate() error {\n\tswitch {\n\tcase c.Spec.Branch == \"\":\n\t\treturn errors.New(\"yaml: invalid cron branch\")\n\tdefault:\n\t\treturn nil\n\t}\n}", "func isCron(fl FieldLevel) bool {\n\tcronString := fl.Field().String()\n\treturn cronRegex.MatchString(cronString)\n}", "func ParseCronExpression(args []string) (string, error) {\n\tsantizedArgs, err := sanitize(args)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tresult, err := parseExpression(santizedArgs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn format(result), nil\n}", "func (ci *CronImpl) Parse(spec string) (cron.Schedule, error) {\n\treturn cron.Parse(spec)\n}", "func Parse(c string) (*Cron, error) {\n\tcron := &Cron{}\n\tif c[len(c) - 1] == spaceByte {\n\t\tc = c[:len(c) - 1]\n\t}\n\tcp := strings.Split(c, \" \")\n\tif len(cp) > 5 {\n\t\treturn nil, fmt.Errorf(\"unknown cron format: %s\", c)\n\t}\n\n\terr := cron.parseMinutes(cp[0])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseHours(cp[1])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseDays(cp[2])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseMonths(cp[3])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseWeekdays(cp[4])\n\n\treturn cron, nil\n}", "func Test_TaskOption_CronExpression(t *testing.T) {\n\t// given\n\toption := crontask.CronExpression(\"bar\")\n\toptions := &crontask.TaskOptions{CronExpression: \"foo\"}\n\n\t// when\n\toption(options)\n\n\t// then\n\tif options.CronExpression != \"bar\" {\n\t\tt.Errorf(\"cron expression not correctly applied, got %s\", options.CronExpression)\n\t}\n}", "func InitCronExpr(ctx context.Context, duration time.Duration) error {\n\tif duration < 0 || duration > 12*time.Hour {\n\t\treturn moerr.NewNotSupported(ctx, \"export cron expr not support cycle: %v\", duration)\n\t}\n\tif duration < 5*time.Minute {\n\t\tMergeTaskCronExpr = fmt.Sprintf(\"@every %.0fs\", duration.Seconds())\n\t} else if duration < time.Hour {\n\t\tconst unit = 5 * time.Minute\n\t\tduration = (duration + unit - 1) / unit * unit\n\t\tswitch duration {\n\t\tcase 5 * time.Minute:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery05Min\n\t\tcase 15 * time.Minute:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery15Min\n\t\tdefault:\n\t\t\tMergeTaskCronExpr = fmt.Sprintf(\"@every %.0fm\", duration.Minutes())\n\t\t}\n\t} else {\n\t\tminHour := duration / time.Hour\n\t\tswitch minHour {\n\t\tcase 1:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery1Hour\n\t\tcase 2:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery2Hour\n\t\tcase 4:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery4Hour\n\t\tdefault:\n\t\t\tvar hours = make([]string, 0, 12)\n\t\t\tfor h := minHour; h < 24; h += minHour {\n\t\t\t\thours = append(hours, strconv.Itoa(int(h)))\n\t\t\t}\n\t\t\tMergeTaskCronExpr = fmt.Sprintf(\"0 0 %s * * *\", strings.Join(hours, \",\"))\n\t\t}\n\t}\n\treturn nil\n}", "func ParseCronExpression(cronExpr string) (cron.Schedule, error) {\n\tif strings.TrimSpace(cronExpr) == \"@never\" {\n\t\treturn Year9999{}, nil\n\t}\n\treturn cron.ParseStandard(cronExpr) //nolint:wrapcheck\n}", "func Cronjob(period string, r *Retriever) {\n\tcronjob := cron.New()\n\tcronjob.AddFunc(period, r.RetrieveIP)\n\tklog.Infof(\"start cron job to retrieve ip period %s\", period)\n\tcronjob.Start()\n}", "func parseCronLine(l string) (string, error) {\n\n\tvar out string\n\n\t// Of course the regex could be a lot more sophisticated\n\tre := regexp.MustCompile(`^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(.+)$`)\n\tvalidCronLine := re.MatchString(l)\n\tif !validCronLine {\n\t\treturn \"\", errors.New(\"Cron line does not comply with standard format\")\n\t}\n\n\tsubMatch := re.FindStringSubmatch(l)\n\n\tminuteStr := subMatch[1]\n\thourStr := subMatch[2]\n\tdayOfMonthStr := subMatch[3]\n\tmonthStr := subMatch[4]\n\tdayOfWeekStr := subMatch[5]\n\tcommandStr := subMatch[6]\n\n\tminutesParsed, err := parseMinute(minuteStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing minutes: %v\", err)\n\t}\n\thoursParsed, err := parseHours(hourStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing hours: %v\", err)\n\t}\n\tdayOfMonthParsed, err := parseDayOfMonth(dayOfMonthStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing days of the month: %v\", err)\n\t}\n\tmonthParsed, err := parseMonth(monthStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing months: %v\", err)\n\t}\n\tdayOfWeekParsed, err := parseDayOfWeek(dayOfWeekStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing days of the week: %v\", err)\n\t}\n\n\tout = fmt.Sprintf(\"%-14s%s\\n\", \"minute\", joinInts(minutesParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"hour\", joinInts(hoursParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"day of month\", joinInts(dayOfMonthParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"month\", joinInts(monthParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"day of week\", joinInts(dayOfWeekParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"command\", commandStr)\n\n\treturn out, nil\n}", "func (p cron) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {\n\tif obj.GroupVersionKind() != cronGVC {\n\t\treturn false, nil, nil\n\t}\n\tmeta, err := processor.ProcessObjMeta(appMeta, obj)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\tname := appMeta.TrimName(obj.GetName())\n\tnameCamelCase := strcase.ToLowerCamel(name)\n\n\tjobObj := batchv1.CronJob{}\n\terr = runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &jobObj)\n\tif err != nil {\n\t\treturn true, nil, errors.Wrap(err, \"unable to cast to Job\")\n\t}\n\tspec := jobObj.Spec\n\tspecMap, exists, err := unstructured.NestedMap(obj.Object, \"spec\")\n\tif err != nil {\n\t\treturn true, nil, errors.Wrap(err, \"unable to get job spec\")\n\t}\n\tif !exists {\n\t\treturn true, nil, errors.New(\"no job spec presented\")\n\t}\n\n\tvalues := helmify.Values{}\n\n\t// process job spec params:\n\tif spec.Schedule != \"\" {\n\t\terr := templateSpecVal(spec.Schedule, &values, specMap, nameCamelCase, \"schedule\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.Suspend != nil {\n\t\terr := templateSpecVal(*spec.Suspend, &values, specMap, nameCamelCase, \"suspend\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.FailedJobsHistoryLimit != nil {\n\t\terr := templateSpecVal(*spec.FailedJobsHistoryLimit, &values, specMap, nameCamelCase, \"failedJobsHistoryLimit\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.StartingDeadlineSeconds != nil {\n\t\terr := templateSpecVal(*spec.StartingDeadlineSeconds, &values, specMap, nameCamelCase, \"startingDeadlineSeconds\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.TimeZone != nil {\n\t\terr := templateSpecVal(*spec.TimeZone, &values, specMap, nameCamelCase, \"timeZone\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.SuccessfulJobsHistoryLimit != nil {\n\t\terr := templateSpecVal(*spec.SuccessfulJobsHistoryLimit, &values, specMap, nameCamelCase, \"successfulJobsHistoryLimit\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\t// process job pod template:\n\tpodSpecMap, podValues, err := pod.ProcessSpec(nameCamelCase, appMeta, jobObj.Spec.JobTemplate.Spec.Template.Spec)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\terr = values.Merge(podValues)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\n\terr = unstructured.SetNestedMap(specMap, podSpecMap, \"jobTemplate\", \"spec\", \"template\", \"spec\")\n\tif err != nil {\n\t\treturn true, nil, fmt.Errorf(\"%w: unable to template job spec\", err)\n\t}\n\n\tspecStr, err := yamlformat.Marshal(map[string]interface{}{\"spec\": specMap}, 0)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\tspecStr = strings.ReplaceAll(specStr, \"'\", \"\")\n\n\treturn true, &resultCron{\n\t\tname: name + \".yaml\",\n\t\tdata: struct {\n\t\t\tMeta string\n\t\t\tSpec string\n\t\t}{Meta: meta, Spec: specStr},\n\t\tvalues: values,\n\t}, nil\n}", "func (p Parser) Parse(spec string) (cron.Schedule, error) {\n\tswitch spec {\n\tcase \"@yearly\", \"@annually\":\n\t\tspec = \"0 0 0 1 1 * *\"\n\tcase \"@monthly\":\n\t\tspec = \"0 0 0 1 * * *\"\n\tcase \"@weekly\":\n\t\tspec = \"0 0 0 * * 0 *\"\n\tcase \"@daily\":\n\t\tspec = \"0 0 0 * * * *\"\n\tcase \"@hourly\":\n\t\tspec = \"0 0 * * * * *\"\n\tcase \"@minutely\":\n\t\tspec = \"0 * * * * *\"\n\t}\n\n\treturn p.parser.Parse(spec)\n}", "func (n *Nodes) DeleteEssNodesCron(req apistructs.DeleteNodesCronRequest, userid string, orgid string) (*uint64, error) {\n\t// check cluster info\n\tclusterInfo, err := n.bdl.QueryClusterInfo(req.ClusterName)\n\tif err != nil {\n\t\terrstr := fmt.Sprintf(\"failed to queryclusterinfo: %v, clusterinfo: %v\", err, clusterInfo)\n\t\tlogrus.Errorf(errstr)\n\t\treturn nil, err\n\t}\n\tif !clusterInfo.IsK8S() {\n\t\terrstr := fmt.Sprintf(\"unsupported cluster type, cluster name: %s, cluster type: %s\",\n\t\t\tclusterInfo.MustGet(apistructs.DICE_CLUSTER_NAME), clusterInfo.MustGet(apistructs.DICE_CLUSTER_TYPE))\n\t\tlogrus.Errorf(errstr)\n\t\terr := errors.New(errstr)\n\t\treturn nil, err\n\t}\n\n\t// create cron expression\n\tcronMap := make(map[string]string)\n\tlayout := \"2006-01-02T15:04Z\"\n\tlaunchTime, err := time.Parse(layout, req.LaunchTime)\n\n\to1, _ := time.ParseDuration(\"8h\")\n\tt1 := launchTime.Add(o1)\n\n\tif err != nil {\n\t\terr := fmt.Errorf(\"parse launch time failed, request: %v, error: %v\", req.LaunchTime, err)\n\t\tlogrus.Error(err)\n\t\treturn nil, err\n\t}\n\tcronMap[\"minute\"] = strconv.Itoa(t1.Minute())\n\tcronMap[\"hour\"] = strconv.Itoa(t1.Hour())\n\tcronMap[\"day\"] = \"*\"\n\tcronMap[\"month\"] = \"*\"\n\tcronMap[\"week\"] = \"*\"\n\tif req.RecurrenceType == \"Daily\" {\n\t\tcronMap[\"day\"] = fmt.Sprintf(\"*/%s\", req.RecurrenceValue)\n\t} else if req.RecurrenceType == \"Monthly\" {\n\t\tcronMap[\"day\"] = req.RecurrenceValue\n\t} else if req.RecurrenceType == \"Weekly\" {\n\t\tcronMap[\"week\"] = req.RecurrenceValue\n\t} else {\n\t\terr := fmt.Errorf(\"unsupport recurrence type, cluster name:%s, type : %s\", req.ClusterName, req.RecurrenceType)\n\t\tlogrus.Error(err)\n\t\treturn nil, err\n\t}\n\tcronExpr := strings.Join([]string{cronMap[\"minute\"], cronMap[\"hour\"], cronMap[\"day\"], cronMap[\"month\"], cronMap[\"week\"]}, \" \")\n\tlogrus.Infof(\"create cron expression, cluster name: %s, cron expression: %s\", req.ClusterName, cronExpr)\n\n\treq.AccessKey = encrypt.AesDecrypt(req.AccessKey, apistructs.TerraformEcyKey)\n\treq.SecretKey = encrypt.AesDecrypt(req.SecretKey, apistructs.TerraformEcyKey)\n\treq.Password = encrypt.AesDecrypt(req.Password, apistructs.TerraformEcyKey)\n\t// default is not force\n\tforce := \"\"\n\tif req.Force {\n\t\tforce = \"true\"\n\t}\n\tyml := apistructs.PipelineYml{\n\t\tVersion: \"1.1\",\n\t\tCron: cronExpr,\n\t\tStages: [][]*apistructs.PipelineYmlAction{{{\n\t\t\tType: \"ess-info\",\n\t\t\tVersion: \"1.0\",\n\t\t\tAlias: string(apistructs.NodePhaseEssInfo),\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"ak\": req.AccessKey,\n\t\t\t\t\"sk\": req.SecretKey,\n\t\t\t\t\"region\": req.Region,\n\t\t\t\t\"scaling_group_id\": req.ScalingGroupId,\n\t\t\t},\n\t\t}}, {{\n\t\t\tType: \"rm-nodes\",\n\t\t\tVersion: \"1.0\",\n\t\t\tAlias: string(apistructs.NodePhaseRmNodes),\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"hosts_file\": fmt.Sprintf(\"${%s}/hosts\", string(apistructs.NodePhaseEssInfo)),\n\t\t\t\t\"password\": req.Password,\n\t\t\t\t\"force\": force,\n\t\t\t\t\"cluster\": req.ClusterName,\n\t\t\t},\n\t\t}}, {{\n\t\t\tType: \"delete-ess-nodes\",\n\t\t\tVersion: \"1.0\",\n\t\t\tAlias: string(apistructs.NodePhaseDeleteNodes),\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"ak\": req.AccessKey,\n\t\t\t\t\"sk\": req.SecretKey,\n\t\t\t\t\"region\": req.Region,\n\t\t\t\t\"scaling_group_id\": req.ScalingGroupId,\n\t\t\t\t\"is_cron\": true,\n\t\t\t\t\"instance_ids_file\": fmt.Sprintf(\"${%s}/instance_ids\", string(apistructs.NodePhaseEssInfo)),\n\t\t\t},\n\t\t}},\n\t\t},\n\t}\n\tb, err := yaml.Marshal(yml)\n\tif err != nil {\n\t\terrstr := fmt.Sprintf(\"failed to marshal pipelineyml: %v\", err)\n\t\tlogrus.Errorf(errstr)\n\t\treturn nil, err\n\t}\n\tdto, err := n.pipelineSvc.PipelineCreateV2(apis.WithInternalClientContext(context.Background(), discover.CMP()), &pipelinepb.PipelineCreateRequestV2{\n\t\tPipelineYml: string(b),\n\t\tPipelineYmlName: fmt.Sprintf(\"%s-%s.yml\", apistructs.DeleteEssNodesCronPrefix, clusterInfo.MustGet(apistructs.DICE_CLUSTER_NAME)),\n\t\tClusterName: clusterInfo.MustGet(apistructs.DICE_CLUSTER_NAME),\n\t\tPipelineSource: apistructs.PipelineSourceOps.String(),\n\t\tAutoStartCron: true,\n\t\tCronStartFrom: timestamppb.New(launchTime),\n\t})\n\n\tif err != nil {\n\t\terrstr := fmt.Sprintf(\"failed to createpipeline: %v\", err)\n\t\tlogrus.Errorf(errstr)\n\t\treturn nil, err\n\t}\n\n\treturn dto.Data.CronID, nil\n}", "func validateFieldDurationScheduleStr(fl validator.FieldLevel) bool {\n\tv, err := strconv.ParseInt(fl.Field().String(), 10, 32)\n\tif err != nil {\n\t\treturn false\n\t}\n\tif v < durationScheduleMinutesMin {\n\t\treturn false\n\t}\n\tif v > durationScheduleMinutesMax {\n\t\treturn false\n\t}\n\treturn true\n}", "func (w *Worker) ByCronSpec(spec string) *Worker {\n\tw.schedule = ByCronSchedule(spec)\n\treturn w\n}", "func NewCronSpec(spec *job.CronSpec) *CronSpec {\n\treturn &CronSpec{\n\t\tCronSchedule: spec.CronSchedule,\n\t\tCreatedAt: spec.CreatedAt,\n\t\tUpdatedAt: spec.UpdatedAt,\n\t}\n}", "func (u *UpdateOption) Valid() error {\n\tif u.CronExpression == nil && u.JobOtherInputs == nil {\n\t\treturn ErrUpdateOptionInvalid\n\t}\n\tif u.CronExpression != nil {\n\t\tif _, err := u.schedule(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func NewCron() helmify.Processor {\n\treturn &cron{}\n}", "func (c *Controller) initCron() error {\n\tcronJob = cron.New()\n\tif err := cronJob.AddFunc(Schedule, c.Run); err != nil {\n\t\treturn err\n\t}\n\n\tcronJob.Start()\n\n\tc.ready <- struct{}{}\n\n\treturn nil\n}", "func (j *JobConfig) validate() error {\n\tif j.Name == \"\" {\n\t\treturn errors.New(\"job must have a name\")\n\t}\n\n\tif j.Spec == \"\" {\n\t\treturn errors.New(\"spec is required\")\n\t}\n\n\tif j.Command == \"\" {\n\t\treturn errors.New(\"command is required\")\n\t}\n\n\t// Configure shell when multi-line scripts\n\tif j.Shell == \"\" && len(strings.Split(j.Command, \"\\n\")) > 1 {\n\t\tj.Shell = defaultShell\n\t}\n\n\tif _, err := cron.Parse(j.Spec); err != nil {\n\t\treturn fmt.Errorf(\"invalid cron spec: %v\", err)\n\t}\n\n\tif val := j.TimeoutString; val != \"\" {\n\t\tdur, err := time.ParseDuration(val)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid timeout: %v\", err)\n\t\t}\n\t\tj.Timeout = dur\n\t}\n\n\tif j.Docker != nil {\n\t\tj.RunMode = dockerMode\n\t} else {\n\t\tj.RunMode = nativeMode\n\t}\n\n\t// Notify on errors only by default\n\tif j.Notify != nil && j.Notify.Mode == \"\" {\n\t\tj.Notify.Mode = notifyError\n\t}\n\n\treturn nil\n}", "func (r *RTVCache) StartCron() {\n\tgo func() {\n\t\tticker := time.NewTicker(defaultPollInterval)\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tr.poll() // Ignores error return.\n\t\t\tcase <-r.stop:\n\t\t\t\tticker.Stop()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n}", "func NewCronSchedule(entry string) *CronSchedule {\n\tschedule := cron.New()\n\treturn &CronSchedule{\n\t\tentry: entry,\n\t\tschedule: schedule,\n\t\tenabled: false,\n\t}\n}", "func (c JobTriggerConfig) validate() error {\n\tif c.Schedule == nil {\n\t\treturn &errFieldMustBeSpecified{\n\t\t\tmissingField: \"schedule\",\n\t\t}\n\t}\n\treturn nil\n}", "func generateModularDailyCronSchedule(input []byte) string {\n\ta := big.NewInt(0).SetBytes(input)\n\tvar hi, mi big.Int\n\tm := mi.Mod(a, big.NewInt(60))\n\th := hi.Mod(a, big.NewInt(24))\n\treturn fmt.Sprintf(\"%d %d * * *\", m.Int64(), h.Int64())\n}", "func CreateCronExpression(interval int) string {\n\tunit := \"minutes\"\n\tif interval == 1 {\n\t\tunit = \"minute\"\n\t}\n\treturn fmt.Sprintf(\"rate(%d %s)\", interval, unit)\n}", "func TestCronBindingTrigger(t *testing.T) {\n\tconst appName = \"cronapp\"\n\tconst sidecarName = \"cron-sidecar\"\n\n\ttestMatrix := []cronTest{\n\t\t{\n\t\t\tcronName: \"cron1s\",\n\t\t\tschedule: \"@every 1s\", // Test macro cron format\n\t\t\texpectedTriggerCount: 10,\n\t\t\tstep: time.Second / 5,\n\t\t\ttestDuration: time.Second * 10,\n\t\t},\n\t\t{\n\t\t\tcronName: \"cron3s\",\n\t\t\tschedule: \"*/3 * * * * *\", // Test non-standard crontab format\n\t\t\texpectedTriggerCount: 10,\n\t\t\tstep: time.Second,\n\t\t\ttestDuration: time.Second * 30,\n\t\t},\n\t\t{\n\t\t\tcronName: \"cron15m\",\n\t\t\tschedule: \"*/15 * * * *\", // Test standard crontab format\n\t\t\texpectedTriggerCount: 12,\n\t\t\tstep: 30 * time.Second,\n\t\t\ttestDuration: time.Hour * 3,\n\t\t},\n\t\t{\n\t\t\tcronName: \"cron6h\",\n\t\t\tschedule: \"0 0 */6 ? * *\", // Test quartz cron format\n\t\t\texpectedTriggerCount: 12,\n\t\t\tstep: time.Minute,\n\t\t\ttestDuration: time.Hour * 24 * 3,\n\t\t},\n\t}\n\n\tfor _, cronTest := range testMatrix {\n\t\tt.Run(cronTest.cronName, func(t *testing.T) {\n\t\t\tcronTest.clk = clocktesting.NewFakeClock(startTime)\n\n\t\t\tports, _ := dapr_testing.GetFreePorts(3)\n\t\t\tgrpcPort := ports[0]\n\t\t\thttpPort := ports[1]\n\t\t\tappPort := ports[2]\n\n\t\t\ttestFn, triggeredCb := testerFn(cronTest.clk, cronTest.testDuration, cronTest.expectedTriggerCount, cronTest.step)\n\n\t\t\tflow.New(t, \"test cron trigger with different schedules\").\n\t\t\t\tStep(app.Run(appName,\n\t\t\t\t\tfmt.Sprintf(\":%d\", appPort),\n\t\t\t\t\tappWithTriggerCounter(t, cronTest.clk, cronTest.cronName, triggeredCb),\n\t\t\t\t)).\n\t\t\t\tStep(sidecar.Run(sidecarName,\n\t\t\t\t\tappend(componentRuntimeOptions(cronTest.clk),\n\t\t\t\t\t\tembedded.WithResourcesPath(\"./components\"),\n\t\t\t\t\t\tembedded.WithDaprGRPCPort(strconv.Itoa(grpcPort)),\n\t\t\t\t\t\tembedded.WithAppProtocol(protocol.HTTPProtocol, strconv.Itoa(appPort)),\n\t\t\t\t\t\tembedded.WithDaprHTTPPort(strconv.Itoa(httpPort)),\n\t\t\t\t\t)...,\n\t\t\t\t)).\n\t\t\t\tStep(\"run test\", testFn).\n\t\t\t\tStep(\"stop sidecar\", sidecar.Stop(sidecarName)).\n\t\t\t\tStep(\"stop app\", app.Stop(appName)).\n\t\t\t\tRun()\n\t\t})\n\t}\n}", "func (o OceanLaunchSpecSchedulingTaskOutput) CronExpression() pulumi.StringOutput {\n\treturn o.ApplyT(func(v OceanLaunchSpecSchedulingTask) string { return v.CronExpression }).(pulumi.StringOutput)\n}", "func NewUpdateAsCronRequestWithoutParam() *UpdateAsCronRequest {\n\n return &UpdateAsCronRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/regions/{regionId}/asCrons/{asCronId}\",\n Method: \"POST\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func (m *MegaCorp) cron() {\n\tt := time.NewTicker(60 * time.Second)\n\tfor _ = range t.C {\n\t\tfmt.Println(\"pay salary\")\n\t\tif time.Now().Day() == m.salaryPayDay {\n\t\t\tm.paySalaries()\n\t\t}\n\t}\n}", "func createCronJobConfig(module *protos.Module) *v1beta1.CronJob {\n\tvolumes, volumeMounts := makeVolumes(module)\n\tcontainers := makeContainers(module, volumeMounts)\n\tm := module.GetSpec()\n\n\tsuccessfulJobHistoryLimit := int32(1)\n\tfailedJobsHistoryLimit := int32(1)\n\treturn &v1beta1.CronJob{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: module.Name,\n\t\t},\n\t\tSpec: v1beta1.CronJobSpec{\n\t\t\tSchedule: m.Schedule,\n\t\t\tJobTemplate: v1beta1.JobTemplateSpec{\n\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\tLabels: map[string]string{\n\t\t\t\t\t\t\"name\": module.Name,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tSpec: batchv1.JobSpec{\n\t\t\t\t\tTemplate: v1.PodTemplateSpec{\n\t\t\t\t\t\tSpec: v1.PodSpec{\n\t\t\t\t\t\t\tContainers: containers,\n\t\t\t\t\t\t\tVolumes: volumes,\n\t\t\t\t\t\t\tHostNetwork: true,\n\t\t\t\t\t\t\tRestartPolicy: \"Never\",\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\tSuccessfulJobsHistoryLimit: &successfulJobHistoryLimit,\n\t\t\tFailedJobsHistoryLimit: &failedJobsHistoryLimit,\n\t\t},\n\t}\n}", "func (m *IoArgoprojWorkflowV1alpha1CronWorkflowStatus) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateActive(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateConditions(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateLastScheduledTime(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *IoArgoprojWorkflowV1alpha1CreateCronWorkflowRequest) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateCreateOptions(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateCronWorkflow(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func cronExec(ctxt appengine.Context, name string) error {\n\tcron.RLock()\n\tlist := cron.list\n\tcron.RUnlock()\n\n\tvar cr cronEntry\n\tfor _, cr = range list {\n\t\tif cr.name == name {\n\t\t\tgoto Found\n\t\t}\n\t}\n\tctxt.Errorf(\"unknown cron entry %q\", name)\n\treturn nil\n\nFound:\n\tif err := cr.f(ctxt); err != nil {\n\t\tif err == ErrMoreCron {\n\t\t\t// The cron job found that it had more work than it could do\n\t\t\t// and wants to run again. Arrange this by making the task\n\t\t\t// seem to fail.\n\t\t\tctxt.Infof(\"cron job %q: ErrMoreCron\", cr.name)\n\t\t\treturn fmt.Errorf(\"cron job %q wants to run some more\", cr.name)\n\t\t}\n\t\t// The cron job failed, but there's no reason to think running it again\n\t\t// right now will help. Let this instance finish successfully.\n\t\t// It will run again at the next scheduled time.\n\t\tctxt.Infof(\"cron job %q: %v\", cr.name, err)\n\t\treturn nil\n\t}\n\treturn nil\n}", "func cleanCron() {\n\tfor _, entry := range mainCron.Entries() {\n\t\tif entry.Schedule.Next(Now()).IsZero() {\n\t\t\tmainCron.Remove(entry.ID)\n\t\t\tremoveJob(entry.ID, true)\n\t\t}\n\t}\n}", "func validateFieldServiceInterval(fl validator.FieldLevel) bool {\n\tv := ParseServiceInterval(fl.Field().String())\n\tif v == nil {\n\t\treturn false\n\t}\n\treturn true\n}", "func Parse(spec string) (cron.Schedule, error) {\n\treturn standaloneParser.Parse(spec)\n}", "func cronFormat(t time.Time) string {\n\treturn fmt.Sprintf(\"%d %d %d %d %d *\", t.Second(), t.Minute(), t.Hour(), t.Day(), int(t.Month()))\n}", "func (y *Yeelight) CronAdd(t, value string) string {\n\tcmd := `{\"id\":12,\"method\":\"cron_add\",\"params\":[` + t + `,` + value + `]}`\n\treturn y.request(cmd)\n}", "func NewCron() *cron {\n\tc := &cron{\n\t\ttasks: make(chan task),\n\t}\n\tgo c.loop()\n\treturn c\n}", "func (j *AuroraJob) CronSchedule(cron string) Job {\n\tj.jobConfig.CronSchedule = &cron\n\treturn j\n}", "func (m *Schedule) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateInterval(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateType(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func cronHandler(ctxt appengine.Context, w http.ResponseWriter, req *http.Request) {\n\tcron.RLock()\n\tlist := cron.list\n\tcron.RUnlock()\n\n\tforce := req.FormValue(\"force\") == \"1\"\n\n\t// We're being called by app engine master cron,\n\t// so look for new work to queue in tasks.\n\tnow := time.Now()\n\tvar old time.Time\n\terr := Transaction(ctxt, func(ctxt appengine.Context) error {\n\t\tif err := ReadMeta(ctxt, \"app.cron.time\", &old); err != nil && err != datastore.ErrNoSuchEntity {\n\t\t\treturn err\n\t\t}\n\t\tif !old.Before(now) {\n\t\t\treturn nil\n\t\t}\n\t\treturn WriteMeta(ctxt, \"app.cron.time\", now)\n\t})\n\tif err != nil { // already logged\n\t\treturn\n\t}\n\n\tctxt.Infof(\"cron %v -> %v\", old, now)\n\n\tfor _, cr := range list {\n\t\tif now.Round(cr.dt) != old.Round(cr.dt) || force {\n\t\t\tctxt.Infof(\"start cron %s\", cr.name)\n\t\t\tTask(ctxt, \"app.cron.\"+cr.name, \"cron\", cr.name)\n\t\t}\n\t}\n}", "func InitCron() {\n\tc := cron.New()\n\tc.AddFunc(\"* * * * * *\", cronSpotify)\n\tgo c.Run()\n}", "func (y *Yeelight) CronDel(t string) string {\n\tcmd := `{\"id\":14,\"method\":\"cron_del\",\"params\":[` + t + `]}`\n\treturn y.request(cmd)\n}", "func TestKubebuilderValidation(t *testing.T) {\n\t// keep in sync with kubebuilder annotations in apis/projectcontour/v1/httpproxy.go\n\tregex := regexp.MustCompile(`^(((\\d*(\\.\\d*)?h)|(\\d*(\\.\\d*)?m)|(\\d*(\\.\\d*)?s)|(\\d*(\\.\\d*)?ms)|(\\d*(\\.\\d*)?us)|(\\d*(\\.\\d*)?µs)|(\\d*(\\.\\d*)?ns))+|infinity|infinite)$`)\n\n\tfor tc, valid := range map[string]bool{\n\t\t// valid duration strings across all allowed units\n\t\t\"1h\": true,\n\t\t\"1.h\": true,\n\t\t\"1.27h\": true,\n\n\t\t\"1m\": true,\n\t\t\"1.m\": true,\n\t\t\"1.27m\": true,\n\n\t\t\"1s\": true,\n\t\t\"1.s\": true,\n\t\t\"1.27s\": true,\n\n\t\t\"1ms\": true,\n\t\t\"1.ms\": true,\n\t\t\"1.27ms\": true,\n\n\t\t\"1us\": true,\n\t\t\"1.us\": true,\n\t\t\"1.27us\": true,\n\n\t\t\"1µs\": true,\n\t\t\"1.µs\": true,\n\t\t\"1.27µs\": true,\n\n\t\t\"1ns\": true,\n\t\t\"1.ns\": true,\n\t\t\"1.27ns\": true,\n\n\t\t// valid combinations of units\n\t\t\"1h2.34m1s\": true,\n\t\t\"1s2.34h1m7.23s0.21us1.ns\": true,\n\n\t\t// invalid duration strings\n\t\t\"abc\": false,\n\t\t\"1\": false,\n\t\t\"9,25s\": false,\n\t\t\"disabled\": false,\n\n\t\t// magic strings\n\t\t\"infinity\": true,\n\t\t\"infinite\": true,\n\t} {\n\t\tregexMatches := regex.MatchString(tc)\n\t\t_, parseErr := Parse(tc)\n\n\t\tif valid {\n\t\t\tassert.True(t, regexMatches, \"input string %q: regex should match but does not\", tc)\n\t\t\tassert.NoError(t, parseErr, \"input string %q: timeout.Parse should succeed but does not\", tc)\n\t\t} else {\n\t\t\tassert.False(t, regexMatches, \"input string %q: regex should not match but does\", tc)\n\t\t\tassert.NotNil(t, parseErr, \"input string %q: timeout.Parse should return an error but does not\", tc)\n\t\t}\n\t}\n}", "func newCronJobForCR(cr *v1alpha1.Copybird) *v1beta1.CronJob {\n\tlabels := map[string]string{\n\t\t\"app\": cr.Name,\n\t}\n\treturn &v1beta1.CronJob{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: cr.Name + \"-cronjob\",\n\t\t\tNamespace: cr.Namespace,\n\t\t\tLabels: labels,\n\t\t},\n\t\tSpec: v1beta1.CronJobSpec{\n\t\t\tSchedule: cr.Spec.Cron,\n\t\t\tJobTemplate: v1beta1.JobTemplateSpec{\n\t\t\t\tSpec: batchv1.JobSpec{\n\t\t\t\t\tTemplate: v1.PodTemplateSpec{\n\t\t\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\t\t\tName: cr.Name + \"-copybird\",\n\t\t\t\t\t\t\tNamespace: cr.Namespace,\n\t\t\t\t\t\t\tLabels: labels,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tSpec: v1.PodSpec{\n\t\t\t\t\t\t\tContainers: []v1.Container{\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tName: cr.Name,\n\t\t\t\t\t\t\t\t\tImage: \"copybird/copybird\",\n\t\t\t\t\t\t\t\t\tCommand: []string{},\n\t\t\t\t\t\t\t\t\tArgs: []string{},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tRestartPolicy: \"OnFailure\",\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}", "func Cron(name string, period time.Duration, f func(appengine.Context) error) {\n\tcron.Lock()\n\tdefer cron.Unlock()\n\tfor _, cr := range cron.list {\n\t\tif cr.name == name {\n\t\t\tpanic(\"app.Cron: multiple registrations for \" + name)\n\t\t}\n\t}\n\tcron.list = append(cron.list, cronEntry{name, period, f})\n}", "func (f *CronField) parsePossibleValues(s string) (vals []int, retErr error) {\n\tdefer func() {\n\t\tif retErr == nil && len(vals) == 0 {\n\t\t\tretErr = fmt.Errorf(\"No possible values\")\n\t\t}\n\t}()\n\n\tcommaParts := strings.Split(s, \",\")\n\tfor _, part := range commaParts {\n\t\tif ma := rangRe.FindStringSubmatch(part); len(ma) == 4 || len(ma) == 6 {\n\t\t\tif ma[1] == \"*\" { // \"*\" means first-last\n\t\t\t\tma[2] = strconv.Itoa(f.Min)\n\t\t\t\tma[3] = strconv.Itoa(f.Max)\n\t\t\t}\n\t\t\tstep := \"\"\n\t\t\tif len(ma) == 6 {\n\t\t\t\tstep = ma[5]\n\t\t\t}\n\n\t\t\tv, err := f.parseRange(ma[2], ma[3], step)\n\t\t\tif err != nil {\n\t\t\t\tretErr = err\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvals = append(vals, v...)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Single digit without range\n\t\tresult, err := f.parseNumeric(part)\n\t\tif err != nil {\n\t\t\tretErr = err\n\t\t\treturn\n\t\t}\n\n\t\tvals = append(vals, result)\n\t}\n\n\treturn\n}", "func (c *checkCronjobImpl) CheckStatus(options CheckStatusOptions) icinga.Result {\n\tname := \"Cronjob.RunInterval\"\n\n\tjobLists, err := api.GetJobsByCronjob(c.Client, api.GetJobOptions{Name: c.Name, Namespace: c.Namespace})\n\tif err != nil {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"can't get jobLists from cronjob: %v\", err))\n\t}\n\n\tif len(jobLists.Items) == 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"No jobs found for [%s] in [%s]\", c.Name, c.Namespace))\n\t}\n\n\tjob := jobLists.Items[len(jobLists.Items)-1]\n\tjobNameParts := strings.Split(job.Name, \"-\")\n\tif jobNameParts[0] == \"\" || strings.Compare(jobNameParts[0], c.Name) != 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"No job found for Cronjob [%s] (job: [%s])\", c.Name, job.Name))\n\t}\n\n\tif job.Status.StartTime == nil {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"No job status (and start time) found for job [%s]\", job.Name))\n\t}\n\n\tstartTime, err := time.Parse(api.JOB_TIME_FORMAT, job.Status.StartTime.String())\n\tif err != nil {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"can't get start time from job [%s]: %v\", job.Name, err))\n\t}\n\n\tif job.Status.Active > 0 {\n\t\tpodRestarts, err := getPodRestarts(c.Client, job)\n\t\tif err != nil {\n\t\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"can't get pods for job [%s]: %v\", job.Name, err))\n\t\t}\n\t\tif podRestarts > 0 {\n\t\t\treturn icinga.NewResult(name, icinga.ServiceStatusCritical, fmt.Sprintf(\"Job [%s] has too many restarts [%d] since start time [%v]\", job.Name, podRestarts, startTime.String()))\n\t\t}\n\n\t\telapsedTime := time.Now().Second() - startTime.Second()\n\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusOk, fmt.Sprintf(\"Job [%s] running since %d seconds for Cronjob [%s]\", job.Name, elapsedTime, c.Name))\n\t}\n\n\tif job.Status.Failed > 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusCritical, fmt.Sprintf(\"Job [%s] failed for Cronjob [%s] at start time [%v]\", job.Name, c.Name, startTime.String()))\n\t}\n\n\tif job.Status.Succeeded > 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusOk, fmt.Sprintf(\"Job [%s] succeeded for Cronjob [%s] at completion time [%v]\", job.Name, c.Name, job.Status.CompletionTime))\n\t}\n\n\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"Unknown running specs for job [%s] in Cronjob [%s] - [%v]\", job.Name, c.Name, job))\n}", "func (s *TestSuite) TestRegisterCrons(c *C) {\n\ttemp1 := &ProcessTemplate{\n\t\tCommand: \"/usr/local/bin/node\",\n\t\tArgs: []string{\n\t\t\t\"samples/longrunning.js\",\n\t\t},\n\t\tCron: \"* * * * * *\",\n\t\tName: \"asdf\",\n\t\t// LogFile: \"/tmp/crontest\",\n\t\tResetLog: true,\n\t}\n\n\tconfig := &Config{\n\t\tProcess: []*ProcessTemplate{\n\t\t\ttemp1,\n\t\t},\n\t}\n\n\tmanager := NewManager(config)\n\n\t// log.Println(manager.monitor)\n\tgo manager.Start()\n\n\tfor {\n\t\tif manager.Started {\n\t\t\tmanager.StartCrons()\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(100 * time.Millisecond)\n\t}\n\n\t// Make the crons are registered\n\n\tfor {\n\t\tselect {\n\t\tcase proc := <-manager.monitor:\n\t\t\t// fmt.Println(\"Got \", proc)\n\t\t\tc.Assert(proc.Template, Equals, temp1)\n\t\t\treturn\n\t\tdefault:\n\t\t\t// Wait a while before we check again\n\t\t\ttime.Sleep(100 * time.Millisecond)\n\t\t}\n\t}\n\n}", "func CreateOrUpdate(ctx context.Context, c client.Client, cj *batchv1.CronJob, equal EqualityFunc, mutate MutateFunc) error {\n\tcurrent := &batchv1.CronJob{}\n\tkey := client.ObjectKey{Name: cj.Name, Namespace: cj.Namespace}\n\terr := c.Get(ctx, key, current)\n\tif err != nil {\n\t\tif apierrors.IsNotFound(err) {\n\t\t\terr = c.Create(ctx, cj)\n\n\t\t\tif err == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn kverrors.Wrap(err, \"failed to create cronjob\",\n\t\t\t\t\"name\", cj.Name,\n\t\t\t\t\"namespace\", cj.Namespace,\n\t\t\t)\n\t\t}\n\n\t\treturn kverrors.Wrap(err, \"failed to get cronjob\",\n\t\t\t\"name\", cj.Name,\n\t\t\t\"namespace\", cj.Namespace,\n\t\t)\n\t}\n\n\tif !equal(current, cj) {\n\t\terr := retry.RetryOnConflict(retry.DefaultRetry, func() error {\n\t\t\tif err := c.Get(ctx, key, current); err != nil {\n\t\t\t\treturn kverrors.Wrap(err, \"failed to get cronjob\",\n\t\t\t\t\t\"name\", cj.Name,\n\t\t\t\t\t\"namespace\", cj.Namespace,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tmutate(current, cj)\n\t\t\tif err := c.Update(ctx, current); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn kverrors.Wrap(err, \"failed to update cronjob\",\n\t\t\t\t\"name\", cj.Name,\n\t\t\t\t\"namespace\", cj.Namespace,\n\t\t\t)\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn nil\n}", "func NewCronFromJobSpec(\n\tjobSpec job.Job,\n\tpipelineRunner pipeline.Runner,\n) (*Cron, error) {\n\n\tcronSpec := jobSpec.CronSpec\n\tspec := jobSpec.PipelineSpec\n\n\tcronLogger := logger.CreateLogger(\n\t\tlogger.Default.With(\n\t\t\t\"jobID\", jobSpec.ID,\n\t\t\t\"schedule\", cronSpec.CronSchedule,\n\t\t),\n\t)\n\n\treturn &Cron{\n\t\tchDone: make(chan struct{}),\n\t\tchStop: make(chan struct{}),\n\t\tcronRunner: cronParser.New(),\n\t\tjobID: jobSpec.ID,\n\t\tlogger: cronLogger,\n\t\tpipelineRunner: pipelineRunner,\n\t\tpipelineSpec: *spec,\n\t\tSchedule: cronSpec.CronSchedule,\n\t}, nil\n}", "func validateconf() (err error) {\n\t// durations\n\tif ctx.config.Periodic.StatsTime, err = time.ParseDuration(ctx.config.Periodic.StatsTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad stats-time format %s, err: %v\", ctx.config.Periodic.StatsTimeStr, err)\n\t}\n\tif ctx.config.Timeout.Default, err = time.ParseDuration(ctx.config.Timeout.DefaultStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout default format %s, err: %v\", ctx.config.Timeout.DefaultStr, err)\n\t}\n\tif ctx.config.Timeout.DefaultLong, err = time.ParseDuration(ctx.config.Timeout.DefaultLongStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout default_long format %s, err %v\", ctx.config.Timeout.DefaultLongStr, err)\n\t}\n\tif ctx.config.Periodic.KeepAliveTime, err = time.ParseDuration(ctx.config.Periodic.KeepAliveTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad keep_alive_time format %s, err: %v\", ctx.config.Periodic.KeepAliveTimeStr, err)\n\t}\n\tif ctx.config.LRU.DontEvictTime, err = time.ParseDuration(ctx.config.LRU.DontEvictTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad dont_evict_time format %s, err: %v\", ctx.config.LRU.DontEvictTimeStr, err)\n\t}\n\tif ctx.config.LRU.CapacityUpdTime, err = time.ParseDuration(ctx.config.LRU.CapacityUpdTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad capacity_upd_time format %s, err: %v\", ctx.config.LRU.CapacityUpdTimeStr, err)\n\t}\n\tif ctx.config.Rebalance.StartupDelayTime, err = time.ParseDuration(ctx.config.Rebalance.StartupDelayTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad startup_delay_time format %s, err: %v\", ctx.config.Rebalance.StartupDelayTimeStr, err)\n\t}\n\n\thwm, lwm := ctx.config.LRU.HighWM, ctx.config.LRU.LowWM\n\tif hwm <= 0 || lwm <= 0 || hwm < lwm || lwm > 100 || hwm > 100 {\n\t\treturn fmt.Errorf(\"Invalid LRU configuration %+v\", ctx.config.LRU)\n\t}\n\tif ctx.config.TestFSP.Count == 0 {\n\t\tfor fp1 := range ctx.config.FSpaths {\n\t\t\tfor fp2 := range ctx.config.FSpaths {\n\t\t\t\tif fp1 != fp2 && (strings.HasPrefix(fp1, fp2) || strings.HasPrefix(fp2, fp1)) {\n\t\t\t\t\treturn fmt.Errorf(\"Invalid fspaths: %q is a prefix or includes as a prefix %q\", fp1, fp2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif ctx.config.Cksum.Checksum != ChecksumXXHash && ctx.config.Cksum.Checksum != ChecksumNone {\n\t\treturn fmt.Errorf(\"Invalid checksum: %s - expecting %s or %s\", ctx.config.Cksum.Checksum, ChecksumXXHash, ChecksumNone)\n\t}\n\tif err := validateVersion(ctx.config.Ver.Versioning); err != nil {\n\t\treturn err\n\t}\n\tif ctx.config.FSKeeper.FSCheckTime, err = time.ParseDuration(ctx.config.FSKeeper.FSCheckTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad FSKeeper fs_check_time format %s, err %v\", ctx.config.FSKeeper.FSCheckTimeStr, err)\n\t}\n\tif ctx.config.FSKeeper.OfflineFSCheckTime, err = time.ParseDuration(ctx.config.FSKeeper.OfflineFSCheckTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad FSKeeper offline_fs_check_time format %s, err %v\", ctx.config.FSKeeper.OfflineFSCheckTimeStr, err)\n\t}\n\tif ctx.config.Timeout.MaxKeepalive, err = time.ParseDuration(ctx.config.Timeout.MaxKeepaliveStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout max_keepalive format %s, err %v\", ctx.config.Timeout.MaxKeepaliveStr, err)\n\t}\n\tif ctx.config.Timeout.ProxyPing, err = time.ParseDuration(ctx.config.Timeout.ProxyPingStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout proxy_ping format %s, err %v\", ctx.config.Timeout.ProxyPingStr, err)\n\t}\n\tif ctx.config.Timeout.VoteRequest, err = time.ParseDuration(ctx.config.Timeout.VoteRequestStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout vote_request format %s, err %v\", ctx.config.Timeout.VoteRequestStr, err)\n\t}\n\treturn nil\n}", "func newCron(schedule string) (chan bool, *cron.Cron) {\n\tchannel := make(chan bool)\n\tcj := cron.New()\n\tcj.AddFunc(schedule, func() { cronTriggered(channel) })\n\tglog.Info(\"db backup schedule: \" + schedule)\n\treturn channel, cj\n}", "func TestIssue279CronJobDeletion(t *testing.T) {\n\tctx := framework.NewTestCtx(t)\n\tdefer ctx.Cleanup()\n\n\tnamespace, err := ctx.GetOperatorNamespace()\n\tif err != nil {\n\t\tt.Fatalf(\"could not get namespace: %v\", err)\n\t}\n\tif err = SetupRbacInNamespace(namespace); err != nil {\n\t\tt.Error(err)\n\t}\n\n\tdefer DumpJobsLogsOnError(t, framework.Global, namespace)\n\terr = framework.AddToFrameworkScheme(apis.AddToScheme, &gitopsv1alpha1.GitOpsConfigList{})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\teunomiaURI, found := os.LookupEnv(\"EUNOMIA_URI\")\n\tif !found {\n\t\teunomiaURI = \"https://github.com/kohlstechnology/eunomia\"\n\t}\n\teunomiaRef, found := os.LookupEnv(\"EUNOMIA_REF\")\n\tif !found {\n\t\teunomiaRef = \"master\"\n\t}\n\n\t// Step 1: create a CR with a Periodic trigger\n\n\tgitops := &gitopsv1alpha1.GitOpsConfig{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"GitOpsConfig\",\n\t\t\tAPIVersion: \"eunomia.kohls.io/v1alpha1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"gitops-issue279\",\n\t\t\tNamespace: namespace,\n\t\t\tFinalizers: []string{\n\t\t\t\t\"gitopsconfig.eunomia.kohls.io/finalizer\",\n\t\t\t},\n\t\t},\n\t\tSpec: gitopsv1alpha1.GitOpsConfigSpec{\n\t\t\tTemplateSource: gitopsv1alpha1.GitConfig{\n\t\t\t\tURI: eunomiaURI,\n\t\t\t\tRef: eunomiaRef,\n\t\t\t\tContextDir: \"test/e2e/testdata/empty-directory\",\n\t\t\t},\n\t\t\tParameterSource: gitopsv1alpha1.GitConfig{\n\t\t\t\tURI: eunomiaURI,\n\t\t\t\tRef: eunomiaRef,\n\t\t\t\tContextDir: \"test/e2e/testdata/empty-yaml\",\n\t\t\t},\n\t\t\tTriggers: []gitopsv1alpha1.GitOpsTrigger{\n\t\t\t\t{\n\t\t\t\t\tType: \"Periodic\",\n\t\t\t\t\tCron: \"*/1 * * * *\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tTemplateProcessorImage: \"quay.io/kohlstechnology/eunomia-base:dev\",\n\t\t\tResourceHandlingMode: \"Apply\",\n\t\t\tResourceDeletionMode: \"Delete\",\n\t\t\tServiceAccountRef: \"eunomia-operator\",\n\t\t},\n\t}\n\tgitops.Annotations = map[string]string{\"gitopsconfig.eunomia.kohls.io/initialized\": \"true\"}\n\n\terr = framework.Global.Client.Create(context.TODO(), gitops, &framework.CleanupOptions{TestContext: ctx, Timeout: timeout, RetryInterval: retryInterval})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Step 2: Wait until CronJob creates a Job, whose pod succeeds\n\n\t// Two minutes timeout to give cronjob enought time to kick off\n\terr = wait.Poll(retryInterval, time.Second*120, func() (done bool, err error) {\n\t\tconst name = \"gitopsconfig-gitops-issue279-\"\n\t\tpod, err := GetPod(t, namespace, name, \"quay.io/kohlstechnology/eunomia-base:dev\", framework.Global.KubeClient)\n\t\tswitch {\n\t\tcase apierrors.IsNotFound(err):\n\t\t\tt.Logf(\"Waiting for availability of %s pod\", name)\n\t\t\treturn false, nil\n\t\tcase err != nil:\n\t\t\treturn false, err\n\t\tcase pod != nil && pod.Status.Phase == \"Succeeded\":\n\t\t\treturn true, nil\n\t\tcase pod != nil:\n\t\t\tt.Logf(\"Waiting for pod %s to succeed\", pod.Name)\n\t\t\treturn false, nil\n\t\tdefault:\n\t\t\tt.Logf(\"Waiting for pod %s\", name)\n\t\t\treturn false, nil\n\t\t}\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Step 3: Change Periodic trigger to Webhook one in GitOpsConfig, and apply it\n\n\terr = framework.Global.Client.Get(context.TODO(), util.NN{Name: \"gitops-issue279\", Namespace: namespace}, gitops)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tgitops.Spec.Triggers = []gitopsv1alpha1.GitOpsTrigger{{Type: \"Webhook\"}}\n\terr = framework.Global.Client.Update(context.TODO(), gitops)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tt.Logf(\"GitOpsConfig successfully updated\")\n\n\t// Step 4: Wait for CronJob to be deleted\n\n\terr = wait.Poll(retryInterval, timeout, func() (done bool, err error) {\n\t\tconst name = \"gitopsconfig-gitops-issue279-\"\n\t\tcronJob, err := GetCronJob(namespace, name, framework.Global.KubeClient)\n\t\tswitch {\n\t\tcase apierrors.IsNotFound(err) || cronJob == nil:\n\t\t\tt.Logf(\"CronJob %s successfully deleted\", name)\n\t\t\treturn true, nil\n\t\tcase err != nil:\n\t\t\treturn false, err\n\t\tcase cronJob != nil:\n\t\t\tt.Logf(\"Waiting for cronJob %s to be deleted\", cronJob.Name)\n\t\t\treturn false, nil\n\t\tdefault:\n\t\t\tt.Logf(\"Waiting for cronJob %s to be deleted\", name)\n\t\t\treturn false, nil\n\t\t}\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n}", "func NewCronWorkflowSpec() *cronworkflowv1.CronWorkflowSpec {\n\treturn &cronworkflowv1.CronWorkflowSpec{\n\t\tSchedule: \"* * * * *\",\n\t\tConcurrencyPolicy: batchv2alpha1.AllowConcurrent,\n\t\tWorkflowTemplate: NewWorkflowTemplateSpec(),\n\t}\n}", "func (o BeanstalkScheduledTaskOutput) CronExpression() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BeanstalkScheduledTask) *string { return v.CronExpression }).(pulumi.StringPtrOutput)\n}", "func (db *DB) ValidPeriod(campus, category, period string) (bool, error) {\n\tconn, err := redishelper.GetRedisConn(db.RedisServer, db.RedisPassword)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer conn.Close()\n\n\tk := fmt.Sprintf(\"ming:%v:%v:periods\", campus, category)\n\tscore, err := redis.String(conn.Do(\"ZSCORE\", k, period))\n\tif err != nil && err != redis.ErrNil {\n\t\treturn false, err\n\t}\n\n\tif score == \"\" {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func KustomizeCronJob(kustomization *Kustomization, tmpl *template.Template) ([]byte, error) {\n\trepo := &kustomization.Repository\n\n\tdata := cronJobData{\n\t\tNs: kustomization.Ns,\n\t\tTier: kustomization.Tier,\n\t\tName: kustomization.Name,\n\t\tSchedule: kustomization.Schedule,\n\t\tGroup: repo.Group,\n\t\tProject: repo.Project,\n\t\tPath: repo.Path,\n\t}\n\n\tmanifestBuffer := new(bytes.Buffer)\n\terr := tmpl.Execute(manifestBuffer, data)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can not apply variables to cronjob template: %v\", err)\n\t}\n\treturn manifestBuffer.Bytes(), nil\n}", "func Cron(\n\tctx context.Context,\n\tcanceler context.CancelFunc,\n\tcronExpression string,\n\tname string,\n\tdesc string,\n\tlogger Logger,\n\tkind daemon.Kind,\n\tdo DaemonJob,\n\tdepends ...string,\n) *ServiceDaemon {\n\treturn CronDaemon(\n\t\tctx,\n\t\tcanceler,\n\t\tcronExpression,\n\t\tdefaultLocation,\n\t\tdefaultCronParserOption,\n\t\tname,\n\t\tdesc,\n\t\tlogger,\n\t\tkind,\n\t\t\"\",\n\t\tdepends,\n\t\tdo,\n\t)\n}", "func ByCronSchedule(schedule string) ScheduleFunc {\n\ts, err := cron.Parse(schedule)\n\tif err != nil {\n\t\tpanic(\"parse cron spec fatal error: \" + err.Error())\n\t}\n\n\treturn func(ctx context.Context, job Job) Job {\n\t\treturn func(ctx context.Context) {\n\t\t\tnow := time.Now()\n\t\t\ttimer := time.NewTimer(s.Next(now).Sub(now))\n\t\t\tdefer timer.Stop()\n\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\treturn\n\t\t\t\tcase <-timer.C:\n\t\t\t\t\tjob(ctx)\n\t\t\t\t\tnow = time.Now()\n\t\t\t\t\ttimer.Reset(s.Next(now).Sub(now))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func main() {\n\n\ta := -1\n\n\tprintln(strconv.Itoa(a))\n\n\t// cr := time.Now()\n\tfmt.Println(time.Now().AddDate(0, 0, -1))\n\n\tfmt.Println(time.Now())\n\tc := cron.New()\n\tc.AddFunc(\"* * * * * ?\", func() { fmt.Println(\"Every 1 minutes\") })\n\tc.AddFunc(\"@hourly\", func() { fmt.Println(time.Now()) })\n\n\tc.Start()\n\n\t// select {}\n\ttime.Sleep(1e10)\n\t// for {\n\n\t// select {}\n\t// println(\"a\")\n\t// }\n\tprintln(\"End here\")\n\n\t// wg := &sync.WaitGroup{}\n\t// wg.Add(1)\n\n\t// cron := cron.New()\n\t// cron.AddFunc(\"* * * * * ?\", func() { println(\"heeee\") })\n\t// cron.Start()\n\t// defer cron.Stop()\n\n\t// // Give cron 2 seconds to run our job (which is always activated).\n\t// // select {\n\t// // case <-time.After(ONE_SECOND):\n\t// // \tprintln(\"aaaaa\")\n\t// // case <-wait(wg):\n\t// // \tprintln(\"hhhhhh\")\n\t// // }\n\n\t// select {}\n\n\t// for {\n\t// }\n\n}", "func Parse(s string) (values []CronValue, cmd string, retErr error) {\n\tfields := Fields()\n\n\tma := lineRe.FindStringSubmatch(s)\n\tif len(ma) != len(fields)+2 { // ma[0] is complete string, ma[last] is command...\n\t\tretErr = fmt.Errorf(\"Format mismatch\")\n\t\treturn\n\t}\n\tcmd = ma[len(fields)+1]\n\n\tfor i := 0; i < len(fields); i++ {\n\t\tv := ma[i+1]\n\t\tpossibleVals, err := fields[i].parsePossibleValues(v)\n\t\tif err != nil {\n\t\t\tretErr = fmt.Errorf(\"Parsing %v: %q is invalid: %v\", fields[i].Name, v, err)\n\t\t\treturn\n\t\t}\n\n\t\tvalues = append(values, CronValue{\n\t\t\tCronField: fields[i],\n\t\t\tValues: possibleVals,\n\t\t})\n\t}\n\n\treturn\n}", "func SetupCron() {\n\tc = cron.New()\n\tc.AddFunc(\"0 * * * *\", CheckIdleMinutes)\n\n\tc.AddFunc(\"@every 1m\", Cron1Minute)\n\n\tc.Start()\n}", "func (s *TrafficOpsSessionThreadsafe) CRConfigValid(crc *tc.CRConfig, cdn string) error {\n\tif crc == nil {\n\t\treturn errors.New(\"CRConfig is nil\")\n\t}\n\tif crc.Stats.CDNName == nil {\n\t\treturn errors.New(\"CRConfig.Stats.CDN missing\")\n\t}\n\tif crc.Stats.DateUnixSeconds == nil {\n\t\treturn errors.New(\"CRConfig.Stats.Date missing\")\n\t}\n\n\t// Note this intentionally takes intended CDN, rather than trusting\n\t// crc.Stats\n\tlastCrc, lastCrcTime, lastCrcStats := s.lastCRConfig.Get(cdn)\n\n\tif lastCrc == nil {\n\t\treturn nil\n\t}\n\tif lastCrcStats.DateUnixSeconds == nil {\n\t\tlog.Warnln(\"TrafficOpsSessionThreadsafe.CRConfigValid returning no error, but last CRConfig Date was missing!\")\n\t\treturn nil\n\t}\n\tif lastCrcStats.CDNName == nil {\n\t\tlog.Warnln(\"TrafficOpsSessionThreadsafe.CRConfigValid returning no error, but last CRConfig CDN was missing!\")\n\t\treturn nil\n\t}\n\tif *lastCrcStats.CDNName != *crc.Stats.CDNName {\n\t\treturn errors.New(\"CRConfig.Stats.CDN \" + *crc.Stats.CDNName + \" different than last received CRConfig.Stats.CDNName \" + *lastCrcStats.CDNName + \" received at \" + lastCrcTime.Format(time.RFC3339Nano))\n\t}\n\tif *lastCrcStats.DateUnixSeconds > *crc.Stats.DateUnixSeconds {\n\t\treturn errors.New(\"CRConfig.Stats.Date \" + strconv.FormatInt(*crc.Stats.DateUnixSeconds, 10) + \" older than last received CRConfig.Stats.Date \" + strconv.FormatInt(*lastCrcStats.DateUnixSeconds, 10) + \" received at \" + lastCrcTime.Format(time.RFC3339Nano))\n\t}\n\treturn nil\n}", "func GetActivationTimeWithCron(curTime time.Time, cronBatchTime string) (time.Time, error) {\n\n\tif strings.HasPrefix(cronBatchTime, intervalPrefix) {\n\t\treturn time.Time{}, errors.Errorf(\"cannot use '%s' in cron batchtime '%s'\", intervalPrefix, cronBatchTime)\n\t}\n\tparser := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)\n\tsched, err := parser.Parse(cronBatchTime)\n\tif err != nil {\n\t\treturn time.Time{}, errors.Wrapf(err, \"error parsing cron batchtime '%s'\", cronBatchTime)\n\t}\n\treturn sched.Next(curTime), nil\n}", "func (o ElastigroupScheduledTaskOutput) CronExpression() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupScheduledTask) *string { return v.CronExpression }).(pulumi.StringPtrOutput)\n}", "func Cron(ctx cadence.Context, schedule *CronSchedule) error {\n\n\tcadence.GetLogger(ctx).Info(\"Cron started\", zap.Int(\"Count\", schedule.Count),\n\t\tzap.Duration(\"frequency\", schedule.Frequency), zap.Strings(\"groups\", schedule.Hostgroups))\n\n\tactivityCtx := cadence.WithActivityOptions(ctx, cadence.ActivityOptions{\n\t\tScheduleToStartTimeout: time.Minute,\n\t\tStartToCloseTimeout: 10 * time.Minute,\n\t\tHeartbeatTimeout: time.Minute,\n\t})\n\n\treturn runScheduler(ctx, activityCtx, schedule)\n}", "func NewDefaultSyntax(input string) (Holder, error) {\n\tds := &DefaultSyntax{\n\t\tname: \"Standard Cron Expression\",\n\t\tfields: fields,\n\t\tseparator: separator,\n\t\tinput: input,\n\t\tdaysMapper: map[string]string{\"SUN\": \"0\", \"MON\": \"1\", \"TUE\": \"2\", \"WED\": \"3\", \"THU\": \"4\", \"FRI\": \"5\", \"SAT\": \"6\"},\n\t\tmonthsMapper: map[string]string{\"JAN\": \"1\",\n\t\t\t\"FEB\": \"2\",\n\t\t\t\"MAR\": \"3\",\n\t\t\t\"APR\": \"4\",\n\t\t\t\"MAY\": \"5\",\n\t\t\t\"JUN\": \"6\",\n\t\t\t\"JUL\": \"7\",\n\t\t\t\"AUG\": \"8\",\n\t\t\t\"SEP\": \"9\",\n\t\t\t\"OCT\": \"10\",\n\t\t\t\"NOV\": \"11\",\n\t\t\t\"DEC\": \"12\"},\n\t\t// Each bit can be in one of the following formats\n\t\t// int | int-int | * | */int | int/int| int-int/int\n\t\ttokenValidatorString: `^[0-9]+$|^\\*$|^[0-9]+\\-[0-9]+$|\\*\\/[0-9]+$|^[0-9]+\\/[0-9]+$|^[0-9]+\\-[0-9]+\\/[0-9]+$`,\n\t}\n\n\tds.regExpTokenValidator = regexp.MustCompile(ds.tokenValidatorString)\n\treturn ds, nil\n}", "func (y *Yeelight) CronGet(t string) string {\n\tcmd := `{\"id\":13,\"method\":\"cron_get\",\"params\":[` + t + `]}`\n\treturn y.request(cmd)\n}", "func New() plugin.Plugin {\n\treturn &cronPlugin{}\n}", "func isCronJob(pod *v1.Pod) bool {\n\tfor _, ref := range pod.GetOwnerReferences() {\n\t\tif *ref.Controller {\n\t\t\treturn ref.Kind == protos.ModuleSpec_Job.String()\n\t\t}\n\t}\n\n\treturn false\n}", "func (i *ImmediateCron) Start() {}", "func (s ScheduledJob) validate() error {\n\tvar err error\n\tif err = s.ScheduledJobConfig.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = s.Workload.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = validateContainerDeps(validateDependenciesOpts{\n\t\tsidecarConfig: s.Sidecars,\n\t\timageConfig: s.ImageConfig.Image,\n\t\tmainContainerName: aws.StringValue(s.Name),\n\t\tlogging: s.Logging,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"validate container dependencies: %w\", err)\n\t}\n\tif err = validateExposedPorts(validateExposedPortsOpts{\n\t\tsidecarConfig: s.Sidecars,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"validate unique exposed ports: %w\", err)\n\t}\n\treturn nil\n}", "func (cli *Client) CronDelete(ctx context.Context, id string) error {\n\tv := url.Values{}\n\tresp, err := cli.delete(ctx, \"/crons/\"+id, v, nil)\n\tensureReaderClosed(resp)\n\treturn err\n}", "func (o MrScalarScheduledTaskOutput) Cron() pulumi.StringOutput {\n\treturn o.ApplyT(func(v MrScalarScheduledTask) string { return v.Cron }).(pulumi.StringOutput)\n}", "func NewDrupalCronSyncer(droplet *drupal.Drupal, c client.Client, scheme *runtime.Scheme) syncer.Interface {\n\tobjLabels := droplet.ComponentLabels(drupal.DrupalCron)\n\n\tobj := &batchv1beta1.CronJob{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: droplet.ComponentName(drupal.DrupalCron),\n\t\t\tNamespace: droplet.Namespace,\n\t\t},\n\t}\n\n\tvar (\n\t\tcronStartingDeadlineSeconds int64 = 10\n\t\tbackoffLimit int32\n\t\tactiveDeadlineSeconds int64 = 10\n\t\tsuccessfulJobsHistoryLimit int32 = 3\n\t\tfailedJobsHistoryLimit int32 = 1\n\t)\n\n\treturn syncer.NewObjectSyncer(\"DrupalCron\", droplet.Unwrap(), obj, c, scheme, func(existing runtime.Object) error {\n\t\tout := existing.(*batchv1beta1.CronJob)\n\n\t\tout.Labels = labels.Merge(labels.Merge(out.Labels, objLabels), common.ControllerLabels)\n\n\t\tout.Spec.Schedule = \"* * * * *\"\n\t\tout.Spec.ConcurrencyPolicy = \"Forbid\"\n\t\tout.Spec.StartingDeadlineSeconds = &cronStartingDeadlineSeconds\n\t\tout.Spec.SuccessfulJobsHistoryLimit = &successfulJobsHistoryLimit\n\t\tout.Spec.FailedJobsHistoryLimit = &failedJobsHistoryLimit\n\n\t\tout.Spec.JobTemplate.ObjectMeta.Labels = labels.Merge(objLabels, common.ControllerLabels)\n\t\tout.Spec.JobTemplate.Spec.BackoffLimit = &backoffLimit\n\t\tout.Spec.JobTemplate.Spec.ActiveDeadlineSeconds = &activeDeadlineSeconds\n\n\t\tcmd := []string{\"crond\", \"-f\", \"-d\", \"8\"}\n\t\ttemplate := droplet.JobPodTemplateSpec(cmd...)\n\n\t\tout.Spec.JobTemplate.Spec.Template.ObjectMeta = template.ObjectMeta\n\n\t\terr := mergo.Merge(&out.Spec.JobTemplate.Spec.Template.Spec, template.Spec, mergo.WithTransformers(transformers.PodSpec))\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}", "func (t *dataType) Valid(val interface{}) error {\n\t// doing this here because this error should come from Valid instead of Format\n\t// which is easier for testing\n\tif t.cost != nil && *t.cost > bcrypt.MaxCost {\n\t\treturn bcrypt.InvalidCostError(*t.cost)\n\t}\n\n\t// convert to string and use the string datatype to validate any validators that hae been added\n\ts := val.(string)\n\treturn t.str.Valid(s)\n}", "func (s *deploymentServer) createCronjob(ctx context.Context, manifest []byte, env []EnvVar, initVariables []EnvVar) error {\n\tdecoder := k8sYaml.NewYAMLOrJSONDecoder(bytes.NewReader(manifest), 1000)\n\n\tj := &apibatch.CronJob{}\n\n\tif err := decoder.Decode(&j); err != nil {\n\t\treturn err\n\t}\n\n\tif len(env) > 0 {\n\t\tcontainers := j.Spec.JobTemplate.Spec.Template.Spec.Containers\n\t\tapplyEnvironment(containers, env)\n\t}\n\n\tinitContainers := j.Spec.JobTemplate.Spec.Template.Spec.InitContainers\n\tif len(initContainers) > 0 {\n\t\tfmt.Println(\"job \" + j.Namespace + \".\" + j.Name + \" has initContainers\")\n\t\tapplyEnvironment(initContainers, initVariables)\n\t} else {\n\t\tfmt.Println(\"job \" + j.Namespace + \".\" + j.Name + \" has not initContainers; bug in config\")\n\t}\n\n\tbatchAPI := s.clientset.BatchV1beta1()\n\tapiJobs := batchAPI.CronJobs(j.Namespace)\n\n\tif _, err := apiJobs.Create(ctx, j, metav1.CreateOptions{}); err != nil {\n\t\treturn fmt.Errorf(\"job create error '%s'\", err.Error())\n\t}\n\treturn nil\n}", "func (m *SnapshotSchedule) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (e *CronJob) matches(def catalog.Definition) bool {\n\treturn e.JobID == def.JobID && e.Schedule == def.Schedule && bytes.Equal(e.Task, def.Task)\n}", "func New(locker Locker, opts *Options) *Cron {\n\tlocation, err := time.LoadLocation(opts.timezone())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn &Cron{\n\t\tjobs: make(map[string]*job),\n\t\tlocker: locker,\n\t\topts: opts,\n\t\tlocation: location,\n\t}\n}", "func (i Interval) Validate() (bool, error) {\n\tif !i.isValidated {\n\t\tif i.ID == \"\" && i.Name == \"\" {\n\t\t\treturn false, NewErrContractInvalid(\"Interval ID and Name are both blank\")\n\t\t}\n\t\tif i.Start != \"\" {\n\t\t\t_, err := time.Parse(timestampLayout, i.Start)\n\t\t\tif err != nil {\n\t\t\t\treturn false, NewErrContractInvalid(fmt.Sprintf(\"error parsing Start %v\", err))\n\t\t\t}\n\t\t}\n\t\tif i.End != \"\" {\n\t\t\t_, err := time.Parse(timestampLayout, i.End)\n\t\t\tif err != nil {\n\t\t\t\treturn false, NewErrContractInvalid(fmt.Sprintf(\"error parsing End %v\", err))\n\t\t\t}\n\t\t}\n\t\tif i.Frequency != \"\" {\n\t\t\t/* legacy frequencyPattern */\n\t\t\tmatched, _ := regexp.MatchString(frequencyPattern, i.Frequency)\n\t\t\tif matched {\n\t\t\t\tif i.Frequency == \"P\" || i.Frequency == \"PT\" {\n\t\t\t\t\tmatched = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !matched {\n\t\t\t\t// parse frequency example \"1h15m30s10us9ns\"\n\t\t\t\t_, err := time.ParseDuration(i.Frequency)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, NewErrContractInvalid(fmt.Sprintf(\"invalid Interval frequency %s format\", i.Frequency))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\terr := validate(i)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\treturn true, nil\n\t}\n\treturn i.isValidated, nil\n}", "func (j *JobConfig) nextRun() (time.Time, error) {\n\tvar t time.Time\n\tschedule, err := cron.Parse(j.fullSpec())\n\tif err != nil {\n\t\treturn t, err\n\t}\n\treturn schedule.Next(time.Now()), nil\n}", "func InitializeCronEngine() *cron.Cron {\n\tc := cron.New()\n\tc.Start()\n\treturn c\n}", "func validateFieldDurationSchedule(fl validator.FieldLevel) bool {\n\tv := fl.Field().Int()\n\tif v < durationScheduleMinutesMin {\n\t\treturn false\n\t}\n\tif v > durationScheduleMinutesMax {\n\t\treturn false\n\t}\n\treturn true\n}", "func New(pool *redis.Pool) *Cron {\n\treturn NewWithLocation(time.Now().Location(), pool)\n}", "func (r *RTVCache) StopCron() {\n\tr.stop <- struct{}{}\n}", "func LogCronStatus(c *cron.Cron) { //TODO add a cron to inspect cron jobs and log the outputs\n\n}", "func (m *PreregConfig) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateConfirmationEnd(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateConfirmationStart(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateCreated(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateMessageType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateMinPeriod(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateName(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateNiccomEnd(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateNiccomStart(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validatePeriodEnd(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validatePeriodStart(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateRegistrationType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateUpdated(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func ParseWhen(spec string) (When, error) {\n\tspec = strings.TrimSpace(spec)\n\tif strings.HasPrefix(spec, \"@every \") {\n\t\tinterval, err := time.ParseDuration(spec[7:])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"When: invalid 'every' argument: '%s'\", spec[7:])\n\t\t}\n\t\treturn &when{spec: spec, every: interval}, nil\n\t}\n\n\tscheduler, err := CronSpecParser.Parse(spec)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tscheduler.Location = time.UTC\n\treturn &when{spec: spec, sched: scheduler}, nil\n}", "func cronHandler(h http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.Header.Get(\"X-Appengine-Cron\") != \"true\" {\n\t\t\thttp.NotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\t// Fallthrough.\n\t\th.ServeHTTP(w, r)\n\t})\n}", "func (ds *DefaultSyntax) tokenize() error {\n\t// Note this split on a single white space, if we want to split on white spaces\n\t// we can use a regexp for it regexp.MustCompile(`\\S+`) and then re.FindAllString(input, -1)\n\ttokens := strings.Split(ds.input, ds.separator)\n\t// We check if it has been passed the strings format for Day of week and month\n\t// and we convert it to the integers\n\ttokens[3] = utils.StringToNumber(tokens[3], ds.monthsMapper)\n\ttokens[4] = utils.StringToNumber(tokens[4], ds.daysMapper)\n\n\t// we do not validate the command token that is in the last position\n\tfor i := 0; i < len(tokens)-2; i++ {\n\t\terr := ds.validateTokens(tokens[i])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t//TO DO use \"enum\" instead of integer here\n\tce := &CronElements{Minute: tokens[0],\n\t\tHour: tokens[1],\n\t\tDayMonth: tokens[2],\n\t\tMonth: tokens[3],\n\t\tDayWeek: tokens[4],\n\t\tCommand: tokens[5],\n\t}\n\tds.cronElements = ce\n\treturn nil\n}", "func (c Config) Validate() error {\n\tif len(c.ClientID) == 0 {\n\t\treturn fmt.Errorf(\"error: ClientID missing\")\n\t}\n\n\tif c.VodID < 1 {\n\t\treturn fmt.Errorf(\"error: VodID missing\")\n\t}\n\n\ttimePattern := `\\d+ \\d+ \\d+`\n\ttimeRegex := regexp.MustCompile(timePattern)\n\tif c.StartTime != \"start\" && !timeRegex.MatchString(c.StartTime) {\n\t\treturn fmt.Errorf(\"error: StartTime must be 'start' or in format '%s'; got '%s'\", timePattern, c.StartTime)\n\t}\n\tif c.EndTime == \"\" && c.Length == \"\" {\n\t\treturn errors.New(\"error: must specify either EndTime or Length\")\n\t}\n\tif c.Length == \"\" && c.EndTime != \"end\" && !timeRegex.MatchString(c.EndTime) {\n\t\treturn fmt.Errorf(\"error: EndTime must be 'end' or in format '%s'; got '%s'\", timePattern, c.EndTime)\n\t}\n\tif c.EndTime == \"\" && c.Length != \"full\" && !timeRegex.MatchString(c.Length) {\n\t\treturn fmt.Errorf(\"error: Length must be 'full' or in format '%s'; got '%s'\", timePattern, c.Length)\n\t}\n\n\tqualityPattern := `\\d{3,4}p[36]0`\n\tqualityRegex := regexp.MustCompile(qualityPattern)\n\tif c.Quality != \"best\" && c.Quality != \"chunked\" && !qualityRegex.MatchString(c.Quality) {\n\t\treturn fmt.Errorf(\"error: Quality must be 'best', 'chunked', or in format '%s'; got '%s'\", qualityPattern, c.Quality)\n\t}\n\n\tif c.FilePrefix != \"\" && !isValidFilename(c.FilePrefix) {\n\t\treturn fmt.Errorf(\"error: FilePrefix contains invalid characters; got '%s'\", c.FilePrefix)\n\t}\n\n\tif c.Workers < 1 {\n\t\treturn fmt.Errorf(\"error: Worker must be an integer greater than 0; got '%d'\", c.Workers)\n\t}\n\n\treturn nil\n}", "func MustParseV1beta1TaskRun(t *testing.T, yaml string) *v1beta1.TaskRun {\n\tt.Helper()\n\tvar tr v1beta1.TaskRun\n\tyaml = `apiVersion: tekton.dev/v1beta1\nkind: TaskRun\n` + yaml\n\tmustParseYAML(t, yaml, &tr)\n\treturn &tr\n}", "func (m *IoArgoprojWorkflowV1alpha1CreateCronWorkflowRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.contextValidateCreateOptions(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateCronWorkflow(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (h *CronJobUpdateHandler) Handle(ctx context.Context, req types.Request) types.Response {\n\tobj := &batchv1.CronJob{}\n\n\terr := h.Decoder.Decode(req, obj)\n\tif err != nil {\n\t\treturn admission.ErrorResponse(http.StatusBadRequest, err)\n\t}\n\n\tallowed, reason, err := h.validatingCronJobFn(ctx, obj)\n\tif err != nil {\n\t\treturn admission.ErrorResponse(http.StatusInternalServerError, err)\n\t}\n\treturn admission.ValidationResponse(allowed, reason)\n}", "func NewCronScheduler() *CronScheduler {\n\treturn &CronScheduler{\n\t\tc: cron.New(),\n\t}\n}" ]
[ "0.80303437", "0.72242135", "0.6995862", "0.6559356", "0.57354695", "0.5719239", "0.5704898", "0.5627016", "0.56057084", "0.5604991", "0.5554886", "0.5496737", "0.54547256", "0.5443391", "0.5397671", "0.5357907", "0.53289336", "0.5317187", "0.5303617", "0.524098", "0.5240222", "0.51942253", "0.5151726", "0.515152", "0.5141478", "0.5081334", "0.5066822", "0.5053667", "0.5035856", "0.5029515", "0.50292593", "0.5028127", "0.5010121", "0.49823034", "0.49767154", "0.49731427", "0.49663204", "0.49612275", "0.49535516", "0.4943468", "0.49385682", "0.4937909", "0.49361256", "0.49357456", "0.49287245", "0.49105003", "0.49091202", "0.49018157", "0.48899627", "0.488137", "0.48806173", "0.4871026", "0.4865313", "0.4863352", "0.48632878", "0.48360214", "0.48066875", "0.4803946", "0.4797741", "0.47960833", "0.4790552", "0.47888538", "0.47790802", "0.47772992", "0.47727975", "0.47672668", "0.47649404", "0.47634822", "0.47602585", "0.47571748", "0.47511458", "0.47436482", "0.4743026", "0.473437", "0.47311288", "0.47239786", "0.47200128", "0.47050935", "0.4704169", "0.46973062", "0.46920034", "0.4677395", "0.46773684", "0.467051", "0.4667457", "0.4659257", "0.46535316", "0.46498695", "0.46491233", "0.46281716", "0.45995674", "0.45987862", "0.45897952", "0.45746127", "0.45740187", "0.45725557", "0.45719692", "0.45480883", "0.45475963", "0.4544363" ]
0.81514907
0
ValidateCronInterval return a nil value when a valid cron string is passed
func ValidateCronInterval(val interface{}) error { return CronIntervalValidator(val, "") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CronIntervalValidator(val interface{}, param string) error {\n\tvalue, ok := val.(string)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid crontab entry, not a valid string\")\n\t}\n\tif _, err := cron.ParseStandard(value); err != nil {\n\t\treturn errors.Wrap(err, \"invalid crontab entry\")\n\t}\n\treturn nil\n}", "func (c *CronSchedule) Validate() error {\n\tif c.entry == \"\" {\n\t\treturn ErrMissingCronEntry\n\t}\n\t_, err := cron.Parse(c.entry)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c Cron) Validate() error {\n\tswitch {\n\tcase c.Spec.Branch == \"\":\n\t\treturn errors.New(\"yaml: invalid cron branch\")\n\tdefault:\n\t\treturn nil\n\t}\n}", "func isCron(fl FieldLevel) bool {\n\tcronString := fl.Field().String()\n\treturn cronRegex.MatchString(cronString)\n}", "func Parse(c string) (*Cron, error) {\n\tcron := &Cron{}\n\tif c[len(c) - 1] == spaceByte {\n\t\tc = c[:len(c) - 1]\n\t}\n\tcp := strings.Split(c, \" \")\n\tif len(cp) > 5 {\n\t\treturn nil, fmt.Errorf(\"unknown cron format: %s\", c)\n\t}\n\n\terr := cron.parseMinutes(cp[0])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseHours(cp[1])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseDays(cp[2])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseMonths(cp[3])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = cron.parseWeekdays(cp[4])\n\n\treturn cron, nil\n}", "func ParseCronExpression(cronExpr string) (cron.Schedule, error) {\n\tif strings.TrimSpace(cronExpr) == \"@never\" {\n\t\treturn Year9999{}, nil\n\t}\n\treturn cron.ParseStandard(cronExpr) //nolint:wrapcheck\n}", "func ParseCronExpression(args []string) (string, error) {\n\tsantizedArgs, err := sanitize(args)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tresult, err := parseExpression(santizedArgs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn format(result), nil\n}", "func (ci *CronImpl) Parse(spec string) (cron.Schedule, error) {\n\treturn cron.Parse(spec)\n}", "func validateFieldDurationScheduleStr(fl validator.FieldLevel) bool {\n\tv, err := strconv.ParseInt(fl.Field().String(), 10, 32)\n\tif err != nil {\n\t\treturn false\n\t}\n\tif v < durationScheduleMinutesMin {\n\t\treturn false\n\t}\n\tif v > durationScheduleMinutesMax {\n\t\treturn false\n\t}\n\treturn true\n}", "func Test_TaskOption_CronExpression(t *testing.T) {\n\t// given\n\toption := crontask.CronExpression(\"bar\")\n\toptions := &crontask.TaskOptions{CronExpression: \"foo\"}\n\n\t// when\n\toption(options)\n\n\t// then\n\tif options.CronExpression != \"bar\" {\n\t\tt.Errorf(\"cron expression not correctly applied, got %s\", options.CronExpression)\n\t}\n}", "func InitCronExpr(ctx context.Context, duration time.Duration) error {\n\tif duration < 0 || duration > 12*time.Hour {\n\t\treturn moerr.NewNotSupported(ctx, \"export cron expr not support cycle: %v\", duration)\n\t}\n\tif duration < 5*time.Minute {\n\t\tMergeTaskCronExpr = fmt.Sprintf(\"@every %.0fs\", duration.Seconds())\n\t} else if duration < time.Hour {\n\t\tconst unit = 5 * time.Minute\n\t\tduration = (duration + unit - 1) / unit * unit\n\t\tswitch duration {\n\t\tcase 5 * time.Minute:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery05Min\n\t\tcase 15 * time.Minute:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery15Min\n\t\tdefault:\n\t\t\tMergeTaskCronExpr = fmt.Sprintf(\"@every %.0fm\", duration.Minutes())\n\t\t}\n\t} else {\n\t\tminHour := duration / time.Hour\n\t\tswitch minHour {\n\t\tcase 1:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery1Hour\n\t\tcase 2:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery2Hour\n\t\tcase 4:\n\t\t\tMergeTaskCronExpr = MergeTaskCronExprEvery4Hour\n\t\tdefault:\n\t\t\tvar hours = make([]string, 0, 12)\n\t\t\tfor h := minHour; h < 24; h += minHour {\n\t\t\t\thours = append(hours, strconv.Itoa(int(h)))\n\t\t\t}\n\t\t\tMergeTaskCronExpr = fmt.Sprintf(\"0 0 %s * * *\", strings.Join(hours, \",\"))\n\t\t}\n\t}\n\treturn nil\n}", "func parseCronLine(l string) (string, error) {\n\n\tvar out string\n\n\t// Of course the regex could be a lot more sophisticated\n\tre := regexp.MustCompile(`^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(.+)$`)\n\tvalidCronLine := re.MatchString(l)\n\tif !validCronLine {\n\t\treturn \"\", errors.New(\"Cron line does not comply with standard format\")\n\t}\n\n\tsubMatch := re.FindStringSubmatch(l)\n\n\tminuteStr := subMatch[1]\n\thourStr := subMatch[2]\n\tdayOfMonthStr := subMatch[3]\n\tmonthStr := subMatch[4]\n\tdayOfWeekStr := subMatch[5]\n\tcommandStr := subMatch[6]\n\n\tminutesParsed, err := parseMinute(minuteStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing minutes: %v\", err)\n\t}\n\thoursParsed, err := parseHours(hourStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing hours: %v\", err)\n\t}\n\tdayOfMonthParsed, err := parseDayOfMonth(dayOfMonthStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing days of the month: %v\", err)\n\t}\n\tmonthParsed, err := parseMonth(monthStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing months: %v\", err)\n\t}\n\tdayOfWeekParsed, err := parseDayOfWeek(dayOfWeekStr)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"problem parsing days of the week: %v\", err)\n\t}\n\n\tout = fmt.Sprintf(\"%-14s%s\\n\", \"minute\", joinInts(minutesParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"hour\", joinInts(hoursParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"day of month\", joinInts(dayOfMonthParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"month\", joinInts(monthParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"day of week\", joinInts(dayOfWeekParsed)) +\n\t\tfmt.Sprintf(\"%-14s%s\\n\", \"command\", commandStr)\n\n\treturn out, nil\n}", "func (p Parser) Parse(spec string) (cron.Schedule, error) {\n\tswitch spec {\n\tcase \"@yearly\", \"@annually\":\n\t\tspec = \"0 0 0 1 1 * *\"\n\tcase \"@monthly\":\n\t\tspec = \"0 0 0 1 * * *\"\n\tcase \"@weekly\":\n\t\tspec = \"0 0 0 * * 0 *\"\n\tcase \"@daily\":\n\t\tspec = \"0 0 0 * * * *\"\n\tcase \"@hourly\":\n\t\tspec = \"0 0 * * * * *\"\n\tcase \"@minutely\":\n\t\tspec = \"0 * * * * *\"\n\t}\n\n\treturn p.parser.Parse(spec)\n}", "func Cronjob(period string, r *Retriever) {\n\tcronjob := cron.New()\n\tcronjob.AddFunc(period, r.RetrieveIP)\n\tklog.Infof(\"start cron job to retrieve ip period %s\", period)\n\tcronjob.Start()\n}", "func (n *Nodes) DeleteEssNodesCron(req apistructs.DeleteNodesCronRequest, userid string, orgid string) (*uint64, error) {\n\t// check cluster info\n\tclusterInfo, err := n.bdl.QueryClusterInfo(req.ClusterName)\n\tif err != nil {\n\t\terrstr := fmt.Sprintf(\"failed to queryclusterinfo: %v, clusterinfo: %v\", err, clusterInfo)\n\t\tlogrus.Errorf(errstr)\n\t\treturn nil, err\n\t}\n\tif !clusterInfo.IsK8S() {\n\t\terrstr := fmt.Sprintf(\"unsupported cluster type, cluster name: %s, cluster type: %s\",\n\t\t\tclusterInfo.MustGet(apistructs.DICE_CLUSTER_NAME), clusterInfo.MustGet(apistructs.DICE_CLUSTER_TYPE))\n\t\tlogrus.Errorf(errstr)\n\t\terr := errors.New(errstr)\n\t\treturn nil, err\n\t}\n\n\t// create cron expression\n\tcronMap := make(map[string]string)\n\tlayout := \"2006-01-02T15:04Z\"\n\tlaunchTime, err := time.Parse(layout, req.LaunchTime)\n\n\to1, _ := time.ParseDuration(\"8h\")\n\tt1 := launchTime.Add(o1)\n\n\tif err != nil {\n\t\terr := fmt.Errorf(\"parse launch time failed, request: %v, error: %v\", req.LaunchTime, err)\n\t\tlogrus.Error(err)\n\t\treturn nil, err\n\t}\n\tcronMap[\"minute\"] = strconv.Itoa(t1.Minute())\n\tcronMap[\"hour\"] = strconv.Itoa(t1.Hour())\n\tcronMap[\"day\"] = \"*\"\n\tcronMap[\"month\"] = \"*\"\n\tcronMap[\"week\"] = \"*\"\n\tif req.RecurrenceType == \"Daily\" {\n\t\tcronMap[\"day\"] = fmt.Sprintf(\"*/%s\", req.RecurrenceValue)\n\t} else if req.RecurrenceType == \"Monthly\" {\n\t\tcronMap[\"day\"] = req.RecurrenceValue\n\t} else if req.RecurrenceType == \"Weekly\" {\n\t\tcronMap[\"week\"] = req.RecurrenceValue\n\t} else {\n\t\terr := fmt.Errorf(\"unsupport recurrence type, cluster name:%s, type : %s\", req.ClusterName, req.RecurrenceType)\n\t\tlogrus.Error(err)\n\t\treturn nil, err\n\t}\n\tcronExpr := strings.Join([]string{cronMap[\"minute\"], cronMap[\"hour\"], cronMap[\"day\"], cronMap[\"month\"], cronMap[\"week\"]}, \" \")\n\tlogrus.Infof(\"create cron expression, cluster name: %s, cron expression: %s\", req.ClusterName, cronExpr)\n\n\treq.AccessKey = encrypt.AesDecrypt(req.AccessKey, apistructs.TerraformEcyKey)\n\treq.SecretKey = encrypt.AesDecrypt(req.SecretKey, apistructs.TerraformEcyKey)\n\treq.Password = encrypt.AesDecrypt(req.Password, apistructs.TerraformEcyKey)\n\t// default is not force\n\tforce := \"\"\n\tif req.Force {\n\t\tforce = \"true\"\n\t}\n\tyml := apistructs.PipelineYml{\n\t\tVersion: \"1.1\",\n\t\tCron: cronExpr,\n\t\tStages: [][]*apistructs.PipelineYmlAction{{{\n\t\t\tType: \"ess-info\",\n\t\t\tVersion: \"1.0\",\n\t\t\tAlias: string(apistructs.NodePhaseEssInfo),\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"ak\": req.AccessKey,\n\t\t\t\t\"sk\": req.SecretKey,\n\t\t\t\t\"region\": req.Region,\n\t\t\t\t\"scaling_group_id\": req.ScalingGroupId,\n\t\t\t},\n\t\t}}, {{\n\t\t\tType: \"rm-nodes\",\n\t\t\tVersion: \"1.0\",\n\t\t\tAlias: string(apistructs.NodePhaseRmNodes),\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"hosts_file\": fmt.Sprintf(\"${%s}/hosts\", string(apistructs.NodePhaseEssInfo)),\n\t\t\t\t\"password\": req.Password,\n\t\t\t\t\"force\": force,\n\t\t\t\t\"cluster\": req.ClusterName,\n\t\t\t},\n\t\t}}, {{\n\t\t\tType: \"delete-ess-nodes\",\n\t\t\tVersion: \"1.0\",\n\t\t\tAlias: string(apistructs.NodePhaseDeleteNodes),\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"ak\": req.AccessKey,\n\t\t\t\t\"sk\": req.SecretKey,\n\t\t\t\t\"region\": req.Region,\n\t\t\t\t\"scaling_group_id\": req.ScalingGroupId,\n\t\t\t\t\"is_cron\": true,\n\t\t\t\t\"instance_ids_file\": fmt.Sprintf(\"${%s}/instance_ids\", string(apistructs.NodePhaseEssInfo)),\n\t\t\t},\n\t\t}},\n\t\t},\n\t}\n\tb, err := yaml.Marshal(yml)\n\tif err != nil {\n\t\terrstr := fmt.Sprintf(\"failed to marshal pipelineyml: %v\", err)\n\t\tlogrus.Errorf(errstr)\n\t\treturn nil, err\n\t}\n\tdto, err := n.pipelineSvc.PipelineCreateV2(apis.WithInternalClientContext(context.Background(), discover.CMP()), &pipelinepb.PipelineCreateRequestV2{\n\t\tPipelineYml: string(b),\n\t\tPipelineYmlName: fmt.Sprintf(\"%s-%s.yml\", apistructs.DeleteEssNodesCronPrefix, clusterInfo.MustGet(apistructs.DICE_CLUSTER_NAME)),\n\t\tClusterName: clusterInfo.MustGet(apistructs.DICE_CLUSTER_NAME),\n\t\tPipelineSource: apistructs.PipelineSourceOps.String(),\n\t\tAutoStartCron: true,\n\t\tCronStartFrom: timestamppb.New(launchTime),\n\t})\n\n\tif err != nil {\n\t\terrstr := fmt.Sprintf(\"failed to createpipeline: %v\", err)\n\t\tlogrus.Errorf(errstr)\n\t\treturn nil, err\n\t}\n\n\treturn dto.Data.CronID, nil\n}", "func NewCronSchedule(entry string) *CronSchedule {\n\tschedule := cron.New()\n\treturn &CronSchedule{\n\t\tentry: entry,\n\t\tschedule: schedule,\n\t\tenabled: false,\n\t}\n}", "func (p cron) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {\n\tif obj.GroupVersionKind() != cronGVC {\n\t\treturn false, nil, nil\n\t}\n\tmeta, err := processor.ProcessObjMeta(appMeta, obj)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\tname := appMeta.TrimName(obj.GetName())\n\tnameCamelCase := strcase.ToLowerCamel(name)\n\n\tjobObj := batchv1.CronJob{}\n\terr = runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &jobObj)\n\tif err != nil {\n\t\treturn true, nil, errors.Wrap(err, \"unable to cast to Job\")\n\t}\n\tspec := jobObj.Spec\n\tspecMap, exists, err := unstructured.NestedMap(obj.Object, \"spec\")\n\tif err != nil {\n\t\treturn true, nil, errors.Wrap(err, \"unable to get job spec\")\n\t}\n\tif !exists {\n\t\treturn true, nil, errors.New(\"no job spec presented\")\n\t}\n\n\tvalues := helmify.Values{}\n\n\t// process job spec params:\n\tif spec.Schedule != \"\" {\n\t\terr := templateSpecVal(spec.Schedule, &values, specMap, nameCamelCase, \"schedule\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.Suspend != nil {\n\t\terr := templateSpecVal(*spec.Suspend, &values, specMap, nameCamelCase, \"suspend\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.FailedJobsHistoryLimit != nil {\n\t\terr := templateSpecVal(*spec.FailedJobsHistoryLimit, &values, specMap, nameCamelCase, \"failedJobsHistoryLimit\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.StartingDeadlineSeconds != nil {\n\t\terr := templateSpecVal(*spec.StartingDeadlineSeconds, &values, specMap, nameCamelCase, \"startingDeadlineSeconds\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.TimeZone != nil {\n\t\terr := templateSpecVal(*spec.TimeZone, &values, specMap, nameCamelCase, \"timeZone\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\tif spec.SuccessfulJobsHistoryLimit != nil {\n\t\terr := templateSpecVal(*spec.SuccessfulJobsHistoryLimit, &values, specMap, nameCamelCase, \"successfulJobsHistoryLimit\")\n\t\tif err != nil {\n\t\t\treturn true, nil, err\n\t\t}\n\t}\n\n\t// process job pod template:\n\tpodSpecMap, podValues, err := pod.ProcessSpec(nameCamelCase, appMeta, jobObj.Spec.JobTemplate.Spec.Template.Spec)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\terr = values.Merge(podValues)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\n\terr = unstructured.SetNestedMap(specMap, podSpecMap, \"jobTemplate\", \"spec\", \"template\", \"spec\")\n\tif err != nil {\n\t\treturn true, nil, fmt.Errorf(\"%w: unable to template job spec\", err)\n\t}\n\n\tspecStr, err := yamlformat.Marshal(map[string]interface{}{\"spec\": specMap}, 0)\n\tif err != nil {\n\t\treturn true, nil, err\n\t}\n\tspecStr = strings.ReplaceAll(specStr, \"'\", \"\")\n\n\treturn true, &resultCron{\n\t\tname: name + \".yaml\",\n\t\tdata: struct {\n\t\t\tMeta string\n\t\t\tSpec string\n\t\t}{Meta: meta, Spec: specStr},\n\t\tvalues: values,\n\t}, nil\n}", "func NewCronSpec(spec *job.CronSpec) *CronSpec {\n\treturn &CronSpec{\n\t\tCronSchedule: spec.CronSchedule,\n\t\tCreatedAt: spec.CreatedAt,\n\t\tUpdatedAt: spec.UpdatedAt,\n\t}\n}", "func (c *Controller) initCron() error {\n\tcronJob = cron.New()\n\tif err := cronJob.AddFunc(Schedule, c.Run); err != nil {\n\t\treturn err\n\t}\n\n\tcronJob.Start()\n\n\tc.ready <- struct{}{}\n\n\treturn nil\n}", "func (c JobTriggerConfig) validate() error {\n\tif c.Schedule == nil {\n\t\treturn &errFieldMustBeSpecified{\n\t\t\tmissingField: \"schedule\",\n\t\t}\n\t}\n\treturn nil\n}", "func (j *JobConfig) validate() error {\n\tif j.Name == \"\" {\n\t\treturn errors.New(\"job must have a name\")\n\t}\n\n\tif j.Spec == \"\" {\n\t\treturn errors.New(\"spec is required\")\n\t}\n\n\tif j.Command == \"\" {\n\t\treturn errors.New(\"command is required\")\n\t}\n\n\t// Configure shell when multi-line scripts\n\tif j.Shell == \"\" && len(strings.Split(j.Command, \"\\n\")) > 1 {\n\t\tj.Shell = defaultShell\n\t}\n\n\tif _, err := cron.Parse(j.Spec); err != nil {\n\t\treturn fmt.Errorf(\"invalid cron spec: %v\", err)\n\t}\n\n\tif val := j.TimeoutString; val != \"\" {\n\t\tdur, err := time.ParseDuration(val)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid timeout: %v\", err)\n\t\t}\n\t\tj.Timeout = dur\n\t}\n\n\tif j.Docker != nil {\n\t\tj.RunMode = dockerMode\n\t} else {\n\t\tj.RunMode = nativeMode\n\t}\n\n\t// Notify on errors only by default\n\tif j.Notify != nil && j.Notify.Mode == \"\" {\n\t\tj.Notify.Mode = notifyError\n\t}\n\n\treturn nil\n}", "func (m *Schedule) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateInterval(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateType(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (w *Worker) ByCronSpec(spec string) *Worker {\n\tw.schedule = ByCronSchedule(spec)\n\treturn w\n}", "func cronExec(ctxt appengine.Context, name string) error {\n\tcron.RLock()\n\tlist := cron.list\n\tcron.RUnlock()\n\n\tvar cr cronEntry\n\tfor _, cr = range list {\n\t\tif cr.name == name {\n\t\t\tgoto Found\n\t\t}\n\t}\n\tctxt.Errorf(\"unknown cron entry %q\", name)\n\treturn nil\n\nFound:\n\tif err := cr.f(ctxt); err != nil {\n\t\tif err == ErrMoreCron {\n\t\t\t// The cron job found that it had more work than it could do\n\t\t\t// and wants to run again. Arrange this by making the task\n\t\t\t// seem to fail.\n\t\t\tctxt.Infof(\"cron job %q: ErrMoreCron\", cr.name)\n\t\t\treturn fmt.Errorf(\"cron job %q wants to run some more\", cr.name)\n\t\t}\n\t\t// The cron job failed, but there's no reason to think running it again\n\t\t// right now will help. Let this instance finish successfully.\n\t\t// It will run again at the next scheduled time.\n\t\tctxt.Infof(\"cron job %q: %v\", cr.name, err)\n\t\treturn nil\n\t}\n\treturn nil\n}", "func CreateCronExpression(interval int) string {\n\tunit := \"minutes\"\n\tif interval == 1 {\n\t\tunit = \"minute\"\n\t}\n\treturn fmt.Sprintf(\"rate(%d %s)\", interval, unit)\n}", "func (u *UpdateOption) Valid() error {\n\tif u.CronExpression == nil && u.JobOtherInputs == nil {\n\t\treturn ErrUpdateOptionInvalid\n\t}\n\tif u.CronExpression != nil {\n\t\tif _, err := u.schedule(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (j *AuroraJob) CronSchedule(cron string) Job {\n\tj.jobConfig.CronSchedule = &cron\n\treturn j\n}", "func (i Interval) Validate() (bool, error) {\n\tif !i.isValidated {\n\t\tif i.ID == \"\" && i.Name == \"\" {\n\t\t\treturn false, NewErrContractInvalid(\"Interval ID and Name are both blank\")\n\t\t}\n\t\tif i.Start != \"\" {\n\t\t\t_, err := time.Parse(timestampLayout, i.Start)\n\t\t\tif err != nil {\n\t\t\t\treturn false, NewErrContractInvalid(fmt.Sprintf(\"error parsing Start %v\", err))\n\t\t\t}\n\t\t}\n\t\tif i.End != \"\" {\n\t\t\t_, err := time.Parse(timestampLayout, i.End)\n\t\t\tif err != nil {\n\t\t\t\treturn false, NewErrContractInvalid(fmt.Sprintf(\"error parsing End %v\", err))\n\t\t\t}\n\t\t}\n\t\tif i.Frequency != \"\" {\n\t\t\t/* legacy frequencyPattern */\n\t\t\tmatched, _ := regexp.MatchString(frequencyPattern, i.Frequency)\n\t\t\tif matched {\n\t\t\t\tif i.Frequency == \"P\" || i.Frequency == \"PT\" {\n\t\t\t\t\tmatched = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !matched {\n\t\t\t\t// parse frequency example \"1h15m30s10us9ns\"\n\t\t\t\t_, err := time.ParseDuration(i.Frequency)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, NewErrContractInvalid(fmt.Sprintf(\"invalid Interval frequency %s format\", i.Frequency))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\terr := validate(i)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\treturn true, nil\n\t}\n\treturn i.isValidated, nil\n}", "func NewUpdateAsCronRequestWithoutParam() *UpdateAsCronRequest {\n\n return &UpdateAsCronRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/regions/{regionId}/asCrons/{asCronId}\",\n Method: \"POST\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func (db *DB) ValidPeriod(campus, category, period string) (bool, error) {\n\tconn, err := redishelper.GetRedisConn(db.RedisServer, db.RedisPassword)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer conn.Close()\n\n\tk := fmt.Sprintf(\"ming:%v:%v:periods\", campus, category)\n\tscore, err := redis.String(conn.Do(\"ZSCORE\", k, period))\n\tif err != nil && err != redis.ErrNil {\n\t\treturn false, err\n\t}\n\n\tif score == \"\" {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func NewCron() helmify.Processor {\n\treturn &cron{}\n}", "func (m *IoArgoprojWorkflowV1alpha1CronWorkflowStatus) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateActive(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateConditions(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateLastScheduledTime(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func cleanCron() {\n\tfor _, entry := range mainCron.Entries() {\n\t\tif entry.Schedule.Next(Now()).IsZero() {\n\t\t\tmainCron.Remove(entry.ID)\n\t\t\tremoveJob(entry.ID, true)\n\t\t}\n\t}\n}", "func Parse(spec string) (cron.Schedule, error) {\n\treturn standaloneParser.Parse(spec)\n}", "func GetActivationTimeWithCron(curTime time.Time, cronBatchTime string) (time.Time, error) {\n\n\tif strings.HasPrefix(cronBatchTime, intervalPrefix) {\n\t\treturn time.Time{}, errors.Errorf(\"cannot use '%s' in cron batchtime '%s'\", intervalPrefix, cronBatchTime)\n\t}\n\tparser := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)\n\tsched, err := parser.Parse(cronBatchTime)\n\tif err != nil {\n\t\treturn time.Time{}, errors.Wrapf(err, \"error parsing cron batchtime '%s'\", cronBatchTime)\n\t}\n\treturn sched.Next(curTime), nil\n}", "func validateFieldDurationSchedule(fl validator.FieldLevel) bool {\n\tv := fl.Field().Int()\n\tif v < durationScheduleMinutesMin {\n\t\treturn false\n\t}\n\tif v > durationScheduleMinutesMax {\n\t\treturn false\n\t}\n\treturn true\n}", "func (r *RTVCache) StartCron() {\n\tgo func() {\n\t\tticker := time.NewTicker(defaultPollInterval)\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tr.poll() // Ignores error return.\n\t\t\tcase <-r.stop:\n\t\t\t\tticker.Stop()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n}", "func validateFieldServiceInterval(fl validator.FieldLevel) bool {\n\tv := ParseServiceInterval(fl.Field().String())\n\tif v == nil {\n\t\treturn false\n\t}\n\treturn true\n}", "func createCronJobConfig(module *protos.Module) *v1beta1.CronJob {\n\tvolumes, volumeMounts := makeVolumes(module)\n\tcontainers := makeContainers(module, volumeMounts)\n\tm := module.GetSpec()\n\n\tsuccessfulJobHistoryLimit := int32(1)\n\tfailedJobsHistoryLimit := int32(1)\n\treturn &v1beta1.CronJob{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: module.Name,\n\t\t},\n\t\tSpec: v1beta1.CronJobSpec{\n\t\t\tSchedule: m.Schedule,\n\t\t\tJobTemplate: v1beta1.JobTemplateSpec{\n\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\tLabels: map[string]string{\n\t\t\t\t\t\t\"name\": module.Name,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tSpec: batchv1.JobSpec{\n\t\t\t\t\tTemplate: v1.PodTemplateSpec{\n\t\t\t\t\t\tSpec: v1.PodSpec{\n\t\t\t\t\t\t\tContainers: containers,\n\t\t\t\t\t\t\tVolumes: volumes,\n\t\t\t\t\t\t\tHostNetwork: true,\n\t\t\t\t\t\t\tRestartPolicy: \"Never\",\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\tSuccessfulJobsHistoryLimit: &successfulJobHistoryLimit,\n\t\t\tFailedJobsHistoryLimit: &failedJobsHistoryLimit,\n\t\t},\n\t}\n}", "func (c *Cron) Stop() error {\n\treturn nil\n}", "func (m *SnapshotSchedule) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (e *CronJob) matches(def catalog.Definition) bool {\n\treturn e.JobID == def.JobID && e.Schedule == def.Schedule && bytes.Equal(e.Task, def.Task)\n}", "func Parse(s string) (values []CronValue, cmd string, retErr error) {\n\tfields := Fields()\n\n\tma := lineRe.FindStringSubmatch(s)\n\tif len(ma) != len(fields)+2 { // ma[0] is complete string, ma[last] is command...\n\t\tretErr = fmt.Errorf(\"Format mismatch\")\n\t\treturn\n\t}\n\tcmd = ma[len(fields)+1]\n\n\tfor i := 0; i < len(fields); i++ {\n\t\tv := ma[i+1]\n\t\tpossibleVals, err := fields[i].parsePossibleValues(v)\n\t\tif err != nil {\n\t\t\tretErr = fmt.Errorf(\"Parsing %v: %q is invalid: %v\", fields[i].Name, v, err)\n\t\t\treturn\n\t\t}\n\n\t\tvalues = append(values, CronValue{\n\t\t\tCronField: fields[i],\n\t\t\tValues: possibleVals,\n\t\t})\n\t}\n\n\treturn\n}", "func validateconf() (err error) {\n\t// durations\n\tif ctx.config.Periodic.StatsTime, err = time.ParseDuration(ctx.config.Periodic.StatsTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad stats-time format %s, err: %v\", ctx.config.Periodic.StatsTimeStr, err)\n\t}\n\tif ctx.config.Timeout.Default, err = time.ParseDuration(ctx.config.Timeout.DefaultStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout default format %s, err: %v\", ctx.config.Timeout.DefaultStr, err)\n\t}\n\tif ctx.config.Timeout.DefaultLong, err = time.ParseDuration(ctx.config.Timeout.DefaultLongStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout default_long format %s, err %v\", ctx.config.Timeout.DefaultLongStr, err)\n\t}\n\tif ctx.config.Periodic.KeepAliveTime, err = time.ParseDuration(ctx.config.Periodic.KeepAliveTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad keep_alive_time format %s, err: %v\", ctx.config.Periodic.KeepAliveTimeStr, err)\n\t}\n\tif ctx.config.LRU.DontEvictTime, err = time.ParseDuration(ctx.config.LRU.DontEvictTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad dont_evict_time format %s, err: %v\", ctx.config.LRU.DontEvictTimeStr, err)\n\t}\n\tif ctx.config.LRU.CapacityUpdTime, err = time.ParseDuration(ctx.config.LRU.CapacityUpdTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad capacity_upd_time format %s, err: %v\", ctx.config.LRU.CapacityUpdTimeStr, err)\n\t}\n\tif ctx.config.Rebalance.StartupDelayTime, err = time.ParseDuration(ctx.config.Rebalance.StartupDelayTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad startup_delay_time format %s, err: %v\", ctx.config.Rebalance.StartupDelayTimeStr, err)\n\t}\n\n\thwm, lwm := ctx.config.LRU.HighWM, ctx.config.LRU.LowWM\n\tif hwm <= 0 || lwm <= 0 || hwm < lwm || lwm > 100 || hwm > 100 {\n\t\treturn fmt.Errorf(\"Invalid LRU configuration %+v\", ctx.config.LRU)\n\t}\n\tif ctx.config.TestFSP.Count == 0 {\n\t\tfor fp1 := range ctx.config.FSpaths {\n\t\t\tfor fp2 := range ctx.config.FSpaths {\n\t\t\t\tif fp1 != fp2 && (strings.HasPrefix(fp1, fp2) || strings.HasPrefix(fp2, fp1)) {\n\t\t\t\t\treturn fmt.Errorf(\"Invalid fspaths: %q is a prefix or includes as a prefix %q\", fp1, fp2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif ctx.config.Cksum.Checksum != ChecksumXXHash && ctx.config.Cksum.Checksum != ChecksumNone {\n\t\treturn fmt.Errorf(\"Invalid checksum: %s - expecting %s or %s\", ctx.config.Cksum.Checksum, ChecksumXXHash, ChecksumNone)\n\t}\n\tif err := validateVersion(ctx.config.Ver.Versioning); err != nil {\n\t\treturn err\n\t}\n\tif ctx.config.FSKeeper.FSCheckTime, err = time.ParseDuration(ctx.config.FSKeeper.FSCheckTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad FSKeeper fs_check_time format %s, err %v\", ctx.config.FSKeeper.FSCheckTimeStr, err)\n\t}\n\tif ctx.config.FSKeeper.OfflineFSCheckTime, err = time.ParseDuration(ctx.config.FSKeeper.OfflineFSCheckTimeStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad FSKeeper offline_fs_check_time format %s, err %v\", ctx.config.FSKeeper.OfflineFSCheckTimeStr, err)\n\t}\n\tif ctx.config.Timeout.MaxKeepalive, err = time.ParseDuration(ctx.config.Timeout.MaxKeepaliveStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout max_keepalive format %s, err %v\", ctx.config.Timeout.MaxKeepaliveStr, err)\n\t}\n\tif ctx.config.Timeout.ProxyPing, err = time.ParseDuration(ctx.config.Timeout.ProxyPingStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout proxy_ping format %s, err %v\", ctx.config.Timeout.ProxyPingStr, err)\n\t}\n\tif ctx.config.Timeout.VoteRequest, err = time.ParseDuration(ctx.config.Timeout.VoteRequestStr); err != nil {\n\t\treturn fmt.Errorf(\"Bad Timeout vote_request format %s, err %v\", ctx.config.Timeout.VoteRequestStr, err)\n\t}\n\treturn nil\n}", "func (r *RTVCache) StopCron() {\n\tr.stop <- struct{}{}\n}", "func ParseWhen(spec string) (When, error) {\n\tspec = strings.TrimSpace(spec)\n\tif strings.HasPrefix(spec, \"@every \") {\n\t\tinterval, err := time.ParseDuration(spec[7:])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"When: invalid 'every' argument: '%s'\", spec[7:])\n\t\t}\n\t\treturn &when{spec: spec, every: interval}, nil\n\t}\n\n\tscheduler, err := CronSpecParser.Parse(spec)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tscheduler.Location = time.UTC\n\treturn &when{spec: spec, sched: scheduler}, nil\n}", "func (o OceanLaunchSpecSchedulingTaskOutput) CronExpression() pulumi.StringOutput {\n\treturn o.ApplyT(func(v OceanLaunchSpecSchedulingTask) string { return v.CronExpression }).(pulumi.StringOutput)\n}", "func (f *CronField) parsePossibleValues(s string) (vals []int, retErr error) {\n\tdefer func() {\n\t\tif retErr == nil && len(vals) == 0 {\n\t\t\tretErr = fmt.Errorf(\"No possible values\")\n\t\t}\n\t}()\n\n\tcommaParts := strings.Split(s, \",\")\n\tfor _, part := range commaParts {\n\t\tif ma := rangRe.FindStringSubmatch(part); len(ma) == 4 || len(ma) == 6 {\n\t\t\tif ma[1] == \"*\" { // \"*\" means first-last\n\t\t\t\tma[2] = strconv.Itoa(f.Min)\n\t\t\t\tma[3] = strconv.Itoa(f.Max)\n\t\t\t}\n\t\t\tstep := \"\"\n\t\t\tif len(ma) == 6 {\n\t\t\t\tstep = ma[5]\n\t\t\t}\n\n\t\t\tv, err := f.parseRange(ma[2], ma[3], step)\n\t\t\tif err != nil {\n\t\t\t\tretErr = err\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvals = append(vals, v...)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Single digit without range\n\t\tresult, err := f.parseNumeric(part)\n\t\tif err != nil {\n\t\t\tretErr = err\n\t\t\treturn\n\t\t}\n\n\t\tvals = append(vals, result)\n\t}\n\n\treturn\n}", "func (y *Yeelight) CronAdd(t, value string) string {\n\tcmd := `{\"id\":12,\"method\":\"cron_add\",\"params\":[` + t + `,` + value + `]}`\n\treturn y.request(cmd)\n}", "func NewCron() *cron {\n\tc := &cron{\n\t\ttasks: make(chan task),\n\t}\n\tgo c.loop()\n\treturn c\n}", "func newCronJobForCR(cr *v1alpha1.Copybird) *v1beta1.CronJob {\n\tlabels := map[string]string{\n\t\t\"app\": cr.Name,\n\t}\n\treturn &v1beta1.CronJob{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: cr.Name + \"-cronjob\",\n\t\t\tNamespace: cr.Namespace,\n\t\t\tLabels: labels,\n\t\t},\n\t\tSpec: v1beta1.CronJobSpec{\n\t\t\tSchedule: cr.Spec.Cron,\n\t\t\tJobTemplate: v1beta1.JobTemplateSpec{\n\t\t\t\tSpec: batchv1.JobSpec{\n\t\t\t\t\tTemplate: v1.PodTemplateSpec{\n\t\t\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\t\t\tName: cr.Name + \"-copybird\",\n\t\t\t\t\t\t\tNamespace: cr.Namespace,\n\t\t\t\t\t\t\tLabels: labels,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tSpec: v1.PodSpec{\n\t\t\t\t\t\t\tContainers: []v1.Container{\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tName: cr.Name,\n\t\t\t\t\t\t\t\t\tImage: \"copybird/copybird\",\n\t\t\t\t\t\t\t\t\tCommand: []string{},\n\t\t\t\t\t\t\t\t\tArgs: []string{},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tRestartPolicy: \"OnFailure\",\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}", "func (cli *Client) CronDelete(ctx context.Context, id string) error {\n\tv := url.Values{}\n\tresp, err := cli.delete(ctx, \"/crons/\"+id, v, nil)\n\tensureReaderClosed(resp)\n\treturn err\n}", "func NewCronFromJobSpec(\n\tjobSpec job.Job,\n\tpipelineRunner pipeline.Runner,\n) (*Cron, error) {\n\n\tcronSpec := jobSpec.CronSpec\n\tspec := jobSpec.PipelineSpec\n\n\tcronLogger := logger.CreateLogger(\n\t\tlogger.Default.With(\n\t\t\t\"jobID\", jobSpec.ID,\n\t\t\t\"schedule\", cronSpec.CronSchedule,\n\t\t),\n\t)\n\n\treturn &Cron{\n\t\tchDone: make(chan struct{}),\n\t\tchStop: make(chan struct{}),\n\t\tcronRunner: cronParser.New(),\n\t\tjobID: jobSpec.ID,\n\t\tlogger: cronLogger,\n\t\tpipelineRunner: pipelineRunner,\n\t\tpipelineSpec: *spec,\n\t\tSchedule: cronSpec.CronSchedule,\n\t}, nil\n}", "func InitCron() {\n\tc := cron.New()\n\tc.AddFunc(\"* * * * * *\", cronSpotify)\n\tgo c.Run()\n}", "func cronHandler(ctxt appengine.Context, w http.ResponseWriter, req *http.Request) {\n\tcron.RLock()\n\tlist := cron.list\n\tcron.RUnlock()\n\n\tforce := req.FormValue(\"force\") == \"1\"\n\n\t// We're being called by app engine master cron,\n\t// so look for new work to queue in tasks.\n\tnow := time.Now()\n\tvar old time.Time\n\terr := Transaction(ctxt, func(ctxt appengine.Context) error {\n\t\tif err := ReadMeta(ctxt, \"app.cron.time\", &old); err != nil && err != datastore.ErrNoSuchEntity {\n\t\t\treturn err\n\t\t}\n\t\tif !old.Before(now) {\n\t\t\treturn nil\n\t\t}\n\t\treturn WriteMeta(ctxt, \"app.cron.time\", now)\n\t})\n\tif err != nil { // already logged\n\t\treturn\n\t}\n\n\tctxt.Infof(\"cron %v -> %v\", old, now)\n\n\tfor _, cr := range list {\n\t\tif now.Round(cr.dt) != old.Round(cr.dt) || force {\n\t\t\tctxt.Infof(\"start cron %s\", cr.name)\n\t\t\tTask(ctxt, \"app.cron.\"+cr.name, \"cron\", cr.name)\n\t\t}\n\t}\n}", "func isCronJob(pod *v1.Pod) bool {\n\tfor _, ref := range pod.GetOwnerReferences() {\n\t\tif *ref.Controller {\n\t\t\treturn ref.Kind == protos.ModuleSpec_Job.String()\n\t\t}\n\t}\n\n\treturn false\n}", "func (m *AzureManagedControlPlane) validateScanInterval() field.ErrorList {\n\tvar allErrs field.ErrorList\n\tif ptr.Deref(m.Spec.AutoScalerProfile.ScanInterval, \"\") != \"\" {\n\t\tif !rScanInterval.MatchString(ptr.Deref(m.Spec.AutoScalerProfile.ScanInterval, \"\")) {\n\t\t\tallErrs = append(allErrs, field.Invalid(field.NewPath(\"Spec\", \"AutoscalerProfile\", \"ScanInterval\"), m.Spec.AutoScalerProfile.ScanInterval, \"invalid value\"))\n\t\t}\n\t}\n\treturn allErrs\n}", "func (m *IoArgoprojWorkflowV1alpha1CreateCronWorkflowRequest) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateCreateOptions(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateCronWorkflow(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (y *Yeelight) CronDel(t string) string {\n\tcmd := `{\"id\":14,\"method\":\"cron_del\",\"params\":[` + t + `]}`\n\treturn y.request(cmd)\n}", "func (c *checkCronjobImpl) CheckStatus(options CheckStatusOptions) icinga.Result {\n\tname := \"Cronjob.RunInterval\"\n\n\tjobLists, err := api.GetJobsByCronjob(c.Client, api.GetJobOptions{Name: c.Name, Namespace: c.Namespace})\n\tif err != nil {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"can't get jobLists from cronjob: %v\", err))\n\t}\n\n\tif len(jobLists.Items) == 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"No jobs found for [%s] in [%s]\", c.Name, c.Namespace))\n\t}\n\n\tjob := jobLists.Items[len(jobLists.Items)-1]\n\tjobNameParts := strings.Split(job.Name, \"-\")\n\tif jobNameParts[0] == \"\" || strings.Compare(jobNameParts[0], c.Name) != 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"No job found for Cronjob [%s] (job: [%s])\", c.Name, job.Name))\n\t}\n\n\tif job.Status.StartTime == nil {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"No job status (and start time) found for job [%s]\", job.Name))\n\t}\n\n\tstartTime, err := time.Parse(api.JOB_TIME_FORMAT, job.Status.StartTime.String())\n\tif err != nil {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"can't get start time from job [%s]: %v\", job.Name, err))\n\t}\n\n\tif job.Status.Active > 0 {\n\t\tpodRestarts, err := getPodRestarts(c.Client, job)\n\t\tif err != nil {\n\t\t\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"can't get pods for job [%s]: %v\", job.Name, err))\n\t\t}\n\t\tif podRestarts > 0 {\n\t\t\treturn icinga.NewResult(name, icinga.ServiceStatusCritical, fmt.Sprintf(\"Job [%s] has too many restarts [%d] since start time [%v]\", job.Name, podRestarts, startTime.String()))\n\t\t}\n\n\t\telapsedTime := time.Now().Second() - startTime.Second()\n\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusOk, fmt.Sprintf(\"Job [%s] running since %d seconds for Cronjob [%s]\", job.Name, elapsedTime, c.Name))\n\t}\n\n\tif job.Status.Failed > 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusCritical, fmt.Sprintf(\"Job [%s] failed for Cronjob [%s] at start time [%v]\", job.Name, c.Name, startTime.String()))\n\t}\n\n\tif job.Status.Succeeded > 0 {\n\t\treturn icinga.NewResult(name, icinga.ServiceStatusOk, fmt.Sprintf(\"Job [%s] succeeded for Cronjob [%s] at completion time [%v]\", job.Name, c.Name, job.Status.CompletionTime))\n\t}\n\n\treturn icinga.NewResult(name, icinga.ServiceStatusUnknown, fmt.Sprintf(\"Unknown running specs for job [%s] in Cronjob [%s] - [%v]\", job.Name, c.Name, job))\n}", "func (e *CronJob) parseSchedule() (*schedule.Schedule, error) {\n\tif e.cachedSchedule == nil && e.cachedScheduleErr == nil {\n\t\thash := fnv.New64()\n\t\thash.Write([]byte(e.JobID))\n\t\tseed := hash.Sum64()\n\t\te.cachedSchedule, e.cachedScheduleErr = schedule.Parse(e.effectiveSchedule(), seed)\n\t\tif e.cachedSchedule == nil && e.cachedScheduleErr == nil {\n\t\t\tpanic(\"no schedule and no error\")\n\t\t}\n\t}\n\treturn e.cachedSchedule, e.cachedScheduleErr\n}", "func TestCronBindingTrigger(t *testing.T) {\n\tconst appName = \"cronapp\"\n\tconst sidecarName = \"cron-sidecar\"\n\n\ttestMatrix := []cronTest{\n\t\t{\n\t\t\tcronName: \"cron1s\",\n\t\t\tschedule: \"@every 1s\", // Test macro cron format\n\t\t\texpectedTriggerCount: 10,\n\t\t\tstep: time.Second / 5,\n\t\t\ttestDuration: time.Second * 10,\n\t\t},\n\t\t{\n\t\t\tcronName: \"cron3s\",\n\t\t\tschedule: \"*/3 * * * * *\", // Test non-standard crontab format\n\t\t\texpectedTriggerCount: 10,\n\t\t\tstep: time.Second,\n\t\t\ttestDuration: time.Second * 30,\n\t\t},\n\t\t{\n\t\t\tcronName: \"cron15m\",\n\t\t\tschedule: \"*/15 * * * *\", // Test standard crontab format\n\t\t\texpectedTriggerCount: 12,\n\t\t\tstep: 30 * time.Second,\n\t\t\ttestDuration: time.Hour * 3,\n\t\t},\n\t\t{\n\t\t\tcronName: \"cron6h\",\n\t\t\tschedule: \"0 0 */6 ? * *\", // Test quartz cron format\n\t\t\texpectedTriggerCount: 12,\n\t\t\tstep: time.Minute,\n\t\t\ttestDuration: time.Hour * 24 * 3,\n\t\t},\n\t}\n\n\tfor _, cronTest := range testMatrix {\n\t\tt.Run(cronTest.cronName, func(t *testing.T) {\n\t\t\tcronTest.clk = clocktesting.NewFakeClock(startTime)\n\n\t\t\tports, _ := dapr_testing.GetFreePorts(3)\n\t\t\tgrpcPort := ports[0]\n\t\t\thttpPort := ports[1]\n\t\t\tappPort := ports[2]\n\n\t\t\ttestFn, triggeredCb := testerFn(cronTest.clk, cronTest.testDuration, cronTest.expectedTriggerCount, cronTest.step)\n\n\t\t\tflow.New(t, \"test cron trigger with different schedules\").\n\t\t\t\tStep(app.Run(appName,\n\t\t\t\t\tfmt.Sprintf(\":%d\", appPort),\n\t\t\t\t\tappWithTriggerCounter(t, cronTest.clk, cronTest.cronName, triggeredCb),\n\t\t\t\t)).\n\t\t\t\tStep(sidecar.Run(sidecarName,\n\t\t\t\t\tappend(componentRuntimeOptions(cronTest.clk),\n\t\t\t\t\t\tembedded.WithResourcesPath(\"./components\"),\n\t\t\t\t\t\tembedded.WithDaprGRPCPort(strconv.Itoa(grpcPort)),\n\t\t\t\t\t\tembedded.WithAppProtocol(protocol.HTTPProtocol, strconv.Itoa(appPort)),\n\t\t\t\t\t\tembedded.WithDaprHTTPPort(strconv.Itoa(httpPort)),\n\t\t\t\t\t)...,\n\t\t\t\t)).\n\t\t\t\tStep(\"run test\", testFn).\n\t\t\t\tStep(\"stop sidecar\", sidecar.Stop(sidecarName)).\n\t\t\t\tStep(\"stop app\", app.Stop(appName)).\n\t\t\t\tRun()\n\t\t})\n\t}\n}", "func cronFormat(t time.Time) string {\n\treturn fmt.Sprintf(\"%d %d %d %d %d *\", t.Second(), t.Minute(), t.Hour(), t.Day(), int(t.Month()))\n}", "func ValidateIntervalDatetime(fl validator.FieldLevel) bool {\n\t_, err := time.Parse(intervalDatetimeLayout, fl.Field().String())\n\treturn err == nil\n}", "func newCron(schedule string) (chan bool, *cron.Cron) {\n\tchannel := make(chan bool)\n\tcj := cron.New()\n\tcj.AddFunc(schedule, func() { cronTriggered(channel) })\n\tglog.Info(\"db backup schedule: \" + schedule)\n\treturn channel, cj\n}", "func (m *MegaCorp) cron() {\n\tt := time.NewTicker(60 * time.Second)\n\tfor _ = range t.C {\n\t\tfmt.Println(\"pay salary\")\n\t\tif time.Now().Day() == m.salaryPayDay {\n\t\t\tm.paySalaries()\n\t\t}\n\t}\n}", "func SetupCron() {\n\tc = cron.New()\n\tc.AddFunc(\"0 * * * *\", CheckIdleMinutes)\n\n\tc.AddFunc(\"@every 1m\", Cron1Minute)\n\n\tc.Start()\n}", "func ValidateToken(token string) error {\n\n\thour := token[0:2]\n\tiHour, err := strconv.Atoi(hour)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif iHour > 24 || iHour < 0 {\n\t\treturn fmt.Errorf((\"Invalid token hour\"))\n\t}\n\n\tmin := token[2:4]\n\tiMinute, err := strconv.Atoi(min)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif iMinute > 60 || iMinute < 0 {\n\t\treturn fmt.Errorf(\"Invalid token minute\")\n\t}\n\n\treturn nil\n}", "func TestIssue279CronJobDeletion(t *testing.T) {\n\tctx := framework.NewTestCtx(t)\n\tdefer ctx.Cleanup()\n\n\tnamespace, err := ctx.GetOperatorNamespace()\n\tif err != nil {\n\t\tt.Fatalf(\"could not get namespace: %v\", err)\n\t}\n\tif err = SetupRbacInNamespace(namespace); err != nil {\n\t\tt.Error(err)\n\t}\n\n\tdefer DumpJobsLogsOnError(t, framework.Global, namespace)\n\terr = framework.AddToFrameworkScheme(apis.AddToScheme, &gitopsv1alpha1.GitOpsConfigList{})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\teunomiaURI, found := os.LookupEnv(\"EUNOMIA_URI\")\n\tif !found {\n\t\teunomiaURI = \"https://github.com/kohlstechnology/eunomia\"\n\t}\n\teunomiaRef, found := os.LookupEnv(\"EUNOMIA_REF\")\n\tif !found {\n\t\teunomiaRef = \"master\"\n\t}\n\n\t// Step 1: create a CR with a Periodic trigger\n\n\tgitops := &gitopsv1alpha1.GitOpsConfig{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"GitOpsConfig\",\n\t\t\tAPIVersion: \"eunomia.kohls.io/v1alpha1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"gitops-issue279\",\n\t\t\tNamespace: namespace,\n\t\t\tFinalizers: []string{\n\t\t\t\t\"gitopsconfig.eunomia.kohls.io/finalizer\",\n\t\t\t},\n\t\t},\n\t\tSpec: gitopsv1alpha1.GitOpsConfigSpec{\n\t\t\tTemplateSource: gitopsv1alpha1.GitConfig{\n\t\t\t\tURI: eunomiaURI,\n\t\t\t\tRef: eunomiaRef,\n\t\t\t\tContextDir: \"test/e2e/testdata/empty-directory\",\n\t\t\t},\n\t\t\tParameterSource: gitopsv1alpha1.GitConfig{\n\t\t\t\tURI: eunomiaURI,\n\t\t\t\tRef: eunomiaRef,\n\t\t\t\tContextDir: \"test/e2e/testdata/empty-yaml\",\n\t\t\t},\n\t\t\tTriggers: []gitopsv1alpha1.GitOpsTrigger{\n\t\t\t\t{\n\t\t\t\t\tType: \"Periodic\",\n\t\t\t\t\tCron: \"*/1 * * * *\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tTemplateProcessorImage: \"quay.io/kohlstechnology/eunomia-base:dev\",\n\t\t\tResourceHandlingMode: \"Apply\",\n\t\t\tResourceDeletionMode: \"Delete\",\n\t\t\tServiceAccountRef: \"eunomia-operator\",\n\t\t},\n\t}\n\tgitops.Annotations = map[string]string{\"gitopsconfig.eunomia.kohls.io/initialized\": \"true\"}\n\n\terr = framework.Global.Client.Create(context.TODO(), gitops, &framework.CleanupOptions{TestContext: ctx, Timeout: timeout, RetryInterval: retryInterval})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Step 2: Wait until CronJob creates a Job, whose pod succeeds\n\n\t// Two minutes timeout to give cronjob enought time to kick off\n\terr = wait.Poll(retryInterval, time.Second*120, func() (done bool, err error) {\n\t\tconst name = \"gitopsconfig-gitops-issue279-\"\n\t\tpod, err := GetPod(t, namespace, name, \"quay.io/kohlstechnology/eunomia-base:dev\", framework.Global.KubeClient)\n\t\tswitch {\n\t\tcase apierrors.IsNotFound(err):\n\t\t\tt.Logf(\"Waiting for availability of %s pod\", name)\n\t\t\treturn false, nil\n\t\tcase err != nil:\n\t\t\treturn false, err\n\t\tcase pod != nil && pod.Status.Phase == \"Succeeded\":\n\t\t\treturn true, nil\n\t\tcase pod != nil:\n\t\t\tt.Logf(\"Waiting for pod %s to succeed\", pod.Name)\n\t\t\treturn false, nil\n\t\tdefault:\n\t\t\tt.Logf(\"Waiting for pod %s\", name)\n\t\t\treturn false, nil\n\t\t}\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Step 3: Change Periodic trigger to Webhook one in GitOpsConfig, and apply it\n\n\terr = framework.Global.Client.Get(context.TODO(), util.NN{Name: \"gitops-issue279\", Namespace: namespace}, gitops)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tgitops.Spec.Triggers = []gitopsv1alpha1.GitOpsTrigger{{Type: \"Webhook\"}}\n\terr = framework.Global.Client.Update(context.TODO(), gitops)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tt.Logf(\"GitOpsConfig successfully updated\")\n\n\t// Step 4: Wait for CronJob to be deleted\n\n\terr = wait.Poll(retryInterval, timeout, func() (done bool, err error) {\n\t\tconst name = \"gitopsconfig-gitops-issue279-\"\n\t\tcronJob, err := GetCronJob(namespace, name, framework.Global.KubeClient)\n\t\tswitch {\n\t\tcase apierrors.IsNotFound(err) || cronJob == nil:\n\t\t\tt.Logf(\"CronJob %s successfully deleted\", name)\n\t\t\treturn true, nil\n\t\tcase err != nil:\n\t\t\treturn false, err\n\t\tcase cronJob != nil:\n\t\t\tt.Logf(\"Waiting for cronJob %s to be deleted\", cronJob.Name)\n\t\t\treturn false, nil\n\t\tdefault:\n\t\t\tt.Logf(\"Waiting for cronJob %s to be deleted\", name)\n\t\t\treturn false, nil\n\t\t}\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n}", "func (o ElastigroupScheduledTaskOutput) CronExpression() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupScheduledTask) *string { return v.CronExpression }).(pulumi.StringPtrOutput)\n}", "func (o AssociationOutput) ApplyOnlyAtCronInterval() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *Association) pulumi.BoolPtrOutput { return v.ApplyOnlyAtCronInterval }).(pulumi.BoolPtrOutput)\n}", "func Cron(ctx cadence.Context, schedule *CronSchedule) error {\n\n\tcadence.GetLogger(ctx).Info(\"Cron started\", zap.Int(\"Count\", schedule.Count),\n\t\tzap.Duration(\"frequency\", schedule.Frequency), zap.Strings(\"groups\", schedule.Hostgroups))\n\n\tactivityCtx := cadence.WithActivityOptions(ctx, cadence.ActivityOptions{\n\t\tScheduleToStartTimeout: time.Minute,\n\t\tStartToCloseTimeout: 10 * time.Minute,\n\t\tHeartbeatTimeout: time.Minute,\n\t})\n\n\treturn runScheduler(ctx, activityCtx, schedule)\n}", "func CreateOrUpdate(ctx context.Context, c client.Client, cj *batchv1.CronJob, equal EqualityFunc, mutate MutateFunc) error {\n\tcurrent := &batchv1.CronJob{}\n\tkey := client.ObjectKey{Name: cj.Name, Namespace: cj.Namespace}\n\terr := c.Get(ctx, key, current)\n\tif err != nil {\n\t\tif apierrors.IsNotFound(err) {\n\t\t\terr = c.Create(ctx, cj)\n\n\t\t\tif err == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn kverrors.Wrap(err, \"failed to create cronjob\",\n\t\t\t\t\"name\", cj.Name,\n\t\t\t\t\"namespace\", cj.Namespace,\n\t\t\t)\n\t\t}\n\n\t\treturn kverrors.Wrap(err, \"failed to get cronjob\",\n\t\t\t\"name\", cj.Name,\n\t\t\t\"namespace\", cj.Namespace,\n\t\t)\n\t}\n\n\tif !equal(current, cj) {\n\t\terr := retry.RetryOnConflict(retry.DefaultRetry, func() error {\n\t\t\tif err := c.Get(ctx, key, current); err != nil {\n\t\t\t\treturn kverrors.Wrap(err, \"failed to get cronjob\",\n\t\t\t\t\t\"name\", cj.Name,\n\t\t\t\t\t\"namespace\", cj.Namespace,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tmutate(current, cj)\n\t\t\tif err := c.Update(ctx, current); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn kverrors.Wrap(err, \"failed to update cronjob\",\n\t\t\t\t\"name\", cj.Name,\n\t\t\t\t\"namespace\", cj.Namespace,\n\t\t\t)\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn nil\n}", "func (s ScheduledJob) validate() error {\n\tvar err error\n\tif err = s.ScheduledJobConfig.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = s.Workload.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = validateContainerDeps(validateDependenciesOpts{\n\t\tsidecarConfig: s.Sidecars,\n\t\timageConfig: s.ImageConfig.Image,\n\t\tmainContainerName: aws.StringValue(s.Name),\n\t\tlogging: s.Logging,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"validate container dependencies: %w\", err)\n\t}\n\tif err = validateExposedPorts(validateExposedPortsOpts{\n\t\tsidecarConfig: s.Sidecars,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"validate unique exposed ports: %w\", err)\n\t}\n\treturn nil\n}", "func ByCronSchedule(schedule string) ScheduleFunc {\n\ts, err := cron.Parse(schedule)\n\tif err != nil {\n\t\tpanic(\"parse cron spec fatal error: \" + err.Error())\n\t}\n\n\treturn func(ctx context.Context, job Job) Job {\n\t\treturn func(ctx context.Context) {\n\t\t\tnow := time.Now()\n\t\t\ttimer := time.NewTimer(s.Next(now).Sub(now))\n\t\t\tdefer timer.Stop()\n\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\treturn\n\t\t\t\tcase <-timer.C:\n\t\t\t\t\tjob(ctx)\n\t\t\t\t\tnow = time.Now()\n\t\t\t\t\ttimer.Reset(s.Next(now).Sub(now))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (o BeanstalkScheduledTaskOutput) CronExpression() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BeanstalkScheduledTask) *string { return v.CronExpression }).(pulumi.StringPtrOutput)\n}", "func (c Config) Validate() error {\n\tif len(c.ClientID) == 0 {\n\t\treturn fmt.Errorf(\"error: ClientID missing\")\n\t}\n\n\tif c.VodID < 1 {\n\t\treturn fmt.Errorf(\"error: VodID missing\")\n\t}\n\n\ttimePattern := `\\d+ \\d+ \\d+`\n\ttimeRegex := regexp.MustCompile(timePattern)\n\tif c.StartTime != \"start\" && !timeRegex.MatchString(c.StartTime) {\n\t\treturn fmt.Errorf(\"error: StartTime must be 'start' or in format '%s'; got '%s'\", timePattern, c.StartTime)\n\t}\n\tif c.EndTime == \"\" && c.Length == \"\" {\n\t\treturn errors.New(\"error: must specify either EndTime or Length\")\n\t}\n\tif c.Length == \"\" && c.EndTime != \"end\" && !timeRegex.MatchString(c.EndTime) {\n\t\treturn fmt.Errorf(\"error: EndTime must be 'end' or in format '%s'; got '%s'\", timePattern, c.EndTime)\n\t}\n\tif c.EndTime == \"\" && c.Length != \"full\" && !timeRegex.MatchString(c.Length) {\n\t\treturn fmt.Errorf(\"error: Length must be 'full' or in format '%s'; got '%s'\", timePattern, c.Length)\n\t}\n\n\tqualityPattern := `\\d{3,4}p[36]0`\n\tqualityRegex := regexp.MustCompile(qualityPattern)\n\tif c.Quality != \"best\" && c.Quality != \"chunked\" && !qualityRegex.MatchString(c.Quality) {\n\t\treturn fmt.Errorf(\"error: Quality must be 'best', 'chunked', or in format '%s'; got '%s'\", qualityPattern, c.Quality)\n\t}\n\n\tif c.FilePrefix != \"\" && !isValidFilename(c.FilePrefix) {\n\t\treturn fmt.Errorf(\"error: FilePrefix contains invalid characters; got '%s'\", c.FilePrefix)\n\t}\n\n\tif c.Workers < 1 {\n\t\treturn fmt.Errorf(\"error: Worker must be an integer greater than 0; got '%d'\", c.Workers)\n\t}\n\n\treturn nil\n}", "func (i *ImmediateCron) Start() {}", "func IsWorkValueValid(work string) bool {\n\treturn len(work) > 9\n}", "func (s *deploymentServer) createCronjob(ctx context.Context, manifest []byte, env []EnvVar, initVariables []EnvVar) error {\n\tdecoder := k8sYaml.NewYAMLOrJSONDecoder(bytes.NewReader(manifest), 1000)\n\n\tj := &apibatch.CronJob{}\n\n\tif err := decoder.Decode(&j); err != nil {\n\t\treturn err\n\t}\n\n\tif len(env) > 0 {\n\t\tcontainers := j.Spec.JobTemplate.Spec.Template.Spec.Containers\n\t\tapplyEnvironment(containers, env)\n\t}\n\n\tinitContainers := j.Spec.JobTemplate.Spec.Template.Spec.InitContainers\n\tif len(initContainers) > 0 {\n\t\tfmt.Println(\"job \" + j.Namespace + \".\" + j.Name + \" has initContainers\")\n\t\tapplyEnvironment(initContainers, initVariables)\n\t} else {\n\t\tfmt.Println(\"job \" + j.Namespace + \".\" + j.Name + \" has not initContainers; bug in config\")\n\t}\n\n\tbatchAPI := s.clientset.BatchV1beta1()\n\tapiJobs := batchAPI.CronJobs(j.Namespace)\n\n\tif _, err := apiJobs.Create(ctx, j, metav1.CreateOptions{}); err != nil {\n\t\treturn fmt.Errorf(\"job create error '%s'\", err.Error())\n\t}\n\treturn nil\n}", "func generateModularDailyCronSchedule(input []byte) string {\n\ta := big.NewInt(0).SetBytes(input)\n\tvar hi, mi big.Int\n\tm := mi.Mod(a, big.NewInt(60))\n\th := hi.Mod(a, big.NewInt(24))\n\treturn fmt.Sprintf(\"%d %d * * *\", m.Int64(), h.Int64())\n}", "func InitializeCronEngine() *cron.Cron {\n\tc := cron.New()\n\tc.Start()\n\treturn c\n}", "func main() {\n\n\ta := -1\n\n\tprintln(strconv.Itoa(a))\n\n\t// cr := time.Now()\n\tfmt.Println(time.Now().AddDate(0, 0, -1))\n\n\tfmt.Println(time.Now())\n\tc := cron.New()\n\tc.AddFunc(\"* * * * * ?\", func() { fmt.Println(\"Every 1 minutes\") })\n\tc.AddFunc(\"@hourly\", func() { fmt.Println(time.Now()) })\n\n\tc.Start()\n\n\t// select {}\n\ttime.Sleep(1e10)\n\t// for {\n\n\t// select {}\n\t// println(\"a\")\n\t// }\n\tprintln(\"End here\")\n\n\t// wg := &sync.WaitGroup{}\n\t// wg.Add(1)\n\n\t// cron := cron.New()\n\t// cron.AddFunc(\"* * * * * ?\", func() { println(\"heeee\") })\n\t// cron.Start()\n\t// defer cron.Stop()\n\n\t// // Give cron 2 seconds to run our job (which is always activated).\n\t// // select {\n\t// // case <-time.After(ONE_SECOND):\n\t// // \tprintln(\"aaaaa\")\n\t// // case <-wait(wg):\n\t// // \tprintln(\"hhhhhh\")\n\t// // }\n\n\t// select {}\n\n\t// for {\n\t// }\n\n}", "func Cron(name string, period time.Duration, f func(appengine.Context) error) {\n\tcron.Lock()\n\tdefer cron.Unlock()\n\tfor _, cr := range cron.list {\n\t\tif cr.name == name {\n\t\t\tpanic(\"app.Cron: multiple registrations for \" + name)\n\t\t}\n\t}\n\tcron.list = append(cron.list, cronEntry{name, period, f})\n}", "func LogCronStatus(c *cron.Cron) { //TODO add a cron to inspect cron jobs and log the outputs\n\n}", "func ParseInterval(s string) (i Interval, err error) {\n\tif len(s) < 3 {\n\t\terr = fmt.Errorf(\"string '%s' is too short\", s)\n\t\treturn\n\t}\n\n\tcomponents := strings.Split(s, \"/\")\n\tswitch len(components) {\n\tcase 1:\n\t\ti.Duration, err = ParseDuration(components[0])\n\t\treturn\n\tcase 2:\n\t\tif len(components[0]) < 3 {\n\t\t\terr = fmt.Errorf(\"parsing start: string '%s' is too short\", components[0])\n\t\t\treturn\n\t\t} else if components[0][0] == 'P' {\n\t\t\tif i.Duration, err = ParseDuration(components[0]); err != nil {\n\t\t\t\terr = fmt.Errorf(\"parsing start duration: %s\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tvar t time.Time\n\t\t\tif t, err = ParseTime(components[0]); err != nil {\n\t\t\t\terr = fmt.Errorf(\"parsing start datestamp: %s\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\ti.Start = &t\n\t\t}\n\n\t\tif len(components[1]) < 3 {\n\t\t\terr = fmt.Errorf(\"parsing end: string '%s' is too short\", components[1])\n\t\t\treturn\n\t\t} else if components[1][0] == 'P' {\n\t\t\tif i.Duration, err = ParseDuration(components[1]); err != nil {\n\t\t\t\terr = fmt.Errorf(\"parsing end duration: %s\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tvar t time.Time\n\t\t\tif t, err = ParseTime(components[1]); err != nil {\n\t\t\t\terr = fmt.Errorf(\"parsing end datestamp: %s\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\ti.End = &t\n\t\t}\n\n\t\tif i.Start != nil && i.End != nil {\n\t\t\ti.Duration = Duration{\n\t\t\t\t// TODO (b5): implement time.Duration to 8601 Period String\n\t\t\t\t// String\n\t\t\t\tDuration: i.End.Sub(*i.Start),\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\terr = fmt.Errorf(\"too many interval designators (slashes)\")\n\t\treturn\n\t}\n\treturn\n}", "func (s *TrafficOpsSessionThreadsafe) CRConfigValid(crc *tc.CRConfig, cdn string) error {\n\tif crc == nil {\n\t\treturn errors.New(\"CRConfig is nil\")\n\t}\n\tif crc.Stats.CDNName == nil {\n\t\treturn errors.New(\"CRConfig.Stats.CDN missing\")\n\t}\n\tif crc.Stats.DateUnixSeconds == nil {\n\t\treturn errors.New(\"CRConfig.Stats.Date missing\")\n\t}\n\n\t// Note this intentionally takes intended CDN, rather than trusting\n\t// crc.Stats\n\tlastCrc, lastCrcTime, lastCrcStats := s.lastCRConfig.Get(cdn)\n\n\tif lastCrc == nil {\n\t\treturn nil\n\t}\n\tif lastCrcStats.DateUnixSeconds == nil {\n\t\tlog.Warnln(\"TrafficOpsSessionThreadsafe.CRConfigValid returning no error, but last CRConfig Date was missing!\")\n\t\treturn nil\n\t}\n\tif lastCrcStats.CDNName == nil {\n\t\tlog.Warnln(\"TrafficOpsSessionThreadsafe.CRConfigValid returning no error, but last CRConfig CDN was missing!\")\n\t\treturn nil\n\t}\n\tif *lastCrcStats.CDNName != *crc.Stats.CDNName {\n\t\treturn errors.New(\"CRConfig.Stats.CDN \" + *crc.Stats.CDNName + \" different than last received CRConfig.Stats.CDNName \" + *lastCrcStats.CDNName + \" received at \" + lastCrcTime.Format(time.RFC3339Nano))\n\t}\n\tif *lastCrcStats.DateUnixSeconds > *crc.Stats.DateUnixSeconds {\n\t\treturn errors.New(\"CRConfig.Stats.Date \" + strconv.FormatInt(*crc.Stats.DateUnixSeconds, 10) + \" older than last received CRConfig.Stats.Date \" + strconv.FormatInt(*lastCrcStats.DateUnixSeconds, 10) + \" received at \" + lastCrcTime.Format(time.RFC3339Nano))\n\t}\n\treturn nil\n}", "func (ct *Chronicle) IsValid() (err error) {\n\tif utils.IsSet(ct.Aspectratio) {\n\t\tif _, _, err = parseAspectRatio(ct.Aspectratio); err != nil {\n\t\t\treturn templateErr(ct, err)\n\t\t}\n\t}\n\n\tif !utils.IsSet(ct.Description) {\n\t\treturn templateErrf(ct, \"Missing description\")\n\t}\n\n\tif err = ct.hasValidFlags(); err != nil {\n\t\treturn templateErr(ct, err)\n\t}\n\n\tif err = ct.Parameters.IsValid(); err != nil {\n\t\treturn templateErr(ct, err)\n\t}\n\n\tif err = ct.Canvas.IsValid(); err != nil {\n\t\treturn templateErr(ct, err)\n\t}\n\n\tif err = ct.Content.IsValid(&ct.Parameters, &ct.Canvas); err != nil {\n\t\treturn templateErr(ct, err)\n\t}\n\n\treturn nil\n}", "func ValidCacheDuration(duration string) bool {\n\telements := strings.Split(duration, \" \")\n\tseenDuration := false\n\n\tfor _, element := range elements {\n\t\tif element == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif statusCodeRegex.MatchString(element) {\n\t\t\tif seenDuration {\n\t\t\t\treturn false // code after duration\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif durationRegex.MatchString(element) {\n\t\t\tseenDuration = true\n\t\t}\n\t}\n\treturn seenDuration\n}", "func NewCronWorkflowSpec() *cronworkflowv1.CronWorkflowSpec {\n\treturn &cronworkflowv1.CronWorkflowSpec{\n\t\tSchedule: \"* * * * *\",\n\t\tConcurrencyPolicy: batchv2alpha1.AllowConcurrent,\n\t\tWorkflowTemplate: NewWorkflowTemplateSpec(),\n\t}\n}", "func (e *Exec) StopCron() {\n\te.Lock()\n\te.Cron.Stop()\n\te.Unlock()\n\te.WriteLog(e.Name + \" cron has stopped!\")\n}", "func (api *ConnpassAPI) HandlerCron(ctx context.Context) error {\n\tm := api.getSeriesIDMap()\n\ttl := []*taskqueue.Task{}\n\tfor k, _ := range m {\n\t\ttl = append(tl, &taskqueue.Task{\n\t\t\tPath: fmt.Sprintf(\"/api/queue/1/connpass/%v\", k),\n\t\t\tMethod: http.MethodGet,\n\t\t})\n\t}\n\t_, err := taskqueue.AddMulti(ctx, tl, \"connpass\")\n\tif err != nil {\n\t\tlog.Errorf(ctx, \"failed taskqueue.AddMulti err:%+v\", err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *ScheduleInstance) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateDaysOfWeek(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateDeletedAt(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEvents(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateName(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateParticipant(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateParticipants(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateScheduleID(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTimeZone(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateType(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func IsTimestampValid(t string) bool {\n\tre1 := regexp.MustCompile(`^[12]\\d{3}-[01]\\d{1}-[0-3]\\d{1}T[0-2]\\d{1}:[0-5]\\d{1}:[0-5]\\d{1}(\\.\\d{0,6})?Z$`)\n\t//re2 := regexp.MustCompile(`^[12]\\d{3}-[01]\\d{1}-[0-3]\\d{1}$`)\n\t//re3 := regexp.MustCompile(`^[12]\\d{3}$`)\n\tif re1.MatchString(t) {\n\t\treturn true\n\t}\n\t//else if re2.MatchString(t) {\n\t//\treturn true\n\t//} else if re3.MatchString(t) {\n\t//\treturn true\n\t//}\n\treturn false\n}", "func (t *dataType) Valid(val interface{}) error {\n\t// doing this here because this error should come from Valid instead of Format\n\t// which is easier for testing\n\tif t.cost != nil && *t.cost > bcrypt.MaxCost {\n\t\treturn bcrypt.InvalidCostError(*t.cost)\n\t}\n\n\t// convert to string and use the string datatype to validate any validators that hae been added\n\ts := val.(string)\n\treturn t.str.Valid(s)\n}", "func validatePromDurationStr(timeStr *string, fldPath *field.Path) field.ErrorList {\n\tallErrs := field.ErrorList{}\n\tif timeStr != nil {\n\t\tif _, err := model.ParseDuration(*timeStr); err != nil {\n\t\t\tallErrs = append(allErrs, field.Invalid(fldPath, timeStr, \"mush be a valid Prom time duration string, e.g. 2h\"))\n\t\t}\n\t}\n\treturn allErrs\n}", "func (t *Task) Valid() error {\n\tif t.Name == \"\" || t.Action == \"\" || t.ScheduledTime == \"\" {\n\t\treturn fmt.Errorf(\"name, action, and scheduled time required\")\n\t}\n\n\treturn nil\n}", "func Cron(\n\tctx context.Context,\n\tcanceler context.CancelFunc,\n\tcronExpression string,\n\tname string,\n\tdesc string,\n\tlogger Logger,\n\tkind daemon.Kind,\n\tdo DaemonJob,\n\tdepends ...string,\n) *ServiceDaemon {\n\treturn CronDaemon(\n\t\tctx,\n\t\tcanceler,\n\t\tcronExpression,\n\t\tdefaultLocation,\n\t\tdefaultCronParserOption,\n\t\tname,\n\t\tdesc,\n\t\tlogger,\n\t\tkind,\n\t\t\"\",\n\t\tdepends,\n\t\tdo,\n\t)\n}", "func (s *TestSuite) TestRegisterCrons(c *C) {\n\ttemp1 := &ProcessTemplate{\n\t\tCommand: \"/usr/local/bin/node\",\n\t\tArgs: []string{\n\t\t\t\"samples/longrunning.js\",\n\t\t},\n\t\tCron: \"* * * * * *\",\n\t\tName: \"asdf\",\n\t\t// LogFile: \"/tmp/crontest\",\n\t\tResetLog: true,\n\t}\n\n\tconfig := &Config{\n\t\tProcess: []*ProcessTemplate{\n\t\t\ttemp1,\n\t\t},\n\t}\n\n\tmanager := NewManager(config)\n\n\t// log.Println(manager.monitor)\n\tgo manager.Start()\n\n\tfor {\n\t\tif manager.Started {\n\t\t\tmanager.StartCrons()\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(100 * time.Millisecond)\n\t}\n\n\t// Make the crons are registered\n\n\tfor {\n\t\tselect {\n\t\tcase proc := <-manager.monitor:\n\t\t\t// fmt.Println(\"Got \", proc)\n\t\t\tc.Assert(proc.Template, Equals, temp1)\n\t\t\treturn\n\t\tdefault:\n\t\t\t// Wait a while before we check again\n\t\t\ttime.Sleep(100 * time.Millisecond)\n\t\t}\n\t}\n\n}", "func (m *VolumeEfficiencyPolicyInlineSchedule) Validate(formats strfmt.Registry) error {\n\treturn nil\n}" ]
[ "0.79615176", "0.74458677", "0.68224376", "0.6681811", "0.5889432", "0.58734566", "0.5814548", "0.57939744", "0.5617034", "0.55219054", "0.55017984", "0.5481706", "0.53538656", "0.5240428", "0.5230663", "0.5189", "0.5160228", "0.51555777", "0.51552075", "0.513699", "0.511997", "0.51128036", "0.5097093", "0.50845397", "0.5080069", "0.5074211", "0.50497186", "0.4991093", "0.49653816", "0.49602345", "0.49526602", "0.49477956", "0.4945042", "0.49067777", "0.48907492", "0.48854515", "0.48696297", "0.48427963", "0.48423466", "0.48141298", "0.48125467", "0.48113582", "0.48090157", "0.47947338", "0.47936046", "0.47902185", "0.47901732", "0.47868326", "0.47612342", "0.47497106", "0.47469208", "0.47419152", "0.47419068", "0.4728356", "0.47268543", "0.47259232", "0.47214565", "0.472101", "0.47130033", "0.4706984", "0.47025797", "0.4695774", "0.46953648", "0.46944815", "0.46919927", "0.46828926", "0.46551254", "0.46517465", "0.46413764", "0.4632472", "0.46236742", "0.46187335", "0.46074986", "0.46035877", "0.45989108", "0.45930025", "0.4592624", "0.4588227", "0.4585474", "0.4575618", "0.45701963", "0.45643288", "0.4553245", "0.45505053", "0.4550298", "0.45467445", "0.45441076", "0.45243824", "0.45141354", "0.4507356", "0.4496367", "0.44960782", "0.4492449", "0.44920117", "0.44855785", "0.4482424", "0.44821036", "0.4460212", "0.44600195", "0.4456846" ]
0.8333683
0
Handle executing the request and returning a response
func (fn PostSilencesHandlerFunc) Handle(params PostSilencesParams) middleware.Responder { return fn(params) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (h *Handler) Handle(payload *router.Payload, response *router.Response) {\n\tbody, err := ioutil.ReadAll(payload.Req.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\twholeRequest := &pluginRequestPayload{\n\t\tMethod: payload.Req.Method,\n\t\tPath: payload.Req.URL.Path,\n\t\tQueryString: payload.Req.URL.RawQuery,\n\t\tHeader: payload.Req.Header,\n\t\tBody: body,\n\t}\n\tinbytes, err := wholeRequest.Encode()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\toutbytes, err := h.Plugin.transport.RunHandler(payload.Context, h.Name, inbytes)\n\tlog.WithFields(logrus.Fields{\n\t\t\"name\": h.Name,\n\t\t\"err\": err,\n\t}).Debugf(\"Executed a handler with result\")\n\n\tif err != nil {\n\t\tswitch e := err.(type) {\n\t\tcase skyerr.Error:\n\t\t\tresponse.Err = e\n\t\tcase error:\n\t\t\tresponse.Err = skyerr.MakeError(err)\n\t\t}\n\t\treturn\n\t}\n\tresponsePayload := &pluginRequestPayload{}\n\tif err := responsePayload.Decode(outbytes); err != nil {\n\t\tresponse.Err = err\n\t}\n\n\tresponse.Meta = responsePayload.Header\n\tresponse.WriteHeader(responsePayload.Status)\n\tresponse.Write(responsePayload.Body)\n}", "func handleRequest(function func() (interface{}, error), functionName string, w http.ResponseWriter, r *http.Request) {\n\tlog.Info(\">>>>> \" + functionName)\n\tdefer log.Info(\"<<<<< \" + functionName)\n\n\tvar chapiResp Response\n\tvars := mux.Vars(r)\n\tid := vars[\"id\"]\n\n\terr := validateHost(id)\n\tif err != nil {\n\t\thandleError(w, chapiResp, err, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tdata, err := function()\n\tif err != nil {\n\t\thandleError(w, chapiResp, err, http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tchapiResp.Data = data\n\tjson.NewEncoder(w).Encode(chapiResp)\n}", "func (c *Sender) Do(r *http.Request) (*http.Response, error) {\n\tc.attempts++\n\n\tif !c.reuseResponse || c.resp == nil {\n\t\tresp := NewResponse()\n\t\tresp.Request = r\n\t\tresp.Body = NewBody(c.content)\n\t\tresp.Status = c.status\n\t\tresp.StatusCode = c.statusCode\n\t\tc.resp = resp\n\t} else {\n\t\tc.resp.Body.(*Body).reset()\n\t}\n\n\tif c.pollAttempts > 0 {\n\t\tc.pollAttempts--\n\t\tc.resp.Status = \"Accepted\"\n\t\tc.resp.StatusCode = http.StatusAccepted\n\t\tSetAcceptedHeaders(c.resp)\n\t}\n\n\tif c.emitErrors > 0 || c.emitErrors < 0 {\n\t\tc.emitErrors--\n\t\tif c.err == nil {\n\t\t\treturn c.resp, fmt.Errorf(\"Faux Error\")\n\t\t}\n\t\treturn c.resp, c.err\n\t}\n\treturn c.resp, nil\n}", "func (p *Server) handle(resp *http.Response) {\n\n\tdefer resp.Body.Close()\n\n\treqId := resp.Header.Get(\"Reqid\")\n\tif reqId == \"\" {\n\t\tlog.Warn(\"unidisvr: Reqid not found\")\n\t\treturn\n\t}\n\n\tb := bufio.NewReader(resp.Body)\n\treq, err := http.ReadRequest(b)\n\tif err != nil {\n\t\tlog.Warn(\"unidisvr: ReadRequest failed -\", p.Addr, p.BaseUrl, err)\n\t\treturn\n\t}\n\n\tw := newResponseWriter(p.BaseUrl, reqId)\n\tp.Handler.ServeHTTP(w, req)\n\terr = w.Done()\n\tif err != nil {\n\t\tlog.Warn(\"unidisvr: ServeHTTP failed -\", p.Addr, p.BaseUrl, err)\n\t}\n}", "func Handle(req gohttp.Request) (gohttp.Response, error) {\n\tvar err error\n\n\tlogrus.Info(\"Value of body: \", string(req.GetBody()))\n\n\tmessage := fmt.Sprintf(\"Body: %s\", string(req.GetBody()))\n\n\treturn gohttp.FunctionResponse{\n\t\tBody: []byte(message),\n\t\tStatusCode: http.StatusAccepted,\n\t\tHeader: http.Header{\"Content-Type\": []string{\"text/plain\"}}}, err\n}", "func (m *Messenger) handle(w http.ResponseWriter, r *http.Request) {\n\tif r.Method == \"GET\" {\n\t\tm.verifyHandler(w, r)\n\t\treturn\n\t}\n\n\tvar rec Receive\n\n\t// consume a *copy* of the request body\n\tbody, _ := ioutil.ReadAll(r.Body)\n\tr.Body = ioutil.NopCloser(bytes.NewBuffer(body))\n\n\terr := json.Unmarshal(body, &rec)\n\tif err != nil {\n\t\terr = xerrors.Errorf(\"could not decode response: %w\", err)\n\t\tfmt.Println(err)\n\t\tfmt.Println(\"could not decode response:\", err)\n\t\trespond(w, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif rec.Object != \"page\" {\n\t\tfmt.Println(\"Object is not page, undefined behaviour. Got\", rec.Object)\n\t\trespond(w, http.StatusUnprocessableEntity)\n\t\treturn\n\t}\n\n\tif m.verify {\n\t\tif err := m.checkIntegrity(r); err != nil {\n\t\t\tfmt.Println(\"could not verify request:\", err)\n\t\t\trespond(w, http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t}\n\n\tm.dispatch(rec)\n\n\trespond(w, http.StatusAccepted) // We do not return any meaningful response immediately so it should be 202\n}", "func (s *SideTwistHandler) handleResponse(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tguid, ok := vars[\"identifier\"]\n\tif !ok {\n\t\tlogger.Error(\"Identifier not included in POST request to /search/{identifier}\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(serverErrMsg))\n\t\treturn\n\t}\n\tpostBody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlogger.Error(fmt.Sprintf(\"Failed to read POST body: %s\", err.Error()))\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(serverErrMsg))\n\t\treturn\n\t}\n\tresponse, err := s.processAndForwardImplantOutput(guid, postBody)\n\tif err != nil {\n\t\tlogger.Error(fmt.Sprintf(\"Failed to process and forward task output: %s\", err.Error()))\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(serverErrMsg))\n\t\treturn\n\t}\n\tlogger.Success(response)\n\tfmt.Fprint(w, \"\")\n}", "func handleRequest(request *http.Request, t http.RoundTripper) (rsp *http.Response) {\n\tvar err error\n\n\tif rsp, err = t.RoundTrip(request); err != nil {\n\t\tlog.Println(\"Request failed:\", err)\n\t}\n\n\treturn\n}", "func Handle(rw http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(rw, \"response\")\n}", "func (h *myHandler) Handle(ctx context.Context, c *jsonrpc2.Conn, r *jsonrpc2.Request) {\n\tswitch r.Method {\n\tcase \"sayHello\":\n\t\tif err := c.Reply(ctx, r.ID, \"hello world\"); err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\tdefault:\n\t\terr := &jsonrpc2.Error{Code: jsonrpc2.CodeMethodNotFound, Message: \"Method not found\"}\n\t\tif err := c.ReplyWithError(ctx, r.ID, err); err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n}", "func HandleRequest(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\t_, _ = pretty.Println(\"parsed:\", request.Body)\n\treturn events.APIGatewayProxyResponse{Body: \"response is working\", StatusCode: 200}, nil\n}", "func requestHandler(w http.ResponseWriter, r *http.Request) {\n\tw.WriteHeader(200)\n\tfmt.Fprintf(w, \"%s\", buildResponse())\n}", "func (g *HTTPGateway) Execute(req *retryablehttp.Request) ([]byte, error) {\n\tif g.Profile.AWS != nil {\n\t\t//sign request\n\t\tif err := signer.SignRequest(req, *g.Profile.AWS, signer.GetV4Signer); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tresponse, err := g.Client.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\terr := response.Body.Close()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}()\n\tif err = g.isValidResponse(response); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ioutil.ReadAll(response.Body)\n}", "func Handle(ctx context.Context, res http.ResponseWriter, req *http.Request) {\n\n\tres.Header().Add(\"Content-Type\", \"text/plain\")\n\tres.WriteHeader(200)\n\n\t_, err := fmt.Fprintf(res, \"HELLO GO FUNCTION\\n\")\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"error or response write: %v\", err)\n\t}\n}", "func (e *Exchange) Handle(w http.ResponseWriter, r *http.Request) {\n\tdata, err := read(r)\n\tcommon.HandleError(w, err, \"could not read request data\")\n\tqry, err := query.ParseTokenQuery(string(data))\n\tcommon.HandleError(w, err, \"could not parse token request form data\")\n\tif !qry.IsValid() {\n\t\tcommon.HandleError(w, errors.New(string(data)), \"query form data is invalid\")\n\t}\n\tif qry.Mode == query.AuthorizationCodeMode {\n\t\te.code(w, r, qry)\n\t}\n\tif qry.Mode == query.RefreshTokenMode {\n\t\te.refresh(w, r, qry)\n\t}\n}", "func (r *analyticsDeferredResultHandle) executeHandle(req *gocbcore.HttpRequest, valuePtr interface{}) error {\n\tresp, err := r.provider.DoHttpRequest(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tjsonDec := json.NewDecoder(resp.Body)\n\terr = jsonDec.Decode(valuePtr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = resp.Body.Close()\n\tif err != nil {\n\t\tlogDebugf(\"Failed to close socket (%s)\", err)\n\t}\n\n\treturn nil\n}", "func (r *Request) Execute() (*Response, error) {\n\treturn r.sendRequest()\n}", "func (proxy *proxyService) handleRequest(\n\tw gohttp.ResponseWriter, r *gohttp.Request,\n) {\n\tlogger := proxy.logger\n\n\t// Per the stdlib docs, \"It is an error to set this field in an HTTP client\n\t// request\". Therefore, we ensure it is empty in case the client set it.\n\tr.RequestURI = \"\"\n\n\t// Send request to target service\n\n\tresp, err := proxy.transport.RoundTrip(r)\n\tif err != nil {\n\t\tlogger.Debugf(\"Error: %v\\n\", err)\n\t\tgohttp.Error(w, err.Error(), 503)\n\t\treturn\n\t}\n\n\t// Send response to client (everything below)\n\n\tlogger.Debugf(\"Received response status: %s\\n\", resp.Status)\n\n\tcopyHeaders(w.Header(), resp.Header)\n\n\tw.WriteHeader(resp.StatusCode)\n\n\t_, err = io.Copy(w, resp.Body)\n\tif err != nil {\n\t\tlogger.Errorf(\"Can't write response to body: %s\\n\", err)\n\t}\n\n\terr = resp.Body.Close()\n\tif err != nil {\n\t\tlogger.Debugf(\"Can't close response body %v\\n\", err)\n\t}\n}", "func (h *Handler) Handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) {\n\tif resp, err := h.handle(req.Method, req.Params); err != nil {\n\t\t// check if the error is a jsonrpc error\n\t\tjsonerr, ok := err.(*jsonrpc2.Error)\n\n\t\tif !ok {\n\t\t\t// if it's not a jsonrpc error then create a CodeInternalError\n\t\t\tjsonerr = &jsonrpc2.Error{\n\t\t\t\tCode: jsonrpc2.CodeInternalError,\n\t\t\t\tMessage: fmt.Sprintf(\"%s\", err),\n\t\t\t}\n\t\t}\n\n\t\tif err := conn.ReplyWithError(ctx, req.ID, jsonerr); err != nil {\n\t\t\tlog.Error(\"Failed to send error response: %s\", err)\n\t\t}\n\t} else if resp != nil {\n\t\tif err := conn.Reply(ctx, req.ID, resp); err != nil {\n\t\t\tlog.Error(\"Failed to send response: %s\", err)\n\t\t}\n\t}\n}", "func (c *Client) HandleRequest(req *http.Request) (res *http.Response, err error) {\n\treq.URL.Path = \"/api/v\" + c.APIVersion + req.URL.Path\n\n\t// Fill out Host and Scheme if it is empty\n\tif req.URL.Host == \"\" {\n\t\treq.URL.Host = c.URLHost\n\t}\n\tif req.URL.Scheme == \"\" {\n\t\treq.URL.Scheme = c.URLScheme\n\t}\n\tif req.Header.Get(\"User-Agent\") == \"\" {\n\t\treq.Header.Set(\"User-Agent\", c.UserAgent)\n\t}\n\tif req.Header.Get(\"Authorization\") == \"\" {\n\t\treq.Header.Set(\"Authorization\", \"Bot \"+c.Token)\n\t}\n\n\tres, err = c.HTTP.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif res.StatusCode == http.StatusUnauthorized {\n\t\terr = errors.New(\"Invalid token passed\")\n\t\treturn\n\t}\n\n\treturn\n}", "func (crawl *Crawl) Execute(req *Request) (resp *Response, err error) {\n\t// Make request\n\tresp, err = crawl.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// If request.Raw is not true - parse html\n\tif !req.Raw {\n\t\terr = resp.ParseHTML()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Set request context if empty\n\tif req.Context == nil {\n\t\treq.Context = context.Background()\n\t}\n\n\t// ctx = context.WithValue(ctx, \"crawl\", crawl)\n\t// ctx = context.WithValue(ctx, \"response\", resp)\n\n\t// Run handlers\n\tfor _, cb := range req.Callbacks {\n\t\tif handler := crawl.GetHandler(cb); handler != nil {\n\t\t\terr = handler(req.Context, crawl, resp)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Warningf(\"Handler %v was not found\", cb)\n\t\t}\n\t}\n\n\tlog.V(2).Infof(\"%s %s %s - %v\", req.GetMethod(), resp.GetStatus(), resp.GetURL(), req.Callbacks)\n\n\treturn\n}", "func HandleRequest(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\t// TODO: check for cookie\n\n\tdb, err := episodic.NewDataBucket(os.Getenv(\"DATA_BUCKET\"), \"data.json\")\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 500}, err\n\t}\n\n\tdata, err := db.Get()\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 500}, err\n\t}\n\n\tidStr, ok := req.QueryStringParameters[\"id\"]\n\tif !ok {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 500}, errors.New(\"no id param found in query string\")\n\t}\n\n\tid, err := strconv.Atoi(idStr)\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 500}, err\n\t}\n\n\tif data, err = db.RemoveEpisode(id); err != nil {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 500}, err\n\t}\n\n\tsort.Sort(episodic.ByAirDate(data.WatchList))\n\n\tjsonStr, err := json.Marshal(&Response{WatchList: data.WatchList})\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 500}, err\n\t}\n\n\treturn events.APIGatewayProxyResponse{\n\t\tStatusCode: 200,\n\t\tHeaders: map[string]string{\n\t\t\t\"content-type\": \"application/json\",\n\t\t\t\"access-control-allow-origin\": \"*\",\n\t\t},\n\t\tBody: string(jsonStr),\n\t}, nil\n}", "func Handle(m modules.Context, rc *modules.RequestContext, r *radius.Request, _ modules.Middleware) (*modules.Response, error) {\n\tctx, ok := m.(moduleContext)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unable to obtain context\")\n\t}\n\n\t// Currently only handling authorization requests - we have roadmap tasks to support full v2 integration T64414814\n\t// When we'll have v2 support we can remove the hand crafted json packet\n\tjsonPacket := map[string]map[string]interface{}{\n\t\t\"Called-Station-Id\": {\"type\": \"string\", \"value\": []string{normalize(rfc2865.CalledStationID_GetString(r.Packet))}},\n\t\t\"Calling-Station-Id\": {\"type\": \"string\", \"value\": []string{normalize(rfc2865.CallingStationID_GetString(r.Packet))}},\n\t\t\"NAS-Identifier\": {\"type\": \"string\", \"value\": []string{rfc2865.NASIdentifier_GetString(r.Packet)}},\n\t}\n\t// If no nas ip address is specified then no field will be sent\n\tif rfc2865.NASIPAddress_Get(r.Packet) != nil {\n\t\tjsonPacket[\"NAS-IP-Address\"] =\n\t\t\tmap[string]interface{}{\"type\": \"string\", \"value\": []string{rfc2865.NASIPAddress_Get(r.Packet).String()}}\n\t}\n\tencodedMsg, err := json.Marshal(jsonPacket)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to marshal radius packet: %w\", err)\n\t}\n\treq, err := http.NewRequest(http.MethodPost, ctx.URI, bytes.NewReader(encodedMsg))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Add(\"Authorization\", \"Bearer \"+ctx.AccessToken)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresp, err := ctx.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error sending response to endpoint: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\trc.Logger.Debug(\"got response\", zap.String(\"status\", resp.Status),\n\t\tzap.String(\"url\", resp.Request.URL.String()),\n\t\tzap.Any(\"request\", r.Packet.Attributes),\n\t\tzap.String(\"Called-Station-Id\", rfc2865.CalledStationID_GetString(r.Packet)),\n\t\tzap.String(\"Calling-Station-Id\", rfc2865.CallingStationID_GetString(r.Packet)),\n\t\tzap.String(\"NAS-Identifier\", rfc2865.NASIdentifier_GetString(r.Packet)))\n\n\tif resp.StatusCode != http.StatusOK {\n\t\trc.Logger.Error(\"bad status code\",\n\t\t\tzap.Int(\"status\", resp.StatusCode),\n\t\t\tzap.String(\"url\", resp.Request.URL.String()))\n\t\treturn nil, fmt.Errorf(\"error processing message by endpoint. Response status %d\", resp.StatusCode)\n\t}\n\tvar endPointResponse EndpointResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&endPointResponse); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to decode endpoint response: %w\", err)\n\t}\n\n\tif len(endPointResponse.Auth) == 0 {\n\t\treturn nil, fmt.Errorf(\"malformed auth response: no acceptance code\")\n\t}\n\tvar p *radius.Packet\n\tswitch endPointResponse.Auth[0] {\n\tcase acceptCode:\n\t\tp = r.Response(radius.CodeAccessAccept)\n\tcase rejectCode:\n\t\tp = r.Response(radius.CodeAccessReject)\n\t}\n\n\tresponse := &modules.Response{\n\t\tCode: p.Code,\n\t\tAttributes: p.Attributes,\n\t}\n\treturn response, nil\n}", "func (r *relay) handleRequest(reqId uint64, req []byte) {\n\trep := r.handler.HandleRequest(req)\n\tif err := r.sendReply(reqId, rep); err != nil {\n\t\tlog.Printf(\"iris: failed to send reply: %v.\", err)\n\t}\n}", "func httpHandler(w http.ResponseWriter, r *http.Request) {\n\tb, err := ioutil.ReadAll(r.Body)\n\tdefer r.Body.Close()\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\treq := json.GetRPCRequestFromJSON(string(b))\n\trespBody, statusCode := handler(req)\n\tw.WriteHeader(statusCode)\n\tw.Write([]byte(respBody))\n}", "func Handle(ctx context.Context, requestEnv *alexa.RequestEnvelope) (interface{}, error) {\n\treturn a.ProcessRequest(ctx, requestEnv)\n}", "func (c *Client) Execute(ctx context.Context, req *http.Request, r interface{}) (*http.Response, error) {\n\treq = req.WithContext(ctx)\n\tdebugReq(req)\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\t// If we got an error, and the context has been canceled,\n\t\t// the context's error is probably more useful.\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, ctx.Err()\n\t\tdefault:\n\t\t}\n\n\t\t// If the error type is *url.Error, sanitize its URL before returning.\n\t\tif e, ok := err.(*url.Error); ok {\n\t\t\tif url, err := url.Parse(e.URL); err == nil {\n\t\t\t\te.URL = sanitizeURL(url).String()\n\t\t\t\treturn nil, e\n\t\t\t}\n\t\t}\n\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 && resp.StatusCode != 201 {\n\t\treturn nil, fmt.Errorf(\"Request to %s responded with status %d\", req.URL, resp.StatusCode)\n\t}\n\n\tif r != nil {\n\t\tif w, ok := r.(io.Writer); ok {\n\t\t\tio.Copy(w, resp.Body)\n\t\t} else {\n\t\t\tdecErr := json.NewDecoder(resp.Body).Decode(r)\n\t\t\tif decErr == io.EOF {\n\t\t\t\tdecErr = nil // ignore EOF errors caused by empty response body\n\t\t\t}\n\t\t\tif decErr != nil {\n\t\t\t\terr = decErr\n\t\t\t}\n\t\t}\n\t}\n\n\treturn resp, err\n}", "func (this *HTTPHandler) handle(req Request) Response {\n\tname := resources.NewObjectName(req.Namespace, req.Name)\n\tlogctx := this.NewContext(\"object\", name.String())\n\tlogctx.Infof(\"handle request for %s\", req.Resource)\n\tresp := this.webhook.Handle(logctx, req)\n\tif err := resp.Complete(req); err != nil {\n\t\tlogctx.Error(err, \"unable to encode response\")\n\t\treturn ErrorResponse(http.StatusInternalServerError, errUnableToEncodeResponse)\n\t}\n\treturn resp\n}", "func (Executor) Handle(w http.ResponseWriter, req *http.Request) {\n\tlogger.Logging(logger.DEBUG)\n\tdefer logger.Logging(logger.DEBUG, \"OUT\")\n\n\tswitch reqUrl := req.URL.Path; {\n\tcase strings.Contains(reqUrl, url.Unregister()):\n\t\tapiInnerExecutor.unregister(w, req)\n\t}\n}", "func handleRequest(resp *http.Response, err error) () {\n if err != nil {\n log.Fatal(err)\n }\n defer resp.Body.Close()\n\n // Dump response\n data, err := ioutil.ReadAll(resp.Body)\n if err != nil {\n log.Fatal(err)\n }\n fmt.Println(string(data))\n}", "func Handler(rc *Context, s storage.Store, storeExecutor kvs) {\r\n\r\n\t// Make sure all resources are cleanup after leaving\r\n\tcancelFunc := rc.CtxCancel\r\n\tdefer cancelFunc()\r\n\r\n\t// Err channel shared across\r\n\terrc := make(chan error, 1)\r\n\r\n\t// Execution call\r\n\tout := make(chan interface{}, 1)\r\n\r\n\tgo func() {\r\n\t\tdefer close(out)\r\n\t\tdefer close(errc)\r\n\r\n\t\tinb := <-httpExtractor(rc, errc)\r\n\r\n\t\tlogging.MsgFields(\r\n\t\t\trc.uID,\r\n\t\t\t\"HttpExtractor\",\r\n\t\t\tlogging.Input,\r\n\t\t\tlogging.Field{{logging.Payload, inb}})\r\n\r\n\t\tif rc.Cancelled() {\r\n\t\t\tlogging.Msg(\r\n\t\t\t\trc.uID,\r\n\t\t\t\t\"Handler\",\r\n\t\t\t\tlogging.Cancelled,\r\n\t\t\t\t\"kvs execution was cancelled from another goroutine\")\r\n\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tres, err := storeExecutor(s, inb)\r\n\r\n\t\tif err != nil {\r\n\t\t\terrc <- err\r\n\t\t\tcancelFunc()\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tselect {\r\n\t\tcase out <- res:\r\n\t\tcase <-rc.Ctx.Done():\r\n\t\t\treturn\r\n\t\t}\r\n\t}()\r\n\r\n\tHTTPResponse(rc, out, errc)\r\n}", "func Handler(ctx context.Context) (response Response, err error) {\n\n\tres, err := Worker()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tjsonRes, err := json.Marshal(res)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresponse = Response{\n\t\tStatusCode: 200,\n\t\tIsBase64Encoded: false,\n\t\tBody: string(jsonRes),\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t}\n\n\treturn\n}", "func (q *eventQ) handleRequest(req *protocol.Request) (*protocol.Response, error) {\n\tvar resp *protocol.Response\n\tvar err error\n\tinternal.Debugf(q.conf, \"request: %s\", &req.Name)\n\n\tswitch req.Name {\n\tcase protocol.CmdBatch:\n\t\tresp, err = q.handleBatch(req)\n\t\tinstrumentRequest(stats.BatchRequests, stats.BatchErrors, err)\n\tcase protocol.CmdRead:\n\t\tresp, err = q.handleRead(req)\n\t\tinstrumentRequest(stats.ReadRequests, stats.ReadErrors, err)\n\tcase protocol.CmdTail:\n\t\tresp, err = q.handleTail(req)\n\t\tinstrumentRequest(stats.TailRequests, stats.TailErrors, err)\n\tcase protocol.CmdStats:\n\t\tresp, err = q.handleStats(req)\n\t\tinstrumentRequest(stats.StatsRequests, stats.StatsErrors, err)\n\tcase protocol.CmdClose:\n\t\tresp, err = q.handleClose(req)\n\t\tinstrumentRequest(stats.CloseRequests, stats.CloseErrors, err)\n\tcase protocol.CmdConfig:\n\t\tresp, err = q.handleConfig(req)\n\t\tinstrumentRequest(stats.ConfigRequests, stats.ConfigErrors, err)\n\tdefault:\n\t\tlog.Printf(\"unhandled request type passed: %v\", req.Name)\n\t\tresp = req.Response\n\t\tcr := req.Response.ClientResponse\n\t\tcr.SetError(protocol.ErrInvalid)\n\t\terr = protocol.ErrInvalid\n\t\tif _, werr := req.WriteResponse(resp, cr); werr != nil {\n\t\t\terr = werr\n\t\t}\n\t}\n\n\treturn resp, err\n}", "func (c *Client) execute(req *Request) (string, bool, error) {\n\tdefer timeTrack(time.Now(), \"Executing\")\n\n\tres := &Response{}\n\n\tswitch req.method {\n\n\tcase \"websocket\":\n\t\trequestID++\n\t\treq.body.Set(requestID, \"id\")\n\n\t\terr := c.wsClient.WriteJSON(req.body)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"ERROR >> %s\\n\", err)\n\t\t}\n\n\t\t_, message, _ := c.wsClient.ReadMessage()\n\t\tif len(string(message)) > 0 {\n\t\t\tres.Parse(req, message)\n\t\t\treturn string(message), true, nil\n\t\t}\n\n\t\treturn string(message), true, nil\n\n\tcase \"post\":\n\t\tif isNil(req.body) {\n\t\t\tresp, err := c.httpClient.R().Post(req.urlPath)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"ERROR >> %s\", err)\n\t\t\t}\n\n\t\t\tif resp.StatusCode() != 200 && resp.StatusCode() != 201 {\n\t\t\t\tlog.Fatalf(\"PARSE ERROR HERE >> %s\", err)\n\t\t\t}\n\t\t\tres.OK = true\n\t\t\tres.Parse(req, resp.Body())\n\t\t} else {\n\t\t\tresp, err := c.httpClient.R().SetBody(req.body).Post(req.urlPath)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"ERROR >> %s\", err)\n\t\t\t}\n\t\t\tif resp.StatusCode() != 200 && resp.StatusCode() != 201 {\n\t\t\t\tlog.Fatalf(\"PARSE ERROR HERE >> %s\", err)\n\t\t\t}\n\t\t\tres.OK = true\n\t\t\tres.Parse(req, resp.Body())\n\t\t}\n\t\treturn \"\", true, nil\n\n\tcase \"get\":\n\t\tresp, err := c.httpClient.R().Get(req.urlPath)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"ERROR >> %s\", err)\n\t\t}\n\t\tif resp.StatusCode() != 200 {\n\t\t\tlog.Fatalf(\"PARSE ERROR HERE >> %s\", err)\n\t\t}\n\t\tres.OK = true\n\t\tres.Parse(req, resp.Body())\n\n\t\treturn string(resp.Body()), true, nil\n\n\tdefault:\n\t\treturn \"\", false, errors.New(\"Something went wrong\")\n\t}\n}", "func HandleRequest(w http.ResponseWriter, req *http.Request) {\n\trequest := &Request{id: atomic.AddUint64(&counter, 1), response: w, request: req}\n\n\trequests <- request\n\n\tfor {\n\t\tselect {\n\t\tcase result := <-results:\n\t\t\tlogger.Println(result)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (res *Resource) HandleRequest(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != http.MethodGet && r.Method != http.MethodHead {\n\t\thandleMethodNotAllowed(w, r)\n\t\treturn\n\t}\n\n\treader := bytes.NewReader(res.Content)\n\thttp.ServeContent(w, r, res.FileName, res.ModTime, reader)\n}", "func (c *controllerImplement) Handle(w http.ResponseWriter, r *http.Request) {\n\tc.branchByMethod(w, r)\n}", "func (c ControlHandlerFunc) Handle(req Request, res *Response) error {\n\t*res = c(req)\n\treturn nil\n}", "func (h *Handler) Handle(c *gin.Context) {\n\tvar req Request\n\terr := c.BindJSON(&req)\n\tif err != nil {\n\t\treturn\n\t}\n\tresp := h.process(c, &req)\n\tc.JSON(http.StatusOK, resp)\n}", "func (Executor) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tlogger.Logging(logger.DEBUG, \"receive msg\", req.Method, req.URL.Path)\n\tdefer logger.Logging(logger.DEBUG, \"OUT\")\n\n\tswitch reqUrl := req.URL.Path; {\n\tdefault:\n\t\tlogger.Logging(logger.DEBUG, \"Unknown URL\")\n\t\tcommon.MakeErrorResponse(w, errors.NotFoundURL{reqUrl})\n\n\tcase !(strings.Contains(reqUrl, (url.Base()+url.Management())) ||\n\t\tstrings.Contains(reqUrl, (url.Base()+url.Monitoring())) ||\n\t\tstrings.Contains(reqUrl, (url.Base()+url.Notification()))):\n\t\tlogger.Logging(logger.DEBUG, \"Unknown URL\")\n\t\tcommon.MakeErrorResponse(w, errors.NotFoundURL{reqUrl})\n\n\tcase strings.Contains(reqUrl, url.Unregister()):\n\t\thealthAPIExecutor.Handle(w, req)\n\n\tcase strings.Contains(reqUrl, url.Management()) &&\n\t\tstrings.Contains(reqUrl, url.Apps()):\n\t\tdeploymentAPIExecutor.Handle(w, req)\n\n\tcase strings.Contains(reqUrl, url.Resource()):\n\t\tresourceAPIExecutor.Handle(w, req)\n\n\tcase strings.Contains(reqUrl, url.Configuration()):\n\t\tconfigurationAPIExecutor.Handle(w, req)\n\n\tcase strings.Contains(reqUrl, url.Device()):\n\t\tdeviceAPIExecutor.Handle(w, req)\n\n\tcase strings.Contains(reqUrl, url.Notification()):\n\t\tnotificationAPIExecutor.Handle(w, req)\n\t}\n}", "func (task *TaskType) RunHandler() (interface{}, error) {\n\tvar response interface{}\n\tvar err error\n\n\tresponse, err = requestHandler[task.Name](task)\n\n\tutils.Log.Info(fmt.Sprintf(\"Proccessing of task %s completed\", task.Name))\n\n\tif err != nil {\n\t\tutils.Log.Error(fmt.Sprintf(\"Failed to process request: %s: \", task.Name), err)\n\t\treturn nil, err\n\t}\n\n\treturn response, nil\n}", "func Handle(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase http.MethodGet:\n\t\tauth(w, r)\n\tcase http.MethodPost:\n\t\tregister(w, r)\n\tdefault:\n\t\tw.WriteHeader(http.StatusNotImplemented)\n\t}\n}", "func (c *HTTPClient) Do(ctx context.Context, method string, path string, params map[string]string, data interface{}, result interface{}) (statusCode int, err error) {\n\tc.l.Lock()\n\tdefer c.l.Unlock()\n\n\treq, err := c.prepareRequest(method, path, params, data)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn c.do(ctx, req, result, true, true, false)\n}", "func (req *Request) ExecuteRequest(client *http.Client) datastructure.Response {\n\tvar response datastructure.Response\n\tvar start = time.Now()\n\tvar err error\n\n\tif client == nil {\n\t\tclient = http.DefaultClient\n\t}\n\n\tlog.Debug(\"ExecuteRequest | Executing request ...\")\n\t//client := &http.Client{Transport: req.Tr, Timeout: req.Timeout}\n\treq.Tr.DisableKeepAlives = true\n\tclient.Transport = req.Tr\n\tclient.Timeout = req.Timeout\n\tlog.Debugf(\"Request: %+v\\n\", req.Req)\n\tlog.Debugf(\"Client: %+v\\n\", client)\n\n\t// If content length was not specified (only for POST) add an headers with the length of the request\n\tif req.Method == \"POST\" && req.Req.Header.Get(\"Content-Length\") == \"\" {\n\t\tcontentLength := strconv.FormatInt(req.Req.ContentLength, 10)\n\t\treq.Req.Header.Set(\"Content-Length\", contentLength)\n\t\tlog.Debug(\"ExecuteRequest | Setting Content-Length -> \", contentLength)\n\n\t}\n\tresp, err := client.Do(req.Req)\n\n\tif err != nil {\n\t\tlog.Error(\"Error executing request | ERR:\", err)\n\t\terr = errors.New(\"ERROR_SENDING_REQUEST -> \" + err.Error())\n\t\tresponse.Error = err\n\t\treturn response\n\t}\n\n\tdefer resp.Body.Close()\n\tresponse.Headers = make(map[string]string, len(resp.Header))\n\tfor k, v := range resp.Header {\n\t\tresponse.Headers[k] = strings.Join(v, `,`)\n\t}\n\tresponse.Cookie = resp.Cookies()\n\n\t//log.Debug(\"ExecuteRequest | Request executed, reading response ...\")]\n\tbodyResp, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif err = resp.Body.Close(); err != nil {\n\t\tlog.Println(\"Error during connection closing! \", err.Error())\n\t}\n\tif err != nil {\n\t\tlog.Error(\"Unable to read response! | Err: \", err)\n\t\terr = errors.New(\"ERROR_READING_RESPONSE -> \" + err.Error())\n\t\tresponse.Error = err\n\t\treturn response\n\t}\n\n\tresponse.Body = bodyResp\n\tresponse.StatusCode = resp.StatusCode\n\tresponse.Error = nil\n\telapsed := time.Since(start)\n\tresponse.Time = elapsed\n\tresponse.Response = resp\n\tlog.Debug(\"ExecuteRequest | Elapsed -> \", elapsed, \" | STOP!\")\n\treturn response\n}", "func (rool *rool) Handle(w http.ResponseWriter, r *http.Request) {\n\tatomic.AddUint64(&rool.hits, 1)\n\turl := &bytes.Buffer{}\n\terr := rool.Pattern.Execute(url, r)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\t// We send TARGET in Location header on HEAD request with 200 OK status\n\tif r.Method == \"HEAD\" {\n\t\tr.Close = true\n\t\tw.Header().Add(\"Location\", strings.TrimSpace(url.String()))\n\t\tw.WriteHeader(http.StatusOK)\n\t\treturn\n\t}\n\tw.Header().Add(\"Content-Length\", \"0\")\n\thttp.Redirect(w, r, strings.TrimSpace(url.String()), http.StatusFound)\n}", "func (handler *WebHandler) Handle(w http.ResponseWriter, req *http.Request) {\n\tswitch req.Method {\n\tcase \"GET\":\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tswitch req.URL.Path[len(\"/analysis/\"):] {\n\t\tcase \"totals\":\n\t\t\tparams, err := processParams(req.URL.Query())\n\t\t\tif err != nil {\n\t\t\t\twebhandler.ReturnError(err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tresults, err := totals(params, handler.rates, handler.backend.DB)\n\t\t\tif err != nil {\n\t\t\t\twebhandler.ReturnError(err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tjson, _ := json.Marshal(results)\n\t\t\tfmt.Fprintln(w, string(json))\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tcase \"graph\":\n\t\t\tparams, err := processParams(req.URL.Query())\n\t\t\tif err != nil {\n\t\t\t\twebhandler.ReturnError(err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tgParams := gInitialise(params)\n\t\t\tresults, err := graph(gParams, handler.rates, handler.backend.DB)\n\t\t\tif err != nil {\n\t\t\t\twebhandler.ReturnError(err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfmt.Fprintln(w, results)\n\t\t\tw.Header().Set(\"Content-Type\", \"image/svg+xml\")\n\t\tcase \"assets\":\n\t\t\tparams, err := processParams(req.URL.Query())\n\t\t\tif err != nil {\n\t\t\t\twebhandler.ReturnError(err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tresults, err := asts(params, handler.rates, handler.backend)\n\t\t\tif err != nil {\n\t\t\t\twebhandler.ReturnError(err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tjson, err := json.Marshal(results)\n\t\t\tif err != nil {\n\t\t\t\twebhandler.ReturnError(err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfmt.Fprintln(w, string(json))\n\t\tdefault:\n\t\t\thttp.Error(w, http.StatusText(404), 404)\n\t\t\treturn\n\t\t}\n\tcase \"OPTIONS\":\n\t\tw.Header().Set(\"Access-Control-Allow-Methods\", \"OPTIONS, GET\")\n\t\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\t\tw.Header().Set(\"Access-Control-Allow-Headers\", \"content-type\")\n\tdefault:\n\t\thttp.Error(w, http.StatusText(405), 405)\n\t}\n}", "func (op *OpQuery) Handle(resp *http.Response) error {\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"get operator can't handle response with code %d, expect %d\", resp.StatusCode, http.StatusOK)\n\t}\n\treturn json.NewDecoder(resp.Body).Decode(&op.result)\n}", "func (s *registry) do(req *http.Request) (*http.Response, error) {\n\tresp, err := s.Client.Do(req)\n\tif err != nil {\n\t\ts.logger.Error(err, \"http.Client cannot Do\",\n\t\t\t\"req-url\", req.URL,\n\t\t)\n\t\treturn nil, err\n\t}\n\n\tbuf := bytesBody{\n\t\tBuffer: new(bytes.Buffer),\n\t}\n\tn, err := buf.ReadFrom(resp.Body)\n\tif err != nil {\n\t\ts.logger.Error(err, \"cannot read HTTP response body\")\n\t\treturn nil, err\n\t}\n\tresp.Body = buf\n\n\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\ts.logger.V(1).Info(\"HTTP response status code is not OK\",\n\t\t\t\"status-code\", resp.StatusCode,\n\t\t\t\"resp-body-size\", n,\n\t\t\t\"req-url\", req.URL,\n\t\t)\n\t\ts.logger.V(1).Info(buf.String())\n\t}\n\treturn resp, nil\n}", "func mainHandler(w http.ResponseWriter, r *http.Request) {\n\t// Use otelhttp to record a span for the outgoing call, and propagate\n\t// context to the destination.\n\tdestination := os.Getenv(\"DESTINATION_URL\")\n\tresp, err := otelhttp.Get(r.Context(), destination)\n\tif err != nil {\n\t\tlog.Fatal(\"could not fetch remote endpoint\")\n\t}\n\tdefer resp.Body.Close()\n\t_, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatalf(\"could not read response from %v\", destination)\n\t}\n\n\tfmt.Fprint(w, strconv.Itoa(resp.StatusCode))\n}", "func ExecuteRequest(req *http.Request, result interface{}) error {\n\tclient := http.Client{}\n\tresponse, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Println(\"Error executing request call\")\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\tdefer response.Body.Close()\n\tout, err := ioutil.ReadAll(response.Body)\n\tif response.StatusCode == http.StatusUnauthorized {\n\t\tlog.Println(\"DOes not have permission to perform that action\")\n\t\treturn types.UnAuthorizedScope\n\t}\n\terr = json.NewDecoder(bytes.NewReader(out)).Decode(result)\n\tif err != nil {\n\t\tlog.Println(\"Error deserializing body in JSON Decoder\")\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Client) Do() (resp SugaredResp, err error) {\n\tdefer resp.Close()\n\n\tif err = c.buildRequest(); err != nil {\n\t\treturn\n\t}\n\n\t// send request and close on func call end\n\tif resp.resp, err = c.client.Do(c.req); err != nil {\n\t\treturn\n\t}\n\n\t// read response data form resp\n\tresp.Data, err = ioutil.ReadAll(resp.resp.Body)\n\tresp.Code = resp.resp.StatusCode\n\treturn\n}", "func Handler(ctx context.Context, req events.APIGatewayProxyRequest) (Response, error) {\n\tvar buf bytes.Buffer\n\n\tvar message string\n\tmessage = req.Path\n\n\tlog.Print(fmt.Sprint(\"Called with path: \", req.Path))\n\tstatusCode := 200\n\n\t// Could use a third party routing library at this point, but being hacky for now\n\titems := strings.Split(req.Path, \"/\")\n\tvar item string\n\tif len(items) > 1 {\n\t\titem = strings.Join(items[2:], \"/\")\n\t}\n\n\t// If we actually have an action to take\n\tif len(items) >= 1 {\n\t\tswitch items[1] {\n\t\tcase \"list\":\n\t\t\titems, err := List()\n\t\t\tif err != nil {\n\t\t\t\tstatusCode = 500\n\t\t\t\tmessage = fmt.Sprint(err)\n\t\t\t} else {\n\t\t\t\tmessage = strings.Join(items, \"\\n\")\n\t\t\t}\n\t\tcase \"add\":\n\t\t\t// Should probably be doing this on PUT or POST only\n\t\t\terr := Add(item)\n\t\t\tif err != nil {\n\t\t\t\tstatusCode = 500\n\t\t\t\tmessage = fmt.Sprint(err)\n\t\t\t} else {\n\t\t\t\tmessage = \"Added\"\n\t\t\t}\n\n\t\tcase \"complete\":\n\t\t\t// Should only be doing this on POST, but demo\n\t\t\terr := Complete(item)\n\t\t\tif err != nil {\n\t\t\t\tstatusCode = 500\n\t\t\t\tmessage = fmt.Sprint(err)\n\t\t\t} else {\n\t\t\t\tmessage = \"Completed\"\n\t\t\t}\n\t\t}\n\t}\n\n\tbody, err := json.Marshal(map[string]interface{}{\n\t\t\"message\": message,\n\t})\n\tif err != nil {\n\t\treturn Response{StatusCode: 404}, err\n\t}\n\tjson.HTMLEscape(&buf, body)\n\n\tresp := Response{\n\t\tStatusCode: statusCode,\n\t\tIsBase64Encoded: false,\n\t\tBody: buf.String(),\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\"X-MyCompany-Func-Reply\": \"hello-handler\",\n\t\t},\n\t}\n\n\treturn resp, nil\n}", "func Handler(w http.ResponseWriter, r *http.Request) {\n\thandler.Submit(w, r)\n}", "func (c *carHandler) Execute(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"CarsHandler actived\")\n\tcontentType := r.Header.Get(\"Content-type\")\n\tif contentType != \"application/json\" {\n\t\tlog.Println(fmt.Errorf(\"Content Type is not valid\"))\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvar input []usecase.CarInput\n\tdefer r.Body.Close()\n\n\tdecoder := json.NewDecoder(r.Body)\n\tif err := decoder.Decode(&input); err != nil {\n\t\tlog.Println(err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err := c.validate(input); err != nil {\n\t\tlog.Println(err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err := c.CarUsecase.PutCars(input); err != nil {\n\t\tlog.Println(err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tlog.Println(fmt.Sprintf(\"Car created\"))\n\tw.WriteHeader(http.StatusOK)\n\treturn\n}", "func Process(c http.ResponseWriter, req *http.Request) {\n\tmainServer.Process(c, req)\n}", "func handleRequestAndRedirect(res http.ResponseWriter, req *http.Request) {\n\tpath := strings.ToLower(req.URL.Path)\n\tif strings.Compare(path, \"/aggregated/caseworkers/:uid/jurisdictions\") == 0 {\n\t\tfirst := fetchJsonArray(CcdHost, req)\n\t\tsecond := fetchJsonArray(IndependentHost, req)\n\t\tresult := append(first, second...)\n\t\tjson.NewEncoder(res).Encode(result)\n\t\treturn\n\t}\n\n\tif strings.Compare(path, \"/health\") == 0 {\n\t\tfmt.Fprintf(res, \"OK\")\n\t\treturn\n\t}\n\n\tif isIndie(req.URL) {\n\t\tserveReverseProxy(\"http://\" + IndependentHost, res, req)\n\t\treturn\n\t}\n\n\tserveReverseProxy(\"http://\" + CcdHost, res, req)\n}", "func (eh *executorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\t// Preprocess\n\tif eh.preprocessHost != \"\" {\n\t\tif err := eh.preprocess(r); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Predict\n\tb, err := eh.predict(r)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Postprocess\n\tif eh.postprocessHost != \"\" {\n\t\tb, err = eh.postprocess(r, b)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Write final response\n\t_, err = w.Write(b)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func (cc *Client) Do(resource Requester) (*Response, error) {\n\treq, err := resource.Request(cc.serverURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"sending ksql request: %w\", err)\n\t}\n\tctx, cancel := context.WithCancel(cc.ctx)\n\ttrace := cc.HTTPTrace()\n\tif trace != nil && trace.RequestPrepared != nil {\n\t\ttrace.RequestPrepared(req)\n\t}\n\tresp, err := cc.httpClient.Do(cc.WithClientConfig(ctx, req))\n\tif trace != nil && trace.ResponseDelivered != nil {\n\t\ttrace.ResponseDelivered(resp, err)\n\t}\n\tif err != nil {\n\t\t// Avoiding a lost cancel.\n\t\treturn &Response{cancelFunc: cancel}, fmt.Errorf(\"sending ksql request: %w\", err)\n\t}\n\treturn &Response{\n\t\tResponse: resp,\n\t\tContext: ctx,\n\t\tcancelFunc: cancel,\n\t}, nil\n}", "func (m *MockServer) HandleRequest(w http.ResponseWriter, r *http.Request) {\n\n\tvar response *MockResponse\n\tfor _, resp := range m.Responses {\n\t\tif !resp.satisfied && resp.Method == r.Method {\n\t\t\tresponse = resp\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif response == nil {\n\n\t\tif m.Checker != nil {\n\t\t\terrstr := fmt.Sprintf(\"Mock server: no matching response to request for %s:%s\\n\", r.Method, r.RequestURI)\n\t\t\tm.Checker.Fatal(errstr)\n\t\t}\n\n\t\tw.WriteHeader(http.StatusTeapot)\n\t\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\t\tfmt.Fprintf(w, \"no matching response to request for %s:%s\\n\", r.Method, r.RequestURI)\n\n\t\treturn\n\t}\n\n\tbody, _ := ioutil.ReadAll(r.Body)\n\n\tresponse.Hits++\n\tif !response.Persistant {\n\t\tresponse.satisfied = true\n\t}\n\n\tresponse.Request = r\n\tresponse.RequestBody = string(body)\n\n\tif response.CheckFn != nil {\n\t\tresponse.CheckFn(r, response.RequestBody)\n\t}\n\n\tm.Requests = append(m.Requests, r)\n\n\tw.WriteHeader(response.Code)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tfmt.Fprintln(w, response.Body)\n}", "func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\tvar buf bytes.Buffer\n\n\tbody, err := json.Marshal(map[string]interface{}{\n\t\t\"message\": \"Okay so your other function also executed successfully!\",\n\t})\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 404}, err\n\t}\n\tjson.HTMLEscape(&buf, body)\n\n\tresp := events.APIGatewayProxyResponse{\n\t\tStatusCode: 200,\n\t\tIsBase64Encoded: false,\n\t\tBody: buf.String(),\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\"X-MyCompany-Func-Reply\": \"world-handler\",\n\t\t},\n\t}\n\n\treturn resp, nil\n}", "func handle(id int, cmd *json.Json, proc Processor) {\n\t// Create a response with the matching ID\n\tr, dat, err := json.MakeMap()\n\tif err != nil {\n\t\t// Echo errors to host\n\t\tfmt.Println(err)\n\t} else {\n\t\tdat[\"id\"] = id\n\t\tdat[\"data\"] = proc(cmd) // Set response data to processor result\t\n\t\tb, _ := r.Encode()\n\t\tfmt.Println(string(b)) // Send JSON result on stdout\n\t}\n}", "func Handle(req []byte) string {\n\tlog.Println(\"Request with \", req)\n\tapi = CreateAPI()\n\tresult, err := api.All()\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\tjsonBytes, err := json.Marshal(result)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\treturn string(jsonBytes)\n}", "func handle(req typhon.Request, service, path string) typhon.Response {\n\turl := fmt.Sprintf(requestFormat, service, path)\n\n\tslog.Trace(req, \"Handling parsed URL: %v\", url)\n\n\tconn, err := net.Dial(\"tcp\", fmt.Sprintf(\"%s:80\", service))\n\tif err != nil {\n\t\tslog.Error(req, \"Unable to connect to %s: %v\", service, err)\n\t\treturn typhon.Response{Error: terrors.NotFound(\"service\", fmt.Sprintf(\"Unable to connect to %v\", service), nil)}\n\t}\n\tdefer conn.Close()\n\n\treq.Host = service\n\treq.URL.Scheme = \"http\"\n\treq.URL.Path = \"/\" + strings.TrimPrefix(path, \"/\")\n\treq.URL.Host = service\n\n\treturn req.Send().Response()\n}", "func (d *Dependencies) HandleRequest(req events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) {\n\n\tvar response events.APIGatewayV2HTTPResponse\n\tvar regionNodeResponse RegionNodeResponse\n\n\tvar request RegionRequest\n\n\tif(req.QueryStringParameters == nil){\n\t\tresponse.StatusCode = 500\n\t\ts := []string{fmt.Sprint(\"Oh noes!\")}\n\t\tregionNodeResponse.Errors = s\n\n\t\tb, _ := json.Marshal(regionNodeResponse)\n\t\tresponse.Body = string(b)\n\n\t\treturn response, errors.New(\"error \")\n\t}\n\n\treqMap := req.QueryStringParameters;\n\tfmt.Print(reqMap);\n\n\trequest.LevelType = reqMap[\"lvl\"]\n\trequest.RegionID = reqMap[\"rgn\"]\n\n\tif(request.LevelType == \"\" || request.RegionID == \"\"){\n\t\t//Bad request.\t\n\t\tresponse.StatusCode = 400\n\t\tb, _ := json.Marshal(response)\n\t\tresponse.Body = \"Bad request, missing params\" + string(b)\n\n\n\t}\n\n\t// Request items from DB.\n\tdb := d.ddb\n\ttable := d.tableID\n\n\tregionNodeResponse = getData(request, db, table)\n\t\n\tb, err := json.Marshal(regionNodeResponse)\n\n\tif err != nil {\n\t\tfmt.Println(\"Error with marshalling request\")\n\t\tresponse.StatusCode = 500\n\t\ts := []string{fmt.Sprint(err)}\n\t\tregionNodeResponse.Errors = s\n\n\t} else {\n\t\tresponse.Body = string(b)\n\t\tresponse.StatusCode = 200\n\t}\n\n\treturn response, nil\n}", "func (c *Core) handleRequest(fctx *fasthttp.RequestCtx) {\n\tctx := c.assignCtx(fctx)\n\tdefer c.releaseCtx(ctx)\n\tif ctx.methodINT == -1 {\n\t\tctx.Status(StatusBadRequest).SendString(\"Invalid http method\")\n\t\treturn\n\t}\n\n\tstart := time.Now()\n\t// Delegate next to handle the request\n\t// Find match in stack\n\tmatch, err := c.next(ctx)\n\tif err != nil {\n\t\t_ = ctx.SendStatus(StatusInternalServerError)\n\t}\n\t// Generate ETag if enabled\n\tif match && c.ETag {\n\t\tsetETag(ctx, false)\n\t}\n\tif c.Debug {\n\t\td := time.Since(start)\n\t\t// d := time.Now().Sub(start).String()\n\t\tLog.D(\"%s %s %d %s\\n\", ctx.method, ctx.path, ctx.Response.StatusCode(), d)\n\t}\n}", "func (h *Handler) ServeHTTP(response http.ResponseWriter, request *http.Request) {\n\tif request.ContentLength > int64(h.Service.MaxRequestLength) {\n\t\tresponse.WriteHeader(http.StatusRequestEntityTooLarge)\n\t\treturn\n\t}\n\tif request.Method == \"GET\" {\n\t\tif h.clientAccessPolicyXMLHandler(response, request) ||\n\t\t\th.crossDomainXMLHandler(response, request) {\n\t\t\treturn\n\t\t}\n\t\tif !h.GET {\n\t\t\tresponse.WriteHeader(http.StatusForbidden)\n\t\t\treturn\n\t\t}\n\t}\n\tdata, err := readAll(request.Body, request.ContentLength)\n\tif err != nil {\n\t\th.onError(response, request, err)\n\t}\n\tif err = request.Body.Close(); err != nil {\n\t\th.onError(response, request, err)\n\t}\n\tserviceContext := h.getServiceContext(response, request)\n\tctx := core.WithContext(request.Context(), serviceContext)\n\tresult, err := h.Service.Handle(ctx, data)\n\tif err != nil {\n\t\th.onError(response, request, err)\n\t}\n\tresponse.Header().Set(\"Content-Length\", strconv.Itoa(len(result)))\n\th.sendHeader(serviceContext, response, request)\n\t_, err = response.Write(result)\n\tif err != nil {\n\t\th.onError(response, request, err)\n\t}\n}", "func HandleRequest(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\n\t// Slack sends its parameters as url encoded data in the request body. These need to be parsed to obtain the key/values. A list of the data slack sends can be seen [here](https://api.slack.com/interactivity/slash-commands).\n\n\t// Get slack params\n\tparams, err := url.ParseQuery(req.Body)\n\tif err != nil {\n\t\treturn internalError(fmt.Errorf(\"decoding slack params: %v\", err))\n\t}\n\ttext := params.Get(\"text\")\n\n\t// Do something. Anything you want really\n\t// Some cool code\n\n\t// Construct response data\n\tr := Response{\n\t\tType: \"in_channel\",\n\t\tText: fmt.Sprintf(\"You said '%s'\", text),\n\t}\n\n\tdata, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{\n\t\t\tStatusCode: 500,\n\t\t\tBody: err.Error(),\n\t\t}, nil\n\t}\n\n\treturn events.APIGatewayProxyResponse{\n\t\tStatusCode: 200,\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tBody: string(data),\n\t}, nil\n}", "func handleRequest(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\tvar err error\n\tvar resp interface{}\n\theaders := map[string]string{\n\t\t\"Access-Control-Allow-Headers\": \"Content-Type\",\n\t\t\"Access-Control-Allow-Origin\": \"*\",\n\t\t\"Access-Control-Allow-Methods\": \"GET\",\n\t}\n\n\tresp, err = getNovelList()\n\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{\n\t\t\tStatusCode: http.StatusInternalServerError,\n\t\t\tHeaders: headers,\n\t\t\tBody: err.Error(),\n\t\t}, err\n\t}\n\tformattedResp := formatResp(resp)\n\n\tresponse := events.APIGatewayProxyResponse{\n\t\tStatusCode: http.StatusOK,\n\t\tHeaders: headers,\n\t\tBody: formattedResp,\n\t}\n\treturn response, nil\n}", "func handleRequest(ctx context.Context, event events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\t// decode the event parameter\n\tvar data EventData\n\tif err := json.Unmarshal([]byte(event.Body), &data); err != nil {\n\t\treturn events.APIGatewayProxyResponse{StatusCode: 500}, err\n\t}\n\n\t// prepare the response string\n\tcurrentTime := time.Now()\n\tcurrentTimeStr := currentTime.Format(\"2006-01-02 15:04:05\")\n\tresponseStr := fmt.Sprintf(\"Hello from AWS Lambda, %s! Its %s\", data.Name, currentTimeStr)\n\n\t// return the response\n\treturn events.APIGatewayProxyResponse{Body: responseStr, StatusCode: 200}, nil\n}", "func (t *task) run(ctx context.Context) {\n\tgo func() {\n\t\tresult, err := t.handler(ctx, t.request)\n\t\tt.resultQ <- Response{Result: result, Err: err} // out channel is buffered by 1\n\t\tt.running = false\n\t\tclose(t.resultQ)\n\t}()\n}", "func (c *Client) Do() (resp SugaredResp, err error) {\n\tdefer resp.Close()\n\n\tif err := c.buildRequest(); err != nil {\n\t\treturn resp, err\n\t}\n\n\t// send request and close on func call end\n\tif resp.resp, err = c.client.Do(c.req); err != nil {\n\t\treturn resp, err\n\t}\n\n\t// read response data form resp\n\tresp.Data, err = ioutil.ReadAll(resp.resp.Body)\n\tresp.Code = resp.resp.StatusCode\n\treturn resp, err\n}", "func (fhp *FastHTTPProvider) Do(ctx context.Context, request *fasthttp.Request) (*fasthttp.Response, error) {\n\treturn fhp.request(ctx, request, nil)\n}", "func (s server) Handle(w http.ResponseWriter, r *http.Request) {\n\t/* If we have creds set, check them */\n\tif \"\" != s.username || \"\" != s.password {\n\t\tw.Header().Set(\n\t\t\t\"WWW-Authenticate\",\n\t\t\t`Basic realm=\"Auth Required\"`,\n\t\t)\n\t\tu, p, ok := r.BasicAuth()\n\t\tif !ok || (\"\" == u && \"\" == p) { /* Client didn't know? */\n\t\t\tlog.Printf(\"[%v] No auth\", r.RemoteAddr)\n\t\t\thttp.Error(w, \"Not authorized\", 401)\n\t\t\treturn\n\t\t}\n\t\tif u != s.username || p != s.password {\n\t\t\tlog.Printf(\n\t\t\t\t\"[%s] Auth fail (%q / %q)\",\n\t\t\t\tr.RemoteAddr,\n\t\t\t\tu,\n\t\t\t\tp,\n\t\t\t)\n\t\t\thttp.Error(w, \"Not authorized\", 401)\n\t\t\treturn\n\t\t}\n\t}\n\n\tlogReq(r)\n\n\t/* Special cases sometimes */\n\tswitch r.Method {\n\tcase http.MethodDelete: /* We may not allow deletes */\n\t\tif s.noDelete {\n\t\t\treturn\n\t\t}\n\tcase http.MethodGet: /* Maybe serve a single file */\n\t\tif \"\" != s.serveFile {\n\t\t\thttp.ServeFile(w, r, s.serveFile)\n\t\t\treturn\n\t\t}\n\t}\n\n\t/* If we're only allowing read access, whitelist the allowed methods */\n\tif s.readOnly {\n\t\tswitch r.Method {\n\t\tcase \"OPTIONS\", \"GET\", \"HEAD\", \"PROPFIND\":\n\t\t\t/* These are ok */\n\t\tdefault:\n\t\t\t/* This is not ok */\n\t\t\treturn\n\t\t}\n\t}\n\n\ts.w.ServeHTTP(w, r)\n}", "func Handler(w http.ResponseWriter, r *http.Request) {\n\tvar responseJSON []byte\n\tqueryParams := r.URL.Query()\n\tglog.Info(\"Prime Number params -> \", queryParams)\n\tif len(queryParams) == 0 {\n\t\tglog.Info(\"Query Params are missing\")\n\t}\n\tinput, ok := queryParams[\"input\"]\n\tif !ok {\n\t\tglog.Info(\"URL Param is missing\")\n\t}\n\tn, err := strconv.Atoi(input[0])\n\tif err != nil {\n\t\tglog.Info(err)\n\t}\n\n\tprimeNumbers := make(chan []int)\n\tgo FindPrime(n, primeNumbers)\n\tresult := <-primeNumbers\n\n\t// Marshal and initialize ResponsJSON\n\tresponseJSON, err = json.Marshal(result)\n\tif err != nil {\n\t\tglog.Info(err)\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(responseJSON))\n}", "func (c *Client) do(req *http.Request) (*http.Response, error) {\n\tc.log(\"%-6s %s\\n\", req.Method, req.URL.Path)\n\treq.Header.Set(\"Content-Type\", \"application/msgpack\")\n\treq.Header.Set(\"Accept\", \"application/msgpack\")\n\tif t := c.token; t != \"\" {\n\t\treq.Header.Set(\"Authorization\", \"Token \"+t)\n\t}\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcode := resp.StatusCode\n\tif code >= 200 && code < 400 {\n\t\treturn resp, nil\n\t}\n\tdefer resp.Body.Close()\n\n\tswitch code {\n\tcase 404:\n\t\treturn nil, errors.New(\"not found\")\n\tcase 500:\n\t\treturn nil, errors.New(\"internal error\")\n\t}\n\n\tvar body ErrorResponse\n\tif err := codec.NewDecoder(resp.Body).Decode(&body); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn nil, &body\n}", "func (hc *httpClientServiceImpl) Do(request *http.Request) (*http.Response, error) {\n\thc.Create()\n\n\tvar (\n\t\tresponse *http.Response\n\t\terr error\n\t\tcbEnabled bool\n\t)\n\n\tcommandName := request.URL.Host\n\tif enabled, ok := circuitBreaker[commandName]; ok {\n\t\tcbEnabled = enabled\n\t}\n\n\terr = circuit.Do(commandName, cbEnabled, func() error {\n\t\tresponse, err = hc.httpClient.Do(request)\n\t\tif err != nil {\n\t\t\terr = checkOffline(err)\n\t\t\treturn err\n\t\t}\n\n\t\tif response.StatusCode >= http.StatusInternalServerError {\n\t\t\treturn err5xx\n\t\t}\n\n\t\treturn nil\n\t}, nil)\n\n\tif err == err5xx {\n\t\treturn response, nil\n\t}\n\n\treturn response, err\n}", "func HandleRequest(request events.APIGatewayProxyRequest) (Response, error) {\n\tlog.Println(\"start\")\n\n\teventsAPIEvent, err := getAPIEvents(request.Body)\n\tif err != nil {\n\t\tlog.Print(err)\n\t\treturn Response{\n\t\t\tStatusCode: 400,\n\t\t}, err\n\t}\n\n\tlog.Printf(\"eventsAPIEvent: %+v\\n\", eventsAPIEvent)\n\tswitch eventsAPIEvent.Type {\n\tcase slackevents.URLVerification:\n\t\treturn getChallengeResponse(request.Body)\n\tcase slackevents.CallbackEvent:\n\t\tinnerEvent := eventsAPIEvent.InnerEvent\n\t\tswitch ev := innerEvent.Data.(type) {\n\t\tcase *slackevents.AppMentionEvent:\n\t\t\treturn getMentionEventResponse(ev)\n\t\tcase *slackevents.MessageEvent:\n\t\t\treturn getDmEventResponse(ev)\n\t\tdefault:\n\t\t\tlog.Printf(\"unsupported event: %+v\\n\", ev)\n\t\t}\n\tdefault:\n\t\tlog.Printf(\"unsupported type: %+v\\n\", eventsAPIEvent)\n\t}\n\tlog.Println(\"no effect.\")\n\treturn Response{\n\t\tStatusCode: 400,\n\t}, nil\n}", "func (s *Server) response(context *Context, handler Handler) {\n\tdefer context.write()\n\n\tcontext.handlerSeq = append(context.handlerSeq, handler)\n\tcontext.run()\n}", "func handleHTTPResponse(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(r.URL.Path)\n\tif r.Method == \"GET\" {\n\t\tif r.URL.Path == \"/getpaths\" {\n\t\t\tquery := r.URL.Query()\n\t\t\tdestination := query[\"dest\"][0]\n\t\t\tsource := query[\"source\"][0]\n\t\t\t// sessionID := query[\"sid\"][0]\n\n\t\t\tformPath(source, destination)\n\t\t\tGetLatencyForPaths()\n\n\t\t\tmessage := \"\"\n\t\t\tfor i := 0; i < len(latencyArray); i++ {\n\t\t\t\tmessage += strconv.FormatFloat(latencyArray[i], 'f', -1, 32)\n\t\t\t\tmessage += \" \"\n\t\t\t}\n\n\t\t\tw.Write([]byte(message))\n\t\t}\n\t} else if r.Method == \"POST\" {\n\t\tif r.URL.Path == \"/setpath\" {\n\t\t\tpath := r.URL.Query()[\"path\"][0]\n\t\t\tpathNumber, err := strconv.Atoi(path)\n\t\t\tCheckError(err)\n\t\t\tsessionID := \"0001000100010001\"\n\t\t\tfmt.Println(pathsArray)\n\t\t\tselectedPath := []string{pathsArray[pathNumber][0], pathsArray[pathNumber][1], pathsArray[pathNumber][2]}\n\t\t\tsetPath(selectedPath, sessionID)\n\t\t\ttellClientToStart(pathsArray[pathNumber][0])\n\t\t\tw.Write([]byte(selectedPath[0] + \" \" + selectedPath[1] + \" \" + selectedPath[2]))\n\t\t} else if r.URL.Path == \"/resettest\" {\n\t\t\t// wipeDatabase()\n\t\t\tw.Write([]byte(\"success\"))\n\t\t}\n\t}\n}", "func handleRequest(z, x, y int, pool chan<- request, writer http.ResponseWriter) error {\n\tch := make(chan response)\n\treq := request{z: z, x: x, y: y, reply: ch}\n\tpool <- req\n\tres := <-ch\n\tif res.err != nil {\n\t\treturn res.err\n\t}\n\t_, err := writer.Write(res.tile)\n\treturn err\n}", "func (c *Executor) do(request *http.Request, followRedirects bool) (*http.Response, error) {\n\tclient, err := c.clientProvider.Client(followRedirects)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error executing request, failed to get the underlying HTTP client: %w\", err)\n\t}\n\tr, err := client.Do(request)\n\tif err != nil {\n\t\t// if we get an error because the context was cancelled, the context's error is more useful.\n\t\tctx := request.Context()\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, ctx.Err()\n\t\tdefault:\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error executing request, failed during HTTP request send: %w\", err)\n\t}\n\treturn r, nil\n}", "func (h *Handler) Handle(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase http.MethodGet:\n\t\th.GetAll(w, r)\n\tcase http.MethodOptions:\n\t\treturn\n\tdefault:\n\t\tw.WriteHeader(http.StatusMethodNotAllowed)\n\t}\n}", "func handleRequest(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\thandleGetRequest(w, r)\n\t\treturn\n\tcase \"POST\":\n\t\thandlePost(w, r)\n\t\treturn\n\tdefault:\n\t\tw.WriteHeader(http.StatusMethodNotAllowed)\n\t\tw.Write([]byte(\"HTTP methos not allowed.\"))\n\t\treturn\n\t}\n}", "func handleAsync(req *netm.Request) netm.Response {\n\treturn netm.Response{Status: &netm.Status{Type: netm.Status_NO_ERROR, Message: \"Success\"}}\n}", "func Handle(req handler.Request) (handler.Response, error) {\n\toptions := &redis.Options{}\n\n\tdata, err := parse(req.Body)\n\tif err != nil {\n\t\treturn handler.Response{\n\t\t\tBody: []byte(\"failed to unmarshal json request\"),\n\t\t\tStatusCode: http.StatusBadRequest,\n\t\t}, nil\n\t}\n\n\t// TODO get redis connnection string from environment\n\tr := &Redis{redis.NewClient(options)}\n\tdc := NewDispatcherConfig(r)\n\td := NewDispatcher(dc)\n\n\tfor _, alert := range data.Alerts {\n\t\tif err := d.Dispatch(alert); err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\t}\n\n\treturn handler.Response{\n\t\tBody: []byte(\"ok\"),\n\t\tStatusCode: http.StatusOK,\n\t}, nil\n}", "func (handler *AuthenticationHandler) HandleRequest(mapper map[string]string, redis redis.Redis, db dbsql.DB) model.Response {\n\tusername := mapper[model.CodeUsername]\n\tpassword := mapper[model.CodePassword]\n\terr := authentication.Authenticate(username, password, db)\n\tmapperResp := make(map[string]string)\n\tif err != nil {\n\t\tif err.Error() == authentication.ErrorNotAuthenticated {\n\t\t\tmapperResp[model.ResponseCode] = authentication.ErrorNotAuthenticated\n\t\t}\n\n\t\tmapperResp[model.ResponseCode] = err.Error()\n\t\treturn model.Response{ResponseID: model.ResponseOK, Data: mapperResp}\n\t}\n\n\tsessionID := stringutil.CreateRandomString(32)\n\tredis.Set(sessionID, username, 5*time.Hour)\n\tmapperResp[model.ResponseCode] = sessionID\n\n\treturn model.Response{ResponseID: model.ResponseOK, Data: mapperResp}\n}", "func (c Client) Do(r *http.Request) (*http.Response, error) {\n\treturn c.sender().Do(r)\n}", "func (faasflow *Faasflow) Handle(req *HttpRequest, response *HttpResponse) (err error) {\n\n\tvar result string\n\tvar reqId string\n\n\tstatus := http.StatusOK\n\n\t// Get flow name\n\tif flowName == \"\" {\n\t\tflowName = getWorkflowNameFromHost(req.Host)\n\t\tif flowName == \"\" {\n\t\t\tpanic(fmt.Sprintf(\"Error: workflow_name must be provided, specify workflow_name: <fucntion_name> using environment\"))\n\t\t}\n\t}\n\n\tif isDagExportRequest(req) {\n\t\tresult = handleDagExport(req)\n\t} else {\n\t\tresult, reqId = handleWorkflow(req)\n\t\tresponse.Header.Set(\"X-Faas-Flow-Reqid\", reqId)\n\t}\n\n\tresponse.Body = []byte(result)\n\tresponse.StatusCode = status\n\n\treturn\n}", "func (c *Client) Execute(r Request, data interface{}) error {\n\tpayload, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequest(\"POST\", c.Endpoint, bytes.NewBuffer(payload))\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor k, v := range c.Headers {\n\t\treq.Header.Set(k, v)\n\t}\n\tres, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer res.Body.Close()\n\n\tvar response Response\n\terr = json.NewDecoder(res.Body).Decode(&response)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif response.Data != nil {\n\t\terr = json.Unmarshal(*response.Data, data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif response.Errors != nil {\n\t\tvar errors Errors\n\t\terr = json.Unmarshal(*response.Errors, &errors)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn errors\n\t}\n\n\treturn nil\n}", "func (c *client) exec(r *http.Request) (io.ReadCloser, error) {\n\tresp, err := c.doRaw(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"bad response code: %d\\n\"+\n\t\t\t\"request was: %v\\n\",\n\t\t\tresp.StatusCode,\n\t\t\tr)\n\t}\n\n\tif resp.Body == nil {\n\t\treturn nil, fmt.Errorf(\"no body in response\")\n\t}\n\n\treturn resp.Body, nil\n}", "func (r *Request) handleResponse(task *task.MessageTask, response *libcoap.Pdu, env *task.Env) {\n\tisMoreBlock, eTag, block := r.env.CheckBlock(response)\n\t// if block is more block, sent request to server with block option\n\t// else display data received from server\n\tif isMoreBlock {\n\t\tr.pdu.MessageID = r.env.CoapSession().NewMessageID()\n\t\tr.pdu.SetOption(libcoap.OptionBlock2, uint32(block.ToInt()))\n\t\tr.pdu.SetOption(libcoap.OptionEtag, uint32(*eTag))\n\n\t\t// Add block2 option for waiting for response\n\t\tr.options[messages.BLOCK2] = block.ToString()\n\t\ttask.SetMessage(r.pdu)\n\t\tr.env.Run(task)\n\t} else {\n\t\tif eTag != nil && block.NUM > 0 {\n\t\t\tblockKey := strconv.Itoa(*eTag) + string(response.Token)\n\t\t\tresponse = r.env.GetBlockData(blockKey)\n\t\t\tdelete(r.env.Blocks(), blockKey)\n\t\t}\n\t\tif response.Type == libcoap.TypeNon {\n\t\t\tlog.Debugf(\"Success incoming PDU(HandleResponse): %+v\", response)\n\t\t}\n\n\t\t// Skip set analyze response data if it is the ping response\n\t\tif response.Code != 0 {\n\t\t\ttask.AddResponse(response)\n\t\t}\n\t}\n\n\t// Handle Session config task and ping task after receive response message \n\t// If this is response of Get session config without abnormal, restart ping task with latest parameters\n\t// Check if the request does not contains sid option -> if not, does not restart ping task when receive response\n\t// Else if this is response of Put session config with code Created -> stop the current session config task\n\t// Else if this is response of Delete session config with code Deleted -> stop the current session config task\n\tlog.Debugf(\"r.queryParam=%v\", r.queryParams)\n\tif (r.requestName == \"session_configuration\") {\n\t\tif (r.method == \"GET\") && (response.Code == libcoap.ResponseContent) && len(r.queryParams) > 0 {\n\t\t\tlog.Debug(\"Get with sid - Client update new values to system session configuration and restart ping task.\")\n\t\t\tRestartHeartBeatTask(response, r.env)\n\t\t\tRefreshSessionConfig(response, r.env, r.pdu)\n\t\t} else if (r.method == \"PUT\") && (response.Code == libcoap.ResponseCreated) {\n\t\t\tlog.Debug(\"The new session configuration has been created. Stop the current session config task\")\n\t\t\tRefreshSessionConfig(response, r.env, r.pdu)\n\t\t} else if (r.method == \"DELETE\") && (response.Code == libcoap.ResponseDeleted) {\n\t\t\tlog.Debug(\"The current session configuration has been deleted. Stop the current session config task\")\n\t\t\tRefreshSessionConfig(response, r.env, r.pdu)\n\t\t}\n\t}\n}", "func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {\n\tfmt.Printf(\"Processing request data for request %s.\\n\", request.RequestContext.RequestID)\n\n\t// extract env var\n\tuser := os.Getenv(\"PIXELA_USER\")\n\ttoken := os.Getenv(\"PIXELA_TOKEN\")\n\tactgraph := os.Getenv(\"PIXELA_ACTTIME_GRAPH\")\n\tcalgraph := os.Getenv(\"PIXELA_CAL_GRAPH\")\n\tdistgraph := os.Getenv(\"PIXELA_DIST_GRAPH\")\n\n\t// extract url from request\n\tvar reqbody Request\n\terr := json.Unmarshal([]byte(request.Body), &reqbody)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn events.APIGatewayProxyResponse{Body: \"Record failed\", StatusCode: 500}, err\n\t}\n\turl := reqbody.URL\n\tfmt.Printf(\"Posted URL: %s\\n\", url)\n\n\t// extract image url\n\timgURLs, err := getImageURL(url)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn events.APIGatewayProxyResponse{Body: \"Record failed\", StatusCode: 500}, err\n\t}\n\tfmt.Printf(\"Image URL: %s\\n\", imgURLs)\n\n\tfor _, imgURL := range imgURLs {\n\t\t// extract image bytes\n\t\timg, err := getImage(imgURL)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t\treturn events.APIGatewayProxyResponse{Body: \"Record failed\", StatusCode: 500}, err\n\t\t}\n\n\t\t// execute text detection of Rekognition\n\t\tres, err := exeRekognitionDetectText(img)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t\treturn events.APIGatewayProxyResponse{Body: \"Record failed\", StatusCode: 500}, err\n\t\t}\n\n\t\t// extract date & quantities from the above result\n\t\tdate, acttime, cal, dist := getValueFromRekognitionResult(res.TextDetections)\n\t\tfmt.Printf(\"date: %s, acttime: %s, cal: %s, dist: %s\\n\", date, acttime, cal, dist)\n\n\t\t// record pixel\n\t\terr = recordPixel(user, token, actgraph, date, acttime)\n\t\terr = recordPixel(user, token, calgraph, date, cal)\n\t\terr = recordPixel(user, token, distgraph, date, dist)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn events.APIGatewayProxyResponse{Body: \"Record failed\", StatusCode: 500}, err\n\t\t}\n\t}\n\n\treturn events.APIGatewayProxyResponse{Body: \"Successfully recorded\", StatusCode: 200}, nil\n}", "func (s *Service) Handle(ctx context.Context, request []byte) ([]byte, error) {\n\treturn s.ioManager.Handler().(NextIOHandler)(ctx, request)\n}", "func Handler(c *gin.Context) {\n\tvar req Request\n\tc.BindJSON(&req)\n\ts := service{\n\t\tcontext: c,\n\t\treq: req,\n\t}\n\tres, err := s.Execute()\n\tif err != nil {\n\t\tc.JSON(400, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\tc.JSON(200, gin.H{\"data\": res.Data})\n}", "func (i *Interceptor) HandleHttp(w http.ResponseWriter, r *http.Request) {\n\n\tresp, err := i.MakeRequest(i.Destination.HttpMethod, i.Destination.Url, i.Destination.Headers)\n\tif err != nil {\n\t\thandleError(w, err)\n\t\treturn\n\t}\n\n\tresults, err := DecodeBody(*resp)\n\tif err != nil {\n\t\thandleError(w, err)\n\t\treturn\n\t}\n\n\t// if mappings exist we need to talk to SB\n\tif len(i.Destination.Mappings) > 0 {\n\t\ti.CallProxy(w, r, results)\n\t\treturn\n\t}\n\n\t// write json results back to the response writer\n\tenc := json.NewEncoder(w)\n\terr = enc.Encode(results)\n\n\tif err != nil {\n\t\thandleError(w, err)\n\t\treturn\n\t}\n}", "func ServeHTTP(urlPrefix string, w http.ResponseWriter, r *http.Request) {\n\tname := r.URL.Path[len(urlPrefix):]\n\troute, ok := routes[name]\n\tif !ok {\n\t\tw.WriteHeader(http.StatusFound)\n\t\treturn\n\t}\n\n\tif len(route.method) > 0 && route.method != r.Method {\n\t\tw.WriteHeader(http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\targ := route.newArg()\n\tif arg != nil {\n\t\tif e := json.NewDecoder(r.Body).Decode(arg); e != nil {\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t}\n\n\tresp := Result{Succeeded: true}\n\tres, e := route.callHandler(r, arg)\n\tif e != nil {\n\t\tresp.Succeeded = false\n\t\tresp.Message = e.Error()\n\t}\n\n\tswitch v := res.(type) {\n\tcase int64:\n\t\tresp.Data = strconv.FormatInt(v, 10)\n\tcase uint64:\n\t\tresp.Data = strconv.FormatUint(v, 10)\n\tdefault:\n\t\tresp.Data = res\n\t}\n\n\tw.Header().Add(\"Content-Type\", contentType)\n\tjson.NewEncoder(w).Encode(&resp)\n}", "func mainHandler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\tw.Header().Set(\"Access-Control-Allow-Headers\", \"Content-Type\")\n\tw.Header().Set(\"Access-Control-Allow-Methods\", \"GET, POST, HEAD\")\n\n\tif r.Method == \"POST\" {\n\t\tvar req dlRequest\n\t\tif err := json.NewDecoder(r.Body).Decode(&req); err != nil {\n\t\t\tlog.Println(err)\n\t\t\thttp.Error(w, \"bad request\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\t// add to queue\n\t\tgo func(qreq *dlRequest) {\n\t\t\tm3u8.DlChan <- &m3u8.WJob{Type: m3u8.ListDL, URL: req.Url, DestPath: req.Path, Filename: req.Filename}\n\t\t}(&req)\n\t\tres := response{req.Url, req.Filename, \"Added to the queue\"}\n\t\tjson.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n}", "func (s *EtcdServer) Do(ctx context.Context, r pb.Request) (Response, error) {\n\tr.ID = s.reqIDGen.Next()\n\tif r.Method == \"GET\" && r.Quorum {\n\t\tr.Method = \"QGET\"\n\t}\n\tv2api := (v2API)(&v2apiStore{s})\n\tswitch r.Method {\n\tcase \"POST\":\n\t\treturn v2api.Post(ctx, &r)\n\tcase \"PUT\":\n\t\treturn v2api.Put(ctx, &r)\n\tcase \"DELETE\":\n\t\treturn v2api.Delete(ctx, &r)\n\tcase \"QGET\":\n\t\treturn v2api.QGet(ctx, &r)\n\tcase \"GET\":\n\t\treturn v2api.Get(ctx, &r)\n\tcase \"HEAD\":\n\t\treturn v2api.Head(ctx, &r)\n\t}\n\treturn Response{}, ErrUnknownMethod\n}", "func (c clientType) execute(method, path string, body interface{}) (*resty.Response, error) {\n\treq := c.rest.R()\n\n\treq.SetBody(body)\n\n\tresp, err := req.Execute(method, path)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\n\t// fmt.Println(\"URL:\", resp.Request.URL)\n\treturn resp, nil\n}", "func HandleRequest(ctx context.Context, evt *webhooks.Data) (*webhooks.DataResponse, error) {\n\trespCode, err := client.SendEvent(ctx, evt)\n\tif err != nil {\n\t\treturn &webhooks.DataResponse{StatusCode: 0, DeliveredTime: 0, Error: err.Error()}, err\n\t}\n\treturn &webhooks.DataResponse{StatusCode: respCode, DeliveredTime: time.Now().UnixNano()}, nil\n}", "func (client *ScriptExecutionsClient) getHandleResponse(resp *http.Response) (ScriptExecutionsClientGetResponse, error) {\n\tresult := ScriptExecutionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ScriptExecution); err != nil {\n\t\treturn ScriptExecutionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}" ]
[ "0.65477353", "0.64089614", "0.63521093", "0.6293218", "0.6220044", "0.618034", "0.611625", "0.6113114", "0.6109798", "0.6105902", "0.60919166", "0.6048176", "0.60456955", "0.60319835", "0.60087895", "0.60002613", "0.599812", "0.59511447", "0.59339225", "0.591396", "0.5902561", "0.5893801", "0.58933014", "0.58753896", "0.58606815", "0.5850322", "0.58422524", "0.58385825", "0.5833221", "0.58263063", "0.58184683", "0.58040315", "0.5786875", "0.57835037", "0.57795817", "0.5771899", "0.57701117", "0.5754482", "0.5753011", "0.57451886", "0.5744216", "0.57414955", "0.5733066", "0.5729241", "0.57262546", "0.5723825", "0.5717444", "0.5709763", "0.5708529", "0.5707284", "0.57056034", "0.5705276", "0.5704922", "0.5698057", "0.5697028", "0.5696204", "0.5684937", "0.5683995", "0.5682424", "0.5680034", "0.5676513", "0.5673384", "0.5665226", "0.56586504", "0.56548065", "0.5638481", "0.5636219", "0.56355613", "0.56316626", "0.56271434", "0.56082743", "0.5599453", "0.55936533", "0.55889076", "0.55851156", "0.5565794", "0.5564286", "0.5561939", "0.5561426", "0.5560939", "0.55601805", "0.5556534", "0.5552534", "0.55499727", "0.5545629", "0.5537844", "0.5535601", "0.5533437", "0.55301166", "0.5529288", "0.55190146", "0.55148655", "0.5512279", "0.55107063", "0.5509272", "0.5509114", "0.55047154", "0.54994553", "0.54974914", "0.5495779", "0.54955256" ]
0.0
-1
NewPostSilences creates a new http.Handler for the post silences operation
func NewPostSilences(ctx *middleware.Context, handler PostSilencesHandler) *PostSilences { return &PostSilences{Context: ctx, Handler: handler} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (fn PostSilencesHandlerFunc) Handle(params PostSilencesParams) middleware.Responder {\n\treturn fn(params)\n}", "func (s *Service) AddPostHandler(w http.ResponseWriter, r *http.Request) {\n\n\tform := PForm{}\n\n\tdefer r.Body.Close()\n\tif err := json.NewDecoder(r.Body).Decode(&form); err != nil {\n\t\tmessage, code := parseError(err)\n\t\thttp.Error(w, message, code)\n\n\t\treturn\n\t}\n\n\tctx, f := context.WithTimeout(r.Context(), TimeoutRequest)\n\tdefer f()\n\n\tpost, err := s.addPost(ctx, form)\n\n\tif err != nil {\n\n\t\tmessage, code := parseError(err)\n\t\thttp.Error(w, message, code)\n\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusCreated)\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\n\tif json.NewEncoder(w).Encode(post); err != nil {\n\t\thttp.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n\t}\n\n\tgo s.broker.Brodcast(post)\n}", "func Post(h http.Handler) http.Handler {\n\treturn HTTP(h, POST)\n}", "func NewPostFunc(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != http.MethodPost {\n\t\ttools.ExecuteError(w, http.StatusMethodNotAllowed, \"Method not allowed\")\n\t\treturn\n\t}\n\tauthorID := r.FormValue(\"authorID\")\n\tauthor := r.FormValue(\"postAuthor\")\n\tthreadsID := r.Form[\"category\"] // returns slice of threadsID\n\tif count := tools.ThreadsCount(threadsID); count < 1 {\n\t\t// TODO Send message to user\n\t\thttp.Redirect(w, r, \"/addpost\", http.StatusSeeOther)\n\t\treturn\n\t}\n\tpostTitle := r.FormValue(\"postTitle\")\n\tpostContent := r.FormValue(\"postContent\")\n\tif tools.IsEmpty(postTitle) || tools.IsEmpty(postContent) {\n\t\t// TODO Send message to user\n\t\thttp.Redirect(w, r, \"/addpost\", http.StatusSeeOther)\n\t\treturn\n\t}\n\tpostsmanager.AddPost(threadsID, postTitle, postContent, author, authorID)\n\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n\tlog.Printf(\"NewPostFunc (postshandler.go) author is %s, it's id is %s, threads are %v, postTitle is %s, content is %s\", author, authorID, threadsID, postTitle, postContent)\n}", "func makeCreatePostHandler(m *http.ServeMux, endpoints endpoint.Endpoints, options []http1.ServerOption) {\n\tm.Handle(\"/create-post\", http1.NewServer(endpoints.CreatePostEndpoint, decodeCreatePostRequest, encodeCreatePostResponse, options...))\n}", "func (base linkableHandler) Post(handlerFunc ...PostHandler) linkableHandler {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tbase(w, r)\n\t\tif r.Context().Err() != nil {\n\t\t\treturn\n\t\t}\n\t\tfor _, handler := range handlerFunc {\n\t\t\thandler(w, r)\n\t\t}\n\t}\n}", "func (this *Route) POST(handlers ...HTTPHandler) *Route {\n\treturn this.addHandler(\"post\", handlers...)\n}", "func Post(handler Handler) Handler {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t// Only POST requests are authorized\n\t\tif r.Method != \"POST\" {\n\t\t\thttp.NotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\thandler(w, r)\n\t}\n}", "func HandlePostRequest(w http.ResponseWriter, r *http.Request) {\n\n}", "func New(s *service.Service) http.Handler {\n h := &handler{s}\n api := way.NewRouter()\n api.HandleFunc(\"POST\", \"/login\", h.login)\n api.HandleFunc(\"POST\", \"/send_magic_link\", h.sendMagicLink)\n api.HandleFunc(\"GET\", \"/auth_redirect\", h.authRedirect)\n api.HandleFunc(\"GET\", \"/user\", h.authUser)\n api.HandleFunc(\"POST\", \"/users/:username/toggle_follow\", h.toggleFollow)\n api.HandleFunc(\"PUT\", \"/user/avatar\", h.updateAvatar)\n api.HandleFunc(\"POST\", \"/users\", h.createUser)\n api.HandleFunc(\"GET\", \"/users\", h.users)\n api.HandleFunc(\"GET\", \"/users/:username\", h.user)\n api.HandleFunc(\"GET\", \"/users/:username/followers\", h.followers)\n api.HandleFunc(\"GET\", \"/users/:username/posts\", h.posts)\n api.HandleFunc(\"GET\", \"/users/:username/followees\", h.followees)\n\n api.HandleFunc(\"POST\", \"/posts\", h.createPost)\n api.HandleFunc(\"GET\", \"/posts/:post_id\", h.post)\n api.HandleFunc(\"POST\", \"/posts/:post_id/toggle_like\", h.togglePostLike)\n api.HandleFunc(\"POST\", \"/posts/:post_id/comments\", h.createComment)\n api.HandleFunc(\"GET\", \"/posts/:post_id/comments\", h.comments)\n\n api.HandleFunc(\"POST\", \"/comments/:comment_id/toggle_like\", h.toggleCommentLike)\n api.HandleFunc(\"GET\", \"/timeline\", h.timeline)\n api.HandleFunc(\"POST\", \"/posts/:post_id/toggle_subscription\", h.togglePostSubscription)\n\n api.HandleFunc(\"GET\", \"/notifications\", h.notifications)\n api.HandleFunc(\"POST\", \"/notifications/:notification_id/mark_as_read\", h.markNotificationAsRead)\n api.HandleFunc(\"POST\", \"/mark_notifications_as_read\", h.markAllNotificationsAsRead)\n\n fs := http.FileServer(&spaFileSystem{http.Dir(\"public\")})\n r := way.NewRouter()\n r.Handle(\"*\", \"/api...\", http.StripPrefix(\"/api\", h.withAuth(api)))\n r.Handle(\"GET\", \"/...\", fs)\n return r\n}", "func New(next http.Handler, httpsPort int) http.Handler {\n\treturn &forceHTTPSMiddleware{next: next, httpsPort: httpsPort}\n}", "func (node *Node) POST(functions ...interface{}) *Handler {\n\n\thandler := &Handler{}\n\n\tif len(functions) > 0 { handler.function = functions[0].(func (req web.RequestInterface) *web.ResponseStatus) }\n\n\tnode.addHandler(\"POST\", handler)\n\n\treturn handler\n}", "func postOnly(main func(http.ResponseWriter, *http.Request)) http.Handler {\n\treturn http.HandlerFunc(\n\t\tfunc(w http.ResponseWriter, r *http.Request) {\n\t\t\tif r.Method != \"POST\" {\n\t\t\t\thttp.Error(w, \"Only POST requests are allowed\", http.StatusMethodNotAllowed)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tmain(w, r)\n\t\t},\n\t)\n}", "func NewPostHandler(repo repository.PostRepository, eve *service.Event) postPB.PostServiceHandler {\n\treturn &PostHandler{\n\t\tpostRepository: repo,\n\t\tevent: eve,\n\t}\n}", "func Inject(inner http.Handler) http.Handler {\n\treturn http.HandlerFunc(handler(inner))\n}", "func (app *App) POST(url string, handler ...Handler) *App {\n\tapp.routeANY = false\n\tapp.AppendReqAndResp(url, \"post\", handler)\n\treturn app\n}", "func Post(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"POST\", path)\n\n\tinfoMutex.Lock()\n\tr.POST(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func makePostAcceptDealHandler(m *mux.Router, endpoints endpoint.Endpoints, options []http.ServerOption) {\n\tm.Methods(\"POST\").Path(\"/api/deals\").Handler(handlers.CORS(handlers.AllowedMethods([]string{\"POST\"}), handlers.AllowedOrigins([]string{\"*\"}))(http.NewServer(endpoints.PostAcceptDealEndpoint, decodePostAcceptDealRequest, encodePostAcceptDealResponse, options...)))\n}", "func basePostHandler(\n\thandler apiPostAction,\n\tconfig Configuration,\n\tlogging logging.Logging,\n\tmeasurement Measurement) http.HandlerFunc {\n\treturn func(writer http.ResponseWriter, request *http.Request) {\n\t\tif request.Method == \"POST\" {\n\n\t\t\trequestBody, err := ioutil.ReadAll(request.Body)\n\t\t\tdefer request.Body.Close()\n\n\t\t\tif config.errorHandle(err, writer, logging) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tstart := time.Now()\n\t\t\terrPkg := handler(writer, requestBody, logging)\n\t\t\tmeasurement.Log(request.URL.Path, time.Since(start).Nanoseconds()/1000000)\n\n\t\t\tif config.errorPkgHandle(errPkg, writer, logging) {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\thttp.Error(writer, \"Unsupported HTTP method\", 422)\n\t\t}\n\t}\n}", "func Middleware(h http.Handler) http.Handler {\n return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n log.Println(\"Running PRE plugin\")\n r.Header.Set(\"X-Trace-ID\", strconv.Itoa(int(rand.Int63())))\n h.ServeHTTP(w, r)\n })\n}", "func (h ManifestHandler) Post(w http.ResponseWriter, r *http.Request) {\n\tmethodNotAllowed(w, errors.New(\"HTTP Method \"+r.Method+\" unrecognized\"))\n}", "func CreatePostHandler(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != http.MethodPost {\n\t\tw.Write([]byte(\"Only Post.\"))\n\t\treturn\n\t}\n\tvar post data.Post\n\terr := json.NewDecoder(r.Body).Decode(&post)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\tuser, err := auth.GetSignInUser(r)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\tpost.UserID = user.UserID\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\terr = post.Save()\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\treturnMsg := fmt.Sprintf(\"Created Post(ID: %d)\", post.ID)\n\tw.Write([]byte(returnMsg))\n\treturn\n}", "func NewHandler(actions []webhook.Action) func(w http.ResponseWriter, r *http.Request) {\n\thttpHandler := func(w http.ResponseWriter, r *http.Request) {\n\n\t\tbody, err := ioutil.ReadAll(io.LimitReader(r.Body, 1048576))\n\t\tif err != nil {\n\t\t\tlog.Panic(err)\n\t\t}\n\t\tdefer r.Body.Close()\n\n\t\tvar message DockerHub\n\t\tif err := json.Unmarshal(body, &message); err != nil {\n\t\t\tlog.Printf(\"got invalid webhook message %q\", err)\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\t\tw.WriteHeader(422) // unprocessable entity\n\t\t\tfmt.Fprintf(w, \"Got an invalid webhook message. Please check the logs.\")\n\t\t} else {\n\t\t\tlog.Printf(\"got webhook message %v\", message)\n\n\t\t\tbackendImage := fmt.Sprintf(\"foo/backend:%s\", message.PushData.Images[0])\n\t\t\tfrontendImage := fmt.Sprintf(\"foo/frontend:%s\", message.PushData.Images[0])\n\t\t\tlog.Printf(\"going to deploy %q and %q\", frontendImage, backendImage)\n\n\t\t\t// docker pull foo/ansible:latest\n\t\t\t// docker run --rm -it .... foo/ansible deploy -t message.Docker.Images[0].Tag\n\t\t}\n\n\t}\n\treturn httpHandler\n}", "func NewUserHandler() *UserHandler {\n h := &UserHandler{\n Router: httprouter.New(),\n Logger: log.New(os.Stderr, \"\", log.LstdFlags),\n }\n h.POST(\"/api/user\", h.handlePostUser)\n return h\n}", "func New(config ...Config) fiber.Handler {\n\t// Set default config\n\tcfg = configDefault(config...)\n\n\t// Return new handler\n\treturn func(c *fiber.Ctx) error {\n\t\t// Don't execute middleware if Next returns true\n\t\tif cfg.Next != nil && cfg.Next(c) {\n\t\t\treturn c.Next()\n\t\t}\n\n\t\t// validate request before continuing to next handler\n\t\tok, err := validateRequest(c)\n\t\tif !ok {\n\t\t\treturn fiber.NewError(fiber.StatusForbidden, err.Error())\n\t\t}\n\n\t\t// Continue stack\n\t\treturn c.Next()\n\t}\n}", "func WithPost(next http.Handler) http.Handler {\n\thandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.Method != \"POST\" {\n\t\t\tJSONErrorResponse(w, \"Method not allowed\", http.StatusMethodNotAllowed)\n\t\t\treturn\n\t\t}\n\t\tnext.ServeHTTP(w, r)\n\t})\n\treturn handler\n}", "func NewMiddleware(handler http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tlogger := WithContext(r.Context())\n\n\t\tlogger.Infow(\"Started request\",\n\t\t\t\"method\", r.Method,\n\t\t\t\"path\", r.URL.Path,\n\t\t)\n\n\t\t// reverse proxy replaces original request with target request, so keep original one\n\t\toriginalURL := &url.URL{}\n\t\t*originalURL = *r.URL\n\n\t\tlogger = logger.With(\n\t\t\t\"method\", r.Method,\n\t\t\t\"host\", r.Host,\n\t\t\t\"request\", r.RequestURI,\n\t\t\t\"remote-addr\", r.RemoteAddr,\n\t\t\t\"referer\", r.Referer(),\n\t\t\t\"user-agent\", r.UserAgent(),\n\t\t)\n\n\t\tm := httpsnoop.CaptureMetrics(handler, w, r)\n\n\t\tlogger = logger.With(\n\t\t\t\"code\", m.Code,\n\t\t\t\"duration\", int(m.Duration/time.Millisecond),\n\t\t\t\"duration-fmt\", m.Duration.String(),\n\t\t)\n\n\t\tlogger.Info(\"Completed handling request\")\n\t})\n}", "func (eh *EventHandler) PostHandler(c *gin.Context) {\n\teventsArray, err := eh.parser.ParseEventsBody(c)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"Error parsing events body: %v\", err)\n\t\tc.JSON(http.StatusBadRequest, middleware.ErrResponse(msg, nil))\n\t\treturn\n\t}\n\n\tiface, ok := c.Get(middleware.TokenName)\n\tif !ok {\n\t\tlogging.SystemError(\"Token wasn't found in the context\")\n\t\treturn\n\t}\n\ttoken := iface.(string)\n\n\treqContext := getRequestContext(c)\n\n\t//put all events to write-ahead-log if idle\n\tif appstatus.Instance.Idle.Load() {\n\t\teh.writeAheadLogService.Consume(eventsArray, reqContext, token, eh.processor.Type())\n\t\tc.JSON(http.StatusOK, middleware.OKResponse())\n\t\treturn\n\t}\n\n\terr = eh.multiplexingService.AcceptRequest(eh.processor, reqContext, token, eventsArray)\n\tif err != nil {\n\t\tcode := http.StatusBadRequest\n\t\tif err == multiplexing.ErrNoDestinations {\n\t\t\tcode = http.StatusUnprocessableEntity\n\t\t\terr = fmt.Errorf(noDestinationsErrTemplate, token)\n\t\t}\n\n\t\treqBody, _ := json.Marshal(eventsArray)\n\t\tlogging.Warnf(\"%v. Event: %s\", err, string(reqBody))\n\t\tc.JSON(code, middleware.ErrResponse(err.Error(), nil))\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, EventResponse{Status: \"ok\", DeleteCookie: !reqContext.CookiesLawCompliant})\n}", "func (node *Node) POST(functionKeys ...string) *Handler {\n\n\th := &Handler{}\n\t\n\tif len(functionKeys) > 0 {\n\t\th.functionKey = functionKeys[0]\n\t}\n\n\tnode.addHandler(\"POST\", h)\n\n\treturn h\n}", "func New(service storage.Service) http.Handler {\n\tr := mux.NewRouter()\n\n\th := handler{service}\n\n\tr.HandleFunc(\"/health\", health)\n\tr.HandleFunc(\"/insfile\", responseJSONWithModules(h.insfileWithModules)).Methods(http.MethodPost)\n\tr.HandleFunc(\"/insfile/text\", responseTextWithModules(h.insfileWithModules)).Methods(http.MethodPost)\n\tr.HandleFunc(\"/insfile/traverse\", responseJSON(h.insfile)).Methods(http.MethodPost)\n\tr.HandleFunc(\"/insfile/traverse/text\", responseText(h.insfile)).Methods(http.MethodPost)\n\n\treturn r\n}", "func NewHandler(c *HandlerConfig) func(http.ResponseWriter, *http.Request) {\n\n\t// pushback receives the push request and writes it into a file\n\t// according to a mapping provided by a json configuration\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tt := r.Header.Get(\"Content-Type\")\n\n\t\tif t != \"binary/octet-stream\" {\n\t\t\tlog.Printf(\"Wrong Content-Type %s\", t)\n\t\t\tw.Write([]byte(fmt.Sprintf(\"%s is not a supported Content-Type\", t)))\n\t\t\treturn\n\t\t}\n\n\t\t// Open test file\n\t\tf, err := os.Create(fmt.Sprintf(\"%s/%s.pushback\", c.Path, \"test\"))\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Could not open file %e\", err)\n\t\t}\n\n\t\tn, err := io.Copy(f, r.Body)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Could only receive %d\", n)\n\t\t}\n\n\t\tw.Write([]byte(\"OK\"))\n\t}\n}", "func defaulthandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"Hello surfer!\")\n}", "func NewPostHandler(postSrv post.Service) PostHandler {\n\treturn &postHandler{postService: postSrv}\n}", "func Post(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\tinfoMutex.Lock()\n\trecord(\"POST\", path)\n\tr.Post(path, alice.New(c...).ThenFunc(fn).(http.HandlerFunc))\n\tinfoMutex.Unlock()\n}", "func makeDeletePostHandler(m *http.ServeMux, endpoints endpoint.Endpoints, options []http1.ServerOption) {\n\tm.Handle(\"/delete-post\", http1.NewServer(endpoints.DeletePostEndpoint, decodeDeletePostRequest, encodeDeletePostResponse, options...))\n}", "func NewPostTxHandler(k keeper.Keeper, contractCaller helper.IContractCaller) hmTypes.PostTxHandler {\n\treturn func(ctx sdk.Context, msg sdk.Msg, sideTxResult tmprototypes.SideTxResultType) (*sdk.Result, error) {\n\t\tctx = ctx.WithEventManager(sdk.NewEventManager())\n\n\t\tswitch msg := msg.(type) {\n\t\tcase *types.MsgValidatorJoin:\n\t\t\treturn PostHandleMsgValidatorJoin(ctx, k, *msg, sideTxResult)\n\t\tcase *types.MsgValidatorExit:\n\t\t\treturn PostHandleMsgValidatorExit(ctx, k, *msg, sideTxResult)\n\t\tcase *types.MsgSignerUpdate:\n\t\t\treturn PostHandleMsgSignerUpdate(ctx, k, *msg, sideTxResult)\n\t\tcase *types.MsgStakeUpdate:\n\t\t\treturn PostHandleMsgStakeUpdate(ctx, k, *msg, sideTxResult)\n\t\tdefault:\n\t\t\terrMsg := fmt.Sprintf(\"unrecognized %s message type: %T\", types.ModuleName, msg)\n\t\t\treturn nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)\n\t\t}\n\t}\n}", "func NewHandler(ctx context.Context, rsService store.RulesetService, cfg Config) http.Handler {\n\ts := service{\n\t\trulesets: rsService,\n\t}\n\n\tvar logger zerolog.Logger\n\n\tif cfg.Logger != nil {\n\t\tlogger = *cfg.Logger\n\t} else {\n\t\tlogger = zerolog.New(os.Stderr).With().Timestamp().Logger()\n\t}\n\n\tif cfg.Timeout == 0 {\n\t\tcfg.Timeout = 5 * time.Second\n\t}\n\n\tif cfg.WatchTimeout == 0 {\n\t\tcfg.WatchTimeout = 30 * time.Second\n\t}\n\n\trs := rulesetService{\n\t\tservice: &s,\n\t\ttimeout: cfg.Timeout,\n\t\twatchTimeout: cfg.WatchTimeout,\n\t}\n\n\t// router\n\tmux := http.NewServeMux()\n\tmux.Handle(\"/rulesets/\", &rs)\n\n\t// middlewares\n\tchain := []func(http.Handler) http.Handler{\n\t\thlog.NewHandler(logger),\n\t\thlog.AccessHandler(func(r *http.Request, status, size int, duration time.Duration) {\n\t\t\thlog.FromRequest(r).Info().\n\t\t\t\tStr(\"method\", r.Method).\n\t\t\t\tStr(\"url\", r.URL.String()).\n\t\t\t\tInt(\"status\", status).\n\t\t\t\tInt(\"size\", size).\n\t\t\t\tDur(\"duration\", duration).\n\t\t\t\tMsg(\"request received\")\n\t\t}),\n\t\thlog.RemoteAddrHandler(\"ip\"),\n\t\thlog.UserAgentHandler(\"user_agent\"),\n\t\thlog.RefererHandler(\"referer\"),\n\t\tfunc(http.Handler) http.Handler {\n\t\t\treturn mux\n\t\t},\n\t}\n\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// playing the middleware chain\n\t\tvar cur http.Handler\n\t\tfor i := len(chain) - 1; i >= 0; i-- {\n\t\t\tcur = chain[i](cur)\n\t\t}\n\n\t\t// serving the request\n\t\tcur.ServeHTTP(w, r.WithContext(ctx))\n\t})\n}", "func makeGetPostHandler(m *http.ServeMux, endpoints endpoint.Endpoints, options []http1.ServerOption) {\n\tm.Handle(\"/get-post\", http1.NewServer(endpoints.GetPostEndpoint, decodeGetPostRequest, encodeGetPostResponse, options...))\n}", "func (app *App) Post(url string, handler handlerFunc) {\n\trequestRegexp := app.craterRouter.normalizeRoute(url)\n\tapp.craterRequestHandler.handlePost(requestRegexp, func(w http.ResponseWriter, r *http.Request) {\n\t\tapp.serveRequest(w, r, handler, requestRegexp)\n\t})\n}", "func NewSilences(db *sql.DB, mk types.Marker) (*Silences, error) {\n\tdbmtx.Lock()\n\tdefer dbmtx.Unlock()\n\n\ttx, err := db.Begin()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif _, err := tx.Exec(createSilencesTable); err != nil {\n\t\ttx.Rollback()\n\t\treturn nil, err\n\t}\n\ttx.Commit()\n\n\treturn &Silences{db: db, marker: mk}, nil\n}", "func (h *HttpHandlerFactory) newHttpHandler(webhookHandler WebhookHandlerBase, mutateFunc func(ctx context.Context, review v1beta1.AdmissionReview) ([]PatchOperation, error)) http.HandlerFunc {\n\treturn func(writer http.ResponseWriter, request *http.Request) {\n\t\tif request.Header.Get(\"Content-Type\") != \"application/json\" {\n\t\t\twebhookHandler.Log(\"level\", \"error\", \"message\", fmt.Sprintf(\"invalid content-type: %q\", request.Header.Get(\"Content-Type\")))\n\t\t\twriter.WriteHeader(http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tdata, err := ioutil.ReadAll(request.Body)\n\t\tif err != nil {\n\t\t\twebhookHandler.Log(\"level\", \"error\", \"message\", \"unable to read request\", \"stack\", microerror.JSON(err))\n\t\t\twriter.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\treview := v1beta1.AdmissionReview{}\n\t\tif _, _, err := Deserializer.Decode(data, nil, &review); err != nil {\n\t\t\twebhookHandler.Log(\"level\", \"error\", \"message\", \"unable to parse admission review request\", \"stack\", microerror.JSON(err))\n\t\t\twriter.WriteHeader(http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tvar patch []PatchOperation\n\t\tif review.Request.DryRun != nil && *review.Request.DryRun {\n\t\t\twebhookHandler.Log(\"level\", \"debug\", \"message\", \"Dry run is not supported. Request processing stopped.\", \"stack\", microerror.JSON(err))\n\t\t} else {\n\t\t\tpatch, err = mutateFunc(request.Context(), review)\n\t\t\tif err != nil {\n\t\t\t\twriteResponse(webhookHandler, writer, errorResponse(review.Request.UID, microerror.Mask(err)))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tresourceName := fmt.Sprintf(\"%s %s/%s\", review.Request.Kind, review.Request.Namespace, extractName(review.Request))\n\t\tpatchData, err := json.Marshal(patch)\n\t\tif err != nil {\n\t\t\twebhookHandler.Log(\"level\", \"error\", \"message\", fmt.Sprintf(\"unable to serialize patch for %s\", resourceName), \"stack\", microerror.JSON(err))\n\t\t\twriteResponse(webhookHandler, writer, errorResponse(review.Request.UID, InternalError))\n\t\t\treturn\n\t\t}\n\n\t\twebhookHandler.Log(\"level\", \"debug\", \"message\", fmt.Sprintf(\"admitted %s (with %d patches)\", resourceName, len(patch)))\n\n\t\tpt := v1beta1.PatchTypeJSONPatch\n\t\twriteResponse(webhookHandler, writer, &v1beta1.AdmissionResponse{\n\t\t\tAllowed: true,\n\t\t\tUID: review.Request.UID,\n\t\t\tPatch: patchData,\n\t\t\tPatchType: &pt,\n\t\t})\n\t}\n}", "func New(handlers ...func(http.Handler) http.Handler) *Chain {\n\treturn &Chain{hs: handlers}\n}", "func (app *application) createSnippet(w http.ResponseWriter, r *http.Request) {\n\n\tif r.Method != http.MethodPost {\n\t\t// If it's not, use the w.WriteHeader() method to send a 405 status\n\t\t// code and the w.Write() method to write a \"Method Not Allowed\"\n\t\t// response body. We then return from the function so that the\n\t\t// subsequent code is not executed.\n\t\tw.Header().Set(\"Allow\", http.MethodPost) // specify allowed method in a header like: Allow: POST\n\t\t// Use the http.Error() function to send a 405 status code and \"Method Not\n\t\t// Allowed\" string as the response body.\n\t\thttp.Error(w, \"Method Not Allowed\", 405)\n\t\treturn\n\n\t}\n\tw.Write([]byte(\"Create a new snippet...\"))\n}", "func (g *RouterGroup) POST(url string, handler ...Handler) *RouterGroup {\n\tg.app.routeANY = false\n\tg.AppendReqAndResp(url, \"post\", handler)\n\treturn g\n}", "func (r *Route) Post(handler http.Handler) *Route {\n\tr.handlers[http.MethodPost] = handler\n\treturn r\n}", "func MakeHttpHandler(ctx context.Context, endpoints endpoint.Endpoints, logger log.Logger, zipkinTracer *gozipkin.Tracer,) http.Handler {\n\tr := mux.NewRouter()\n\t// 链路追踪\n\tzipkinServer := zipkin.HTTPServerTrace(zipkinTracer, zipkin.Name(\"http-transport\"))\n\toptions := []kithttp.ServerOption{\n\t\tkithttp.ServerErrorLogger(logger),\n\t\tkithttp.ServerErrorEncoder(kithttp.DefaultErrorEncoder),\n\t\tkithttp.ServerErrorEncoder(func(ctx context.Context, err error, w http.ResponseWriter) {\n\t\t\tlogger.Log(fmt.Sprint(ctx.Value(ContextReqUUid)))\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\tjson.NewEncoder(w).Encode(err)\n\t\t}),\n\t\tkithttp.ServerBefore(func(ctx context.Context, request *http.Request) context.Context {\n\t\t\tUUID := uuid.NewV5(uuid.Must(uuid.NewV4(),nil), \"req_uuid\").String()\n\t\t\tlogger.Log(\"给请求添加uuid\", zap.Any(\"UUID\", UUID))\n\t\t\tctx = context.WithValue(ctx, ContextReqUUid, UUID)\n\t\t\treturn ctx\n\t\t}),\n\t\tzipkinServer,\n\t}\n\tr.Methods(\"POST\").Path(\"/movie-tags\").Handler(kithttp.NewServer(\n\t\tendpoints.MovieTags,\n\t\tdecodeMoviesTagsRequest, // 请求参数\n\t\tencode.JsonResponse,\n\t\toptions...,\n\t))\n // 暴露具体的 endpoint\n\tr.Methods(\"POST\").Path(\"/movie-list\").Handler(kithttp.NewServer(\n\t\tendpoints.MoviesList,\n\t\tdecodeHotPlayMoviesrRequest, // 请求参数\n\t\tencode.JsonResponse,\n\t\toptions...,\n\t))\n\n\tr.Methods(\"POST\").Path(\"/movie-detail\").Handler(kithttp.NewServer(\n\t\tendpoints.MovieDetail,\n\t\tdecodMovieDetailRequest, // 请求参数\n\t\tencode.JsonResponse,\n\t\toptions...,\n\t))\n\tr.Methods(\"POST\").Path(\"/credits\").Handler(kithttp.NewServer(\n\t\tendpoints.MovieCreditsWithTypes,\n\t\tdecodeMovieCreditsWithTypes, // 请求参数\n\t\tencode.JsonResponse,\n\t\toptions...,\n\t))\n\treturn r\n}", "func Trace(handler http.Handler) http.Handler {\n\tif handler == nil {\n\t\thandler = http.DefaultServeMux\n\t}\n\treturn TracingHandlerFunc(\n\t\thttp.HandlerFunc(\n\t\t\tfunc(w http.ResponseWriter, r *http.Request) {\n\t\t\t\thandler.ServeHTTP(w, r)\n\t\t\t},\n\t\t),\n\t)\n}", "func NewPost(url string) *Request { return NewRequest(\"POST\", url) }", "func (c *HookEventControllers) Post() {\n\tif ok := c.isLegitimateHookEvent(); !ok {\n\t\tc.Ctx.ResponseWriter.WriteHeader(406)\n\t\tc.Ctx.WriteString(\"Illegal incident, discarded\")\n\t\treturn\n\t}\n\teventType := c.Ctx.Request.Header.Get(XGIteeEventType)\n\tc.Ctx.ResponseWriter.WriteHeader(200)\n\tc.Ctx.WriteString(\"Event received: \" + eventType)\n\tswitch eventType {\n\tcase NoteHookType: //handle comment hook data\n\t\tc.handleNoteDate()\n\tcase PullReqHookType:\n\t\tc.handlePullReq()\n\tcase IssueHookType:\n\t\tc.handleIssue()\n\tcase PushTagHookType:\n\t\tc.handlePushTag()\n\tdefault:\n\t\tlogs.Info(eventType)\n\t}\n}", "func New(middlewares ...Middleware) Middleware {\n\treturn Middleware(func(handler http.Handler) http.Handler {\n\t\treturn handler\n\t}).Use(middlewares...)\n}", "func handleNewHook(resp http.ResponseWriter, request *http.Request) {\n\tcors := handleCors(resp, request)\n\tif cors {\n\t\treturn\n\t}\n\n\tuser, err := handleApiAuthentication(resp, request)\n\tif err != nil {\n\t\tlog.Printf(\"Api authentication failed in set new workflowhandler: %s\", err)\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false}`))\n\t\treturn\n\t}\n\n\ttype requestData struct {\n\t\tType string `json:\"type\"`\n\t\tDescription string `json:\"description\"`\n\t\tId string `json:\"id\"`\n\t\tName string `json:\"name\"`\n\t\tWorkflow string `json:\"workflow\"`\n\t}\n\n\tbody, err := ioutil.ReadAll(request.Body)\n\tif err != nil {\n\t\tlog.Printf(\"Body data error: %s\", err)\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false}`))\n\t\treturn\n\t}\n\n\tlog.Println(\"Data: %s\", string(body))\n\n\tctx := context.Background()\n\tvar requestdata requestData\n\terr = yaml.Unmarshal([]byte(body), &requestdata)\n\tif err != nil {\n\t\tlog.Printf(\"Failed unmarshaling inputdata: %s\", err)\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false}`))\n\t\treturn\n\t}\n\tlog.Printf(\"%#v\", requestdata)\n\n\t// CBA making a real thing. Already had some code lol\n\tnewId := requestdata.Id\n\tif len(newId) != 36 {\n\t\tlog.Printf(\"Bad ID\")\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false, \"reason\": \"Invalid ID\"}`))\n\t\treturn\n\t}\n\n\tif requestdata.Id == \"\" || requestdata.Name == \"\" {\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false, \"reason\": \"Requires fields id and name can't be empty\"}`))\n\t\treturn\n\n\t}\n\n\tvalidTypes := []string{\n\t\t\"webhook\",\n\t}\n\n\tisTypeValid := false\n\tfor _, thistype := range validTypes {\n\t\tif requestdata.Type == thistype {\n\t\t\tisTypeValid = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !(isTypeValid) {\n\t\tlog.Printf(\"Type %s is not valid. Try any of these: %s\", requestdata.Type, strings.Join(validTypes, \", \"))\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false}`))\n\t\treturn\n\t}\n\n\thook := Hook{\n\t\tId: newId,\n\t\tWorkflows: []string{requestdata.Workflow},\n\t\tInfo: Info{\n\t\t\tName: requestdata.Name,\n\t\t\tDescription: requestdata.Description,\n\t\t\tUrl: fmt.Sprintf(\"https://shuffler.io/functions/webhooks/webhook_%s\", newId),\n\t\t},\n\t\tType: \"webhook\",\n\t\tOwner: user.Username,\n\t\tStatus: \"uninitialized\",\n\t\tActions: []HookAction{\n\t\t\tHookAction{\n\t\t\t\tType: \"workflow\",\n\t\t\t\tName: requestdata.Name,\n\t\t\t\tId: requestdata.Workflow,\n\t\t\t\tField: \"\",\n\t\t\t},\n\t\t},\n\t\tRunning: false,\n\t}\n\n\tlog.Printf(\"Hello\")\n\n\t// FIXME: Add cloud function execution?\n\t//b, err := json.Marshal(hook)\n\t//if err != nil {\n\t//\tlog.Printf(\"Failed marshalling: %s\", err)\n\t//\tresp.WriteHeader(401)\n\t//\tresp.Write([]byte(`{\"success\": false}`))\n\t//\treturn\n\t//}\n\n\t//environmentVariables := map[string]string{\n\t//\t\"FUNCTION_APIKEY\": user.ApiKey,\n\t//\t\"CALLBACKURL\": \"https://shuffler.io\",\n\t//\t\"HOOKID\": hook.Id,\n\t//}\n\n\t//applocation := fmt.Sprintf(\"gs://%s/triggers/webhook.zip\", bucketName)\n\t//hookname := fmt.Sprintf(\"webhook_%s\", hook.Id)\n\t//err = deployWebhookFunction(ctx, hookname, defaultLocation, applocation, environmentVariables)\n\t//if err != nil {\n\t//\tlog.Printf(\"Error deploying hook: %s\", err)\n\t//\tresp.WriteHeader(401)\n\t//\tresp.Write([]byte(fmt.Sprintf(`{\"success\": false, \"reason\": \"Issue with starting hook. Please wait a second and try again\"}`)))\n\t//\treturn\n\t//}\n\n\thook.Status = \"running\"\n\thook.Running = true\n\terr = setHook(ctx, hook)\n\tif err != nil {\n\t\tlog.Printf(\"Failed setting hook: %s\", err)\n\t\tresp.WriteHeader(401)\n\t\tresp.Write([]byte(`{\"success\": false}`))\n\t\treturn\n\t}\n\n\terr = increaseStatisticsField(ctx, \"total_workflow_triggers\", requestdata.Workflow, 1)\n\tif err != nil {\n\t\tlog.Printf(\"Failed to increase total workflows: %s\", err)\n\t}\n\n\tlog.Println(\"Generating new hook\")\n\tresp.WriteHeader(200)\n\tresp.Write([]byte(`{\"success\": true}`))\n}", "func Create() http.Handler {\n\trouter := httprouter.New()\n\n\trouter.Handle(\"GET\", \"/\", middle.ResponseHandler(Hello))\n\trouter.Handle(\"POST\", \"/post\", middle.ResponseHandler(Hello))\n\trouter.Handle(\"GET\", \"/error\", middle.ResponseHandler(ErrorRoute))\n\trouter.Handle(\"GET\", \"/user-error\", middle.ResponseHandler(UserErrorRoute))\n\trouter.Handle(\"GET\", \"/multi-error\", middle.ResponseHandler(MultiErrorRoute))\n\trouter.Handle(\"GET\", \"/panic\", middle.ResponseHandler(Panic))\n\trouter.Handle(\"GET\", \"/version\", Version)\n\n\treturn alice.New(\n\t\tmiddle.RecoveryHandler,\n\t\tmiddle.FrameHandler,\n\t\tmiddle.RequestIDHandler,\n\t\tmiddle.RequestPathHandler,\n\t\tmiddle.BodyHandler).\n\t\tThen(router)\n}", "func NewHandler(\n\tstateDecoder oidc.Decoder,\n\tcookieDecoder oidc.Decoder,\n\tgetHandler HandlerFunc, // use NewGetHandler() for production\n\tpostHandler HandlerFunc, // use NewPostHandler() for production\n) http.Handler {\n\tloginHandler := httperr.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {\n\t\tvar handler HandlerFunc\n\t\tswitch r.Method {\n\t\tcase http.MethodGet:\n\t\t\thandler = getHandler\n\t\tcase http.MethodPost:\n\t\t\thandler = postHandler\n\t\tdefault:\n\t\t\treturn httperr.Newf(http.StatusMethodNotAllowed, \"%s (try GET or POST)\", r.Method)\n\t\t}\n\n\t\tencodedState, decodedState, err := oidc.ReadStateParamAndValidateCSRFCookie(r, cookieDecoder, stateDecoder)\n\t\tif err != nil {\n\t\t\tplog.InfoErr(\"state or CSRF error\", err)\n\t\t\treturn err\n\t\t}\n\n\t\tswitch decodedState.UpstreamType {\n\t\tcase string(idpdiscoveryv1alpha1.IDPTypeLDAP), string(idpdiscoveryv1alpha1.IDPTypeActiveDirectory):\n\t\t\t// these are the types supported by this endpoint, so no error here\n\t\tdefault:\n\t\t\treturn httperr.Newf(http.StatusBadRequest, \"not a supported upstream IDP type for this endpoint: %q\", decodedState.UpstreamType)\n\t\t}\n\n\t\treturn handler(w, r, encodedState, decodedState)\n\t})\n\n\treturn wrapSecurityHeaders(loginHandler)\n}", "func (serv *Server) POST(url string, handlers ...Handler) {\n\tserv.Handle(\"POST\", url, handlers...)\n}", "func ValPOST(next http.Handler) http.Handler {\n\tm := \"POST\"\n\n\t// Define a function that passes on a POST but returns for any other type of request\n\tfn := func(w http.ResponseWriter, r *http.Request) {\n\t\t// Check the existing request method\n\t\tif r.Method == m {\n\t\t\t// Request method is a post, continue down the chain of middleware\n\t\t\tnext.ServeHTTP(w, r)\n\t\t} else {\n\t\t\t// Request is NOT a post return\n\t\t\tlog.Printf(\"INFO: Request from %v is not a %v. Not continuing.\\n\", r.URL.String(), m)\n\t\t\t// Reply to the request with an Error\n\t\t\thttp.Error(w, fmt.Sprintf(\"STATUS = Method [%v] not allowed.\", r.Method), http.StatusMethodNotAllowed)\n\t\t}\n\t}\n\n\treturn http.HandlerFunc(fn)\n}", "func make(metricsName string, h util.JSONRequestHandler) http.Handler {\n\treturn prometheus.InstrumentHandler(metricsName, util.MakeJSONAPI(h))\n}", "func ServeNew(w http.ResponseWriter, r *http.Request) {\n\tvar data newReq\n\n\tID, err := ulid.New(ulid.Now(), entropy)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\terr = json.NewDecoder(r.Body).Decode(&data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\tnewH := NewHMST(data.Resolution, data.MaxTime, data.Keys)\n\tregistry[ID.String()] = newH\n\tlog.Println(\"/new\", ID.String(), data, len(newH.Registers))\n\tfmt.Fprintf(w, \"%v\", ID)\n}", "func denitialise(h *HTTP) {\n\tclose(h.events)\n\tclose(h.signals)\n}", "func NewMiddleware(handler http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif acceptedMethods[r.Method] {\n\t\t\thandler.ServeHTTP(w, r)\n\t\t} else {\n\t\t\tmetrics.RejectedRequestsCount.Inc()\n\t\t\thttp.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)\n\t\t}\n\t})\n}", "func (s *AppServer) new(w http.ResponseWriter, r *http.Request, params *AppParams, handlers []Middleware) *Context {\n\t// adjust request id\n\trequestId := r.Header.Get(s.requestId)\n\tif requestId == \"\" {\n\t\trequestId = NewObjectId().Hex()\n\n\t\t// inject request header with new request id\n\t\tr.Header.Set(s.requestId, requestId)\n\t}\n\tw.Header().Set(s.requestId, requestId)\n\n\tctx := s.pool.Get().(*Context)\n\tctx.Request = r\n\tctx.Response = &ctx.writer\n\tctx.Params = params\n\tctx.Logger = s.logger.New(requestId)\n\tctx.settings = nil\n\tctx.frozenSettings = nil\n\tctx.writer.reset(w)\n\tctx.handlers = handlers\n\tctx.index = -1\n\tctx.startedAt = time.Now()\n\tctx.downAfter = ctx.startedAt.Add(s.slowdown)\n\n\treturn ctx\n}", "func New() context.Handler {\n\treturn func(ctx *context.Context) {\n\t\tdefer func() {\n\t\t\tif err := recover(); err != nil {\n\t\t\t\tif ctx.IsStopped() { // handled by other middleware.\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tvar stacktrace string\n\t\t\t\tfor i := 1; ; i++ {\n\t\t\t\t\t_, f, l, got := runtime.Caller(i)\n\t\t\t\t\tif !got {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tstacktrace += fmt.Sprintf(\"%s:%d\\n\", f, l)\n\t\t\t\t}\n\n\t\t\t\t// when stack finishes\n\t\t\t\tlogMessage := fmt.Sprintf(\"Recovered from a route's Handler('%s')\\n\", ctx.HandlerName())\n\t\t\t\tlogMessage += fmt.Sprintf(\"At Request: %s\\n\", getRequestLogs(ctx))\n\t\t\t\tlogMessage += fmt.Sprintf(\"Trace: %s\\n\", err)\n\t\t\t\tlogMessage += fmt.Sprintf(\"\\n%s\", stacktrace)\n\t\t\t\tctx.Application().Logger().Warn(logMessage)\n\n\t\t\t\tctx.StopWithStatus(500)\n\t\t\t}\n\t\t}()\n\n\t\tctx.Next()\n\t}\n}", "func Post(route string, do interface{}) *handler {\n\treturn handlerByMethod(&route, do, \"POST\")\n}", "func CreatePostHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params) {\n\tresponse, err := restClient.Post(postsUrl, r, r.Header)\n\n\tif err != nil {\n\t\trestClient.WriteErrorResponse(w, \"server_error\", \"Server error occured\")\n\t\treturn\n\t}\n\n\tvar post Post\n\trestClient.WriteJSONResponse(w, response, post)\n}", "func newHTTPHandler(web3Handler Web3Handler) *hTTPHandler {\n\treturn &hTTPHandler{\n\t\tmsgHandler: web3Handler,\n\t}\n}", "func NewHandler(clusterService agent.ClusterService, agentTags *agent.InfoTags, notaryService *security.NotaryService) *Handler {\n\th := &Handler{\n\t\tRouter: mux.NewRouter(),\n\t\tconnectionUpgrader: websocket.Upgrader{},\n\t\tclusterService: clusterService,\n\t\tagentTags: agentTags,\n\t}\n\n\th.Handle(\"/websocket/attach\", notaryService.DigitalSignatureVerification(httperror.LoggerHandler(h.websocketAttach)))\n\th.Handle(\"/websocket/exec\", notaryService.DigitalSignatureVerification(httperror.LoggerHandler(h.websocketExec)))\n\treturn h\n}", "func MakeHandler(service Service, logger kitlog.Logger, ml machineLearning.Service) http.Handler {\n\topts := gokit.GetServerOpts(logger, ml)\n\n\talertHandler := kithttp.NewServer(makeAlertEndpoint(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\timageAlertHandler := kithttp.NewServer(makeImageAlertEndpoint(service), gokit.DecodeFromBase64, gokit.EncodeResponse, opts...)\n\n\theartbeatAlertHandler := kithttp.NewServer(makeHeartbeatMessageEncpoint(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\theartbeatImageHandler := kithttp.NewServer(makeImageHeartbeatEndpoint(service), gokit.DecodeFromBase64, gokit.EncodeResponse, opts...)\n\n\tbusienssAlertHandler := kithttp.NewServer(makeBusinessAlertEndpoint(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\n\talertErrorHandler := kithttp.NewServer(makeAlertErrorHandler(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\n\tr := mux.NewRouter()\n\n\tr.Handle(\"/alert/\", alertHandler).Methods(\"POST\")\n\tr.Handle(\"/alert/image\", imageAlertHandler).Methods(\"POST\")\n\n\tr.Handle(\"/alert/heartbeat\", heartbeatAlertHandler).Methods(\"POST\")\n\tr.Handle(\"/alert/heartbeat/image\", heartbeatImageHandler).Methods(\"POST\")\n\n\tr.Handle(\"/alert/error\", alertErrorHandler).Methods(\"POST\")\n\n\tr.Handle(\"/alert/business\", busienssAlertHandler).Methods(\"POST\")\n\n\treturn r\n}", "func AddHandlers(\n\tservices *Services,\n\tmalformedHandler func(w http.ResponseWriter, r *http.Request)) {\n\thttp.HandleFunc(\"/swift/register\", HandlerRegister(services))\n\thttp.HandleFunc(\"/swift/api/v1/create\", HandlerCreate(services))\n\thttp.HandleFunc(\"/swift/api/v1/encrypt\", HandlerEncrypt(services))\n\thttp.HandleFunc(\"/swift/api/v1/decrypt\", HandlerDecrypt(services))\n\thttp.HandleFunc(\"/swift/api/v1/decode-as-json\", HandlerDecodeAsJSON(services))\n\thttp.HandleFunc(\"/\", HandlerStore(services, malformedHandler))\n}", "func createPoolHandler(cliCtx client.Context) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvar req CreatePoolReq\n\t\tif !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {\n\t\t\trest.WriteErrorResponse(w, http.StatusBadRequest, \"failed to parse request\")\n\t\t\treturn\n\t\t}\n\n\t\treq.BaseReq = req.BaseReq.Sanitize()\n\t\tif !req.BaseReq.ValidateBasic(w) {\n\t\t\treturn\n\t\t}\n\n\t\tsigner, err := sdk.AccAddressFromBech32(req.Signer)\n\t\tif err != nil {\n\t\t\trest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())\n\t\t\treturn\n\t\t}\n\n\t\tmsg := types.NewMsgCreatePool(signer, req.ExternalAsset, req.NativeAssetAmount, req.ExternalAssetAmount)\n\n\t\terr = msg.ValidateBasic()\n\t\tif err != nil {\n\t\t\trest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())\n\t\t\treturn\n\t\t}\n\n\t\ttx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, &msg)\n\t}\n}", "func PostEntryNew(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\tif isLoggedIn(w, req) {\n\t\tq := req.URL.Query()\n\t\tbox, _ := strconv.Atoi(q[\"box\"][0])\n\t\tpacket, _ := strconv.Atoi(q[\"packet\"][0])\n\t\tid, _ := strconv.Atoi(q[\"product\"][0])\n\t\tje := opdatabase.JournalEntry{\n\t\t\tID: 0,\n\t\t\tLabour: q[\"labour\"][0],\n\t\t\tDate: q[\"date\"][0],\n\t\t\tBox: box,\n\t\t\tPacket: packet,\n\t\t\tProductID: id,\n\t\t}\n\t\tgo model.UpdateLabourNames(je.Labour, je.Date, labours)\n\t\tmodel.CreateJournalEntry(je)\n\t\tres := Response{\n\t\t\t301,\n\t\t\tResponse{20, \", \"},\n\t\t}\n\t\tp, err := json.Marshal(res)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\t\tio.WriteString(w, string(p))\n\n\t}\n}", "func PostsCreateHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Posts create\")\n}", "func HandleNew() http.HandlerFunc {\n\tdb, err := sql.Open(\"mysql\", \"root:my-secret-pw@/goauth\")\n\tif err != nil {\n\t\tlog.Fatalf(\"could not establish database connection: %v\", err)\n\t}\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tencoder := json.NewEncoder(w)\n\t\tvars := mux.Vars(r)\n\t\temail, ok := vars[\"email\"]\n\t\tif !ok {\n\t\t\tlog.Fatalln(\"no `email` in URL for HandleNew() handler\")\n\t\t}\n\n\t\tvar id int64\n\t\trow := db.QueryRow(\"SELECT id FROM users WHERE email = ?\", email)\n\t\terr := row.Scan(&id)\n\t\tif err == sql.ErrNoRows {\n\t\t\tw.WriteHeader(404)\n\t\t\terr := encoder.Encode(map[string]string{\n\t\t\t\t\"error\": \"email not found\",\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tvar req createNewRequest\n\t\terr = json.NewDecoder(r.Body).Decode(&req)\n\t\tif err != nil {\n\t\t\t// TODO make response format consistent\n\t\t\thttp.Error(w, \"bad request\", 400)\n\t\t\treturn\n\t\t}\n\n\t\terrors := req.validate()\n\t\tif len(errors) > 0 {\n\t\t\tw.WriteHeader(400)\n\t\t\terr := encoder.Encode(map[string]interface{}{\n\t\t\t\t\"errors\": errors,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tstmt, err := db.Prepare(\"INSERT INTO scopes (user_id, scope) VALUES (?, ?)\")\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"internal error\", 500)\n\t\t\tlog.Printf(\"could not create insert statement: %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\t_, err = stmt.Exec(id, req.Scope)\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"internal error\", 500)\n\t\t\tlog.Printf(\"error while inserting scope: %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(201)\n\t\tencoder.Encode(map[string]string{\n\t\t\t\"message\": \"scope created\",\n\t\t})\n\t}\n}", "func newHTTPHandler(c ServiceController, k8sStorage ServiceStorage) *httpHandler {\n\treturn &httpHandler{\n\t\tcontroller: c,\n\t\tk8sStorage: k8sStorage,\n\t}\n}", "func (c *GaussHookEventControllers) Post() {\n\tif ok := c.isLegitimateHookEvent(); !ok {\n\t\tc.Ctx.ResponseWriter.WriteHeader(406)\n\t\tc.Ctx.WriteString(\"Illegal incident, discarded\")\n\t\treturn\n\t}\n\teventType := c.Ctx.Request.Header.Get(XGIteeEventType)\n\tlogs.Info(string(c.Ctx.Input.RequestBody), \"\\n\", \"eventTyped: \", eventType)\n\tc.Ctx.ResponseWriter.WriteHeader(200)\n\tc.Ctx.WriteString(\"Event received: \" + eventType)\n\tswitch eventType {\n\tcase NoteHookType: //handle comment hook data\n\t\tc.handleNoteDate()\n\tcase PullReqHookType:\n\t\tc.handlePullReq()\n\tcase IssueHookType:\n\t\tc.handleIssue()\n\tcase PushTagHookType:\n\t\tc.handlePushTag()\n\tdefault:\n\t\tlogs.Info(eventType)\n\t}\n}", "func New(s *service.Service) http.Handler {\n\th := handler{s}\n\tapi := way.NewRouter()\n\tapi.HandleFunc(\"POST\", \"/\", h.twillioHandler)\n\tapi.HandleFunc(\"POST\", \"/passcodes\", h.generatePasswords)\n\tapi.HandleFunc(\"GET\", \"/passcodes\", h.getPasscodes)\n\t// api.HandleFunc(\"POST\", \"/passcode/validate\", h.validatePasscode)\n\treturn api\n}", "func NewHTTPHandler() http.Handler { // Zipkin HTTP Server Trace can either be instantiated per endpoint with a\n\tm := bone.New()\n\tm.Get(\"/*\", httpSwagger.Handler(\n\t\thttpSwagger.URL(\"https://mask.goodideas-studio.com/docs/doc.json\"), //The url pointing to API definition\"\n\t))\n\treturn cors.AllowAll().Handler(m)\n}", "func (base linkableHandler) PreWithRunPost(handlerFunc ...PreHandler, ) linkableHandler {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, cancel := context.WithCancel(r.Context())\n\t\tcancelableRequest := r.Clone(ctx)\n\t\tfor _, handler := range handlerFunc {\n\t\t\thandler(w, cancelableRequest, cancel)\n\t\t\tif cancelableRequest.Context().Err() != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tbase(w, cancelableRequest)\n\t}\n}", "func makeHandler(server *ServerContext, privs handlerPrivs, method handlerMethod) http.Handler {\n\treturn http.HandlerFunc(func(r http.ResponseWriter, rq *http.Request) {\n\t\th := newHandler(server, privs, r, rq)\n\t\terr := h.invoke(method)\n\t\th.writeError(err)\n\t\th.logDuration(true) \n\t})\n}", "func (d *Daemon) createHandler(w *rest.ResponseWriter, r *rest.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tApiResponse(w, 500, \"BAD_REQUEST\")\n\t\treturn\n\t}\n\n\tvar id string\n\tvar blockType string\n\tfType, typeExists := r.Form[\"blockType\"]\n\tfID, idExists := r.Form[\"id\"]\n\n\tif typeExists == false {\n\t\tApiResponse(w, 500, \"MISSING_BLOCKTYPE\")\n\t\treturn\n\t} else {\n\t\tblockType = fType[0]\n\t}\n\n\t_, inLibrary := blocks.Library[blockType]\n\tif inLibrary == false {\n\t\tApiResponse(w, 500, \"INVALID_BLOCKTYPE\")\n\t\treturn\n\t}\n\n\tif idExists == false {\n\t\tid = <-idChan\n\t} else {\n\n\t\tif len(strings.TrimSpace(fID[0])) == 0 {\n\t\t\tApiResponse(w, 500, \"BAD_BLOCK_ID\")\n\t\t\treturn\n\t\t}\n\n\t\t_, notUnique := d.blockMap[fID[0]]\n\t\tif notUnique == true {\n\t\t\tApiResponse(w, 500, \"BLOCK_ID_ALREADY_EXISTS\")\n\t\t\treturn\n\t\t} else {\n\t\t\tid = fID[0]\n\t\t}\n\t}\n\n\td.CreateBlock(blockType, id)\n\n\tApiResponse(w, 200, \"BLOCK_CREATED\")\n}", "func NewHandler(k Keeper) sdk.Handler {\n\treturn func(ctx sdk.Context, msg sdk.Msg) sdk.Result {\n\t\tswitch msg := msg.(type) {\n\t\tcase MsgRecordReputation:\n\t\t\treturn handleMsgRecordReputation(ctx, k, msg)\n\t\tdefault:\n\t\t\terrMsg := fmt.Sprintf(\"unrecognized %s message type: %T\", types.ModuleName, msg)\n\t\t\treturn sdk.ErrUnknownRequest(errMsg).Result()\n\t\t}\n\t}\n}", "func New(next http.Handler, requestFilters []RequestFilter,\n\tresponseFilters []ResponseFilter, mode ProtectionMode) Middleware {\n\treturn Middleware{\n\t\tNext: next,\n\t\tRequestFilters: requestFilters,\n\t\tResponseFilters: responseFilters,\n\t\tMode: mode,\n\t\tError: BasicError,\n\t\tNow: time.Now,\n\t\tLogger: func(s string) { os.Stderr.WriteString(s) },\n\t}\n}", "func NewPostWebhook(branchesToIgnore string, committersToIgnore string, enabled bool, id int32, title string, url string) *PostWebhook {\n\tthis := PostWebhook{}\n\tthis.BranchesToIgnore = branchesToIgnore\n\tthis.CommittersToIgnore = committersToIgnore\n\tthis.Enabled = enabled\n\tthis.Id = id\n\tthis.Title = title\n\tthis.Url = url\n\treturn &this\n}", "func PostHandler(basePath string, w http.ResponseWriter, r *http.Request) {\n\tname := fileKey(r.URL)\n\tf := NewFile(name, r.Header.Get(\"Content-Type\"))\n\n\tFilesLock.Lock()\n\tFiles.Add(name, f)\n\tFilesLock.Unlock()\n\n\t// Start writing to file without holding lock so that GET requests can read from it\n\tio.Copy(f, r.Body)\n\tr.Body.Close()\n\tf.Close()\n\n\terr := f.WriteToDisk(basePath)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error saving to disk: %v\", err)\n\t}\n\n\tw.WriteHeader(http.StatusNoContent)\n}", "func createPostHandler(res http.ResponseWriter, req *http.Request) {\n\tvar post MongoPostSchema\n\tpost.Timestamp = time.Now()\n\tjson.NewDecoder(req.Body).Decode(&post)\n\n\tpostsCol := client.Database(\"Aviroop_Nandy_Appointy\").Collection(\"posts\")\n\tctx, _ := context.WithTimeout(context.Background(), 15*time.Second)\n\tpostResult, insertErrorPost := postsCol.InsertOne(ctx, post)\n\n\tif insertErrorPost != nil {\n\t\tfmt.Println(\"Error while creating post: \", insertErrorPost)\n\t} else {\n\t\tnewPostID := postResult.InsertedID\n\t\tfmt.Println(\"New post ID: \", newPostID)\n\t}\n\n\tres.Header().Add(\"content-type\", \"application/json\")\n\tres.WriteHeader(http.StatusOK)\n}", "func (h *HttpHandlerFactory) NewCreateHandler(mutator WebhookCreateHandler) http.HandlerFunc {\n\tmutateFunc := func(ctx context.Context, review v1beta1.AdmissionReview) ([]PatchOperation, error) {\n\t\t// Decode the new CR from the request.\n\t\tobject, err := mutator.Decode(review.Request.Object)\n\t\tif err != nil {\n\t\t\treturn nil, microerror.Mask(err)\n\t\t}\n\n\t\townerClusterGetter := func(objectMeta metav1.ObjectMetaAccessor) (capi.Cluster, bool, error) {\n\t\t\townerCluster, ok, err := generic.TryGetOwnerCluster(ctx, h.ctrlClient, object)\n\t\t\tif err != nil {\n\t\t\t\treturn capi.Cluster{}, false, microerror.Mask(err)\n\t\t\t}\n\n\t\t\treturn ownerCluster, ok, nil\n\t\t}\n\n\t\t// Check if the CR should be mutated by the azure-admission-controller.\n\t\tok, err := filter.IsObjectReconciledByLegacyRelease(ctx, h.logger, h.ctrlReader, object, ownerClusterGetter)\n\t\tif err != nil {\n\t\t\treturn nil, microerror.Mask(err)\n\t\t}\n\n\t\tvar patch []PatchOperation\n\n\t\tif ok {\n\t\t\t// Mutate the CR and get patch for those mutations.\n\t\t\tpatch, err = mutator.OnCreateMutate(ctx, object)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, microerror.Mask(err)\n\t\t\t}\n\t\t}\n\n\t\treturn patch, nil\n\t}\n\n\treturn h.newHttpHandler(mutator, mutateFunc)\n}", "func New(cfg config.Proxy, bp httputil.BufferPool, token ntokend.TokenProvider, access service.AccessProvider, role service.RoleProvider, svcCert service.SvcCertProvider) Handler {\n\treturn &handler{\n\t\tproxy: &httputil.ReverseProxy{\n\t\t\tBufferPool: bp,\n\t\t},\n\t\ttoken: token,\n\t\taccess: access,\n\t\trole: role,\n\t\tcfg: cfg,\n\t\tsvcCert: svcCert,\n\t}\n}", "func NewHandler(ctx context.Context, cfg diag.Config, logger *zap.Logger) (http.Handler, error) {\n\tdiagSvc, err := diag.NewService(ctx, cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\th := handler{\n\t\tdiagSvc: diagSvc,\n\t\tlogger: logger,\n\t}\n\n\texpConfigHandler, err := exposureConfig(cfg.ExposureConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmux := http.NewServeMux()\n\n\tmux.HandleFunc(\"/diagnosis-keys\", h.diagnosisKeys)\n\tmux.HandleFunc(\"/exposure-config\", expConfigHandler)\n\tmux.HandleFunc(\"/health\", h.health)\n\n\treturn mux, nil\n}", "func (traceEndpoint *TraceEndpoint) Attach(router *mux.Router) {\n\t// Route handlers\n\trouter.HandleFunc(\"/\", instrument(func(w http.ResponseWriter, r *http.Request) {\n\t\ttimer := prometheus.NewTimer(metrics.PrometheusPostRequestDurations)\n\n\t\trequestID := r.Header.Get(\"X-Request-ID\")\n\t\taccountID := r.Header.Get(\"X-Account-ID\")\n\n\t\tlogger := edge_log.WithContext(r.Context(), traceEndpoint.Logger).With(zap.String(\"url\", r.URL.String())).With(zap.String(\"request_id\", requestID)).With(zap.String(\"account_id\", accountID)).With(zap.String(\"sub-component\", \"add-device-trace-handler\"))\n\n\t\tspan := opentracing.SpanFromContext(r.Context())\n\t\tspan.SetTag(\"http.method\", \"POST\")\n\t\tspan.SetTag(\"http.url\", r.URL.String())\n\t\tspan.SetTag(\"request_id\", requestID)\n\t\tspan.SetTag(\"account_id\", accountID)\n\t\tdefer span.Finish()\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"receive a request\"),\n\t\t\ttrace_log.String(\"message\", \"starting to handle request\"),\n\t\t)\n\n\t\tdataStream, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\terrMsg := fmt.Sprintf(\"Error reading request body: %s\", err.Error())\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusBadRequestErrType, errMsg, \"\", \"\", requestID))\n\n\t\t\tlogger.Warn(\"Could not read request body.\", zap.Error(err), zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"could not read request body\"),\n\t\t\t\ttrace_log.Error(err),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusPostRequestErrorCounter.Inc()\n\n\t\t\treturn\n\t\t}\n\n\t\t// Print out the request body to the logger\n\t\tlogger.Debug(\"Read request body.\", zap.String(\"body\", string(dataStream)))\n\n\t\t// Decode the data stream into a list of trace logs\n\t\tlogs, err := UnmarshalJSON(dataStream)\n\t\tif err != nil {\n\t\t\terrMsg := fmt.Sprintf(\"Error decoding request body: %s\", err.Error())\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusBadRequestErrType, errMsg, \"\", \"\", requestID))\n\n\t\t\tlogger.Warn(\"Could not decode request body.\", zap.Error(err), zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"could not decode request body as trace logs\"),\n\t\t\t\ttrace_log.Error(err),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusPostRequestErrorCounter.Inc()\n\n\t\t\treturn\n\t\t}\n\n\t\t// Handle the device id\n\t\tdeviceID := r.Header.Get(\"X-WigWag-RelayID\")\n\t\tif len(deviceID) == 0 {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusValidationErrType, \"Empty RelayID\", \"X-WigWag-RelayID\", \"Header X-WigWag-RelayID should not be empty\", requestID))\n\n\t\t\tlogger.Warn(\"Empty RelayID.\", zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"empty RelayID\"),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\n\t\t\tmetrics.PrometheusPostRequestErrorCounter.Inc()\n\n\t\t\treturn\n\t\t}\n\n\t\tLogs := make([]storage.Trace, len(logs))\n\n\t\tvar MinTime time.Time = time.Unix(0, 0)\n\t\tvar MaxTime time.Time = time.Unix(MaxTimestamp / 1000, (MaxTimestamp % 1000) * 1000000)\n\n\t\t// Assign the DeviceID, AccountID into logs\n\t\tfor index,log := range logs {\n\t\t\t// Validate the timestamp range\n\t\t\ttimestamp, err := time.Parse(time.RFC3339, log.Timestamp)\n\t\t\tif err != nil {\n\t\t\t\tfieldErr := fmt.Sprintf(\"Cannot parse 'timestamp' as RFC3339 string.\")\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusValidationErrType, \"Invalid log timestamp, cannot parse as RFC3339 format.\", \"timestamp\", fieldErr, requestID))\n\n\t\t\t\tlogger.Warn(\"Invalid timestamp param in Trace body, cannot parse.\", zap.Error(err), zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"invalid 'timestamp', cannot parse.\"),\n\t\t\t\t\ttrace_log.Error(err),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusPostRequestErrorCounter.Inc()\n\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif timestamp.Before(MinTime) || timestamp.After(MaxTime) {\n\t\t\t\tfieldErr := fmt.Sprintf(\"Unacceptable 'timestamp' value, not in range.\")\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusValidationErrType, \"Invalid log timestamp.\", \"timestamp\", fieldErr, requestID))\n\n\t\t\t\tlogger.Warn(\"Invalid timestamp param in Trace body, not in range.\", zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"invalid 'timestamp', not in range\"),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusPostRequestErrorCounter.Inc()\n\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tmuuid := traceEndpoint.UUIDGenerator.UUID()\n\n\t\t\tmessageBytes,_ := json.Marshal(log.Message)\n\n\t\t\tLogs[index] = storage.Trace {\n\t\t\t\tID : muuid.String(),\n\t\t\t\tDeviceID : deviceID,\n\t\t\t\tAccountID : accountID,\n\t\t\t\tTimestamp : int64(timestamp.UnixNano() / int64(time.Millisecond)),\n\t\t\t\tCloudTimestamp : timestampFromUUID(muuid),\n\t\t\t\tAppName : log.AppName,\n\t\t\t\tMessage : string(messageBytes),\n\t\t\t\tType : log.Type,\n\t\t\t}\n\t\t}\n\n\t\tif len(logs) > 0 {\n\t\t\t// Store the trace logs to the store layer\n\t\t\tctx := buildContextWithValue(requestID, accountID)\n\t\t\tctx, cancel := context.WithTimeout(ctx, storage.CtxTimeout)\n\t\t\tdefer cancel()\n\t\t\terr = traceEndpoint.TraceStore.AddDeviceTrace(span, ctx, Logs)\n\t\t\tif err != nil {\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusInternalServerError, StatusInternalServerErrType, err.Error(), \"\", \"\", requestID))\n\n\t\t\t\tlogger.Error(\"Some error occurred inside of the AddDeviceTrace().\", zap.Error(err), zap.Int(\"response_code\", http.StatusInternalServerError))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"storage error occured\"),\n\t\t\t\t\ttrace_log.Error(err),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusPostRequestErrorCounter.Inc()\n\t\t\t\tmetrics.PrometheusPostRequestElasticSearchFailureCounter.Inc()\n\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.Debug(\"There is nothing to commit.\")\n\t\t}\n\n\t\tmetrics.PrometheusPostTraceIndicator.Add(float64(len(logs)))\n\t\ttimer.ObserveDuration()\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\tw.WriteHeader(http.StatusCreated)\n\t\tlogger.Info(\"Success Request.\", zap.Int(\"response_code\", http.StatusCreated))\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"add device traces\"),\n\t\t\ttrace_log.String(\"message\", \"finished adding device traces\"),\n\t\t)\n\t})).Methods(\"POST\")\n\n\t// Create a subrouter for /v3 GET requests\n\tmethods := []string{\"GET\"}\n\tv3GetRouter := router.Methods(methods...).Subrouter()\n\n\t// Add middlewares\n\tv3GetRouter.Use(traceEndpoint.AccessTokenMiddleware)\n\tv3GetRouter.Use(middleware.RequestLoggerMiddleware())\n\n\tvar TraceHandler = func(span opentracing.Span, w http.ResponseWriter, r *http.Request, timer *prometheus.Timer, devices []string) {\n\t\tarmAccessToken, _ := r.Context().Value(middleware.ArmAccessTokenContextKey).(token.ArmAccessToken)\n\t\trequestID := armAccessToken.RequestID\n\t\taccountID := armAccessToken.AccountID\n\n\t\tlogger := edge_log.WithContext(r.Context(), traceEndpoint.Logger).With(zap.String(\"function\", \"TraceHandler\")).With(zap.String(\"request_id\", requestID)).With(zap.String(\"account_id\", accountID))\n\n\t\tvar err error\n\t\tvar MinTime time.Time = time.Unix(0, 0)\n\t\tvar MaxTime time.Time = time.Unix(MaxTimestamp / 1000, (MaxTimestamp % 1000) * 1000000)\n\t\tvar afterTime time.Time\n\t\tvar beforeTime time.Time\n\t\tvar appName string\n\t\tvar typ string\n\t\tvar message string\n\t\tvar after []interface{}\n\t\tvar include bool\n\t\tlimit := DefaultLimit\n\t\tsort := DefalutSort\n\n\t\tquery := r.URL.Query()\n\n\t\tvar fieldErr error\n\t\t// Verify query fields\n\t\tfor field := range query {\n\t\t\tswitch field {\n\n\t\t\tcase \"timestamp__gte\":\n\t\t\t\t// Handle the After Timestamp\n\t\t\t\tafterTime, err = time.Parse(time.RFC3339, query[field][0])\n\t\t\t\tif err != nil {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value. Could not parse as RFC3339 format.\")\n\t\t\t\t}\n\n\t\t\tcase \"timestamp__lte\":\n\t\t\t\t// Handle the Before Timestamp\n\t\t\t\tbeforeTime, err = time.Parse(time.RFC3339, query[field][0])\n\t\t\t\tif err != nil {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value. Could not parse as RFC3339 format.\")\n\t\t\t\t}\n\n\t\t\tcase \"app_name__eq\":\n\t\t\t\t// Handle the app_name parameter\n\t\t\t\tif len(query[field][0]) != 0 {\n\t\t\t\t\tappName = query[field][0]\n\t\t\t\t} else {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value ''\")\n\t\t\t\t}\n\n\t\t\tcase \"type__eq\":\n\t\t\t\t// Handle the type parameter\n\t\t\t\tif len(query[field][0]) != 0 {\n\t\t\t\t\ttyp = query[field][0]\n\t\t\t\t} else {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value ''\")\n\t\t\t\t}\n\n\t\t\tcase \"message__eq\":\n\t\t\t\t// Handle the message parameter\n\t\t\t\tif len(query[field][0]) != 0 {\n\t\t\t\t\tmessage = query[field][0]\n\t\t\t\t} else {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value ''\")\n\t\t\t\t}\n\n\t\t\tcase \"limit\":\n\t\t\t\t// Handle the limit parameter\n\t\t\t\tif len(query[field][0]) != 0 {\n\t\t\t\t\tlimit, fieldErr = strconv.ParseUint(query[field][0], 10, 64)\n\t\t\t\t\tif fieldErr == nil && (limit > MaxLimit || limit < MinLimit) {\n\t\t\t\t\t\tfieldErr = errors.New(\"Invalid 'limit' provided. Acceptable value is 2-1000.\")\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value ''\")\n\t\t\t\t}\n\n\t\t\tcase \"order\":\n\t\t\t\t// Handle the sort parameter\n\t\t\t\tif len(query[field][0]) != 0 {\n\t\t\t\t\tif strings.ToLower(query[field][0]) == \"asc\" {\n\t\t\t\t\t\tsort = true\n\t\t\t\t\t} else if strings.ToLower(query[field][0]) != \"desc\" {\n\t\t\t\t\t\tfieldErr = errors.New(\"Invalid 'order'. Acceptable values [ASC|DESC]\")\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value ''\")\n\t\t\t\t}\n\n\t\t\tcase \"after\":\n\t\t\t\t// Handle the after parameter\n\t\t\t\tif len(query[field][0]) != 0 {\n\t\t\t\t\tif !isValidUUID(query[field][0]) {\n\t\t\t\t\t\tfieldErr = errors.New(\"Invalid after cursor.\")\n\t\t\t\t\t} else {\n\t\t\t\t\t\tafter = make([]interface{}, 1)\n\t\t\t\t\t\tafter[0] = strings.ToLower(query[field][0])\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value ''\")\n\t\t\t\t}\n\n\t\t\tcase \"include\":\n\t\t\t\t// Handle the include parameter\n\t\t\t\tif len(query[field][0]) != 0 {\n\t\t\t\t\tif query[field][0] == \"total_count\" {\n\t\t\t\t\t\tinclude = true\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfieldErr = errors.New(\"Invalid field value ''\")\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\t// Return error for invalid query field\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\t\terrMsg := fmt.Sprintf(\"Invalid field name '%s'\", field)\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusBadRequestErrType, errMsg, \"\", \"\", requestID))\n\n\t\t\t\tlogger.Warn(errMsg, zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"invalid field name\"),\n\t\t\t\t\ttrace_log.String(\"field\", field),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif fieldErr != nil {\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\t\terrMsg := fmt.Sprintf(\"Invalid query field '%s'\", field)\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusValidationErrType, errMsg, field, fieldErr.Error(), requestID))\n\n\t\t\t\tlogger.Warn(errMsg, zap.Error(fieldErr), zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"invalid query field\"),\n\t\t\t\t\ttrace_log.String(\"field\", field),\n\t\t\t\t\ttrace_log.Error(fieldErr),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif len(query[\"timestamp__gte\"]) != 0 && len(query[\"timestamp__lte\"]) != 0 {\n\t\t\t// Check the provided whether the provided before Time is after the after Time\n\t\t\tif beforeTime.Before(afterTime) {\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusBadRequestErrType, \"Invalid time range. timerange__gte should be after timerange__lte\", \"\", \"\", requestID))\n\n\t\t\t\tlogger.Warn(\"Invalid time range.\", zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"invalid time query\"),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tvar results storage.TracePage\n\n\t\t// If gte > MaxTime or lte < MinTime, retuen empty page\n\t\tif afterTime.After(MaxTime) || (len(query[\"timestamp__lte\"]) != 0 && beforeTime.Before(MinTime)) {\n\t\t\tresults = storage.TracePage {\n\t\t\t\tObject: \"list\",\n\t\t\t\tHasMore: false,\n\t\t\t\tLimit: limit,\n\t\t\t\tData: []storage.TraceResponse{},\n\t\t\t}\n\n\t\t\tif after != nil {\n\t\t\t\tresults.After = after[0]\n\t\t\t}\n\t\t\tif sort {\n\t\t\t\tresults.Order = \"ASC\"\n\t\t\t} else {\n\t\t\t\tresults.Order = \"DESC\"\n\t\t\t}\n\n\t\t\tif include {\n\t\t\t\tresults.TotalCount = 0\n\t\t\t}\n\t\t} else {\n\t\t\t// If lte > MaxTime, don't use the query\n\t\t\tif len(query[\"timestamp__lte\"]) != 0 && beforeTime.After(MaxTime) {\n\t\t\t\tbeforeTime = time.Time{}\n\t\t\t}\n\n\t\t\t// If gte < MinTime, don't use the query\n\t\t\tif len(query[\"timestamp__gte\"]) != 0 && afterTime.Before(MinTime) {\n\t\t\t\tafterTime = time.Time{}\n\t\t\t}\n\n\t\t\t// Initialize the query by the parameters that handled before\n\t\t\tvar query storage.TraceQuery\n\t\t\tquery = storage.TraceQuery{\n\t\t\t\tDevice : devices,\n\t\t\t\tAccount : accountID,\n\t\t\t\tAfter : afterTime,\n\t\t\t\tBefore : beforeTime,\n\t\t\t\tAppName : appName,\n\t\t\t\tType : typ,\n\t\t\t\tLimit : limit,\n\t\t\t\tMessage : message,\n\t\t\t\tSort : sort,\n\t\t\t\tAfterCursor: after,\n\t\t\t}\n\n\t\t\tlogger.Debug(\"Sending query to storage SearchDeviceTrace()\", zap.Any(\"query\", query))\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"send query to storage\"),\n\t\t\t\ttrace_log.String(\"message\", \"Sending search query to storage\"),\n\t\t\t\ttrace_log.Object(\"query\", query),\n\t\t\t)\n\n\t\t\tctx := buildContextWithValue(requestID, accountID)\n\t\t\tresults, err = traceEndpoint.TraceStore.SearchDeviceTrace(span, ctx, query, include)\n\n\t\t\tif err != nil {\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusInternalServerError, StatusInternalServerErrType, err.Error(), \"\", \"\", requestID))\n\n\t\t\t\tlogger.Error(\"An error occurred inside of SearchDeviceTrace().\", zap.Error(err), zap.Int(\"response_code\", http.StatusInternalServerError))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"storage error occured\"),\n\t\t\t\t\ttrace_log.Error(err),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\t\tmetrics.PrometheusGetRequestElasticSearchFailureCounter.Inc()\n\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Encode the results into json format\n\t\tencodedResults, err := json.Marshal(results)\n\n\t\tif err != nil {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusInternalServerError, StatusInternalServerErrType, err.Error(), \"\", \"\", requestID))\n\n\t\t\tlogger.Warn(\"Could not encode result as json.\", zap.Error(err), zap.Int(\"response_code\", http.StatusInternalServerError))\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"could not encode as json\"),\n\t\t\t\ttrace_log.Error(err),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\n\t\t\treturn\n\t\t}\n\n\t\ttimer.ObserveDuration()\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tio.WriteString(w, string(encodedResults)+\"\\n\")\n\t\tlogger.Info(\"Success Request.\", zap.Int(\"response_code\", http.StatusOK))\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"success\"),\n\t\t\ttrace_log.String(\"message\", \"Successfully retreived trace data\"),\n\t\t)\n\n\t}\n\n\tv3GetRouter.HandleFunc(\"/v3/device-trace{route:\\\\/?}\", instrument(func(w http.ResponseWriter, r *http.Request) {\n\t\ttimer := prometheus.NewTimer(metrics.PrometheusGetRequestDurations)\n\n\t\tlogger := edge_log.WithContext(r.Context(), traceEndpoint.Logger).With(zap.String(\"url\", r.URL.String())).With(zap.String(\"sub-component\", \"get-device-trace-handler\"))\n\n\t\tspan := opentracing.SpanFromContext(r.Context())\n\t\tspan.SetTag(\"http.method\", \"GET\")\n\t\tspan.SetTag(\"http.url\", r.URL.String())\n\t\tdefer span.Finish()\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"receive a request\"),\n\t\t\ttrace_log.String(\"message\", \"starting to handle request\"),\n\t\t)\n\n\t\tarmAccessToken, ok := r.Context().Value(middleware.ArmAccessTokenContextKey).(token.ArmAccessToken)\n\t\tif !ok {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusUnauthorized, StatusUnauthorized, \"Unable to decode token\", \"\", \"\", armAccessToken.RequestID))\n\n\t\t\tlogger.Error(\"access token missing\", zap.Int(\"response_code\", http.StatusUnauthorized))\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\ttrace_log.String(\"message\", \"access token missing\"),\n\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\treturn\n\t\t}\n\t\trequestID := armAccessToken.RequestID\n\t\taccountID := armAccessToken.AccountID\n\n\t\tlogger = logger.With(zap.String(\"request_id\", requestID)).With(zap.String(\"account_id\", accountID))\n\t\tspan.SetTag(\"request_id\", requestID)\n\n\t\tquery := r.URL.Query()\n\n\t\t// Handle the device_id query\n\t\tvar devices []string\n\t\tif len(query[\"device_id__in\"]) != 0 {\n\t\t\tif query[\"device_id__in\"][0] != \"\" {\n\t\t\t\tdevices = strings.Split(query[\"device_id__in\"][0], \",\")\n\t\t\t} else {\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\t\terrMsg := \"Invalid query field 'device_id__in'\"\n\t\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusValidationErrType, errMsg, \"device_id__in\", \"Invalid field value ''\", requestID))\n\n\t\t\t\tlogger.Warn(errMsg, zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\t\tspan.LogFields(\n\t\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\t\ttrace_log.String(\"message\", \"invalid query field 'device_id__in'\"),\n\t\t\t\t)\n\n\t\t\t\ttimer.ObserveDuration()\n\t\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tquery.Del(\"device_id__in\")\n\t\tr.URL.RawQuery = query.Encode()\n\n\t\tTraceHandler(span, w, r, timer, devices)\n\t})).Methods(\"GET\")\n\n\tv3GetRouter.HandleFunc(\"/v3/devices/{device_id}/trace{route:\\\\/?}\", instrument(func(w http.ResponseWriter, r *http.Request) {\n\t\ttimer := prometheus.NewTimer(metrics.PrometheusGetRequestDurations)\n\n\t\tlogger := edge_log.WithContext(r.Context(), traceEndpoint.Logger).With(zap.String(\"url\", r.URL.String())).With(zap.String(\"sub-component\", \"get-single-device-trace-handler\"))\n\n\t\tspan := opentracing.SpanFromContext(r.Context())\n\t\tspan.SetTag(\"http.method\", \"GET\")\n\t\tspan.SetTag(\"http.url\", r.URL.String())\n\t\tdefer span.Finish()\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"receive a request\"),\n\t\t\ttrace_log.String(\"message\", \"starting to handle request\"),\n\t\t)\n\n\t\tarmAccessToken, ok := r.Context().Value(middleware.ArmAccessTokenContextKey).(token.ArmAccessToken)\n\t\tif !ok {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusUnauthorized, StatusUnauthorized, \"Unable to decode token\", \"\", \"\", armAccessToken.RequestID))\n\n\t\t\tlogger.Error(\"access token missing\", zap.Int(\"response_code\", http.StatusUnauthorized))\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\ttrace_log.String(\"message\", \"access token missing\"),\n\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\treturn\n\t\t}\n\t\trequestID := armAccessToken.RequestID\n\t\taccountID := armAccessToken.AccountID\n\n\t\tr, _ = httputil.WithContextValue(r, httputil.ContextKeyRequestID, requestID)\n\t\tr, _ = httputil.WithContextValue(r, httputil.ContextKeyAccountID, accountID)\n\n\t\tlogger = logger.With(zap.String(\"request_id\", requestID)).With(zap.String(\"account_id\", accountID))\n\t\tspan.SetTag(\"request_id\", requestID)\n\n\t\tparams := mux.Vars(r)\n\n\t\tdeviceID := params[\"device_id\"]\n\t\tspan.SetTag(\"device_id\", deviceID)\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"device validation\"),\n\t\t\ttrace_log.String(\"message\", \"Starting to validate device id\"),\n\t\t)\n\n\t\t// Validate device_id\n\t\tctx := opentracing.ContextWithSpan(r.Context(), span)\n\t\tdeviceData, publicError := traceEndpoint.DeviceDirectory.DeviceRetrieve(span, ctx, deviceID)\n\n\t\tif publicError != nil {\n\t\t\tlogger.Debug(\"DeviceDirectory.DeviceRetrieve responded with error.\", zap.Any(\"error\", publicError))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"device validation failed\"),\n\t\t\t\ttrace_log.Object(\"error\", publicError),\n\t\t\t)\n\n\t\t\tif publicError.Code == http.StatusUnauthorized {\n\t\t\t\tpublicError = &httputil.PublicError{\n\t\t\t\t\tObject : \"error\",\n\t\t\t\t\tCode : http.StatusInternalServerError,\n\t\t\t\t\tType : \"internal_server_error\",\n\t\t\t\t\tMessage : \"Could not generate valid access token, error: \" + publicError.Message,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpublicError.Message = fmt.Sprintf(\"Failed validating device_id: %s\", publicError.Message)\n\t\t\tpublicError.RequestID = requestID\n\t\t\tpe, _ := json.Marshal(publicError)\n\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(publicError.Code)\n\t\t\tio.WriteString(w, string(pe))\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\n\t\t\treturn\n\t\t} else {\n\t\t\tlogger.Debug(\"DeviceRetrieve: Success response\", zap.Any(\"response\", deviceData))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"device validated\"),\n\t\t\t\ttrace_log.String(\"message\", \"device exists in account\"),\n\t\t\t\ttrace_log.Object(\"device-data\", deviceData),\n\t\t\t)\n\t\t}\n\n\t\t// Handle the device_id path param\n\t\tvar devices = []string { deviceID }\n\n\t\tTraceHandler(span, w, r, timer, devices)\n\t})).Methods(\"GET\")\n\n\tv3GetRouter.HandleFunc(\"/v3/device-trace/{device_trace_id}{route:\\\\/?}\", instrument(func(w http.ResponseWriter, r *http.Request) {\n\t\ttimer := prometheus.NewTimer(metrics.PrometheusGetRequestDurations)\n\n\t\tlogger := edge_log.WithContext(r.Context(), traceEndpoint.Logger).With(zap.String(\"url\", r.URL.String())).With(zap.String(\"sub-component\", \"get-specific-trace-handler\"))\n\n\t\tspan := opentracing.SpanFromContext(r.Context())\n\t\tspan.SetTag(\"http.method\", \"GET\")\n\t\tspan.SetTag(\"http.url\", r.URL.String())\n\t\tdefer span.Finish()\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"receive a request\"),\n\t\t\ttrace_log.String(\"message\", \"starting to handle request\"),\n\t\t)\n\n\t\tarmAccessToken, ok := r.Context().Value(middleware.ArmAccessTokenContextKey).(token.ArmAccessToken)\n\t\tif !ok {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusUnauthorized, StatusUnauthorized, \"Unable to decode token\", \"\", \"\", armAccessToken.RequestID))\n\n\t\t\tlogger.Error(\"access token missing\", zap.Int(\"response_code\", http.StatusUnauthorized))\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\ttrace_log.String(\"message\", \"access token missing\"),\n\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\treturn\n\t\t}\n\t\trequestID := armAccessToken.RequestID\n\t\taccountID := armAccessToken.AccountID\n\n\t\tlogger = logger.With(zap.String(\"request_id\", requestID)).With(zap.String(\"account_id\", accountID))\n\t\tspan.SetTag(\"request_id\", requestID)\n\n\t\tquery := r.URL.Query()\n\t\tif len(query) > 0 {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusBadRequest, StatusBadRequestErrType, \"Invalid field query\", \"\", \"\", requestID))\n\n\t\t\tlogger.Warn(\"Invalid query fields.\", zap.Any(\"query\", query), zap.Int(\"response_code\", http.StatusBadRequest))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"invalid query field\"),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\tmetrics.PrometheusGetRequestElasticSearchFailureCounter.Inc()\n\n\t\t\treturn\n\t\t}\n\n\t\tparams := mux.Vars(r)\n\t\tid := params[\"device_trace_id\"]\n\t\tspan.SetTag(\"device_trace_id\", id)\n\n\t\tvar err error\n\n\t\t// Initialize the query by the parameters that handled before\n\t\tvar traceQuery storage.TraceQuery\n\t\ttraceQuery = storage.TraceQuery{\n\t\t\tAccount : accountID,\n\t\t\tID : id,\n\t\t\tLimit : MinLimit,\n\t\t}\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"sending storage query\"),\n\t\t\ttrace_log.String(\"message\", \"Sending search query to storage\"),\n\t\t\ttrace_log.Object(\"query\", traceQuery),\n\t\t)\n\n\t\tlogger.Debug(\"Sending query to storage SearchDeviceTrace()\", zap.Any(\"query\", traceQuery))\n\t\tctx := buildContextWithValue(requestID, accountID)\n\t\tresults, err := traceEndpoint.TraceStore.SearchDeviceTrace(span, ctx, traceQuery, true)\n\n\t\tif err != nil {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusInternalServerError, StatusInternalServerErrType, err.Error(), \"\", \"\", requestID))\n\n\t\t\tlogger.Error(\"An error occurred inside of SearchDeviceTrace().\", zap.Error(err), zap.Int(\"response_code\", http.StatusInternalServerError))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"storage error occured\"),\n\t\t\t\ttrace_log.Error(err),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\t\t\tmetrics.PrometheusGetRequestElasticSearchFailureCounter.Inc()\n\n\t\t\treturn\n\t\t}\n\n\t\tif results.TotalCount == 0 {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusNotFound)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusNotFound, StatusNotFound, \"Could not retreive device trace by this ID\", \"\", \"\", requestID))\n\n\t\t\tlogger.Warn(\"Could not find trace for id \" + id, zap.Int(\"response_code\", http.StatusNotFound))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"trace not found\"),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\n\t\t\treturn\n\t\t} else if results.TotalCount > 1 {\n\t\t\tlogger.Error(\"Found multiple trace logs for id \"+ id +\". This should not have happened.\")\n\t\t}\n\n\t\t// Encode the result into json format\n\t\tencodedresults, err := json.Marshal(results.Data[0])\n\n\t\tif err != nil {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tio.WriteString(w, encodePublicErrorObject(http.StatusInternalServerError, StatusInternalServerErrType, err.Error(), \"\", \"\", requestID))\n\n\t\t\tlogger.Warn(\"Error encoding result as json.\", zap.Error(err), zap.Int(\"response_code\", http.StatusInternalServerError))\n\n\t\t\tspan.LogFields(\n\t\t\t\ttrace_log.String(\"event\", \"error\"),\n\t\t\t\ttrace_log.String(\"message\", \"could not encode result as json\"),\n\t\t\t\ttrace_log.Error(err),\n\t\t\t)\n\n\t\t\ttimer.ObserveDuration()\n\t\t\tmetrics.PrometheusGetRequestErrorCounter.Inc()\n\n\t\t\treturn\n\t\t}\n\n\t\ttimer.ObserveDuration()\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tio.WriteString(w, string(encodedresults)+\"\\n\")\n\t\tlogger.Info(\"Success Request.\", zap.Int(\"response_code\", http.StatusOK))\n\n\t\tspan.LogFields(\n\t\t\ttrace_log.String(\"event\", \"success\"),\n\t\t\ttrace_log.String(\"message\", \"successfully retreived trace\"),\n\t\t)\n\t})).Methods(\"GET\")\n\n\trouter.HandleFunc(\"/liveness\", func(w http.ResponseWriter, r *http.Request) {\n\t\tlogger := edge_log.WithContext(r.Context(), traceEndpoint.Logger).With(zap.String(\"sub-component\", \"liveness-handler\"))\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tlogger.Info(\"Success Request\", zap.Int(\"response_code\", http.StatusOK))\n\t}).Methods(\"GET\")\n\n\trouter.HandleFunc(\"/readiness\", func(w http.ResponseWriter, r *http.Request) {\n\t\tlogger := edge_log.WithContext(r.Context(), traceEndpoint.Logger).With(zap.String(\"sub-component\", \"readiness-handler\"))\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf8\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tlogger.Info(\"Success Request.\", zap.Int(\"response_code\", http.StatusOK))\n\t}).Methods(\"GET\")\n\n\trouter.Handle(\"/metrics\", promhttp.Handler())\n}", "func Post(path string, handler func(http.ResponseWriter, *http.Request)) {\n\tdefaultRoutes.post(path, handler)\n}", "func (h *Handler) PostHandler(w http.ResponseWriter, r *http.Request) {\n\tv := r.URL.Query()\n\tif v == nil {\n\t\ttpl := template.Must(template.ParseFiles(\"error.html\"))\n\t\ttpl.Execute(w, errorField{Detail: \"Not find URL value\"})\n\t\treturn\n\t}\n\n\tvar userid string\n\tfor key, vs := range v {\n\t\tlog.Printf(\"%s = %s\\n\", key, vs[0])\n\t\tuserid = vs[0] // UserIDをdatastoreに登録するデータのメンバに含める\n\t}\n\tif r.Method != http.MethodPost {\n\t\treturn\n\t}\n\n\tregistData, err := h.convertRegistration(r, userid)\n\tif err != nil {\n\t\ttpl := template.Must(template.ParseFiles(\"error.html\"))\n\t\ttpl.Execute(w, errorField{Detail: \"Error convert parameter\"})\n\t\treturn\n\t}\n\n\terr = h.regist.Put(context.Background(), datastore.NameKey(\"RegistrationData\", \"\", nil), registData)\n\tif err != nil {\n\t\ttpl := template.Must(template.ParseFiles(\"error.html\"))\n\t\ttpl.Execute(w, errorField{Detail: \"Error writing to datastore\"})\n\t\treturn\n\t}\n\n\ttpl := template.Must(template.ParseFiles(\"success.html\"))\n\ttpl.Execute(w, nil)\n}", "func newHTTPTracePolicy(allowedQueryParams []string) exported.Policy {\n\treturn &httpTracePolicy{allowedQP: getAllowedQueryParams(allowedQueryParams)}\n}", "func (f *frontendServer) postHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Printf(\"received request: %s %s\", r.Method, r.URL.Path)\n\tif r.Method != http.MethodPost {\n\t\thttp.Error(w, \"only POST requests are supported\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\tauthor := r.FormValue(\"name\")\n\tmessage := r.FormValue(\"message\")\n\tif author == \"\" {\n\t\thttp.Error(w, `\"name\" not specified in the form`, http.StatusBadRequest)\n\t\treturn\n\t}\n\tif message == \"\" {\n\t\thttp.Error(w, `\"message\" not specified in the form`, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err := f.saveMessage(r.FormValue(\"name\"), r.FormValue(\"message\")); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"failed to save message: %+v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\thttp.Redirect(w, r, \"/\", http.StatusFound) // redirect to homepage\n}", "func makeUpdatePostHandler(m *http.ServeMux, endpoints endpoint.Endpoints, options []http1.ServerOption) {\n\tm.Handle(\"/update-post\", http1.NewServer(endpoints.UpdatePostEndpoint, decodeUpdatePostRequest, encodeUpdatePostResponse, options...))\n}", "func New(h []IHandler) *Handler {\n\treturn &Handler{handler: h}\n}", "func NewPost(w http.ResponseWriter, r *http.Request, u *models.User) {\n\tswitch r.Method {\n\tcase \"POST\":\n\t\terr := savePost(0, r.FormValue, u)\n\t\tif err != nil {\n\t\t\ttpl.ExecuteTemplate(w, \"404\", nil)\n\t\t\treturn\n\t\t}\n\n\t\thttp.Redirect(w, r, \"/manage\", http.StatusFound)\n\n\tcase \"GET\":\n\t\ttpl.ExecuteTemplate(w, \"editPost\", nil)\n\t}\n}", "func prodHandler(w http.ResponseWriter, r *http.Request) {\n\thandlerReal(true, w, r)\n}", "func SilentHandler(h http.Handler) http.Handler {\n\treturn &silentHandler{h}\n}", "func NewHandler(site *Site, path *Path) http.HandlerFunc {\r\n\treturn func(w http.ResponseWriter, r *http.Request) {\r\n\t\tdata, err := doRequest(site, path, r)\r\n\t\tif err != nil {\r\n\t\t\tsite.Flush(w, nil, err)\r\n\t\t\treturn\r\n\t\t}\r\n\t\tsite.Flush(w, data, err)\r\n\t}\r\n}", "func NewHandler(adventure Adventure) http.Handler {\n\treturn handler{adventure}\n}", "func (s *Service) GetPostHandler(w http.ResponseWriter, r *http.Request) {\n\n\tid, err := utilities.GetURLID(r, \"\")\n\tif err != nil {\n\n\t\tmessage, code := parseError(err)\n\t\thttp.Error(w, message, code)\n\n\t\treturn\n\t}\n\n\tgroupID, err := utilities.GetURLID(r, \"groupID\")\n\tif err != nil {\n\n\t\tmessage, code := parseError(err)\n\t\thttp.Error(w, message, code)\n\n\t\treturn\n\t}\n\n\tctx, f := context.WithTimeout(r.Context(), TimeoutRequest)\n\tdefer f()\n\n\tpost, err := s.getPost(ctx, id, groupID)\n\n\tif err != nil {\n\n\t\tmessage, code := parseError(err)\n\t\thttp.Error(w, message, code)\n\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\n\tif json.NewEncoder(w).Encode(post); err != nil {\n\t\thttp.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n\t}\n}", "func (mock *MockUserCredentialsAPI) POSTHandler() http.Handler {\n\treturn nil\n}" ]
[ "0.5782889", "0.5709932", "0.55733293", "0.5463332", "0.5406926", "0.5386403", "0.5368965", "0.53227884", "0.5293708", "0.52551687", "0.5246721", "0.52441657", "0.52388203", "0.5234427", "0.5228126", "0.52029496", "0.51942873", "0.51863825", "0.51829284", "0.5158858", "0.5144485", "0.51238817", "0.5121372", "0.5099998", "0.507269", "0.5071226", "0.50690174", "0.50668764", "0.50589824", "0.50377995", "0.5025029", "0.5010933", "0.5005692", "0.4998915", "0.4977223", "0.49687198", "0.49631897", "0.4950453", "0.49485645", "0.49454877", "0.4942902", "0.494286", "0.4940186", "0.49358866", "0.4932972", "0.49307835", "0.49252436", "0.49033135", "0.49032778", "0.49027622", "0.4902581", "0.4902577", "0.49000898", "0.48998418", "0.48778474", "0.48664463", "0.48628178", "0.48511398", "0.4849774", "0.48391536", "0.4838695", "0.48288795", "0.48258418", "0.48235968", "0.48212418", "0.48208967", "0.4820756", "0.4812229", "0.48107508", "0.48080957", "0.48057762", "0.48033303", "0.48022476", "0.48005787", "0.4797502", "0.47946167", "0.47936085", "0.47886312", "0.47446018", "0.4730541", "0.47282523", "0.4727984", "0.47262824", "0.47234833", "0.47175124", "0.47169992", "0.47165266", "0.4713862", "0.47109982", "0.47033417", "0.46911618", "0.46902943", "0.46878", "0.4682793", "0.4682753", "0.46770012", "0.46710318", "0.46705967", "0.4669406", "0.4651964" ]
0.7520936
0
Validate validates this post silences o k body
func (o *PostSilencesOKBody) Validate(formats strfmt.Registry) error { return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (mt *Post) Validate() (err error) {\n\n\tif mt.URLName == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"url_name\"))\n\t}\n\tif mt.Title == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"title\"))\n\t}\n\tif mt.Contents == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"contents\"))\n\t}\n\tif mt.Status == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"status\"))\n\t}\n\tif !(mt.Status == \"draft\" || mt.Status == \"published\") {\n\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(`response.status`, mt.Status, []interface{}{\"draft\", \"published\"}))\n\t}\n\treturn\n}", "func (o *PostSiteBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostcommentsBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (nS *PostMessageBody) Validate() error {\n\treturn validator.New().Struct(nS)\n}", "func (o *PostWebhookBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateOn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateSign(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateURL(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func validatePost(post *pb.Post) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tswitch x := r.(type) {\n\t\t\tcase string:\n\t\t\t\terr = errors.New(x)\n\t\t\tcase error:\n\t\t\t\terr = x\n\t\t\tdefault:\n\t\t\t\terr = ErrPostUnknownValidationPanic\n\t\t\t}\n\t\t}\n\t}()\n\n\t// Slug\n\tif post.Slug == \"\" {\n\t\treturn ErrPostSlugNotEmpty\n\t}\n\tif len(post.Slug) > SentenceMaxCharacters {\n\t\treturn ErrPostSlugTooLong\n\t}\n\tif strings.Contains(post.Slug, \" \") {\n\t\treturn ErrPostSlugContainsSpaces\n\t}\n\tif strings.Contains(post.Slug, \"/\") {\n\t\treturn ErrPostSlugContainsSlashes\n\t}\n\n\t// Type\n\tif _, ok := pb.Post_PostType_value[post.PostType.String()]; !ok {\n\t\treturn ErrPostInvalidType\n\t}\n\n\t// Status\n\tif len(post.Status) > PostStatusMaxCharacters {\n\t\treturn ErrPostStatusTooLong\n\t}\n\n\t// Long Form\n\tif len(post.LongForm) > PostLongFormMaxCharacters {\n\t\treturn ErrPostBodyTooLong\n\t}\n\n\t// Tags\n\tif len(post.Tags) > PostMaximumTotalTags {\n\t\treturn ErrPostTagsTooMany\n\t}\n\tfor _, tag := range post.Tags {\n\t\tif tag == \"\" {\n\t\t\treturn ErrPostTagsEmpty\n\t\t}\n\t\tif len(tag) > PostTagsMaxCharacters {\n\t\t\treturn ErrPostTagTooLong\n\t\t}\n\t}\n\n\t// Channels\n\tif len(post.Channels) > PostMaximumTotalChannels {\n\t\treturn ErrPostChannelsTooMany\n\t}\n\tfor _, channel := range post.Channels {\n\t\tif len(channel) > PostChannelsMaxCharacters {\n\t\t\treturn ErrPostChannelTooLong\n\t\t}\n\t}\n\n\t// Reference\n\tif post.PostType == pb.Post_COMMENT || post.PostType == pb.Post_REPOST {\n\t\tif post.Reference == \"\" {\n\t\t\treturn ErrPostReferenceEmpty\n\t\t}\n\t\tif len(post.Reference) > PostReferenceMaxCharacters {\n\t\t\treturn ErrPostReferenceTooLong\n\t\t}\n\t\tif strings.Contains(post.Reference, \" \") {\n\t\t\treturn ErrPostReferenceContainsSpaces\n\t\t}\n\t}\n\n\t// Images\n\tif len(post.Images) > MaxListItems {\n\t\treturn ErrPostImagesTooMany\n\t}\n\tfor _, img := range post.Images {\n\t\t_, err := cid.Decode(img.Tiny)\n\t\tif err != nil {\n\t\t\treturn ErrPostImageTinyFormatInvalid\n\t\t}\n\t\t_, err = cid.Decode(img.Small)\n\t\tif err != nil {\n\t\t\treturn ErrPostImageSmallFormatInvalid\n\t\t}\n\t\t_, err = cid.Decode(img.Medium)\n\t\tif err != nil {\n\t\t\treturn ErrPostImageMediumFormatInvalid\n\t\t}\n\t\t_, err = cid.Decode(img.Large)\n\t\tif err != nil {\n\t\t\treturn ErrPostImageLargeFormatInvalid\n\t\t}\n\t\t_, err = cid.Decode(img.Original)\n\t\tif err != nil {\n\t\t\treturn ErrPostImageOriginalFormatInvalid\n\t\t}\n\t\tif img.Filename == \"\" {\n\t\t\treturn ErrPostImageFilenameNil\n\t\t}\n\t\tif len(img.Filename) > FilenameMaxCharacters {\n\t\t\treturn ErrPostImageFilenameTooLong\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *PostSiteForbiddenBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (p *PostTag) Validate(tx *pop.Connection) (*validate.Errors, error) {\n\treturn validate.NewErrors(), nil\n}", "func ValidatePost(request AddStoryRequest) error {\n\ts := strings.Split(request.Word, \" \")\n\tif len(s) > 1 {\n\t\treturn errors.New(utils.MultipleWordError)\n\t}\n\treturn nil\n}", "func (p Post) Validate() error {\n\treturn validation.ValidateStruct(&p,\n\t\t// FirstName is require\n\t\tvalidation.Field(&p.Title, validation.Required, validation.Length(3, 40)),\n\t\tvalidation.Field(&p.Body, validation.Required),\n\t)\n}", "func (o *PostSiteCreatedBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateData(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostProfileBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func ValidatePostUnAuthResponseBody(body *PostUnAuthResponseBody) (err error) {\n\tif body.Name == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"name\", \"body\"))\n\t}\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Message == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"message\", \"body\"))\n\t}\n\tif body.Temporary == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"temporary\", \"body\"))\n\t}\n\tif body.Timeout == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"timeout\", \"body\"))\n\t}\n\tif body.Fault == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"fault\", \"body\"))\n\t}\n\treturn\n}", "func (payload *postEventPayload) Validate() (err error) {\n\tif payload.Etype == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (post *Post) Validate() map[string]string {\n\n\t// if user.Name == \"\" && len(user.Name) < 5 {\n\t// \treturn err(\"The Name you entered was too short\")\n\t// }\n\n\treturn map[string]string{\"Message\": \"\", \"IsValid\": \"1\"}\n}", "func (o *GetAPIV1PostsPostIDOKBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateVotedAge(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateVotedBloodType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateVotedMonth(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateVotedSex(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostcommentsOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostSiteNotFoundBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func ValidatePostBadReqResponseBody(body *PostBadReqResponseBody) (err error) {\n\tif body.Name == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"name\", \"body\"))\n\t}\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Message == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"message\", \"body\"))\n\t}\n\tif body.Temporary == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"temporary\", \"body\"))\n\t}\n\tif body.Timeout == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"timeout\", \"body\"))\n\t}\n\tif body.Fault == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"fault\", \"body\"))\n\t}\n\treturn\n}", "func ValidatePostBadReqResponseBody(body *PostBadReqResponseBody) (err error) {\n\tif body.Name == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"name\", \"body\"))\n\t}\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Message == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"message\", \"body\"))\n\t}\n\tif body.Temporary == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"temporary\", \"body\"))\n\t}\n\tif body.Timeout == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"timeout\", \"body\"))\n\t}\n\tif body.Fault == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"fault\", \"body\"))\n\t}\n\treturn\n}", "func (payload *PostEventPayload) Validate() (err error) {\n\tif payload.Etype == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (o *PostSiteCreatedBodyData) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateRoutes(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *S3PresignedPost) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateFields(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateURL(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostDeviceURLOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostLeasesIDAuthCreatedBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostEntitiesEntityFidAttachmentsUploadURLOKBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateData(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (body *CreateResponseBody) Validate() (err error) {\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Color == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"color\", \"body\"))\n\t}\n\tif body.Cron == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"cron\", \"body\"))\n\t}\n\tif body.Name != nil {\n\t\tif utf8.RuneCountInString(*body.Name) > 100 {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidLengthError(\"body.name\", *body.Name, utf8.RuneCountInString(*body.Name), 100, false))\n\t\t}\n\t}\n\tif body.Color != nil {\n\t\tif !(*body.Color == \"red\" || *body.Color == \"yellow\" || *body.Color == \"green\" || *body.Color == \"off\") {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(\"body.color\", *body.Color, []interface{}{\"red\", \"yellow\", \"green\", \"off\"}))\n\t\t}\n\t}\n\treturn\n}", "func validatePOSTRequest(body []byte, schema *gojsonschema.Schema) (err error) {\n\tdocLoader := gojsonschema.NewStringLoader(string(body))\n\tif result, err := schema.Validate(docLoader); err != nil && !result.Valid() {\n\t\treturn errors.New(\"Couldn't validate json\")\n\t}\n\treturn nil\n}", "func (o *PostDocumentFieldextractOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (pu *PostUpdate) check() error {\n\tif v, ok := pu.mutation.UserID(); ok {\n\t\tif err := post.UserIDValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"user_id\", err: fmt.Errorf(`ent: validator failed for field \"Post.user_id\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.Title(); ok {\n\t\tif err := post.TitleValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"title\", err: fmt.Errorf(`ent: validator failed for field \"Post.title\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.Content(); ok {\n\t\tif err := post.ContentValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"content\", err: fmt.Errorf(`ent: validator failed for field \"Post.content\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.Status(); ok {\n\t\tif err := post.StatusValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"status\", err: fmt.Errorf(`ent: validator failed for field \"Post.status\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.ReplyNum(); ok {\n\t\tif err := post.ReplyNumValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"reply_num\", err: fmt.Errorf(`ent: validator failed for field \"Post.reply_num\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.UpdateAt(); ok {\n\t\tif err := post.UpdateAtValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"update_at\", err: fmt.Errorf(`ent: validator failed for field \"Post.update_at\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.Pin(); ok {\n\t\tif err := post.PinValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"pin\", err: fmt.Errorf(`ent: validator failed for field \"Post.pin\": %w`, err)}\n\t\t}\n\t}\n\treturn nil\n}", "func (o *CreateWidgetUnprocessableEntityBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostTemplateTemplateIDCopyBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostSiteBadRequestBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *RemovePolicyBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (pu *PostUpdate) check() error {\n\tif v, ok := pu.mutation.Slug(); ok {\n\t\tif err := post.SlugValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"slug\", err: fmt.Errorf(`ent: validator failed for field \"Post.slug\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.Title(); ok {\n\t\tif err := post.TitleValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"title\", err: fmt.Errorf(`ent: validator failed for field \"Post.title\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.Content(); ok {\n\t\tif err := post.ContentValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"content\", err: fmt.Errorf(`ent: validator failed for field \"Post.content\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.ContentHTML(); ok {\n\t\tif err := post.ContentHTMLValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"content_html\", err: fmt.Errorf(`ent: validator failed for field \"Post.content_html\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.Summary(); ok {\n\t\tif err := post.SummaryValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"summary\", err: fmt.Errorf(`ent: validator failed for field \"Post.summary\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := pu.mutation.ViewCount(); ok {\n\t\tif err := post.ViewCountValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"view_count\", err: fmt.Errorf(`ent: validator failed for field \"Post.view_count\": %w`, err)}\n\t\t}\n\t}\n\tif _, ok := pu.mutation.AuthorID(); pu.mutation.AuthorCleared() && !ok {\n\t\treturn errors.New(`ent: clearing a required unique edge \"Post.author\"`)\n\t}\n\treturn nil\n}", "func (h CreatePostMsgHandler) validate(ctx weave.Context, db weave.KVStore, tx weave.Tx) (*CreatePostMsg, *Blog, error) {\n\tmsg, err := tx.GetMsg()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tcreatePostMsg, ok := msg.(*CreatePostMsg)\n\tif !ok {\n\t\treturn nil, nil, errors.WithType(errors.ErrMsg, msg)\n\t}\n\n\t// Check the author is one of the Tx signer\n\tif !h.auth.HasAddress(ctx, createPostMsg.Author) {\n\t\treturn nil, nil, errors.Wrapf(errors.ErrUnauthorized, unauthorisedPostAuthorFmt, weave.Address(createPostMsg.Author))\n\t}\n\n\terr = createPostMsg.Validate()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// Check that the parent blog exists\n\tobj, err := h.blogs.Get(db, []byte(createPostMsg.Blog))\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif obj == nil || (obj != nil && obj.Value() == nil) {\n\t\treturn nil, nil, errors.Wrap(errors.ErrNotFound, \"blog\")\n\t}\n\n\tblog := obj.Value().(*Blog)\n\treturn createPostMsg, blog, nil\n}", "func (mt PostCollection) Validate() (err error) {\n\tfor _, e := range mt {\n\t\tif e != nil {\n\t\t\tif err2 := e.Validate(); err2 != nil {\n\t\t\t\terr = goa.MergeErrors(err, err2)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (o *PostPunchInOKBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateResponse(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostProductModelProposalUnprocessableEntityBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (body *AddRequestBody) Validate() (err error) {\n\tif body.Token == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"token\", \"body\"))\n\t}\n\treturn\n}", "func (m Name) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := validate.Pattern(\"\", \"body\", string(m), `^[A-Za-z0-1.\\-_]*$`); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (puo *PostUpdateOne) check() error {\n\tif v, ok := puo.mutation.UserID(); ok {\n\t\tif err := post.UserIDValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"user_id\", err: fmt.Errorf(`ent: validator failed for field \"Post.user_id\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.Title(); ok {\n\t\tif err := post.TitleValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"title\", err: fmt.Errorf(`ent: validator failed for field \"Post.title\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.Content(); ok {\n\t\tif err := post.ContentValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"content\", err: fmt.Errorf(`ent: validator failed for field \"Post.content\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.Status(); ok {\n\t\tif err := post.StatusValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"status\", err: fmt.Errorf(`ent: validator failed for field \"Post.status\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.ReplyNum(); ok {\n\t\tif err := post.ReplyNumValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"reply_num\", err: fmt.Errorf(`ent: validator failed for field \"Post.reply_num\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.UpdateAt(); ok {\n\t\tif err := post.UpdateAtValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"update_at\", err: fmt.Errorf(`ent: validator failed for field \"Post.update_at\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.Pin(); ok {\n\t\tif err := post.PinValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"pin\", err: fmt.Errorf(`ent: validator failed for field \"Post.pin\": %w`, err)}\n\t\t}\n\t}\n\treturn nil\n}", "func (m *SubnetPost) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateMtu(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostPatientsBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.MainData\n\tif err := o.MainData.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\t// validation for a type composition with models.PatientObject\n\tif err := o.PatientObject.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\t// validation for a type composition with models.PasswordObject\n\tif err := o.PasswordObject.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *AddExternalBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func ValidateNewPostRequestBody(body *NewPostRequestBody) (err error) {\n\tif body.Body == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"body\", \"body\"))\n\t}\n\treturn\n}", "func (l *LogIn) PostValidate() []string {\n\terrSlice := []string{}\n\n\tif !lib.ValidateEmail(l.Email) {\n\t\terrSlice = append(errSlice, \"email\")\n\t}\n\n\tif l.FacebookToken == \"\" {\n\t\terrSlice = append(errSlice, \"facebook_token\")\n\t}\n\n\tif l.Imei == \"\" {\n\t\terrSlice = append(errSlice, \"imei\")\n\t}\n\n\treturn errSlice\n}", "func (puo *PostUpdateOne) check() error {\n\tif v, ok := puo.mutation.Slug(); ok {\n\t\tif err := post.SlugValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"slug\", err: fmt.Errorf(`ent: validator failed for field \"Post.slug\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.Title(); ok {\n\t\tif err := post.TitleValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"title\", err: fmt.Errorf(`ent: validator failed for field \"Post.title\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.Content(); ok {\n\t\tif err := post.ContentValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"content\", err: fmt.Errorf(`ent: validator failed for field \"Post.content\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.ContentHTML(); ok {\n\t\tif err := post.ContentHTMLValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"content_html\", err: fmt.Errorf(`ent: validator failed for field \"Post.content_html\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.Summary(); ok {\n\t\tif err := post.SummaryValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"summary\", err: fmt.Errorf(`ent: validator failed for field \"Post.summary\": %w`, err)}\n\t\t}\n\t}\n\tif v, ok := puo.mutation.ViewCount(); ok {\n\t\tif err := post.ViewCountValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"view_count\", err: fmt.Errorf(`ent: validator failed for field \"Post.view_count\": %w`, err)}\n\t\t}\n\t}\n\tif _, ok := puo.mutation.AuthorID(); puo.mutation.AuthorCleared() && !ok {\n\t\treturn errors.New(`ent: clearing a required unique edge \"Post.author\"`)\n\t}\n\treturn nil\n}", "func (o *PostSiteGatewayTimeoutBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (ut *todoPayload) Validate() (err error) {\n\tif ut.Title != nil {\n\t\tif utf8.RuneCountInString(*ut.Title) < 8 {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidLengthError(`response.title`, *ut.Title, utf8.RuneCountInString(*ut.Title), 8, true))\n\t\t}\n\t}\n\treturn\n}", "func (o *PostProductModelProposalUnauthorizedBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *HttpBody) Validate() error {\n\tif m == nil {\n\t\treturn nil\n\t}\n\n\t// no validation rules for Body\n\n\t// no validation rules for EndOfStream\n\n\treturn nil\n}", "func (m DNSServers1) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tiDNSServers1Size := int64(len(m))\n\n\tif err := validate.MinItems(\"\", \"body\", iDNSServers1Size, 0); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostChannelsEmailForbiddenBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Error403Data\n\tif err := o.Error403Data.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *JudgeForbiddenBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (mc *Controller) validatePostResponse(apiResponse *http.Response) driver.PostResponseType {\n\tlog.Debug().Msgf(\"Executing validatePostResponse.\")\n\tvar body driver.PostResponseType\n\terr := json.NewDecoder(apiResponse.Body).Decode(&body)\n\tif apiResponse.StatusCode != http.StatusOK {\n\t\tlog.Debug().Msgf(\"Status from Server: %d\", apiResponse.StatusCode)\n\t\tlog.Fatal().Err(err).Msgf(\"Stack Analyses Post Request Failed. Please retry after sometime. If issue persists, Please raise at https://github.com/fabric8-analytics/cli-tools/issues.\")\n\t}\n\tlog.Debug().Msgf(\"Success validatePostResponse.\")\n\treturn body\n}", "func (o *AddPMMAgentBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostRetentionsIDExecutionsBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (upvc *UnsavedPostVideoCreate) check() error {\n\tif _, ok := upvc.mutation.UUID(); !ok {\n\t\treturn &ValidationError{Name: \"uuid\", err: errors.New(\"ent: missing required field \\\"uuid\\\"\")}\n\t}\n\tif v, ok := upvc.mutation.UUID(); ok {\n\t\tif err := unsavedpostvideo.UUIDValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"uuid\", err: fmt.Errorf(\"ent: validator failed for field \\\"uuid\\\": %w\", err)}\n\t\t}\n\t}\n\tif _, ok := upvc.mutation.Validity(); !ok {\n\t\treturn &ValidationError{Name: \"validity\", err: errors.New(\"ent: missing required field \\\"validity\\\"\")}\n\t}\n\tif v, ok := upvc.mutation.Validity(); ok {\n\t\tif err := unsavedpostvideo.ValidityValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"validity\", err: fmt.Errorf(\"ent: validator failed for field \\\"validity\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := upvc.mutation.Title(); ok {\n\t\tif err := unsavedpostvideo.TitleValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"title\", err: fmt.Errorf(\"ent: validator failed for field \\\"title\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := upvc.mutation.URL(); ok {\n\t\tif err := unsavedpostvideo.URLValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"url\", err: fmt.Errorf(\"ent: validator failed for field \\\"url\\\": %w\", err)}\n\t\t}\n\t}\n\tif _, ok := upvc.mutation.CreatedAt(); !ok {\n\t\treturn &ValidationError{Name: \"created_at\", err: errors.New(\"ent: missing required field \\\"created_at\\\"\")}\n\t}\n\tif _, ok := upvc.mutation.UnsavedPostID(); !ok {\n\t\treturn &ValidationError{Name: \"unsaved_post\", err: errors.New(\"ent: missing required edge \\\"unsaved_post\\\"\")}\n\t}\n\treturn nil\n}", "func (o *PostTemplateTemplateIDCopyOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (payload *CreateVerificationPayload) Validate() (err error) {\n\n\treturn\n}", "func (payload *CreateMessagePayload) Validate() (err error) {\n\n\tif payload.Text == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"text\"))\n\t}\n\treturn\n}", "func (m *OffloadPost) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAzure(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateGoogleCloud(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateNfs(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateS3(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (mt *Article) Validate() (err error) {\n\n\tif mt.Text == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"text\"))\n\t}\n\n\treturn\n}", "func (ut *TodoPayload) Validate() (err error) {\n\tif ut.Title != nil {\n\t\tif utf8.RuneCountInString(*ut.Title) < 8 {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidLengthError(`response.title`, *ut.Title, utf8.RuneCountInString(*ut.Title), 8, true))\n\t\t}\n\t}\n\treturn\n}", "func (m *VolumeSnapshotPostAllOf1) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostLoginUnauthorizedBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *SaveBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateHash(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateKeyPair(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (mt *EasypostPostagelabel) Validate() (err error) {\n\tif mt.ID != nil {\n\t\tif ok := goa.ValidatePattern(`^pl_`, *mt.ID); !ok {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.id`, *mt.ID, `^pl_`))\n\t\t}\n\t}\n\tif ok := goa.ValidatePattern(`^PostageLabel$`, mt.Object); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.object`, mt.Object, `^PostageLabel$`))\n\t}\n\treturn\n}", "func (o *CreateShortLinkBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateURL(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetAPIV1PostsPostIDNotFoundBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (ut *addFieldNotePayload) Validate() (err error) {\n\tif ut.Created == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"created\"))\n\t}\n\treturn\n}", "func (o *PostIPAMIpsOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (payload *CreateCommentPayload) Validate() (err error) {\n\n\tif payload.Text == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"text\"))\n\t}\n\n\treturn\n}", "func ValidatePostMessageRequestBody(body *PostMessageRequestBody) (err error) {\n\tif body.Post == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"post\", \"body\"))\n\t}\n\tif body.Post != nil {\n\t\tif err2 := ValidateNewPostRequestBody(body.Post); err2 != nil {\n\t\t\terr = goa.MergeErrors(err, err2)\n\t\t}\n\t}\n\treturn\n}", "func (o *GetAPIV1PostsPostIDOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.contextValidateVotedAge(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateVotedBloodType(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateVotedMonth(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateVotedSex(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *EnclosureUpdateBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (swr *SearchWordsRequest) Validate(r *http.Request) (bool, *SearchWordsRespnse) {\n\n\tsearchWordsRespnse := new(SearchWordsRespnse)\n\n\t// Check if body is empty, because we expect some input\n\tif r.Body == nil {\n\n\t\tsearchWordsRespnse.Code = status.EmptyBody\n\t\tsearchWordsRespnse.Errors = append(searchWordsRespnse.Errors, Error{Code: status.EmptyBody, Message: status.Text(status.EmptyBody)})\n\t\treturn false, searchWordsRespnse\n\t}\n\n\t// Decode request\n\terr := json.NewDecoder(r.Body).Decode(&swr)\n\n\tdefer r.Body.Close()\n\n\tif err != nil {\n\t\tsearchWordsRespnse.Code = status.IncorrectBodyFormat\n\t\tsearchWordsRespnse.Errors = append(searchWordsRespnse.Errors, Error{Code: status.IncorrectBodyFormat, Message: status.Text(status.IncorrectBodyFormat)})\n\t\treturn false, searchWordsRespnse\n\t}\n\n\treturn true, searchWordsRespnse\n}", "func (m *WebhookActionBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAction(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateApplication(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateDevice(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateRule(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTimestamp(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *TicketPosts) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validatePosts(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateProductUnprocessableEntityBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostProductModelProposalForbiddenBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func validatePostPrice(i interface{}) error {\n\tconst paramName = \"post_price\"\n\n\t_, ok := i.(Params_PostPriceParams)\n\tif !ok {\n\t\treturn fmt.Errorf(\"%s param: invalid type: %T\", paramName, i)\n\t}\n\n\treturn nil\n}", "func ValidateStoredStepRequestBody(body *StoredStepRequestBody) (err error) {\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Title == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"title\", \"body\"))\n\t}\n\tif body.Target == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"target\", \"body\"))\n\t}\n\tif body.StepNumber == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"stepNumber\", \"body\"))\n\t}\n\tif body.Content == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"content\", \"body\"))\n\t}\n\tif body.Placement == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"placement\", \"body\"))\n\t}\n\tif body.Action == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"action\", \"body\"))\n\t}\n\tif body.Placement != nil {\n\t\tif !(*body.Placement == \"left\" || *body.Placement == \"right\" || *body.Placement == \"top\" || *body.Placement == \"buttom\") {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(\"body.placement\", *body.Placement, []interface{}{\"left\", \"right\", \"top\", \"buttom\"}))\n\t\t}\n\t}\n\tif body.Action != nil {\n\t\tif !(*body.Action == \"click\" || *body.Action == \"next\" || *body.Action == \"end\") {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(\"body.action\", *body.Action, []interface{}{\"click\", \"next\", \"end\"}))\n\t\t}\n\t}\n\treturn\n}", "func (o *SyncCopyBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *NiaapiApicCcoPost) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with NiaapiNewReleasePost\n\tif err := m.NiaapiNewReleasePost.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\t// validation for a type composition with NiaapiApicCcoPostAllOf1\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *EavAttributeSetManagementV1CreatePostBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateAttributeSet(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateEntityTypeCode(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateSkeletonID(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (mt *EasypostFieldObject) Validate() (err error) {\n\tif mt.Key == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"key\"))\n\t}\n\tif mt.Value == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"value\"))\n\t}\n\tif mt.Visibility == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"visibility\"))\n\t}\n\tif mt.Label == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"label\"))\n\t}\n\n\treturn\n}", "func (payload *createMessagePayload) Validate() (err error) {\n\tif payload.OfferID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"offer_id\"))\n\t}\n\tif payload.Text == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"text\"))\n\t}\n\treturn\n}", "func (m EndpointMetadata) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := validate.Required(\"\", \"body\", EndpointMetadata(m)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *RemovePolicyNotFoundBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func Validate(ctx http.IContext, vld *validator.Validate, arg interface{}) bool {\n\n\tif err := ctx.GetRequest().GetBodyAs(arg); err != nil {\n\t\thttp.InternalServerException(ctx)\n\t\treturn false\n\t}\n\n\tswitch err := vld.Struct(arg); err.(type) {\n\tcase validator.ValidationErrors:\n\t\thttp.FailedValidationException(ctx, err.(validator.ValidationErrors))\n\t\treturn false\n\n\tcase nil:\n\t\tbreak\n\n\tdefault:\n\t\thttp.InternalServerException(ctx)\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (mt *EasypostCustomitem) Validate() (err error) {\n\tif mt.ID == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"id\"))\n\t}\n\tif mt.Object == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"object\"))\n\t}\n\tif mt.Description == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"description\"))\n\t}\n\tif mt.Quantity == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"quantity\"))\n\t}\n\tif mt.Value == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"value\"))\n\t}\n\tif mt.Weight == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"weight\"))\n\t}\n\tif mt.OriginCountry == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"origin_country\"))\n\t}\n\n\tif ok := goa.ValidatePattern(`^cstitem_`, mt.ID); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.id`, mt.ID, `^cstitem_`))\n\t}\n\tif ok := goa.ValidatePattern(`^CustomsItem$`, mt.Object); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.object`, mt.Object, `^CustomsItem$`))\n\t}\n\treturn\n}", "func (mt *EasypostScanform) Validate() (err error) {\n\tif mt.Address != nil {\n\t\tif err2 := mt.Address.Validate(); err2 != nil {\n\t\t\terr = goa.MergeErrors(err, err2)\n\t\t}\n\t}\n\tif mt.ID != nil {\n\t\tif ok := goa.ValidatePattern(`^sf_`, *mt.ID); !ok {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.id`, *mt.ID, `^sf_`))\n\t\t}\n\t}\n\tif ok := goa.ValidatePattern(`^ScanForm$`, mt.Object); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.object`, mt.Object, `^ScanForm$`))\n\t}\n\tif mt.Status != nil {\n\t\tif !(*mt.Status == \"creating\" || *mt.Status == \"created\" || *mt.Status == \"failed\") {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(`response.status`, *mt.Status, []interface{}{\"creating\", \"created\", \"failed\"}))\n\t\t}\n\t}\n\treturn\n}", "func (a *Misc_ApiService) ShowValidationsPost(ctx context.Context, emptyRequest EmptyRequest) (ValidationsReply, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Post\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue ValidationsReply\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/show-validations\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\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 = &emptyRequest\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"X-chkp-sid\"] = key\n\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode < 300 {\n\t\t// If we succeed, return the data, otherwise pass on to decode error.\n\t\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\tif err == nil {\n\t\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t\t}\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v ValidationsReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 400 {\n\t\t\tvar v ApiValidationErrorReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 401 {\n\t\t\tvar v ApiValidationErrorReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 403 {\n\t\t\tvar v ApiValidationErrorReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 404 {\n\t\t\tvar v ApiValidationErrorReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 409 {\n\t\t\tvar v ApiValidationErrorReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 500 {\n\t\t\tvar v ApiValidationErrorReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 501 {\n\t\t\tvar v ApiValidationErrorReply\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"));\n\t\t\t\tif err != nil {\n\t\t\t\t\tnewErr.error = err.Error()\n\t\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t\t}\n\t\t\t\tnewErr.model = v\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHttpResponse, nil\n}", "func (o *PatchAssetTagsCodeUnprocessableEntityBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostAPIV2EventsBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateAttributes(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateEntityID(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateEvent(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *DeleteDatasetCreatedBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (input *BeegoInput) IsPost() bool {\n\treturn input.Is(\"POST\")\n}", "func (o *PostSilencesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}" ]
[ "0.6828625", "0.6763795", "0.66514206", "0.66498876", "0.6551311", "0.6549796", "0.6481227", "0.64445597", "0.64433396", "0.6426678", "0.6376102", "0.62443596", "0.6219988", "0.60760933", "0.6075056", "0.6064885", "0.6051017", "0.6040373", "0.6032003", "0.6032003", "0.6004105", "0.5961311", "0.59543484", "0.59232914", "0.58718675", "0.5869643", "0.5834727", "0.58301306", "0.5812692", "0.5808903", "0.58080536", "0.5789717", "0.57804805", "0.5718396", "0.56985253", "0.56542313", "0.56405944", "0.5638702", "0.5637714", "0.56136894", "0.55997705", "0.5568371", "0.55654067", "0.5550289", "0.55472374", "0.5527998", "0.55038524", "0.5502022", "0.5493991", "0.54884714", "0.54854673", "0.54729414", "0.54695404", "0.54548997", "0.5448394", "0.54476064", "0.5437806", "0.5434419", "0.5422249", "0.5407806", "0.5394352", "0.5383058", "0.5379616", "0.53631043", "0.535333", "0.53385115", "0.53295445", "0.53162", "0.53099686", "0.5307452", "0.53066427", "0.5301772", "0.5300107", "0.5299673", "0.52976006", "0.5290857", "0.5290326", "0.52839005", "0.52613086", "0.5259818", "0.5250613", "0.5250115", "0.524948", "0.5241036", "0.52306867", "0.52243817", "0.5214034", "0.52126515", "0.52100825", "0.52082026", "0.52004296", "0.51954716", "0.51917744", "0.51866734", "0.51849264", "0.51810086", "0.51807755", "0.51686245", "0.51610667", "0.5157247" ]
0.6716438
2
ContextValidate validates this post silences o k body based on context it is used
func (o *PostSilencesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetAPIV1PostsPostIDOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.contextValidateVotedAge(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateVotedBloodType(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateVotedMonth(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateVotedSex(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostWalletSiafundsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *PostUpdatePushTokenPayload) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostPunchInOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.contextValidateResponse(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostSilencesOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostEntitiesEntityFidAttachmentsUploadURLOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostOauth2TokenOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *CreateProductUnprocessableEntityBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetAPIV1PostsPostIDNotFoundBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetAPIV1PostsPostIDOKBodyVotedBloodType) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *TicketPosts) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.contextValidatePosts(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *TogglePacketGeneratorsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *CreateTicketPayload) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetAPIV1PostsPostIDOKBodyVotedSex) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *AcceptInvitationBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *RemovePolicyOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostPunchInOKBodyResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.contextValidateAttendance(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ScanProductsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostWebhookBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateOn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateSign(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateURL(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UtilTestBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetAPIV1PostsPublicPostIDNotFoundBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *DeleteUserForbiddenBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostProfileBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostLeasesIDAuthCreatedBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetAPIV1PostsPostIDOKBodyVotedAge) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostSiteForbiddenBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *RemovePolicyNotFoundBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func Validate(ctx flamego.Context, x CSRF) {\n\tx.Validate(ctx)\n}", "func (m *FalconxMITREAttackParent) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetInteractionsInteractionFidOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostDeviceURLOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetPublishersOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetPastUsageBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetMeOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateProductNotImplementedBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetWellKnownJSONWebKeysInternalServerErrorBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *UtilTestOKBodyResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostProductModelProposalUnauthorizedBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m PinPolicy) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostProductModelProposalUnprocessableEntityBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *StartPlaidLinkV1Body) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetLighthouseOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func ValidatePostBadReqResponseBody(body *PostBadReqResponseBody) (err error) {\n\tif body.Name == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"name\", \"body\"))\n\t}\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Message == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"message\", \"body\"))\n\t}\n\tif body.Temporary == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"temporary\", \"body\"))\n\t}\n\tif body.Timeout == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"timeout\", \"body\"))\n\t}\n\tif body.Fault == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"fault\", \"body\"))\n\t}\n\treturn\n}", "func ValidatePostBadReqResponseBody(body *PostBadReqResponseBody) (err error) {\n\tif body.Name == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"name\", \"body\"))\n\t}\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Message == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"message\", \"body\"))\n\t}\n\tif body.Temporary == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"temporary\", \"body\"))\n\t}\n\tif body.Timeout == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"timeout\", \"body\"))\n\t}\n\tif body.Fault == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"fault\", \"body\"))\n\t}\n\treturn\n}", "func (o *DeleteVMTempOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (payload *postEventPayload) Validate() (err error) {\n\tif payload.Etype == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (o *GetHelloOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostcommentsBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (tmpl *FixtureTemplate) ValidateContext(context *TemplateBuildContext) *axerror.AXError {\n\t// for each action make sure template exists\n\tif tmpl.Actions != nil {\n\t\t// Build up a scope of fixture attributes which we will use to validate any %%attributes.name%% usages in the action parameters\n\t\tscopedParams := make(paramMap)\n\t\tattributeNames := map[string]bool{}\n\t\tfor k := range FixtureAttributeReservedNamesMap {\n\t\t\tattributeNames[k] = true\n\t\t\tp := param{\n\t\t\t\tname: fmt.Sprintf(\"%s.%s\", KeywordAttributes, k),\n\t\t\t\tparamType: paramTypeString,\n\t\t\t}\n\t\t\tscopedParams[p.name] = p\n\t\t}\n\t\tfor k := range tmpl.Attributes {\n\t\t\tattributeNames[k] = true\n\t\t\tp := param{\n\t\t\t\tname: fmt.Sprintf(\"%s.%s\", KeywordAttributes, k),\n\t\t\t\tparamType: paramTypeString,\n\t\t\t}\n\t\t\tscopedParams[p.name] = p\n\t\t}\n\n\t\tfor actionName, action := range tmpl.Actions {\n\t\t\tst, exists := context.Templates[action.Template]\n\t\t\tif !exists {\n\t\t\t\t// template should exist\n\t\t\t\treturn axerror.ERR_API_INVALID_PARAM.NewWithMessagef(\"actions.%s template %s does not exist\", actionName, action.Template)\n\t\t\t}\n\t\t\trcvrInputs := st.GetInputs()\n\t\t\tswitch st.GetType() {\n\t\t\tcase TemplateTypeWorkflow, TemplateTypeContainer:\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn axerror.ERR_API_INVALID_PARAM.NewWithMessagef(\"actions.%s template %s must be of type container or workflow\", actionName, action.Template)\n\t\t\t}\n\t\t\tvar axErr *axerror.AXError\n\t\t\tif actionName == \"create\" || actionName == \"delete\" {\n\t\t\t\t// for create and delete actions, all reciever params need to be resolved because these actions cannot accept inputs\n\t\t\t\t// since we trigger these actions automatically on fixture create/delete.\n\t\t\t\taxErr = validateReceiverParams(st.GetName(), rcvrInputs, action.Arguments, scopedParams)\n\t\t\t} else {\n\t\t\t\t// otherwise, we just need to check the parameter type matches. unresolved attributes will become UI input parameters\n\t\t\t\t_, axErr = validateReceiverParamsPartial(st.GetName(), rcvrInputs, action.Arguments, scopedParams)\n\t\t\t}\n\t\t\tif axErr != nil {\n\t\t\t\treturn axerror.ERR_API_INVALID_PARAM.NewWithMessagef(\"actions.%s %v\", actionName, axErr)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (p *PostTag) Validate(tx *pop.Connection) (*validate.Errors, error) {\n\treturn validate.NewErrors(), nil\n}", "func (body *AddRequestBody) Validate() (err error) {\n\tif body.Token == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"token\", \"body\"))\n\t}\n\treturn\n}", "func (o *DeleteUserUnauthorizedBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *SnippetDTO) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.contextValidateConnections(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateFunnels(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateInputPorts(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateLabels(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateOutputPorts(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateProcessGroups(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateProcessors(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateRemoteProcessGroups(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m InlineTypes) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *OBWriteDomesticResponse5DataMultiAuthorisation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *UserUpdatePayload) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (nS *PostMessageBody) Validate() error {\n\treturn validator.New().Struct(nS)\n}", "func (o *PostDocumentFieldextractOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *DeleteUserOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m HTTPMethod) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *CreateCustomerContactPayload) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostTemplateTemplateIDCopyBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *PostV1ScimV2UsersName) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *OBWriteDomesticResponse5) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateLinks(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.contextValidateMeta(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostProductModelProposalForbiddenBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostSiteBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (ctx *Context) IsPost() bool {\r\n\treturn ctx.Is(\"POST\")\r\n}", "func (o *PostEntitiesEntityFidAttachmentsUploadURLOKBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateData(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (s DialogflowServer) DialogPostContext(w http.ResponseWriter, r *http.Request) {\r\n\tvars := mux.Vars(r)\r\n\tsessionID := vars[\"sessionID\"]\r\n\tcontextID := vars[\"context\"]\r\n\r\n\tlog.Printf(\"Route: %s , SessionID: %s , ContextID: %s\\n\", r.URL, sessionID, contextID)\r\n\r\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\r\n\tif r.Method == http.MethodOptions {\r\n\t\treturn\r\n\t}\r\n\r\n\trequest := dialogflowpb.CreateContextRequest{\r\n\t\tParent: fmt.Sprintf(\"projects/%s/agent/sessions/%s\", s.projectID, sessionID),\r\n\t\tContext: &dialogflowpb.Context{\r\n\t\t\tLifespanCount: 10,\r\n\t\t\tName: fmt.Sprintf(\"projects/%s/agent/sessions/%s/contexts/%s\", s.projectID, sessionID, contextID),\r\n\t\t\tParameters: &structpb.Struct{\r\n\t\t\t\tFields: map[string]*structpb.Value{\r\n\t\t\t\t\tcontextID: structpb.NewStringValue(\"hello world\"),\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t},\r\n\t}\r\n\r\n\tresponse, err := s.contextClient.CreateContext(s.ctx, &request)\r\n\tif err != nil {\r\n\t\tlog.Printf(\"Error in communication with Dialogflow %s\\n\", err.Error())\r\n\t\tw.WriteHeader(http.StatusInternalServerError)\r\n\t\treturn\r\n\t}\r\n\r\n\tw.Header().Set(\"Content-Type\", \"application/json\")\r\n\tjson.NewEncoder(w).Encode(response)\r\n}", "func (o *GetVersionOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetPresetChatSessionIDOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func ValidatePostUnAuthResponseBody(body *PostUnAuthResponseBody) (err error) {\n\tif body.Name == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"name\", \"body\"))\n\t}\n\tif body.ID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"id\", \"body\"))\n\t}\n\tif body.Message == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"message\", \"body\"))\n\t}\n\tif body.Temporary == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"temporary\", \"body\"))\n\t}\n\tif body.Timeout == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"timeout\", \"body\"))\n\t}\n\tif body.Fault == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingFieldError(\"fault\", \"body\"))\n\t}\n\treturn\n}", "func (m *SentEmail) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (mt *Post) Validate() (err error) {\n\n\tif mt.URLName == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"url_name\"))\n\t}\n\tif mt.Title == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"title\"))\n\t}\n\tif mt.Contents == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"contents\"))\n\t}\n\tif mt.Status == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"status\"))\n\t}\n\tif !(mt.Status == \"draft\" || mt.Status == \"published\") {\n\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(`response.status`, mt.Status, []interface{}{\"draft\", \"published\"}))\n\t}\n\treturn\n}", "func (m TenderCardDetailsEntryMethod) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *executionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *DeviceapiUpdateDeviceTagsRequestV1) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *UtilTestOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.contextValidateResponse(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetRelationTuplesInternalServerErrorBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostTemplateTemplateIDCopyOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetAPIV1PostsPostIDOKBodyVotedMonth) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func validatePOSTRequest(body []byte, schema *gojsonschema.Schema) (err error) {\n\tdocLoader := gojsonschema.NewStringLoader(string(body))\n\tif result, err := schema.Validate(docLoader); err != nil && !result.Valid() {\n\t\treturn errors.New(\"Couldn't validate json\")\n\t}\n\treturn nil\n}", "func (m VipType) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetInteractionsInviteInviteCodeStatusOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *PacketAnalyzerConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *PostV1ConversationsConversationIDComments) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetPastUsageNotFoundBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *BatchObjectsCreateBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.contextValidateObjects(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostcommentsOKBody) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m OrderLineItemDiscountType) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func ValidateCreateExpenseContext(req CreateExpenseContext) error {\n\tif req.Amount <= 0 {\n\t\treturn errors.New(\"amount should be positive number\")\n\t}\n\tif req.UserID == 0 {\n\t\treturn errors.New(\"incorrect user\")\n\t}\n\tif req.GroupID == 0 {\n\t\treturn errors.New(\"incorrect group\")\n\t}\n\tif len(req.Shares) == 0 {\n\t\treturn errors.New(\"shares should contain at least one share\")\n\t}\n\ttotalPercent := Percent(0)\n\tfor _, share := range req.Shares {\n\t\ttotalPercent += share\n\t}\n\tif totalPercent != 100 {\n\t\treturn errors.New(\"total percent for shares incorrect\")\n\t}\n\treturn nil\n}", "func (payload *PostEventPayload) Validate() (err error) {\n\tif payload.Etype == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (m *OBWriteDomesticStandingOrderConsent5DataAuthorisation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m Type) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *AuthRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *CreateSignal) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *MinGasPriceResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetSearchbyIDOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *GetProductsOffersOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with models.Envelope\n\tif err := o.Envelope.ContextValidate(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.contextValidateData(ctx, formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *DeleteVMTempNotFoundBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}" ]
[ "0.6598052", "0.65758985", "0.65550315", "0.65479106", "0.653154", "0.6530507", "0.64153093", "0.6161927", "0.60246253", "0.5965307", "0.59410894", "0.5938023", "0.5882044", "0.5875261", "0.58471507", "0.58214104", "0.5811343", "0.5792734", "0.5791356", "0.5773505", "0.57603574", "0.5750155", "0.5747556", "0.5717232", "0.5708027", "0.5702849", "0.5668089", "0.5643511", "0.56386805", "0.56353766", "0.5618522", "0.56176865", "0.5617208", "0.56096566", "0.5548496", "0.55348665", "0.55329376", "0.5527951", "0.5527737", "0.55251384", "0.55118555", "0.54960644", "0.549466", "0.549466", "0.5487646", "0.5473552", "0.5468905", "0.5467895", "0.5465296", "0.5451992", "0.54499614", "0.54496735", "0.5446083", "0.54417056", "0.5435245", "0.54343337", "0.54182863", "0.54127204", "0.54113406", "0.5409666", "0.54088837", "0.5402066", "0.5400595", "0.53977925", "0.5397168", "0.53912085", "0.5391102", "0.5378265", "0.5370605", "0.5369997", "0.5356025", "0.5355609", "0.53474903", "0.5347364", "0.5339061", "0.53288007", "0.5323364", "0.5311865", "0.53031325", "0.5296272", "0.5290838", "0.52811974", "0.52705914", "0.5265932", "0.5258019", "0.52547157", "0.5250846", "0.52484256", "0.5248373", "0.52394015", "0.52393544", "0.52354395", "0.5229408", "0.52058125", "0.5200945", "0.519583", "0.519377", "0.519184", "0.518554", "0.51852345" ]
0.73734653
0
NewDesktopApp is a esktopApp constructor
func NewDesktopApp(c *restapi.RestClient) *DesktopApp { s := DesktopApp{} s.client = c s.apiRead = "/SaasManage/GetApplication" s.apiCreate = "/SaasManage/ImportAppFromTemplate" s.apiDelete = "/SaasManage/DeleteApplication" s.apiUpdate = "/SaasManage/UpdateApplicationDE" s.apiPermissions = "/SaasManage/SetApplicationPermissions" return &s }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewMicrosoftManagedDesktop()(*MicrosoftManagedDesktop) {\n m := &MicrosoftManagedDesktop{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func newApp(name string) (app *App, err error) {\n\tapp = &App{\n\t\tName: name,\n\t\tID: uuid.NewV5(namespace, \"org.homealone.\"+name).String(),\n\t\thandler: make(map[queue.Topic]message.Handler),\n\t\tdebug: *debug,\n\t\tfilterMessages: true,\n\t}\n\tapp.Log = log.NewLogger().With(log.Fields{\"app\": name, \"id\": app.ID})\n\treturn app, errors.Wrap(err, \"newApp failed\")\n}", "func App() *Application {\r\n\r\n\t// Return singleton if already created\r\n\tif a != nil {\r\n\t\treturn a\r\n\t}\r\n\ta = new(Application)\r\n\t// Initialize window\r\n\terr := window.Init(width, height, title)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\ta.IWindow = window.Get()\r\n\ta.openDefaultAudioDevice() // Set up audio\r\n\ta.keyState = window.NewKeyState(a) // Create KeyState\r\n\t// Create renderer and add default shaders\r\n\ta.renderer = renderer.NewRenderer(a.Gls())\r\n\terr = a.renderer.AddDefaultShaders()\r\n\tif err != nil {\r\n\t\tpanic(fmt.Errorf(\"AddDefaultShaders:%v\", err))\r\n\t}\r\n\treturn a\r\n}", "func CreateApp(appoptions *options.App) (*App, error) {\n\tvar err error\n\n\tctx := context.Background()\n\n\t// Merge default options\n\toptions.MergeDefaults(appoptions)\n\n\tdebug := IsDebug()\n\tdevtools := IsDevtoolsEnabled()\n\tctx = context.WithValue(ctx, \"debug\", debug)\n\tctx = context.WithValue(ctx, \"devtools\", devtools)\n\n\t// Set up logger\n\tmyLogger := logger.New(appoptions.Logger)\n\tif IsDebug() {\n\t\tmyLogger.SetLogLevel(appoptions.LogLevel)\n\t} else {\n\t\tmyLogger.SetLogLevel(appoptions.LogLevelProduction)\n\t}\n\tctx = context.WithValue(ctx, \"logger\", myLogger)\n\tctx = context.WithValue(ctx, \"obfuscated\", IsObfuscated())\n\n\t// Preflight Checks\n\terr = PreflightChecks(appoptions, myLogger)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create the menu manager\n\tmenuManager := menumanager.NewManager()\n\n\t// Process the application menu\n\tif appoptions.Menu != nil {\n\t\terr = menuManager.SetApplicationMenu(appoptions.Menu)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Create binding exemptions - Ugly hack. There must be a better way\n\tbindingExemptions := []interface{}{\n\t\tappoptions.OnStartup,\n\t\tappoptions.OnShutdown,\n\t\tappoptions.OnDomReady,\n\t\tappoptions.OnBeforeClose,\n\t}\n\tappBindings := binding.NewBindings(myLogger, appoptions.Bind, bindingExemptions, IsObfuscated())\n\teventHandler := runtime.NewEvents(myLogger)\n\tctx = context.WithValue(ctx, \"events\", eventHandler)\n\t// Attach logger to context\n\tif debug {\n\t\tctx = context.WithValue(ctx, \"buildtype\", \"debug\")\n\t} else {\n\t\tctx = context.WithValue(ctx, \"buildtype\", \"production\")\n\t}\n\n\tmessageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler, appoptions.ErrorFormatter)\n\tappFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher)\n\teventHandler.AddFrontend(appFrontend)\n\n\tctx = context.WithValue(ctx, \"frontend\", appFrontend)\n\tresult := &App{\n\t\tctx: ctx,\n\t\tfrontend: appFrontend,\n\t\tlogger: myLogger,\n\t\tmenuManager: menuManager,\n\t\tstartupCallback: appoptions.OnStartup,\n\t\tshutdownCallback: appoptions.OnShutdown,\n\t\tdebug: debug,\n\t\tdevtools: devtools,\n\t\toptions: appoptions,\n\t}\n\n\treturn result, nil\n\n}", "func newApp(desc string) *cli.App {\n\tapp := cli.NewApp()\n\tapp.Name = name\n\tapp.HelpName = filepath.Base(os.Args[0])\n\tapp.Author = author\n\tapp.Version = version\n\tapp.Description = desc\n\tapp.Writer = os.Stdout\n\treturn app\n}", "func makeApp(def pchannel.App, data pchannel.Data) perun.App {\n\treturn perun.App{\n\t\tDef: def,\n\t\tData: data,\n\t}\n}", "func CreateApplication() *Alpha {\n app := &Alpha{}\n app.Request = &Request{}\n app.Response = &Response{}\n app.init()\n return app\n}", "func onLaunch() {\n\tmenu := &Menu{}\n\n\tapp.MenuBar().Mount(menu)\n\tapp.Dock().Mount(menu)\n\n\tmainWindow = newWelcomeWindow()\n}", "func GetApp() *cli.App {\n\tglobalFlags := map[string]cli.Flag{\n\t\t\"no-color\": &cli.BoolFlag{\n\t\t\tName: \"no-color\",\n\t\t\tUsage: \"Disable coloured output.\",\n\t\t},\n\t}\n\n\ttimerFlags := []cli.Flag{\n\t\t&cli.BoolFlag{\n\t\t\tName: \"disable-notifications\",\n\t\t\tAliases: []string{\"d\"},\n\t\t\tUsage: \"Disable the system notification after a session is completed.\",\n\t\t},\n\t\tglobalFlags[\"no-color\"],\n\t\t&cli.StringFlag{\n\t\t\tName: \"sound\",\n\t\t\tUsage: \"Play ambient sounds continuously during a session. Default options: coffee_shop, fireplace, rain,\\n\\t\\t\\t\\twind, summer_night, playground. Disable sound by setting to 'off'\",\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"sound-on-break\",\n\t\t\tAliases: []string{\"sob\"},\n\t\t\tUsage: \"Play ambient sounds during a break sessions.\",\n\t\t},\n\t}\n\n\tapp := &cli.App{\n\t\tName: \"Focus\",\n\t\tAuthors: []*cli.Author{\n\t\t\t{\n\t\t\t\tName: \"Ayooluwa Isaiah\",\n\t\t\t\tEmail: \"[email protected]\",\n\t\t\t},\n\t\t},\n\t\tUsage: \"Focus is a cross-platform productivity timer for the command-line. It is based on the Pomodoro Technique,\\n\\t\\ta time management method developed by Francesco Cirillo in the late 1980s.\",\n\t\tUsageText: \"[COMMAND] [OPTIONS]\",\n\t\tVersion: \"v1.2.0\",\n\t\tEnableBashCompletion: true,\n\t\tCommands: []*cli.Command{\n\t\t\t{\n\t\t\t\tName: \"resume\",\n\t\t\t\tUsage: \"Resume a previously interrupted work session\",\n\t\t\t\tFlags: timerFlags,\n\t\t\t\tAction: func(ctx *cli.Context) error {\n\t\t\t\t\tif ctx.Bool(\"no-color\") {\n\t\t\t\t\t\tdisableStyling()\n\t\t\t\t\t}\n\n\t\t\t\t\tstore, err := focus.NewStore()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tt := &focus.Timer{\n\t\t\t\t\t\tStore: store,\n\t\t\t\t\t}\n\n\t\t\t\t\terr = t.Resume()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tt.SetResumeOptions(ctx)\n\n\t\t\t\t\treturn t.Run()\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"stats\",\n\t\t\t\tUsage: \"Track your progress with detailed statistics reporting. Defaults to a reporting period of 7 days.\",\n\t\t\t\tAction: func(ctx *cli.Context) error {\n\t\t\t\t\tif ctx.Bool(\"no-color\") {\n\t\t\t\t\t\tpterm.DisableColor()\n\t\t\t\t\t}\n\n\t\t\t\t\tstore, err := focus.NewStore()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tstats, err := focus.NewStats(ctx, store)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tif ctx.Bool(\"delete\") {\n\t\t\t\t\t\treturn stats.Delete(os.Stdout, os.Stdin)\n\t\t\t\t\t}\n\n\t\t\t\t\tif ctx.Bool(\"list\") {\n\t\t\t\t\t\treturn stats.List(os.Stdout)\n\t\t\t\t\t}\n\n\t\t\t\t\tif len(stats.Tags) != 0 {\n\t\t\t\t\t\treturn stats.EditTag(os.Stdout, os.Stdin)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn stats.Show(os.Stdout)\n\t\t\t\t},\n\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t&cli.BoolFlag{\n\t\t\t\t\t\tName: \"delete\",\n\t\t\t\t\t\tAliases: []string{\"d\"},\n\t\t\t\t\t\tUsage: \"Delete the all work sessions within the specified time period.\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.BoolFlag{\n\t\t\t\t\t\tName: \"list\",\n\t\t\t\t\t\tAliases: []string{\"l\"},\n\t\t\t\t\t\tUsage: \"List all the work sessions within the specified time period.\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"tag\",\n\t\t\t\t\t\tAliases: []string{\"t\"},\n\t\t\t\t\t\tUsage: \"Match only sessions with a specific tag\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"period\",\n\t\t\t\t\t\tAliases: []string{\"p\"},\n\t\t\t\t\t\tUsage: \"Specify a time period for (defaults to 7days). Possible values are: today, yesterday, 7days, 14days, 30days, 90days, 180days, 365days, all-time.\",\n\t\t\t\t\t\tValue: \"7days\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"start\",\n\t\t\t\t\t\tAliases: []string{\"s\"},\n\t\t\t\t\t\tUsage: \"Specify a start date in the following format: YYYY-MM-DD [HH:MM:SS PM].\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"end\",\n\t\t\t\t\t\tAliases: []string{\"e\"},\n\t\t\t\t\t\tUsage: \"Specify an end date in the following format: YYYY-MM-DD [HH:MM:SS PM] (defaults to the current time).\",\n\t\t\t\t\t},\n\t\t\t\t\tglobalFlags[\"no-color\"],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"max-sessions\",\n\t\t\t\tAliases: []string{\"max\"},\n\t\t\t\tUsage: \"The maximum number of work sessions (unlimited by default).\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"short-break\",\n\t\t\t\tAliases: []string{\"s\"},\n\t\t\t\tUsage: \"Short break duration in minutes (default: 5).\",\n\t\t\t},\n\t\t\t&cli.StringFlag{\n\t\t\t\tName: \"tag\",\n\t\t\t\tAliases: []string{\"t\"},\n\t\t\t\tUsage: \"Add a tag to a session\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"long-break\",\n\t\t\t\tAliases: []string{\"l\"},\n\t\t\t\tUsage: \"Long break duration in minutes (default: 15).\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"long-break-interval\",\n\t\t\t\tAliases: []string{\"int\"},\n\t\t\t\tUsage: \"The number of work sessions before a long break (default: 4).\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"work\",\n\t\t\t\tAliases: []string{\"w\"},\n\t\t\t\tUsage: \"Work duration in minutes (default: 25).\",\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx *cli.Context) error {\n\t\t\tif ctx.Bool(\"no-color\") {\n\t\t\t\tdisableStyling()\n\t\t\t}\n\n\t\t\tstore, err := focus.NewStore()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tconfig, err := focus.NewConfig()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tt := focus.NewTimer(ctx, config, store)\n\n\t\t\treturn t.Run()\n\t\t},\n\t}\n\n\tapp.Flags = append(app.Flags, timerFlags...)\n\n\treturn app\n}", "func NewApp() App {\n\treturn App{}\n}", "func NewApp() App {\n\treturn App{}\n}", "func NewApp(cfg *Config) *App {\n\treturn &App{\n\t\tl: log.With().Str(\"m\", \"app\").Logger(),\n\t\tcfg: cfg,\n\t\tgui: gui.NewGui(&cfg.Gui),\n\t}\n}", "func newAppBar(desk fynedesk.Desktop, children ...fyne.CanvasObject) *bar {\n\tbar := &bar{desk: desk, children: children}\n\tbar.ExtendBaseWidget(bar)\n\tbar.iconSize = desk.Settings().LauncherIconSize()\n\tbar.iconScale = float32(desk.Settings().LauncherZoomScale())\n\tbar.disableTaskbar = desk.Settings().LauncherDisableTaskbar()\n\n\treturn bar\n}", "func NewApp() App {\n\n\tvar err error\n\tvar app *appmgr\n\n\tconst appname = \"app\"\n\n\tapp = &appmgr{\n\t\tstate: fsm.Undefined,\n\t\tname: appname,\n\t\tprops: make(map[string]map[string]interface{}),\n\t\tdflow: nil,\n\t\tstore: nil,\n\t\tmsg: newMsgStream(\n\t\t\tappname,\n\t\t\tLvlInfo,\n\t\t\t//LvlDebug,\n\t\t\t//LvlError,\n\t\t\tnil,\n\t\t),\n\t\tevtmax: -1,\n\t\tnprocs: -1,\n\t\tcomps: make(map[string]Component),\n\t\ttsks: make([]Task, 0),\n\t\tsvcs: make([]Svc, 0),\n\t}\n\n\tsvc, err := app.New(\"go-hep.org/x/hep/fwk.datastore\", \"evtstore\")\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create evtstore: %w\\n\", err)\n\t\treturn nil\n\t}\n\tapp.store = svc.(*datastore)\n\n\terr = app.AddSvc(app.store)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create evtstore: %w\\n\", err)\n\t\treturn nil\n\t}\n\n\tsvc, err = app.New(\"go-hep.org/x/hep/fwk.dflowsvc\", \"dataflow\")\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create dataflow svc: %w\\n\", err)\n\t\treturn nil\n\t}\n\tapp.dflow = svc.(*dflowsvc)\n\n\terr = app.AddSvc(app.dflow)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create dataflow svc: %w\\n\", err)\n\t\treturn nil\n\t}\n\n\terr = app.DeclProp(app, \"EvtMax\", &app.evtmax)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not declare property 'EvtMax': %w\\n\", err)\n\t\treturn nil\n\t}\n\n\terr = app.DeclProp(app, \"NProcs\", &app.nprocs)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not declare property 'NProcs': %w\\n\", err)\n\t\treturn nil\n\t}\n\n\terr = app.DeclProp(app, \"MsgLevel\", &app.msg.lvl)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not declare property 'MsgLevel': %w\\n\", err)\n\t\treturn nil\n\t}\n\n\treturn app\n}", "func NewApp() *App {\n\treturn &App{\n\t\tName: filepath.Base(os.Args[0]),\n\t\tUsage: \"A new cli application\",\n\t\tVersion: \"0.0.0\",\n\t\tShowHelp: showHelp,\n\t\tShowVersion: showVersion,\n\t}\n}", "func newManifestApp() *types.App {\n\treturn &types.App{\n\t\tUser: \"0\",\n\t\tGroup: \"0\",\n\t}\n}", "func newManifestApp() *types.App {\n\treturn &types.App{\n\t\tUser: \"0\",\n\t\tGroup: \"0\",\n\t}\n}", "func NewApp(f interface{}, args Arguments, info *debug.Info) App {\n\treturn App{f, args, info}\n}", "func appFromNative(app unsafe.Pointer) interface{} {\n\tga := C.to_GtkApplication(app)\n\tgtkapp := &Application{ga}\n\n\tif gobject.IsObjectFloating(gtkapp) {\n\t\tgobject.RefSink(gtkapp)\n\t} else {\n\t\tgobject.Ref(gtkapp)\n\t}\n\treturn &Application{ga}\n}", "func NewApp() *App {\n\tv := new(App)\n\tv.opened = false\n\tv.simType = \"runreset\"\n\tv.status = \"Stopped\"\n\tv.mode = \"Main\"\n\tv.incSize = 10.0\n\tv.decSize = 10.0\n\tv.keyMaps = make([]IKeyMap, 10)\n\tv.keyMaps[0] = NewKeyMap0(v)\n\tv.keyMaps[1] = NewKeyMap1(v)\n\n\treturn v\n}", "func newCliApp() *cli.App {\n\tapp := cli.NewApp()\n\tapp.Usage = \"A little gopher companion for andOTP\"\n\tapp.Version = gotpher.Version\n\tapp.Commands = commands\n\treturn app\n}", "func NewApp() *App {\n\tpages := ui.NewPageHandler()\n\n\tapp := tview.NewApplication().\n\t\tSetInputCapture(pages.InputCapture()).\n\t\tSetRoot(pages, true)\n\n\treturn &App{\n\t\tPageHandler: pages,\n\t\tapp: app,\n\t}\n}", "func newApp() (*app, error) {\n\tapp := &app{}\n\n\tgd, err := newGDrive(\"\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Unable initializate Google Drive configuration: %v\", err)\n\t}\n\tapp.gDrive = gd\n\n\tsrv, err := app.gDrive.getService()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Unable to retrieve Drive client: %v\", err)\n\t}\n\tapp.srv = srv\n\n\treturn app, nil\n}", "func StartApp(info string) {\n\tvar k8sJcascApp = app.NewWithID(\"k8s_jcasc_mgmt_go_ui\")\n\tk8sJcascApp.SetIcon(resources.K8sJcascMgmtIcon())\n\n\t// set theme\n\tsetTheme(k8sJcascApp)\n\n\tvar k8sJcascWindow = k8sJcascApp.NewWindow(uiconstants.K8sJcasCMgmtTitle + kubernetesactions.GetKubernetesConfig().CurrentContext())\n\tk8sJcascWindow.SetIcon(resources.K8sJcascMgmtIcon())\n\tvar mainMenu = menu.CreateMainMenu(k8sJcascApp, k8sJcascWindow)\n\n\tk8sJcascWindow.SetMainMenu(mainMenu)\n\tk8sJcascWindow.SetMaster()\n\n\ttabs = menu.CreateTabMenu(k8sJcascApp, k8sJcascWindow, info)\n\n\tk8sJcascWindow.SetContent(tabs)\n\tk8sJcascWindow.Resize(fyne.Size{\n\t\tWidth: 980,\n\t\tHeight: 400,\n\t})\n\tk8sJcascWindow.ShowAndRun()\n}", "func NewApplication() *Application {\n\treturn &Application{\n\t\tevents: make(chan tcell.Event, queueSize),\n\t\tupdates: make(chan func(), queueSize),\n\t\tscreenReplacement: make(chan tcell.Screen, 1),\n\t}\n}", "func New() App {\n\treturn App{}\n}", "func NewApp(config *config.Config) (*App, error) {\n\tapp := &App{Config: config}\n\tapp.Log = logger.NewLogger(config)\n\tapp.Gui = gui.NewGui()\n\treturn app, nil\n\n}", "func newTestApp() *App {\n\treturn &App{\n\t\tstorage: storage.NewMemory(),\n\t}\n}", "func NewApp() *App {\n\tapp := &App{\n\t\tTodoList: &TodoList{},\n\t\tPrinter: NewScreenPrinter(true),\n\t\tTodoStore: NewFileStore(),\n\t}\n\treturn app\n}", "func (b BotApp) construct() BotAppClass { return &b }", "func init() {\n\tApp = New()\n}", "func (b BotAppNotModified) construct() BotAppClass { return &b }", "func newUssdApp(hostName string, services ServiceManager, sessionStore phada.SessionStore) *UssdApp {\n\treturn &UssdApp{\n\t\thost: hostName,\n\t\tsessionStore: sessionStore,\n\t\tservicectl: services,\n\t}\n}", "func NewApp(s *Services, c *Clients, a alert.Alert) *App {\n\treturn &App{\n\t\tServices: s,\n\t\tClients: c,\n\t\tAlert: a,\n\t}\n}", "func CreateApplication(pid int) *UIElement {\n\tref := C.AXUIElementCreateApplication(C.pid_t(pid))\n\treturn newUIElement(ref)\n}", "func NewApp() *cli.App {\n\tcli.HelpPrinter = WrappedHelpPrinter\n\tcli.AppHelpTemplate = CLI_APP_HELP_TEMPLATE\n\tcli.CommandHelpTemplate = CLI_COMMAND_HELP_TEMPLATE\n\tcli.SubcommandHelpTemplate = CLI_APP_HELP_TEMPLATE\n\tapp := cli.NewApp()\n\treturn app\n}", "func New(descr string) App {\n\treturn &app{descr: descr}\n}", "func newUserApp() *userApp {\n\tmem := newMemory()\n\tcpu := cpu.New6502(mem)\n\treturn &userApp{\n\t\tmem: mem,\n\t\tcpu: cpu,\n\t}\n}", "func NewApp() *App {\n\tlogger := Log.With(zap.String(\"type\", \"app\")).Sugar()\n\tetcd := embed.NewServer(Config, Log)\n\tws := ws.NewServer(Config, Log)\n\tapp := &App{\n\t\tcfg: Config,\n\t\tlogger: logger,\n\t\tetcd: etcd,\n\t\tws: ws,\n\t\trepo: repository.NewRepo(),\n\t\tstopch: make(chan struct{}),\n\t}\n\tapp.scheduler = NewScheduler(Log, app)\n\treturn app\n}", "func initApp() *app {\n\tmainTimer := _wireRealTimeValue\n\tmainGreeter := greeter{\n\t\tT: mainTimer,\n\t}\n\tmainApp := &app{\n\t\tg: mainGreeter,\n\t}\n\treturn mainApp\n}", "func CreateDesktopShortcut(\n\toutpath,\n\texepath,\n\targs,\n\ticonpath,\n\tname,\n\tcomment string,\n\tstartup bool) error {\n\n\t// Build command with args\n\tcmd := exepath\n\tif args != \"\" {\n\t\tcmd += \" \" + args\n\t}\n\n\t// Create desktop entry\n\ttext := `[Desktop Entry]\nType=Application\nVersion=1.0\nTerminal=false`\n\n\ttext += fmt.Sprintf(\"\\nName=%s\", name)\n\ttext += fmt.Sprintf(\"\\nComment=%s\", comment)\n\ttext += fmt.Sprintf(\"\\nExec=%s\", cmd)\n\ttext += fmt.Sprintf(\"\\nIcon=%s\", iconpath)\n\ttext += \"\\n\"\n\n\tmode := os.FileMode(0755)\n\tif startup {\n\t\tmode = 0644\n\t}\n\n\treturn ioutil.WriteFile(outpath, []byte(text), mode)\n}", "func NewMgmtApp(config *Config) (*MgmtApp, error) {\n\n c := &MgmtApp{}\n c.userAuthenticator = config.UserAuthenticator\n c.handleCommand = config.HandleCommand\n c.notifyClientAuthenticated = config.NotifyClientAuthenticated\n c.notifyClientAuthenticatedFailed = config.NotifyClientAuthenticatedFailed\n c.welcomeUser = config.WelcomeUser\n c.unregisterUser = config.UnregisterUser\n c.defaultPrompt = config.DefaultPrompt\n\n c.clientInitializer = config.ClientInitializer\n\n if c.userAuthenticator == nil {\n c.userAuthenticator = c.defaultUserAuthenticator\n }\n if c.handleCommand == nil {\n c.handleCommand = HandleCommands(DefaultCommands)\n }\n if c.notifyClientAuthenticated == nil {\n c.notifyClientAuthenticated = c.defaultNotifyClientAuthenticated\n }\n if c.notifyClientAuthenticatedFailed == nil {\n c.notifyClientAuthenticatedFailed = c.defaultNotifyClientAuthenticatedFailed\n }\n if c.welcomeUser == nil {\n c.welcomeUser = c.defaultWelcomeUser\n }\n\n if c.unregisterUser == nil {\n c.unregisterUser = c.defaultUnregisterUser\n }\n\n if c.clientInitializer == nil {\n c.clientInitializer = c.defaultClientInitializer\n }\n\n if c.defaultPrompt == \"\" {\n c.defaultPrompt = \"$\"\n }\n\n c.hub = newHub()\n go c.hub.run()\n return c, nil\n}", "func NewApp(name string, basename string, opts ...Option) *App {\n\ta := &App{\n\t\tname: name,\n\t\tbasename: basename,\n\t}\n\n\tfor _, o := range opts {\n\t\to(a)\n\t}\n\n\treturn a\n}", "func newApp(infile, outfile string) *App {\n\treturn &App{\n\t\tAddressFile: infile,\n\t\tGeoDecodeFile: outfile,\n\t\tClient: &http.Client{},\n\t}\n}", "func NewApp(queue QueueService) *App {\n\tapp := &App{queue: queue}\n\tapp.init()\n\treturn app\n}", "func NewApp(useMBTS, useSpecialEBmods bool) *App {\n\tapp := &App{\n\t\tworkers: []Worker{},\n\t\tdetector: nil,\n\t}\n\tapp.msg(\"Welcome to Go-TUCS (pid=%d). Building detector tree...\\n\", os.Getpid())\n\tapp.detector = TileCal(useMBTS, useSpecialEBmods)\n\tapp.msg(\"done.\\n\")\n\treturn app\n}", "func NewApp(port, dataFileName string) *App {\n\ta := &App{Port: port, DataFileName: dataFileName}\n\tnoteRepository := repositories.NewNoteRepository(a.DataFileName)\n\ta.NoteController = controllers.NewNoteController(noteRepository)\n\ta.Router = routers.NewRouter(http.NewServeMux(), a.NoteController)\n\n\treturn a\n}", "func New() *App {\n\treturn NewApp(newDefaultApp())\n}", "func Main(f func(oswin.App)) {\n\toswin.TheApp = theApp\n\ttheApp.initScreens()\n\n\t// It does not matter which OS thread we are on.\n\t// All that matters is that we confine all UI operations\n\t// to the thread that created the respective window.\n\truntime.LockOSThread()\n\n\tif err := initCommon(); err != nil {\n\t\treturn\n\t}\n\n\tif err := initAppWindow(); err != nil {\n\t\treturn\n\t}\n\tdefer func() {\n\t\t// TODO(andlabs): log an error if this fails?\n\t\t_DestroyWindow(appHWND)\n\t\t// TODO(andlabs): unregister window class\n\t}()\n\n\tif err := initWindowClass(); err != nil {\n\t\treturn\n\t}\n\n\t// Prime the pump.\n\tmainCallback = f\n\t_PostMessage(appHWND, msgMainCallback, 0, 0)\n\n\t// Main message pump.\n\tvar m _MSG\n\tfor {\n\t\tdone, err := _GetMessage(&m, 0, 0, 0)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"win32 GetMessage failed: %v\", err)\n\t\t\treturn\n\t\t}\n\t\tif done == 0 { // WM_QUIT\n\t\t\tbreak\n\t\t}\n\t\t_TranslateMessage(&m)\n\t\t_DispatchMessage(&m)\n\t}\n}", "func NewApp() App {\n\treturn new(app)\n}", "func NewApp(host string, port int) (*App, error) {\n\ta := &App{\n\t\tHost: host,\n\t\tPort: port,\n\t}\n\t// setup DB\n\tdb, err := newDB(\"hades.db\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ta.DB = db\n\t// setup Sessions\n\ts, err := newSessions(a)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ta.Sessions = s\n\t// setup Hades\n\th, err := hades.NewHades(db)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ta.Hades = h\n\t// setup Listener\n\tln, err := newListener(a)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ta.Listener = ln\n\t// setup Templates\n\tt, err := newTemplates(\"../../templates\")\n\ta.Templates = t\n\t// setup Router\n\tr := mux.NewRouter().StrictSlash(true)\n\t// static file handler\n\tsbox := packr.NewBox(\"../../static\")\n\tfsHandler := http.StripPrefix(\"/static/\", http.FileServer(sbox))\n\tr.PathPrefix(\"/static/\").Handler(fsHandler).Methods(\"GET\")\n\t// application routes\n\tr.HandleFunc(\"/\", a.getIndexHandler).Methods(\"GET\")\n\tr.HandleFunc(\"/error\", a.getErrorHandler).Methods(\"GET\")\n\tr.HandleFunc(\"/login\", a.getLoginHandler).Methods(\"GET\")\n\tr.HandleFunc(\"/login\", a.postLoginHandler).Methods(\"POST\")\n\tr.HandleFunc(\"/logout\", a.getLogoutHandler).Methods(\"POST\")\n\tr.HandleFunc(\"/add\", a.getAddHandler).Methods(\"GET\")\n\tr.HandleFunc(\"/add\", a.postAddHandler).Methods(\"POST\")\n\tr.HandleFunc(\"/{id}/action\", a.postActionHandler).Methods(\"POST\")\n\ta.Router = r\n\treturn a, nil\n}", "func NewApp() *App {\n\treturn &App{}\n}", "func NewApp() *App {\n\treturn &App{}\n}", "func NewApp() *App {\n\treturn &App{}\n}", "func New(\n\tfactories config.Factories,\n\tappInfo ApplicationStartInfo,\n) (*Application, error) {\n\n\tif err := configcheck.ValidateConfigFromFactories(factories); err != nil {\n\t\treturn nil, err\n\t}\n\n\tapp := &Application{\n\t\tinfo: appInfo,\n\t\tv: viper.New(),\n\t\treadyChan: make(chan struct{}),\n\t\tfactories: factories,\n\t}\n\n\trootCmd := &cobra.Command{\n\t\tUse: appInfo.ExeName,\n\t\tLong: appInfo.LongName,\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tapp.init()\n\t\t\tapp.execute()\n\t\t},\n\t}\n\n\t// TODO: coalesce this code and expose this information to other components.\n\tflagSet := new(flag.FlagSet)\n\taddFlagsFns := []func(*flag.FlagSet){\n\t\ttelemetryFlags,\n\t\tbuilder.Flags,\n\t\tloggerFlags,\n\t}\n\tfor _, addFlags := range addFlagsFns {\n\t\taddFlags(flagSet)\n\t}\n\trootCmd.Flags().AddGoFlagSet(flagSet)\n\n\tapp.rootCmd = rootCmd\n\n\treturn app, nil\n}", "func New(config *Config, modules *Modules) *App {\n\teosws.DisabledWsMessage = config.DisabledWsMessage\n\treturn &App{\n\t\tShutter: shutter.New(),\n\t\tConfig: config,\n\t\tModules: modules,\n\t}\n\n}", "func NewApp() *App {\n\tapp := App{}\n\treturn &app\n}", "func NewApp(gitCommit, usage string) *cli.App {\r\n\tapp := cli.NewApp()\r\n\tapp.Name = filepath.Base(os.Args[0])\r\n\tapp.Author = \"\"\r\n\t//app.Authors = nil\r\n\tapp.Email = \"\"\r\n\tapp.Version = params.Version\r\n\tif len(gitCommit) >= 8 {\r\n\t\tapp.Version += \"-\" + gitCommit[:8]\r\n\t}\r\n\tapp.Usage = usage\r\n\treturn app\r\n}", "func NewApp(name string) *App {\n\treturn &App{Name: name, Labels: make(map[string]string)}\n}", "func NewApp(cfg config.Config, opts ...Option) *App {\n\tapp := &App{\n\t\tcfg: cfg,\n\t\tlogger: zap.NewNop(),\n\t\tstopCommandChan: make(chan struct{}),\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(app)\n\t}\n\n\treturn app\n}", "func NewApp(clientService ClientService, lobby Lobby) *App {\n\treturn &App{clientService, lobby}\n}", "func NewApp(listenAddr string, ghClient *githubclient.Client, cache cache.Cache, objTTL time.Duration) App {\n\treturn App{\n\t\tlistenAddr: listenAddr,\n\t\tghClient: ghClient,\n\t\tcache: cache,\n\t\tcacheObjTTL: objTTL,\n\t}\n}", "func main() {\n\tgo func() {\n\t\tw := app.NewWindow(\n\t\t\tapp.Title(\"Gopher-Garden\"),\n\t\t\tapp.Size(unit.Dp(ui.WidthPx+500), unit.Dp(ui.HeightPx)))\n\t\tu := ui.NewUi(w)\n\t\tif err := u.Loop(); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tos.Exit(0)\n\t}()\n\tapp.Main()\n}", "func mainStartGtk(winTitle string, width, height int, center bool) {\n\tobj = new(MainControlsObj)\n\tgtk.Init(nil)\n\tif newBuilder(mainGlade) == nil {\n\t\t// Init tempDir and Remove it on quit if requested.\n\t\tif doTempDir {\n\t\t\ttempDir = tempMake(Name)\n\t\t\tdefer os.RemoveAll(tempDir)\n\t\t}\n\t\t// Parse Gtk objects\n\t\tgladeObjParser()\n\t\t// Objects Signals initialisations\n\t\tsignalsPropHandler()\n\t\t/* Fill control with images */\n\t\tassignImages()\n\t\t// Set Window Properties\n\t\tif center {\n\t\t\tobj.MainWindow.SetPosition(gtk.WIN_POS_CENTER)\n\t\t}\n\t\tobj.MainWindow.SetTitle(winTitle)\n\t\tobj.MainWindow.SetDefaultSize(width, height)\n\t\tobj.MainWindow.Connect(\"delete-event\", windowDestroy)\n\t\t// Start main application ...\n\t\tmainApplication()\n\t\t//\tStart Gui loop\n\t\tobj.MainWindow.ShowAll()\n\t\tgtk.Main()\n\t} else {\n\t\tlog.Fatal(\"Builder initialisation error.\")\n\t}\n}", "func NewEdirApp() (edir *Edir) {\n\n\tedir = &Edir{Tab: component.NewTab(`C:\\Workspace\\go\\edir`)}\n\treturn\n}", "func NewApplication()(*Application) {\n m := &Application{\n DirectoryObject: *NewDirectoryObject(),\n }\n odataTypeValue := \"#microsoft.graph.application\";\n m.SetOdataType(&odataTypeValue);\n return m\n}", "func Instance() Desktop {\n\treturn instance\n}", "func NewApp() *cli.App {\n\treturn &cli.App{\n\t\tUsage: \"CLI client for images compressing using tinypng.com API\",\n\t\tBefore: func(context *cli.Context) error {\n\t\t\tif _, exists := env.ForceColors.Lookup(); exists {\n\t\t\t\ttext.EnableColors()\n\t\t\t} else if _, exists = env.NoColors.Lookup(); exists {\n\t\t\t\ttext.DisableColors()\n\t\t\t} else if v, ok := env.Term.Lookup(); ok && v == \"dumb\" {\n\t\t\t\ttext.DisableColors()\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t\tCommands: []*cli.Command{\n\t\t\tquota.NewCommand(),\n\t\t\tcompress.NewCommand(),\n\t\t},\n\t\tVersion: version.Version(),\n\t}\n}", "func NewApp(g Generator) *App {\n\treturn &App{gene: g}\n}", "func New() *App {\n\treturn &App{}\n}", "func initMockedAppFromArgs(mt timer) *app {\n\tmainGreeter := greeter{\n\t\tT: mt,\n\t}\n\tmainApp := &app{\n\t\tg: mainGreeter,\n\t}\n\treturn mainApp\n}", "func NewApp(entry *Entry) (app *App) {\n\tapp = new(App)\n\tapp.ID = entry.TrackID\n\tapp.Name = entry.TrackName\n\tapp.URL = entry.TrackViewURL\n\n\tapp.Icon = entry.ArtworkURL512\n\tapp.Kind = entry.Kind\n\tapp.Version = entry.Version\n\tapp.BundleID = entry.BundleID\n\n\tapp.AuthorID = entry.ArtistID\n\tapp.AuthorName = entry.ArtistName\n\tapp.AuthorURL = entry.ArtistViewURL\n\tapp.VendorName = entry.SellerName\n\tapp.VendorURL = entry.SellerURL\n\n\tapp.GenreID = entry.PrimaryGenreID\n\tapp.GenreIDList = stringSliceToInt(entry.GenreIDs)\n\tapp.Genre = entry.PrimaryGenreName\n\tapp.GenreList = entry.Genres\n\n\tapp.Icon60 = entry.ArtworkURL60\n\tapp.Icon100 = entry.ArtworkURL100\n\tapp.Price = int64(math.Ceil(entry.Price))\n\tapp.Currency = entry.Currency\n\n\tapp.System = entry.MinimumOsVersion\n\tapp.Features = entry.Features\n\tapp.Devices = entry.SupportedDevices\n\tapp.Languages = entry.LanguageCodesISO2A\n\n\tapp.Rating = entry.TrackContentRating\n\tif app.Rating == \"\" {\n\t\tapp.Rating = entry.ContentAdvisoryRating\n\t}\n\tapp.Reasons = entry.Advisories\n\n\tapp.Size, _ = strconv.ParseInt(entry.FileSizeBytes, 10, 64)\n\tapp.CntRating = entry.UserRatingCount\n\tapp.AvgRating = entry.AverageUserRating\n\tapp.CntRatingCurrent = entry.UserRatingCountForCurrentVersion\n\tapp.AvgRatingCurrent = entry.AverageUserRatingForCurrentVersion\n\tapp.VppDevice = entry.IsVppDeviceBasedLicensingEnabled\n\tapp.GameCenter = entry.IsGameCenterEnabled\n\n\tapp.Screenshots = merge(entry.ScreenshotURLs, entry.AppletvScreenshotURLs, entry.IpadScreenshotURLs)\n\n\t// Reserved fields: these fields should be fetched from iTunes page\n\t// app.Copyright\n\t// app.Platforms\n\t// app.InAppPurchase\n\t// app.SiblingApps\n\t// app.RelatedApps\n\t// app.SupportSites\n\t// app.Reviews\n\n\tapp.Description = entry.Description\n\tapp.ReleaseNotes = entry.ReleaseNotes\n\tapp.ReleaseTime, _ = time.Parse(time.RFC3339, entry.CurrentVersionReleaseDate)\n\tapp.PublishTime, _ = time.Parse(time.RFC3339, entry.ReleaseDate)\n\tapp.CrawledTime = time.Now()\n\tsort.Strings(app.Devices)\n\tsort.Strings(app.Languages)\n\n\treturn app\n}", "func NewWindowsUniversalAppX()(*WindowsUniversalAppX) {\n m := &WindowsUniversalAppX{\n MobileLobApp: *NewMobileLobApp(),\n }\n odataTypeValue := \"#microsoft.graph.windowsUniversalAppX\";\n m.SetOdataType(&odataTypeValue);\n return m\n}", "func NewApp(shutdown chan os.Signal, mw ...Middleware) *App {\n\tapp := &App{\n\t\tRouter: mux.NewRouter(),\n\t\tshutdown: shutdown,\n\t\tmw: mw,\n\t}\n\n\treturn app\n}", "func NewApp() *App_ {\n\treturn NewApp_WithOverrides(nil)\n}", "func New(prj *project.Project) *Application {\n\tcli := &Application{\n\t\tLog: log.NewStdout(log.NOTICE),\n\t\tProject: prj,\n\t\tcommands: make(map[string]Command),\n\t\tflags: make(map[int]flags.Interface),\n\t\tflagAliases: make(map[string]int),\n\t\tosArgs: os.Args[1:],\n\t}\n\t// set initial startup time\n\tcli.started = time.Now()\n\tcli.Log.TsDisabled()\n\tif prj.Config.InitTerm {\n\t\tcli.Log.InitTerm()\n\t}\n\tcli.Log.SetPrimaryColor(prj.Config.Color)\n\tcli.Log.SetLogLevel(prj.Config.LogLevel)\n\tcli.addInternalFlags()\n\tif prj.Config.Color != \"\" {\n\t\tcli.Log.Colors()\n\t}\n\n\t// Set log level to debug and lock the log level, but only if --debug\n\t// flag was found before any command. If --debug flag was found later\n\t// then we want to set debugging later for that command only.\n\tif cli.flag(\"debug\").IsGlobal() && cli.flag(\"debug\").Present() {\n\t\tcli.Log.SetLogLevel(log.DEBUG)\n\t\tcli.Log.LockLevel()\n\t\tcli.flag(\"verbose\").Unset()\n\t}\n\n\t// Only lock log level to verbose if no --debug flag was set\n\tif !cli.flag(\"debug\").Present() && cli.flag(\"verbose\").Present() {\n\t\tcli.Log.SetLogLevel(log.INFO)\n\t\tcli.Log.LockLevel()\n\t}\n\n\tcli.Log.Debugf(\"CLI:Create - accepting configuration changes debugging(%t)\",\n\t\tcli.flag(\"debug\").Present())\n\n\t// Add internal commands besides help\n\tcli.AddCommand(cmdAbout())\n\tcli.rootCmd = NewCommand(prj.Name)\n\tcli.Header.Defaults()\n\tcli.Footer.Defaults()\n\treturn cli\n}", "func CreateMainWindow() {\n\n\tvBox := tui.NewVBox()\n\tvBox.SetSizePolicy(tui.Minimum, tui.Minimum)\n\tSidebar := tui.NewVBox()\n\tSidebar.SetSizePolicy(tui.Minimum, tui.Minimum)\n\n\tfor _, cmd := range strings.Split(libs.Cmds, \",\") {\n\t\tSidebar.Append(tui.NewLabel(wordwrap.WrapString(cmd, 50)))\n\t}\n\n\tSidebar.SetBorder(true)\n\tSidebar.Prepend(tui.NewLabel(\"***COMMANDS***\"))\n\n\tInput.SetFocused(true)\n\tInput.SetSizePolicy(tui.Expanding, tui.Maximum)\n\n\tinputBox := tui.NewHBox(Input)\n\tinputBox.SetBorder(true)\n\tinputBox.SetSizePolicy(tui.Expanding, tui.Maximum)\n\n\thistoryScroll := tui.NewScrollArea(History)\n\thistoryScroll.SetAutoscrollToBottom(true)\n\thistoryBox := tui.NewVBox(historyScroll)\n\thistoryBox.SetBorder(true)\n\n\tchat := tui.NewVBox(historyBox, inputBox)\n\tchat.SetSizePolicy(tui.Expanding, tui.Expanding)\n\n\t// create root window and add all windows\n\troot := tui.NewHBox(Sidebar, chat)\n\tui, err := tui.New(root)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tui.SetKeybinding(\"Esc\", func() { ui.Quit() })\n\n\tInput.OnSubmit(func(e *tui.Entry) {\n\t\t// this is just to see what command given\n\t\tuserCommand := e.Text()\n\t\tif userCommand == \"\" {\n\t\t\tHistory.Append(tui.NewLabel(\"that is not acceptable command\"))\n\t\t\tHistory.Append(tui.NewLabel(libs.PrintHelp()))\n\t\t} else {\n\t\t\tHistory.Append(tui.NewHBox(\n\t\t\t\ttui.NewLabel(\"Your Command: \" + userCommand),\n\t\t\t))\n\t\t\tHistory.Append(tui.NewHBox(tui.NewLabel(\"\")))\n\n\t\t\tif strings.HasPrefix(userCommand, \"\\\\\") {\n\t\t\t\t// then this is command ..\n\t\t\t\tswitch userCommand {\n\t\t\t\tcase \"\\\\help\":\n\t\t\t\t\tHistory.Append(tui.NewLabel(libs.PrintHelp()))\n\t\t\t\tcase \"\\\\monitor\":\n\t\t\t\t\tHistory.Append(tui.NewLabel(\"Switching to MONITOR mode for device \" + DeviceName))\n\t\t\t\t\tChangeToMonitorMode()\n\t\t\t\tcase \"\\\\managed\":\n\t\t\t\t\tHistory.Append(tui.NewLabel(\"Switching to MANAGED mode for device \" + DeviceName))\n\t\t\t\t\tChangeToManagedMode()\n\t\t\t\tcase \"\\\\exit\":\n\t\t\t\t\tHistory.Append(tui.NewHBox(tui.NewLabel(\"quitting...\")))\n\t\t\t\t\ttime.Sleep(1000 * time.Millisecond)\n\t\t\t\t\t// os.Exit(0)\n\n\t\t\t\t}\n\t\t\t} else if strings.Contains(userCommand, \":\") {\n\t\t\t\t// then this is declaration\n\t\t\t\tcmdSplit := strings.Split(userCommand, \":\")\n\t\t\t\tif cmdSplit[1] == \"\" {\n\t\t\t\t\tHistory.Append(tui.NewLabel(\"that is not acceptable command\"))\n\t\t\t\t\tHistory.Append(tui.NewLabel(libs.PrintHelp()))\n\t\t\t\t} else {\n\t\t\t\t\tswitch cmdSplit[0] {\n\t\t\t\t\tcase \"device\":\n\t\t\t\t\t\tSetDeviceName(cmdSplit[1])\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tHistory.Append(tui.NewLabel(\"there is no such declaration or command\"))\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tHistory.Append(tui.NewHBox(tui.NewLabel(userCommand + \" is not command or a declaration\")))\n\t\t\t}\n\t\t}\n\t\tInput.SetText(\"\")\n\t})\n\n\tif err := ui.Run(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func NewApp() *App {\n\treturn &App{ver: \"v0\"}\n}", "func NewApplication() Application {\n\treturn app\n}", "func NewCmdNewApplication(f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {\n\to := NewAppOptions(streams)\n\n\tcmd := &cobra.Command{\n\t\tUse: \"new-app (IMAGE | IMAGESTREAM | TEMPLATE | PATH | URL ...)\",\n\t\tShort: \"Create a new application\",\n\t\tLong: newAppLong,\n\t\tExample: newAppExample,\n\t\tSuggestFor: []string{\"app\", \"application\"},\n\t\tRun: func(c *cobra.Command, args []string) {\n\t\t\tkcmdutil.CheckErr(o.Complete(f, c, args))\n\t\t\tkcmdutil.CheckErr(o.RunNewApp())\n\t\t},\n\t}\n\n\to.PrintFlags.AddFlags(cmd)\n\n\tcmd.Flags().BoolVar(&o.Config.AsTestDeployment, \"as-test\", o.Config.AsTestDeployment, \"If true create this application as a test deployment, which validates that the deployment succeeds and then scales down.\")\n\tcmd.Flags().BoolVar(&o.Config.DeploymentConfig, \"as-deployment-config\", o.Config.DeploymentConfig, \"If true create this application as a deployment config, which allows for hooks and custom strategies.\")\n\tcmd.Flags().StringSliceVar(&o.Config.SourceRepositories, \"code\", o.Config.SourceRepositories, \"Source code to use to build this application.\")\n\tcmd.Flags().StringVar(&o.Config.ContextDir, \"context-dir\", o.Config.ContextDir, \"Context directory to be used for the build.\")\n\tcmd.Flags().StringSliceVarP(&o.Config.ImageStreams, \"image-stream\", \"i\", o.Config.ImageStreams, \"Name of an existing image stream to use to deploy an app.\")\n\tcmd.Flags().StringSliceVar(&o.Config.DockerImages, \"image\", o.Config.DockerImages, \"Name of a container image to include in the app. Note: not specifying a registry or repository means defaults in place for client image pulls are employed.\")\n\tcmd.Flags().StringSliceVar(&o.Config.DockerImages, \"docker-image\", o.Config.DockerImages, \"\")\n\tcmd.Flags().MarkDeprecated(\"docker-image\", \"Deprecated flag use --image\")\n\tcmd.Flags().StringSliceVar(&o.Config.Templates, \"template\", o.Config.Templates, \"Name of a stored template to use in the app.\")\n\tcmd.Flags().StringSliceVarP(&o.Config.TemplateFiles, \"file\", \"f\", o.Config.TemplateFiles, \"Path to a template file to use for the app.\")\n\tcmd.MarkFlagFilename(\"file\", \"yaml\", \"yml\", \"json\")\n\tcmd.Flags().StringArrayVarP(&o.Config.TemplateParameters, \"param\", \"p\", o.Config.TemplateParameters, \"Specify a key-value pair (e.g., -p FOO=BAR) to set/override a parameter value in the template.\")\n\tcmd.Flags().StringArrayVar(&o.Config.TemplateParameterFiles, \"param-file\", o.Config.TemplateParameterFiles, \"File containing parameter values to set/override in the template.\")\n\tcmd.MarkFlagFilename(\"param-file\")\n\tcmd.Flags().StringSliceVar(&o.Config.Groups, \"group\", o.Config.Groups, \"Indicate components that should be grouped together as <comp1>+<comp2>.\")\n\tcmd.Flags().StringArrayVarP(&o.Config.Environment, \"env\", \"e\", o.Config.Environment, \"Specify a key-value pair for an environment variable to set into each container.\")\n\tcmd.Flags().StringArrayVar(&o.Config.EnvironmentFiles, \"env-file\", o.Config.EnvironmentFiles, \"File containing key-value pairs of environment variables to set into each container.\")\n\tcmd.MarkFlagFilename(\"env-file\")\n\tcmd.Flags().StringArrayVar(&o.Config.BuildEnvironment, \"build-env\", o.Config.BuildEnvironment, \"Specify a key-value pair for an environment variable to set into each build image.\")\n\tcmd.Flags().StringArrayVar(&o.Config.BuildEnvironmentFiles, \"build-env-file\", o.Config.BuildEnvironmentFiles, \"File containing key-value pairs of environment variables to set into each build image.\")\n\tcmd.MarkFlagFilename(\"build-env-file\")\n\tcmd.Flags().StringVar(&o.Config.Name, \"name\", o.Config.Name, \"Set name to use for generated application artifacts\")\n\tcmd.Flags().Var(&o.Config.Strategy, \"strategy\", \"Specify the build strategy to use if you don't want to detect (docker|pipeline|source). NOTICE: the pipeline strategy is deprecated; consider using Jenkinsfiles directly on Jenkins or OpenShift Pipelines.\")\n\tcmd.Flags().StringP(\"labels\", \"l\", \"\", \"Label to set in all resources for this application.\")\n\tcmd.Flags().BoolVar(&o.Config.IgnoreUnknownParameters, \"ignore-unknown-parameters\", o.Config.IgnoreUnknownParameters, \"If true, will not stop processing if a provided parameter does not exist in the template.\")\n\tcmd.Flags().BoolVar(&o.Config.InsecureRegistry, \"insecure-registry\", o.Config.InsecureRegistry, \"If true, indicates that the referenced container images are on insecure registries and should bypass certificate checking\")\n\tcmd.Flags().BoolVarP(&o.Config.AsList, \"list\", \"L\", o.Config.AsList, \"List all local templates and image streams that can be used to create.\")\n\tcmd.Flags().BoolVarP(&o.Config.AsSearch, \"search\", \"S\", o.Config.AsSearch, \"Search all templates, image streams, and container images that match the arguments provided. Note: the container images search is run on the OpenShift cluster via the ImageStreamImport API.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowMissingImages, \"allow-missing-images\", o.Config.AllowMissingImages, \"If true, indicates that referenced container images that cannot be found locally or in a registry should still be used.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowMissingImageStreamTags, \"allow-missing-imagestream-tags\", o.Config.AllowMissingImageStreamTags, \"If true, indicates that image stream tags that don't exist should still be used.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowSecretUse, \"grant-install-rights\", o.Config.AllowSecretUse, \"If true, a component that requires access to your account may use your token to install software into your project. Only grant images you trust the right to run with your token.\")\n\tcmd.Flags().StringVar(&o.Config.SourceSecret, \"source-secret\", o.Config.SourceSecret, \"The name of an existing secret that should be used for cloning a private git repository.\")\n\tcmd.Flags().BoolVar(&o.Config.SkipGeneration, \"no-install\", o.Config.SkipGeneration, \"Do not attempt to run images that describe themselves as being installable\")\n\tcmd.Flags().BoolVar(&o.Config.BinaryBuild, \"binary\", o.Config.BinaryBuild, \"Instead of expecting a source URL, set the build to expect binary contents. Will disable triggers.\")\n\tcmd.Flags().StringVar(&o.Config.ImportMode, \"import-mode\", o.Config.ImportMode, \"Imports the full manifest list of a tag when set to 'PreserveOriginal'. Defaults to 'Legacy'.\")\n\n\to.Action.BindForOutput(cmd.Flags(), \"output\", \"template\")\n\tcmd.Flags().String(\"output-version\", \"\", \"The preferred API versions of the output objects\")\n\n\treturn cmd\n}", "func newMemPCApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseApp)) *memoryPCApp {\n\tapp := newMemoryPCBaseApp(logger, db, baseAppOptions...)\n\t// setup subspaces\n\tauthSubspace := sdk.NewSubspace(auth.DefaultParamspace)\n\tnodesSubspace := sdk.NewSubspace(nodesTypes.DefaultParamspace)\n\tappsSubspace := sdk.NewSubspace(appsTypes.DefaultParamspace)\n\tpocketSubspace := sdk.NewSubspace(pocketTypes.DefaultParamspace)\n\t// The AuthKeeper handles address -> account lookups\n\tapp.accountKeeper = auth.NewKeeper(\n\t\tapp.cdc,\n\t\tapp.keys[auth.StoreKey],\n\t\tauthSubspace,\n\t\tmoduleAccountPermissions,\n\t)\n\t// The nodesKeeper keeper handles pocket core nodes\n\tapp.nodesKeeper = nodesKeeper.NewKeeper(\n\t\tapp.cdc,\n\t\tapp.keys[nodesTypes.StoreKey],\n\t\tapp.accountKeeper,\n\t\tnodesSubspace,\n\t\tnodesTypes.DefaultCodespace,\n\t)\n\t// The apps keeper handles pocket core applications\n\tapp.appsKeeper = appsKeeper.NewKeeper(\n\t\tapp.cdc,\n\t\tapp.keys[appsTypes.StoreKey],\n\t\tapp.nodesKeeper,\n\t\tapp.accountKeeper,\n\t\tappsSubspace,\n\t\tappsTypes.DefaultCodespace,\n\t)\n\t// The main pocket core\n\tapp.pocketKeeper = pocketKeeper.NewPocketCoreKeeper(\n\t\tapp.keys[pocketTypes.StoreKey],\n\t\tapp.cdc,\n\t\tapp.nodesKeeper,\n\t\tapp.appsKeeper,\n\t\tgetInMemHostedChains(),\n\t\tpocketSubspace,\n\t)\n\t// The governance keeper\n\tapp.govKeeper = govKeeper.NewKeeper(\n\t\tapp.cdc,\n\t\tapp.keys[pocketTypes.StoreKey],\n\t\tapp.tkeys[pocketTypes.StoreKey],\n\t\tgovTypes.DefaultCodespace,\n\t\tapp.accountKeeper,\n\t\tauthSubspace, nodesSubspace, appsSubspace, pocketSubspace,\n\t)\n\tapp.pocketKeeper.Keybase = getInMemoryKeybase()\n\tapp.pocketKeeper.TmNode = getInMemoryTMClient()\n\tapp.mm = module.NewManager(\n\t\tauth.NewAppModule(app.accountKeeper),\n\t\tnodes.NewAppModule(app.nodesKeeper),\n\t\tapps.NewAppModule(app.appsKeeper),\n\t\tpocket.NewAppModule(app.pocketKeeper),\n\t\tgov.NewAppModule(app.govKeeper),\n\t)\n\tapp.mm.SetOrderBeginBlockers(nodesTypes.ModuleName, appsTypes.ModuleName, pocketTypes.ModuleName)\n\tapp.mm.SetOrderEndBlockers(nodesTypes.ModuleName, appsTypes.ModuleName)\n\tapp.mm.SetOrderInitGenesis(\n\t\tnodesTypes.ModuleName,\n\t\tappsTypes.ModuleName,\n\t\tpocketTypes.ModuleName,\n\t\tauth.ModuleName,\n\t\tgov.ModuleName,\n\t)\n\tapp.mm.RegisterRoutes(app.Router(), app.QueryRouter())\n\tapp.SetInitChainer(app.InitChainer)\n\tapp.SetAnteHandler(auth.NewAnteHandler(app.accountKeeper))\n\tapp.SetBeginBlocker(app.BeginBlocker)\n\tapp.SetEndBlocker(app.EndBlocker)\n\tapp.MountKVStores(app.keys)\n\tapp.MountTransientStores(app.tkeys)\n\terr := app.LoadLatestVersion(app.keys[bam.MainStoreKey])\n\tif err != nil {\n\t\tcmn.Exit(err.Error())\n\t}\n\treturn app\n}", "func NewApp(gitCommit, usage string) *cli.App {\n\tapp := cli.NewApp()\n\tapp.Name = filepath.Base(os.Args[0])\n\tapp.Author = \"\"\n\tapp.Email = \"\"\n\tapp.Version = Version\n\tapp.Usage = usage\n\treturn app\n}", "func CreateApp(conf *config.Config) *TelegramBotApp {\n\n\t// Init the telegram bot\n\tbot, err := botFactory.BotFactory(conf)\n\tif err != nil {\n\t\tlog.Fatal(\"Can't create a telegram bot: \", err)\n\t}\n\n\t// Init the database\n\tdb, err := dbFactory.DatabaseFactory(conf)\n\tif err != nil {\n\t\tlog.Fatal(\"Couldn't create database: \", err)\n\t}\n\n\t// Init the database storage\n\tstorage, err := storages.CreateStorages(db)\n\tif err != nil {\n\t\tlog.Fatal(\"Couldn't setup database: \", err)\n\t}\n\n\t// Init the database Repository\n\trepository, err := repositories.CreateRepository(db)\n\tif err != nil {\n\t\tlog.Fatal(\"Couldn't setup database: \", err)\n\t}\n\n\treturn &TelegramBotApp{conf, bot, storage, repository}\n}", "func main() {\n\tapplication.Application()\n}", "func NewApp() *App {\n\treturn &App{\n\t\tConfig: &Config{},\n\t}\n}", "func getApp(cx *pod.State) (a *cli.App) {\n\treturn &cli.App{\n\t\tName: \"pod\",\n\t\tVersion: version.Get(),\n\t\tDescription: cx.Language.RenderText(\"goApp_DESCRIPTION\"),\n\t\tCopyright: cx.Language.RenderText(\"goApp_COPYRIGHT\"),\n\t\tAction: walletGUIHandle(cx),\n\t\tBefore: beforeFunc(cx),\n\t\tAfter: func(c *cli.Context) (e error) {\n\t\t\tD.Ln(\"subcommand completed\", os.Args)\n\t\t\tif interrupt.Restart {\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tCommands: []cli.Command{\n\t\t\tau.Command(\n\t\t\t\t\"version\", \"print version and exit\",\n\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\tfmt.Println(c.App.Name, c.App.Version)\n\t\t\t\t\treturn nil\n\t\t\t\t}, au.SubCommands(), nil, \"v\",\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"gui\", \"start wallet GUI\", walletGUIHandle(cx),\n\t\t\t\tau.SubCommands(), nil,\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"ctl\",\n\t\t\t\t\"send RPC commands to a node or wallet and print the result\",\n\t\t\t\tctlHandle(cx), au.SubCommands(\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"listcommands\",\n\t\t\t\t\t\t\"list commands available at endpoint\",\n\t\t\t\t\t\tctlHandleList,\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t\t\"list\",\n\t\t\t\t\t\t\"l\",\n\t\t\t\t\t),\n\t\t\t\t), nil, \"c\",\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"rpc\", \"start parallelcoin full node for vps/rpc services usage\",\n\t\t\t\trpcNodeHandle(cx),\n\t\t\t\tau.SubCommands(\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"dropaddrindex\",\n\t\t\t\t\t\t\"drop the address search index\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropAddrIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"droptxindex\",\n\t\t\t\t\t\t\"drop the address search index\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropTxIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"dropindexes\",\n\t\t\t\t\t\t\"drop all of the indexes\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropAddrIndex = true\n\t\t\t\t\t\t\tcx.StateCfg.DropTxIndex = true\n\t\t\t\t\t\t\tcx.StateCfg.DropCfIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"dropcfindex\",\n\t\t\t\t\t\t\"drop the address search index\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropCfIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"resetchain\",\n\t\t\t\t\t\t\"reset the chain\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tpodconfig.Configure(cx, \"resetchain\", true)\n\t\t\t\t\t\t\tdbName := blockdb.NamePrefix + \"_\" + *cx.Config.DbType\n\t\t\t\t\t\t\tif *cx.Config.DbType == \"sqlite\" {\n\t\t\t\t\t\t\t\tdbName += \".db\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdbPath := filepath.Join(\n\t\t\t\t\t\t\t\tfilepath.Join(\n\t\t\t\t\t\t\t\t\t*cx.Config.DataDir,\n\t\t\t\t\t\t\t\t\tcx.ActiveNet.Name,\n\t\t\t\t\t\t\t\t), dbName,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif e = os.RemoveAll(dbPath); E.Chk(e) {\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t), nil, \"n\",\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"node\", \"start parallelcoin full node\",\n\t\t\t\tnodeHandle(cx), au.SubCommands(\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"dropaddrindex\",\n\t\t\t\t\t\t\"drop the address search index\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropAddrIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t\t// return nil\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"droptxindex\",\n\t\t\t\t\t\t\"drop the address search index\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropTxIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t\t// return nil\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"dropindexes\",\n\t\t\t\t\t\t\"drop all of the indexes\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropAddrIndex = true\n\t\t\t\t\t\t\tcx.StateCfg.DropTxIndex = true\n\t\t\t\t\t\t\tcx.StateCfg.DropCfIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t\t// return nil\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"dropcfindex\",\n\t\t\t\t\t\t\"drop the address search index\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tcx.StateCfg.DropCfIndex = true\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t\t// return nil\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"resetchain\",\n\t\t\t\t\t\t\"reset the chain\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tpodconfig.Configure(cx, \"resetchain\", true)\n\t\t\t\t\t\t\tdbName := blockdb.NamePrefix + \"_\" + *cx.Config.DbType\n\t\t\t\t\t\t\tif *cx.Config.DbType == \"sqlite\" {\n\t\t\t\t\t\t\t\tdbName += \".db\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdbPath := filepath.Join(\n\t\t\t\t\t\t\t\tfilepath.Join(\n\t\t\t\t\t\t\t\t\t*cx.Config.DataDir,\n\t\t\t\t\t\t\t\t\tcx.ActiveNet.Name,\n\t\t\t\t\t\t\t\t), dbName,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif e = os.RemoveAll(dbPath); E.Chk(e) {\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn nodeHandle(cx)(c)\n\t\t\t\t\t\t\t// return nil\n\t\t\t\t\t\t},\n\t\t\t\t\t\tau.SubCommands(),\n\t\t\t\t\t\tnil,\n\t\t\t\t\t),\n\t\t\t\t), nil, \"n\",\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"wallet\", \"start parallelcoin wallet server\",\n\t\t\t\tWalletHandle(cx), au.SubCommands(\n\t\t\t\t\tau.Command(\n\t\t\t\t\t\t\"drophistory\", \"drop the transaction history in the wallet (for \"+\n\t\t\t\t\t\t\t\"development and testing as well as clearing up transaction mess)\",\n\t\t\t\t\t\tfunc(c *cli.Context) (e error) {\n\t\t\t\t\t\t\tpodconfig.Configure(cx, \"wallet\", true)\n\t\t\t\t\t\t\tI.Ln(\"dropping wallet history\")\n\t\t\t\t\t\t\tgo func() {\n\t\t\t\t\t\t\t\tD.Ln(\"starting wallet\")\n\t\t\t\t\t\t\t\tif e = walletmain.Main(cx); E.Chk(e) {\n\t\t\t\t\t\t\t\t\t// os.Exit(1)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tD.Ln(\"wallet started\")\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}()\n\t\t\t\t\t\t\t// D.Ln(\"waiting for walletChan\")\n\t\t\t\t\t\t\t// cx.WalletServer = <-cx.WalletChan\n\t\t\t\t\t\t\t// D.Ln(\"walletChan sent\")\n\t\t\t\t\t\t\te = walletrpc2.DropWalletHistory(cx.WalletServer, cx.Config)(c)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}, au.SubCommands(), nil,\n\t\t\t\t\t),\n\t\t\t\t), nil, \"w\",\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"shell\", \"start combined wallet/node shell\",\n\t\t\t\tShellHandle(cx), au.SubCommands(), nil, \"s\",\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"kopach\", \"standalone miner for clusters\",\n\t\t\t\tKopachHandle(cx), au.SubCommands(), nil, \"k\",\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"worker\",\n\t\t\t\t\"single thread parallelcoin miner controlled with binary IPC interface on stdin/stdout; \"+\n\t\t\t\t\t\"internal use, must have network name string as second arg after worker and nothing before;\"+\n\t\t\t\t\t\" communicates via net/rpc encoding/gob as default over stdio\",\n\t\t\t\tkopach_worker.KopachWorkerHandle(cx),\n\t\t\t\tau.SubCommands(),\n\t\t\t\tnil,\n\t\t\t),\n\t\t\tau.Command(\n\t\t\t\t\"init\",\n\t\t\t\t\"steps through creation of new wallet and initialization for a network with these specified \"+\n\t\t\t\t\t\"in the main\",\n\t\t\t\tinitHandle(cx),\n\t\t\t\tau.SubCommands(),\n\t\t\t\tnil,\n\t\t\t\t\"I\",\n\t\t\t),\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"datadir, D\",\n\t\t\t\tValue: *cx.Config.DataDir,\n\t\t\t\tUsage: \"sets the data directory base for a pod instance\",\n\t\t\t\tEnvVar: \"POD_DATADIR\",\n\t\t\t\tDestination: cx.Config.DataDir,\n\t\t\t},\n\t\t\tcli.BoolFlag{\n\t\t\t\tName: \"pipelog, P\",\n\t\t\t\tUsage: \"enables pipe logger (\" +\n\t\t\t\t\t\"setting only activates on use of cli flag or environment\" +\n\t\t\t\t\t\" variable as it alters stdin/out behaviour)\",\n\t\t\t\tEnvVar: \"POD_PIPELOG\",\n\t\t\t\tDestination: cx.Config.PipeLog,\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"lang, L\",\n\t\t\t\tValue: *cx.Config.Language,\n\t\t\t\tUsage: \"sets the data directory base for a pod instance\",\n\t\t\t\tEnvVar: \"POD_LANGUAGE\",\n\t\t\t\tDestination: cx.Config.Language,\n\t\t\t},\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"walletfile, WF\",\n\t\t\t\tValue: *cx.Config.WalletFile,\n\t\t\t\tUsage: \"sets the data directory base for a pod instance\",\n\t\t\t\tEnvVar: \"POD_WALLETFILE\",\n\t\t\t\tDestination: cx.Config.WalletFile,\n\t\t\t},\n\t\t\tau.BoolTrue(\n\t\t\t\t\"save, i\",\n\t\t\t\t\"save settings as effective from invocation\",\n\t\t\t\t&cx.StateCfg.Save,\n\t\t\t),\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"loglevel, l\",\n\t\t\t\tValue: *cx.Config.LogLevel,\n\t\t\t\tUsage: \"sets the base for all subsystem logging\",\n\t\t\t\tEnvVar: \"POD_LOGLEVEL\",\n\t\t\t\tDestination: cx.Config.LogLevel,\n\t\t\t},\n\t\t\tau.StringSlice(\n\t\t\t\t\"highlight\",\n\t\t\t\t\"define the set of packages whose logs will have attention-grabbing keywords to aid scanning logs\",\n\t\t\t\tcx.Config.Hilite,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"logfilter\",\n\t\t\t\t\"define the set of packages whose logs will not print\",\n\t\t\t\tcx.Config.LogFilter,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"network, n\",\n\t\t\t\t\"connect to mainnet/testnet/regtest/simnet\",\n\t\t\t\t\"mainnet\",\n\t\t\t\tcx.Config.Network,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"username\",\n\t\t\t\t\"sets the username for services\",\n\t\t\t\t\"server\",\n\t\t\t\tcx.Config.Username,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"password\",\n\t\t\t\t\"sets the password for services\",\n\t\t\t\tgenPassword(),\n\t\t\t\tcx.Config.Password,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"serveruser\",\n\t\t\t\t\"sets the username for clients of services\",\n\t\t\t\t\"client\",\n\t\t\t\tcx.Config.ServerUser,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"serverpass\",\n\t\t\t\t\"sets the password for clients of services\",\n\t\t\t\tgenPassword(),\n\t\t\t\tcx.Config.ServerPass,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"limituser\",\n\t\t\t\t\"sets the limited rpc username\",\n\t\t\t\t\"limit\",\n\t\t\t\tcx.Config.LimitUser,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"limitpass\",\n\t\t\t\t\"sets the limited rpc password\",\n\t\t\t\tgenPassword(),\n\t\t\t\tcx.Config.LimitPass,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"rpccert\",\n\t\t\t\t\"File containing the certificate file\",\n\t\t\t\t\"\",\n\t\t\t\tcx.Config.RPCCert,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"rpckey\",\n\t\t\t\t\"File containing the certificate key\",\n\t\t\t\t\"\",\n\t\t\t\tcx.Config.RPCKey,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"cafile\",\n\t\t\t\t\"File containing root certificates to authenticate a TLS\"+\n\t\t\t\t\t\" connections with pod\",\n\t\t\t\t\"\",\n\t\t\t\tcx.Config.CAFile,\n\t\t\t),\n\t\t\tau.BoolTrue(\n\t\t\t\t\"clienttls\",\n\t\t\t\t\"Enable TLS for client connections\",\n\t\t\t\tcx.Config.TLS,\n\t\t\t),\n\t\t\tau.BoolTrue(\n\t\t\t\t\"servertls\",\n\t\t\t\t\"Enable TLS for server connections\",\n\t\t\t\tcx.Config.ServerTLS,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"proxy\",\n\t\t\t\t\"Connect via SOCKS5 proxy\",\n\t\t\t\t\"\",\n\t\t\t\tcx.Config.Proxy,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"proxyuser\",\n\t\t\t\t\"Username for proxy server\",\n\t\t\t\t\"user\",\n\t\t\t\tcx.Config.ProxyUser,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"proxypass\",\n\t\t\t\t\"Password for proxy server\",\n\t\t\t\t\"pa55word\",\n\t\t\t\tcx.Config.ProxyPass,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"onion\",\n\t\t\t\t\"Enable connecting to tor hidden services\",\n\t\t\t\tcx.Config.Onion,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"onionproxy\",\n\t\t\t\t\"Connect to tor hidden services via SOCKS5 proxy (eg. 127.0.\"+\n\t\t\t\t\t\"0.1:9050)\",\n\t\t\t\t\"127.0.0.1:9050\",\n\t\t\t\tcx.Config.OnionProxy,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"onionuser\",\n\t\t\t\t\"Username for onion proxy server\",\n\t\t\t\t\"user\",\n\t\t\t\tcx.Config.OnionProxyUser,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"onionpass\",\n\t\t\t\t\"Password for onion proxy server\",\n\t\t\t\tgenPassword(),\n\t\t\t\tcx.Config.OnionProxyPass,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"torisolation\",\n\t\t\t\t\"Enable Tor stream isolation by randomizing user credentials\"+\n\t\t\t\t\t\" for each connection.\",\n\t\t\t\tcx.Config.TorIsolation,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"addpeer\",\n\t\t\t\t\"Add a peer to connect with at startup\",\n\t\t\t\tcx.Config.AddPeers,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"connect\",\n\t\t\t\t\"Connect only to the specified peers at startup\",\n\t\t\t\tcx.Config.ConnectPeers,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"nolisten\",\n\t\t\t\t\"Disable listening for incoming connections -- NOTE:\"+\n\t\t\t\t\t\" Listening is automatically disabled if the --connect or\"+\n\t\t\t\t\t\" --proxy options are used without also specifying listen\"+\n\t\t\t\t\t\" interfaces via --listen\",\n\t\t\t\tcx.Config.DisableListen,\n\t\t\t),\n\t\t\tau.BoolTrue(\n\t\t\t\t\"autolisten\",\n\t\t\t\t\"enable automatically populating p2p and controller reachable addresses\",\n\t\t\t\tcx.Config.AutoListen,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"p2pconnect\",\n\t\t\t\t\"Addresses that are configured to receive inbound connections\",\n\t\t\t\tcx.Config.P2PConnect,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"listen\",\n\t\t\t\t\"Add an interface/port to listen for connections\",\n\t\t\t\tcx.Config.P2PListeners,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"maxpeers\",\n\t\t\t\t\"Max number of inbound and outbound peers\",\n\t\t\t\tnode.DefaultMaxPeers,\n\t\t\t\tcx.Config.MaxPeers,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"nobanning\",\n\t\t\t\t\"Disable banning of misbehaving peers\",\n\t\t\t\tcx.Config.DisableBanning,\n\t\t\t),\n\t\t\tau.Duration(\n\t\t\t\t\"banduration\",\n\t\t\t\t\"How long to ban misbehaving peers\",\n\t\t\t\ttime.Hour*24,\n\t\t\t\tcx.Config.BanDuration,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"banthreshold\",\n\t\t\t\t\"Maximum allowed ban score before disconnecting and\"+\n\t\t\t\t\t\" banning misbehaving peers.\",\n\t\t\t\tnode.DefaultBanThreshold,\n\t\t\t\tcx.Config.BanThreshold,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"whitelist\",\n\t\t\t\t\"Add an IP network or IP that will not be banned. (eg. 192.\"+\n\t\t\t\t\t\"168.1.0/24 or ::1)\",\n\t\t\t\tcx.Config.Whitelists,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"rpcconnect\",\n\t\t\t\t\"Hostname/IP and port of pod RPC server to connect to\",\n\t\t\t\t\"\",\n\t\t\t\tcx.Config.RPCConnect,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"rpclisten\",\n\t\t\t\t\"Add an interface/port to listen for RPC connections\",\n\t\t\t\tcx.Config.RPCListeners,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"rpcmaxclients\",\n\t\t\t\t\"Max number of RPC clients for standard connections\",\n\t\t\t\tnode.DefaultMaxRPCClients,\n\t\t\t\tcx.Config.RPCMaxClients,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"rpcmaxwebsockets\",\n\t\t\t\t\"Max number of RPC websocket connections\",\n\t\t\t\tnode.DefaultMaxRPCWebsockets,\n\t\t\t\tcx.Config.RPCMaxWebsockets,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"rpcmaxconcurrentreqs\",\n\t\t\t\t\"Max number of RPC requests that may be\"+\n\t\t\t\t\t\" processed concurrently\",\n\t\t\t\tnode.DefaultMaxRPCConcurrentReqs,\n\t\t\t\tcx.Config.RPCMaxConcurrentReqs,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"rpcquirks\",\n\t\t\t\t\"Mirror some JSON-RPC quirks of Bitcoin Core -- NOTE:\"+\n\t\t\t\t\t\" Discouraged unless interoperability issues need to be worked\"+\n\t\t\t\t\t\" around\",\n\t\t\t\tcx.Config.RPCQuirks,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"norpc\",\n\t\t\t\t\"Disable built-in RPC server -- NOTE: The RPC server\"+\n\t\t\t\t\t\" is disabled by default if no rpcuser/rpcpass or\"+\n\t\t\t\t\t\" rpclimituser/rpclimitpass is specified\",\n\t\t\t\tcx.Config.DisableRPC,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"nodnsseed\",\n\t\t\t\t\"Disable DNS seeding for peers\",\n\t\t\t\tcx.Config.DisableDNSSeed,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"externalip\",\n\t\t\t\t\"Add an ip to the list of local addresses we claim to\"+\n\t\t\t\t\t\" listen on to peers\",\n\t\t\t\tcx.Config.ExternalIPs,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"addcheckpoint\",\n\t\t\t\t\"Add a custom checkpoint. Format: '<height>:<hash>'\",\n\t\t\t\tcx.Config.AddCheckpoints,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"nocheckpoints\",\n\t\t\t\t\"Disable built-in checkpoints. Don't do this unless\"+\n\t\t\t\t\t\" you know what you're doing.\",\n\t\t\t\tcx.Config.DisableCheckpoints,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"dbtype\",\n\t\t\t\t\"Database backend to use for the Block Chain\",\n\t\t\t\tnode.DefaultDbType,\n\t\t\t\tcx.Config.DbType,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"profile\",\n\t\t\t\t\"Enable HTTP profiling on given port -- NOTE port\"+\n\t\t\t\t\t\" must be between 1024 and 65536\",\n\t\t\t\t\"\",\n\t\t\t\tcx.Config.Profile,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"cpuprofile\",\n\t\t\t\t\"Write CPU profile to the specified file\",\n\t\t\t\t\"\",\n\t\t\t\tcx.Config.CPUProfile,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"upnp\",\n\t\t\t\t\"Use UPnP to map our listening port outside of NAT\",\n\t\t\t\tcx.Config.UPNP,\n\t\t\t),\n\t\t\tau.Float64(\n\t\t\t\t\"minrelaytxfee\",\n\t\t\t\t\"The minimum transaction fee in DUO/kB to be\"+\n\t\t\t\t\t\" considered a non-zero fee.\",\n\t\t\t\tmempool.DefaultMinRelayTxFee.ToDUO(),\n\t\t\t\tcx.Config.MinRelayTxFee,\n\t\t\t),\n\t\t\tau.Float64(\n\t\t\t\t\"limitfreerelay\",\n\t\t\t\t\"Limit relay of transactions with no transaction\"+\n\t\t\t\t\t\" fee to the given amount in thousands of bytes per minute\",\n\t\t\t\tnode.DefaultFreeTxRelayLimit,\n\t\t\t\tcx.Config.FreeTxRelayLimit,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"norelaypriority\",\n\t\t\t\t\"Do not require free or low-fee transactions to have\"+\n\t\t\t\t\t\" high priority for relaying\",\n\t\t\t\tcx.Config.NoRelayPriority,\n\t\t\t),\n\t\t\tau.Duration(\n\t\t\t\t\"trickleinterval\",\n\t\t\t\t\"Minimum time between attempts to send new\"+\n\t\t\t\t\t\" inventory to a connected peer\",\n\t\t\t\tnode.DefaultTrickleInterval,\n\t\t\t\tcx.Config.TrickleInterval,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"maxorphantx\",\n\t\t\t\t\"Max number of orphan transactions to keep in memory\",\n\t\t\t\tnode.DefaultMaxOrphanTransactions,\n\t\t\t\tcx.Config.MaxOrphanTxs,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"generate, g\",\n\t\t\t\t\"Generate (mine) DUO using the CPU\",\n\t\t\t\tcx.Config.Generate,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"genthreads, G\",\n\t\t\t\t\"Number of CPU threads to use with CPU miner\"+\n\t\t\t\t\t\" -1 = all cores\",\n\t\t\t\t1,\n\t\t\t\tcx.Config.GenThreads,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"solo\",\n\t\t\t\t\"mine DUO even if not connected to the network\",\n\t\t\t\tcx.Config.Solo,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"lan\",\n\t\t\t\t\"mine duo if not connected to nodes on internet\",\n\t\t\t\tcx.Config.LAN,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"controller\",\n\t\t\t\t\"enables multicast\",\n\t\t\t\tcx.Config.Controller,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"autoports\",\n\t\t\t\t\"uses random automatic ports for p2p & rpc\",\n\t\t\t\tcx.Config.AutoPorts,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"miningaddr\",\n\t\t\t\t\"Add the specified payment address to the list of\"+\n\t\t\t\t\t\" addresses to use for generated blocks, at least one is \"+\n\t\t\t\t\t\"required if generate or minerlistener are set\",\n\t\t\t\tcx.Config.MiningAddrs,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"minerpass\",\n\t\t\t\t\"password to authorise sending work to a miner\",\n\t\t\t\tgenPassword(),\n\t\t\t\tcx.Config.MinerPass,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"blockminsize\",\n\t\t\t\t\"Minimum block size in bytes to be used when\"+\n\t\t\t\t\t\" creating a block\",\n\t\t\t\tnode.BlockMaxSizeMin,\n\t\t\t\tcx.Config.BlockMinSize,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"blockmaxsize\",\n\t\t\t\t\"Maximum block size in bytes to be used when\"+\n\t\t\t\t\t\" creating a block\",\n\t\t\t\tnode.BlockMaxSizeMax,\n\t\t\t\tcx.Config.BlockMaxSize,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"blockminweight\",\n\t\t\t\t\"Minimum block weight to be used when creating\"+\n\t\t\t\t\t\" a block\",\n\t\t\t\tnode.BlockMaxWeightMin,\n\t\t\t\tcx.Config.BlockMinWeight,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"blockmaxweight\",\n\t\t\t\t\"Maximum block weight to be used when creating\"+\n\t\t\t\t\t\" a block\",\n\t\t\t\tnode.BlockMaxWeightMax,\n\t\t\t\tcx.Config.BlockMaxWeight,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"blockprioritysize\",\n\t\t\t\t\"Size in bytes for high-priority/low-fee\"+\n\t\t\t\t\t\" transactions when creating a block\",\n\t\t\t\tmempool.DefaultBlockPrioritySize,\n\t\t\t\tcx.Config.BlockPrioritySize,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"uacomment\",\n\t\t\t\t\"Comment to add to the user agent -- See BIP 14 for\"+\n\t\t\t\t\t\" more information.\",\n\t\t\t\tcx.Config.UserAgentComments,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"nopeerbloomfilters\",\n\t\t\t\t\"Disable bloom filtering support\",\n\t\t\t\tcx.Config.NoPeerBloomFilters,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"nocfilters\",\n\t\t\t\t\"Disable committed filtering (CF) support\",\n\t\t\t\tcx.Config.NoCFilters,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"sigcachemaxsize\",\n\t\t\t\t\"The maximum number of entries in the\"+\n\t\t\t\t\t\" signature verification cache\",\n\t\t\t\tnode.DefaultSigCacheMaxSize,\n\t\t\t\tcx.Config.SigCacheMaxSize,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"blocksonly\",\n\t\t\t\t\"Do not accept transactions from remote peers.\",\n\t\t\t\tcx.Config.BlocksOnly,\n\t\t\t),\n\t\t\tau.BoolTrue(\n\t\t\t\t\"txindex\",\n\t\t\t\t\"Disable the transaction index which makes all transactions available via the getrawtransaction RPC\",\n\t\t\t\tcx.Config.TxIndex,\n\t\t\t),\n\t\t\tau.BoolTrue(\n\t\t\t\t\"addrindex\",\n\t\t\t\t\"Disable address-based transaction index which makes the searchrawtransactions RPC available\",\n\t\t\t\tcx.Config.AddrIndex,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"relaynonstd\",\n\t\t\t\t\"Relay non-standard transactions regardless of the default settings for the active network.\",\n\t\t\t\tcx.Config.RelayNonStd,\n\t\t\t), au.Bool(\n\t\t\t\t\"rejectnonstd\",\n\t\t\t\t\"Reject non-standard transactions regardless of the default settings for the active network.\",\n\t\t\t\tcx.Config.RejectNonStd,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"noinitialload\",\n\t\t\t\t\"Defer wallet creation/opening on startup and enable loading wallets over RPC (loading not yet implemented)\",\n\t\t\t\tcx.Config.NoInitialLoad,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"walletconnect, wc\",\n\t\t\t\t\"connect to wallet instead of full node\",\n\t\t\t\tcx.Config.Wallet,\n\t\t\t),\n\t\t\tau.String(\n\t\t\t\t\"walletserver, ws\",\n\t\t\t\t\"set wallet server to connect to\",\n\t\t\t\t\"127.0.0.1:11046\",\n\t\t\t\tcx.Config.WalletServer,\n\t\t\t),\n\t\t\tcli.StringFlag{\n\t\t\t\tName: \"walletpass\",\n\t\t\t\tValue: *cx.Config.WalletPass,\n\t\t\t\tUsage: \"The public wallet password -- Only required if the wallet was created with one\",\n\t\t\t\tEnvVar: \"POD_WALLETPASS\",\n\t\t\t\tDestination: cx.Config.WalletPass,\n\t\t\t},\n\t\t\tau.Bool(\n\t\t\t\t\"onetimetlskey\",\n\t\t\t\t\"Generate a new TLS certificate pair at startup, but only write the certificate to disk\",\n\t\t\t\tcx.Config.OneTimeTLSKey,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"tlsskipverify\",\n\t\t\t\t\"skip verifying tls certificates\",\n\t\t\t\tcx.Config.TLSSkipVerify,\n\t\t\t),\n\t\t\tau.StringSlice(\n\t\t\t\t\"walletrpclisten\",\n\t\t\t\t\"Listen for wallet RPC connections on this\"+\n\t\t\t\t\t\" interface/port (default port: 11046, testnet: 21046,\"+\n\t\t\t\t\t\" simnet: 41046)\",\n\t\t\t\tcx.Config.WalletRPCListeners,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"walletrpcmaxclients\",\n\t\t\t\t\"Max number of legacy RPC clients for\"+\n\t\t\t\t\t\" standard connections\",\n\t\t\t\t8,\n\t\t\t\tcx.Config.WalletRPCMaxClients,\n\t\t\t),\n\t\t\tau.Int(\n\t\t\t\t\"walletrpcmaxwebsockets\",\n\t\t\t\t\"Max number of legacy RPC websocket connections\",\n\t\t\t\t8,\n\t\t\t\tcx.Config.WalletRPCMaxWebsockets,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"nodeoff\",\n\t\t\t\t\"Starts with node turned off\",\n\t\t\t\tcx.Config.NodeOff,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"walletoff\",\n\t\t\t\t\"Starts with wallet turned off\",\n\t\t\t\tcx.Config.WalletOff,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"discover\",\n\t\t\t\t\"enable LAN multicast peer discovery in GUI wallet\",\n\t\t\t\tcx.Config.WalletOff,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"delaystart\",\n\t\t\t\t\"pauses for 3 seconds before starting, for internal use with restart function\",\n\t\t\t\tnil,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"darktheme\",\n\t\t\t\t\"sets the dark theme on the gui interface\",\n\t\t\t\tcx.Config.DarkTheme,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"notty\",\n\t\t\t\t\"tells pod there is no keyboard input available\",\n\t\t\t\tnil,\n\t\t\t),\n\t\t\tau.Bool(\n\t\t\t\t\"runasservice\",\n\t\t\t\t\"tells wallet to shut down when the wallet locks\",\n\t\t\t\tcx.Config.RunAsService,\n\t\t\t),\n\t\t},\n\t}\n}", "func nativeFromApp(app interface{}) *gobject.GValue {\n\targapp, ok := app.(*Application)\n\tif ok {\n\t\tgv := gobject.CreateCGValue(GtkType.APPLICATION, argapp.ToNative())\n\t\treturn gv\n\t}\n\n\treturn nil\n}", "func NewApp(config gettConfig.AppConfig, handler http.Handler, logger *logrus.Logger, pingers []healthcheck.Pinger) App {\n\tapp := App{\n\t\tconfig: config,\n\t\thandler: handler,\n\t\tlogger: logger,\n\t\tpingers: pingers,\n\t}\n\n\tgettOps.InitOps()\n\n\tlog.SetFlags(0)\n\tlog.Print(skeletonBanner)\n\tlog.SetFlags(log.LstdFlags)\n\n\treturn app\n}", "func NewApplication(app *kingpin.Application) ApplicationArguments {\n\treturn ApplicationArguments{\n\t\tApplication: app,\n\t\tlongs: map[string]bool{\n\t\t\t\"help-man\": true,\n\t\t\t\"help-long\": true,\n\t\t\t\"completion-bash\": true,\n\t\t\t\"completion-script-bash\": true,\n\t\t\t\"completion-script-zsh\": true,\n\t\t},\n\t\tshorts: map[rune]bool{},\n\t}\n}", "func App() *Application {\n\treturn &app\n}", "func createHelp() *cli.App {\n\ta := cli.NewApp()\n\ta.Name = appname\n\ta.Author = \"tanaike [ https://github.com/tanaikech/\" + appname + \" ] \"\n\ta.Email = \"[email protected]\"\n\ta.Usage = \"Download shared files on Google Drive.\"\n\ta.Version = \"1.0.2\"\n\ta.Flags = []cli.Flag{\n\t\tcli.StringFlag{\n\t\t\tName: \"url, u\",\n\t\t\tUsage: \"URL of shared file on Google Drive. This is a required parameter.\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"extension, e\",\n\t\t\tUsage: \"Extension of output file. This is for only Google Docs (Spreadsheet, Document, Presentation).\",\n\t\t\tValue: \"pdf\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"filename, f\",\n\t\t\tUsage: \"Filename of file which is output. When this was not used, the original filename on Google Drive is used.\",\n\t\t},\n\t}\n\treturn a\n}", "func NewApplication(aOptrions Options) (*Application, error) {\n\tservices := []startable{}\n\n\ttools := processing.NewTools(aOptrions.UploadLocation, aOptrions.PreviewSize)\n\n\tsrv := newServer(aOptrions.Listen, aOptrions.Port, tools)\n\n\tif srv == nil {\n\t\treturn nil, fmt.Errorf(\"Can't create server\")\n\t}\n\n\tservices = append(services, srv)\n\n\treturn &Application{\n\t\tservices: services,\n\t}, nil\n}", "func (c Client) createApp(body io.Reader) (*App, error) {\n\treq, err := http.NewRequest(\"POST\", c.getURL(\"/apps\"), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar marshalled map[string]*App\n\terr = c.executeRequestAndMarshal(req, &marshalled)\n\treturn marshalled[\"app\"], err\n}", "func main() {\n\tlog.Println(\"Done.\")\n\tapp.Run(func() error {\n\t\tw1 := NewWindow()\n\t\t//w1.Self = w1\n\t\tw1.SetObjID(\"window1\")\n\t\tw1.SetHints(gui.HintResizable)\n\t\tw1.Create(0, 0)\n\t\tw1.SetTitle(\"w1 resizable\")\n\t\tw1.Show()\n\t\t// w1.ToggleFullScreen()\n\t\tw1.Destroy()\n\t\tw2 := NewWindow()\n\t\tw2.SetObjID(\"window2\")\n\t\tw2.Create(200, 200)\n\t\tw2.SetTitle(\"w2 fixed\")\n\t\tw2.Show()\n\t\t// w2.ToggleFullScreen()\n\t\t// runtime.GC()\n\t\treturn nil\n\t}, nil)\n}", "func NewApp(database string) *Application {\n\tfolder := filepath.Dir(os.Args[0]) /* go 1.7.5 */\n\tconn, err := sql.Open(\"sqlite3\", folder+\"/\"+database)\n\n\tif err != nil {\n\t\tlog.Fatal(\"SQLite open; \", err)\n\t\treturn &Application{}\n\t}\n\n\tlog.Println(\"Database:\", folder+\"/\"+database)\n\n\tquery := `\n\tCREATE TABLE IF NOT EXISTS reviews (\n\t\tid INTEGER PRIMARY KEY,\n\t\tuid TEXT,\n\t\tname TEXT,\n\t\temail TEXT,\n\t\trating INTEGER,\n\t\tcomment TEXT,\n\t\tapproved INTEGER,\n\t\ttimestamp TIMESTAMP\n\t);\n\t`\n\n\tif _, err := conn.Exec(query); err != nil {\n\t\tlog.Fatal(\"Database setup; \", err)\n\t\treturn &Application{}\n\t}\n\n\treturn &Application{db: conn}\n}", "func init() {\n\truntime.LockOSThread()\n\tflag.IntVar(&flagDesktopNumber, \"desktop\", -1, \"the index of the desktop to create the main window on\")\n\tflag.StringVar(&flagComponentFile, \"cf\", \"component.json\", \"the name of the component file to load and save\")\n}", "func NewCli() *cli.App {\n\tapp := cli.NewApp()\n\tcli.AppHelpTemplate = `\nNAME:\n {{.Name}} - {{.UsageText}}\n{{if len .Authors}}\nAUTHOR:\n {{range .Authors}}{{ . }}{{end}}\n{{end}}\nUSAGE:\n {{.HelpName}}{{if .VisibleFlags}} [global options]{{end}}{{if .Commands}} command [command options]{{end}}\n{{if .Commands}}\nCOMMANDS:\n{{range .Commands}}{{if not .HideHelp}} {{join .Names \", \"}}{{ \"\\t\"}}{{.Usage}}{{ \"\\n\" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}}\nGLOBAL OPTIONS:\n {{range .VisibleFlags}}{{.}}\n {{end}}{{end}}\n`\n\tapp.UsageText = \"Web application for Kubernetes CLI configuration with OIDC\"\n\tapp.Version = fmt.Sprintf(\"%v build %v\", GitVersion, GitHash)\n\tapp.Authors = []cli.Author{\n\t\t{\n\t\t\tName: \"fydrah\",\n\t\t\tEmail: \"[email protected]\",\n\t\t},\n\t}\n\tapp.Commands = []cli.Command{\n\t\t{\n\t\t\tName: \"serve\",\n\t\t\tUsage: \"Run loginapp application\",\n\t\t\tSkipFlagParsing: true,\n\t\t\tArgsUsage: \"[configuration file]\",\n\t\t\tBefore: func(c *cli.Context) error {\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif len(c.Args()) == 0 {\n\t\t\t\t\tif err := cli.ShowCommandHelp(c, c.Command.Name); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"error while rendering command help: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"missing argument\")\n\t\t\t\t}\n\t\t\t\ts := &Server{}\n\t\t\t\tif err := s.config.Init(c.Args().First()); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif err := s.Run(); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\treturn app\n}", "func NewApp(mode string, cfg *Config) (app *App, err error) {\n\tif cfg == nil {\n\t\tcfg = DefaultConfig()\n\t}\n\tv := &App{\n\t\tobjs: make(map[int]*_object),\n\t\teventMux: newMux(),\n\t\ttrans: newFnMgr(mode),\n\t\tcfg: *cfg,\n\t}\n\tv.b = newBridge(mode, v.trans)\n\n\t// refer to 'ReadMostly' example in sync/atomic\n\tv.eventOut.Store(make(map[int]*_eventListener))\n\tv.eventMux.Handle(func(val interface{}, _ int) {\n\t\te := val.(*Event)\n\t\tm := v.eventOut.Load().(map[int]*_eventListener)\n\t\t// to the channel containing everythin errors\n\t\tfor _, eln := range m {\n\t\t\tif (eln.targets&e.Origin) == 0 || eln.level > e.Level {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// non-blocking channel sending\n\t\t\tselect {\n\t\t\tcase eln.events <- e:\n\t\t\tdefault:\n\t\t\t\t// drop this event\n\t\t\t\t// TODO: log it?\n\t\t\t}\n\t\t}\n\t})\n\n\tremain, err := v.eventMux.More(1)\n\tif err != nil || remain != 0 {\n\t\terr = fmt.Errorf(\"Unable to allocate mux routine: %v\", remain)\n\t}\n\n\t// init mappers\n\tif v.mappers, err = newMappers(v.trans, v.b.(exHooks)); err != nil {\n\t\treturn\n\t}\n\tif err = v.attachObject(v.mappers, ObjT.Mapper); err != nil {\n\t\treturn\n\t}\n\t// 'local' mode\n\tif err = v.allocateMappers(); err != nil {\n\t\treturn\n\t}\n\n\t// init workers\n\tif v.workers, err = newWorkers(v.trans, v.b.(exHooks)); err != nil {\n\t\treturn\n\t}\n\tif err = v.attachObject(v.workers, ObjT.Worker); err != nil {\n\t\treturn\n\t}\n\n\tapp = v\n\treturn\n}", "func createApp() *menta.MentaApp {\n\t// runs tendermint init if needed\n\tmenta.InitTendermint(homeDir)\n\t// setup the app\n\tapp := menta.NewApp(\"counter-example\", homeDir)\n\t// Register the service\n\tapp.AddService(counter.Service{})\n\n\treturn app\n}", "func NewReplApp(meProfileFile, contactsFile, privateKeyFile string, output io.Writer) App {\n\tui := new(ReplApp)\n\tui.meProfileFile = meProfileFile\n\tui.contactsFile = contactsFile\n\tui.privateKeyFile = privateKeyFile\n\tui.output = output\n\tui.setupCommands()\n\n\t// read profile/contacts\n\tme, err := ReadProfile(meProfileFile)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\tcontacts, err := ReadContacts(contactsFile)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\tprivKey, err := ReadPrivateKey(privateKeyFile)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\t// setup engine\n\tui.engine, err = NewChatEngine(privKey, me, contacts)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\t// setup console\n\tui.console = NewConsole(os.Stdin)\n\tui.console.Format = func() string { return time.Now().Format(\"3:04:05 PM\") + \" > \" }\n\t// ui.console.Format = func() string { return ui.engine.Me.Name + \" > \" }\n\n\treturn ui\n}" ]
[ "0.67276466", "0.6412036", "0.6337244", "0.6161679", "0.6158922", "0.6152389", "0.6087091", "0.6004905", "0.5998879", "0.5976587", "0.5976587", "0.59525", "0.5938636", "0.59010977", "0.58993447", "0.58642554", "0.58642554", "0.5835353", "0.58348334", "0.5830582", "0.57973415", "0.5788753", "0.57884926", "0.5769283", "0.57628655", "0.57401794", "0.5716573", "0.5693248", "0.569046", "0.56895703", "0.56801647", "0.5660867", "0.56562346", "0.56363434", "0.56297505", "0.56168413", "0.5556816", "0.555493", "0.55457723", "0.55440724", "0.5537403", "0.55349046", "0.5520663", "0.5511611", "0.549472", "0.54945886", "0.5484288", "0.5483138", "0.5479661", "0.5472839", "0.5471221", "0.54638964", "0.54638964", "0.54638964", "0.5447731", "0.54369235", "0.5416071", "0.5405583", "0.5402943", "0.5402467", "0.53972584", "0.5391101", "0.53815395", "0.5378801", "0.53691226", "0.5356724", "0.5355679", "0.5354525", "0.5349714", "0.5309924", "0.5307892", "0.52974945", "0.52959627", "0.5293076", "0.52927095", "0.527916", "0.52758306", "0.52752954", "0.5271136", "0.52663493", "0.5260324", "0.52599835", "0.52568144", "0.52450454", "0.5224196", "0.52222234", "0.5218499", "0.5212438", "0.5205103", "0.5200105", "0.51988196", "0.5198121", "0.5191682", "0.5182793", "0.5178361", "0.51641357", "0.51508325", "0.51483464", "0.51468194", "0.51387346" ]
0.66225857
1
Read function fetches a DesktopApp from source, including attribute values. Returns error if any
func (o *DesktopApp) Read() error { if o.ID == "" { return errors.New("error: ID is empty") } var queryArg = make(map[string]interface{}) queryArg["_RowKey"] = o.ID // Attempt to read from an upstream API resp, err := o.client.CallGenericMapAPI(o.apiRead, queryArg) if err != nil { return err } if !resp.Success { return errors.New(resp.Message) } fillWithMap(o, resp.Result) LogD.Printf("Filled object: %+v", o) return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c Client) Application(name string) (types.Application, error) {\n var app types.ApplicationResponse\n\n resp, err := c.get(\"/applications/\" + name, nil)\n defer ensureReaderClosed(resp)\n if err != nil {\n return app.Attributes, err\n }\n\n err = json.NewDecoder(resp.body).Decode(&app)\n\n if err != nil {\n return app.Attributes, err\n }\n return app.Attributes, err\n}", "func ReadProgram(filePath string) (interface{}, error) {\n\text := strings.ToLower(path.Ext(filePath))\n\n\t// ZIP archive\n\tif ext == \".zip\" {\n\t\treturn readZIP(filePath)\n\t}\n\n\tdata, err := ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar format *FormatInfo\n\tformat, err = detectFormat(filePath, ENCAPSULATION_NONE, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif format.Format == FORMAT_TAP {\n\t\treturn NewTAP(data)\n\t}\n\n\treturn SnapshotData(data).Decode(format.Format)\n}", "func (s Store) GetApplication(title string) ([]utils.Metadata, error) {\n\tvar listMetadata []utils.Metadata\n\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\tif !s.isTitlePresent(title) {\n\t\treturn listMetadata, messages.MetadataTitleAbsent\n\t}\n\n\tfor _, metadata := range s.appToDetails[title] {\n\t\tlistMetadata = append(listMetadata, metadata)\n\t}\n\n\treturn listMetadata, nil\n}", "func (r Application) GetReader() io.Reader {\n\tv := url.Values{}\n\tif r.FriendlyName != \"\" {\n\t\tv.Add(\"FriendlyName\", r.FriendlyName)\n\t}\n\tif r.APIVersion != \"\" {\n\t\tv.Add(\"ApiVersion\", r.APIVersion)\n\t}\n\tif r.VoiceURL != \"\" {\n\t\tv.Add(\"VoiceUrl\", r.VoiceURL)\n\t}\n\tif r.VoiceMethod != \"\" {\n\t\tv.Add(\"VoiceMethod\", r.VoiceMethod)\n\t}\n\tif r.VoiceFallbackURL != \"\" {\n\t\tv.Add(\"VoiceFallbackUrl\", r.VoiceFallbackURL)\n\t}\n\tif r.VoiceFallbackMethod != \"\" {\n\t\tv.Add(\"VoiceFallbackMethod\", r.VoiceFallbackMethod)\n\t}\n\tif r.SmsURL != \"\" {\n\t\tv.Add(\"SmsUrl\", r.SmsURL)\n\t}\n\tif r.SmsMethod != \"\" {\n\t\tv.Add(\"SmsMethod\", r.SmsMethod)\n\t}\n\tif r.SmsFallbackURL != \"\" {\n\t\tv.Add(\"SmsFallbackUrl\", r.SmsFallbackURL)\n\t}\n\tif r.SmsFallbackMethod != \"\" {\n\t\tv.Add(\"SmsFallbackMethod\", r.SmsFallbackMethod)\n\t}\n\tif r.SmsStatusCallback != \"\" {\n\t\tv.Add(\"SmsStatusCallback\", r.SmsStatusCallback)\n\t}\n\tif r.MessageStatusCallback != \"\" {\n\t\tv.Add(\"MessageStatusCallback\", r.MessageStatusCallback)\n\t}\n\tv.Add(\"VoiceCallerIdLookup\", strconv.FormatBool(r.VoiceCallerIDLookup))\n\treturn strings.NewReader(v.Encode())\n}", "func ApplicationFrom(a *udetect.App) *openrtb.App {\n\tif a == nil {\n\t\treturn nil\n\t}\n\treturn &openrtb.App{\n\t\tInventory: openrtb.Inventory{\n\t\t\tID: a.ExtID, // External ID\n\t\t\tKeywords: a.Keywords, // Comma separated list of keywords about the site.\n\t\t\tCat: a.Cat, // Array of IAB content categories\n\t\t\tPrivacyPolicy: intRef(a.PrivacyPolicy), // Default: 1 (\"1\": has a privacy policy)\n\t\t},\n\t\tBundle: a.Bundle, // App bundle or package name\n\t\tStoreURL: a.StoreURL, // App store URL for an installed app\n\t\tVer: a.Ver, // App version\n\t\tPaid: a.Paid, // \"1\": Paid, \"2\": Free\n\t}\n}", "func (p *Pvr) GetApplicationInfo(appname string) error {\n\tsrcFilePath := filepath.Join(p.Dir, appname, \"src.json\")\n\tif _, err := os.Stat(srcFilePath); err != nil {\n\t\treturn errors.New(\"App '\" + appname + \"' doesn't exist\")\n\t}\n\tsrc, _ := ioutil.ReadFile(srcFilePath)\n\tvar fileData interface{}\n\terr := pvjson.Unmarshal(src, &fileData)\n\tif err != nil {\n\t\treturn err\n\t}\n\tjsonData, err := json.MarshalIndent(fileData, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(string(jsonData))\n\treturn nil\n}", "func (am *AppManager) GetAppData(appGUID string) AppInfo {\n\t//logger.Printf(\"Searching for %s\\n\", appGUID)\n\treq := readRequest{appGUID, make(chan AppInfo)}\n\tam.readChannel <- req\n\tai := <-req.responseChan\n\t//logger.Printf(\"Recevied response for %s: %+v\", appGUID, ai)\n\treturn ai\n}", "func (c *Client) App(user, name string) (*App, error) {\n\tlog.Printf(\"[INFO] getting application %s/%s\", user, name)\n\n\tendpoint := fmt.Sprintf(\"/api/v1/vagrant/applications/%s/%s\", user, name)\n\trequest, err := c.Request(\"GET\", endpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse, err := checkResp(c.HTTPClient.Do(request))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar app App\n\tif err := decodeJSON(response, &app); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &app, nil\n}", "func AppReadHandler(context utils.Context, w http.ResponseWriter, r *http.Request) {\n\tlog.LogInfo.Println(\"accessing route:\", r.URL.Path)\n\n\tvars := mux.Vars(r)\n\n\tenv := vars[\"environment\"]\n\tapp := vars[\"application\"]\n\n\tdbConn := context.DBConn\n\tdbBucket := context.DBBucketApp\n\n\t//return everything\n\tif env == \"\" && app == \"\" {\n\t\tgetAllApplications(dbConn, dbBucket, w)\n\t\treturn\n\t}\n\n\tif env != \"\" && app == \"\" {\n\t\tgetAllAppsInEnv(env, dbConn, dbBucket, w)\n\t\treturn\n\t}\n\n\tgetAppInEnv(env, app, dbConn, dbBucket, w)\n\n}", "func ReadCurrent() *AppConfig {\n\tconfigPath := os.Getenv(\"OAUTH_CONFIG_PATH\")\n\tif configPath == \"\" {\n\t\tconfigPath = \"../../../config/default.json\"\n\t}\n\n\treturn Read(configPath)\n}", "func (s *appInfoBaseline) GetAppInfo() (AppInfo, error) {\n\n\tinfo := AppInfo{}\n\tinfo.Labels = make(map[string]string)\n\n\tinfo.PodName = os.Getenv(\"MY_POD_NAME\") //custom defined in the deployment spec\n\t//time.Sleep(3*time.Second)\n\t//info.Namespace = os.Getenv(\"MY_POD_NAMESPACE\") //custom defined in the deployment spec\n\n\tfile, err := os.Open(\"/etc/labels\")\n\tif err != nil {\n\t\treturn info, err\n\t}\n\tdefer file.Close()\n\n\t//overkill, but read it fresh each time\n\treader := bufio.NewReader(file)\n\n\tfor {\n\t\tline, err := reader.ReadString('\\n')\n\n\t\t// check if the line has = sign\n\t\t// and process the line. Ignore the rest.\n\t\tif equal := strings.Index(line, \"=\"); equal >= 0 {\n\t\t\tif key := strings.TrimSpace(line[:equal]); len(key) > 0 {\n\t\t\t\tvalue := \"\"\n\t\t\t\tif len(line) > equal {\n\t\t\t\t\tvalue = strings.TrimSpace(line[equal+1:])\n\t\t\t\t}\n\n\t\t\t\tvalue = strings.Replace(value, \"\\\"\", \"\", -1)\n\t\t\t\tswitch key {\n\t\t\t\tcase \"app\":\n\t\t\t\t\tinfo.AppName = value\n\t\t\t\tcase \"release\":\n\t\t\t\t\tinfo.Release = value\n\t\t\t\tdefault:\n\t\t\t\t\tinfo.Labels[key] = value\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn info, err\n\t\t}\n\t}\n\n\t//return info, fmt.Errorf(\"Forced error\")\n\treturn info, err\n}", "func (ds *MySQLDatastore) GetApp(ctx context.Context, name string) (*models.App, error) {\n\trow := ds.db.QueryRow(`SELECT name, config FROM apps WHERE name=?`, name)\n\n\tvar resName string\n\tvar config string\n\terr := row.Scan(&resName, &config)\n\n\tres := &models.App{\n\t\tName: resName,\n\t}\n\n\tjson.Unmarshal([]byte(config), &res.Config)\n\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil, models.ErrAppsNotFound\n\t\t}\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "func (c Client) createApp(body io.Reader) (*App, error) {\n\treq, err := http.NewRequest(\"POST\", c.getURL(\"/apps\"), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar marshalled map[string]*App\n\terr = c.executeRequestAndMarshal(req, &marshalled)\n\treturn marshalled[\"app\"], err\n}", "func (m *PromptManager) Read(opts ...RequestOption) (p *Prompt, err error) {\n\terr = m.Request(\"GET\", m.URI(\"prompts\"), &p, opts...)\n\treturn\n}", "func (c Client) fetchApp() (*Identity, error) {\n\treq, err := http.NewRequest(\"GET\", c.getURL(\"/me\"), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar marshalled map[string]*Identity\n\terr = c.executeRequestAndMarshal(req, &marshalled)\n\treturn marshalled[\"identity\"], err\n}", "func (store *managerStore) FetchApplication(runAs, appID string) (*types.Application, error) {\n\n\tpath := getApplicationRootPath() + runAs + \"/\" + appID\n\n\tdata, err := store.Db.Fetch(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapp := &types.Application{}\n\tif err := json.Unmarshal(data, app); err != nil {\n\t\tblog.Error(\"fail to unmarshal application(%s:%s) data(%s) err:%s\", runAs, appID, string(data), err.Error())\n\t\treturn nil, err\n\t}\n\n\treturn app, nil\n}", "func (o *DesktopApp) Query() (map[string]interface{}, error) {\n\tquery := \"SELECT * FROM Application WHERE 1=1 AND AppType='Desktop'\"\n\tif o.Name != \"\" {\n\t\tquery += \" AND Name='\" + o.Name + \"'\"\n\t}\n\n\treturn queryVaultObject(o.client, query)\n}", "func GetApp(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *AppState, opts ...pulumi.ResourceOption) (*App, error) {\n\tvar resource App\n\terr := ctx.ReadResource(\"aws-native:sagemaker:App\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func getMachineReadableFormat(client *occlient.Client, appName string, projectName string, active bool) application.App {\n\tcomponentList, _ := component.List(client, appName)\n\tvar compList []string\n\tfor _, comp := range componentList {\n\t\tcompList = append(compList, comp.ComponentName)\n\t}\n\tappDef := application.App{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"app\",\n\t\t\tAPIVersion: \"odo.openshift.io/v1alpha1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: appName,\n\t\t\tNamespace: projectName,\n\t\t},\n\t\tSpec: application.AppSpec{\n\t\t\tComponents: compList,\n\t\t},\n\t\tStatus: application.AppStatus{\n\t\t\tActive: active,\n\t\t},\n\t}\n\treturn appDef\n}", "func (e *EurekaConnection) GetApp(name string) (*Application, error) {\n\tslug := fmt.Sprintf(\"%s/%s\", EurekaURLSlugs[\"Apps\"], name)\n\treqURL := e.generateURL(slug)\n\tlog.Debugf(\"Getting app %s from url %s\", name, reqURL)\n\tout, rcode, err := getBody(reqURL, e.UseJson)\n\tif err != nil {\n\t\tlog.Errorf(\"Couldn't get app %s, error: %s\", name, err.Error())\n\t\treturn nil, err\n\t}\n\tif rcode == 404 {\n\t\tlog.Errorf(\"App %s not found (received 404)\", name)\n\t\treturn nil, AppNotFoundError{specific: name}\n\t}\n\tif rcode > 299 || rcode < 200 {\n\t\tlog.Warningf(\"Non-200 rcode of %d\", rcode)\n\t}\n\n\tvar v *Application\n\tif e.UseJson {\n\t\tvar r GetAppResponseJson\n\t\terr = json.Unmarshal(out, &r)\n\t\tv = &r.Application\n\t} else {\n\t\terr = xml.Unmarshal(out, &v)\n\t}\n\tif err != nil {\n\t\tlog.Errorf(\"Unmarshalling error: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\tv.ParseAllMetadata()\n\treturn v, nil\n}", "func appconfig() {\n\tif len(job.desktop) == 0 {\n\t\treturn\n\t}\n\tu, e := url.Parse(job.desktop)\n\tif e != nil {\n\t\tfmt.Fprintln(os.Stderr, e)\n\t\tos.Exit(1)\n\t}\n\tif u.Scheme != \"file\" && u.Scheme != \"\" {\n\t\tfmt.Fprintln(os.Stderr, \"app: cannot handle scheme \" + u.Scheme)\n\t\tos.Exit(1)\n\t}\n\tc, e := mini.LoadConfiguration(u.Path)\n\tif e != nil {\n\t\tfmt.Fprintln(os.Stderr, e)\n\t\tos.Exit(1)\n\t}\n\tsect := c.SectionNames()\n\tfor s := range sect {\n\t\tswitch(sect[s]) {\n\t\t\tcase \"Desktop Entry\":\n\t\t\t\tcontinue\n\t\t\tcase \"Job\":\n\t\t\t\tprocessjob()\n\t\t\tdefault:\n\t\t}\n\t}\n}", "func UnmarshalWindowsDesktop(data []byte, opts ...MarshalOption) (types.WindowsDesktop, error) {\n\tif len(data) == 0 {\n\t\treturn nil, trace.BadParameter(\"missing windows desktop data\")\n\t}\n\tcfg, err := CollectOptions(opts)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\tvar h types.ResourceHeader\n\tif err := utils.FastUnmarshal(data, &h); err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\tswitch h.Version {\n\tcase types.V3:\n\t\tvar s types.WindowsDesktopV3\n\t\tif err := utils.FastUnmarshal(data, &s); err != nil {\n\t\t\treturn nil, trace.BadParameter(err.Error())\n\t\t}\n\t\tif err := s.CheckAndSetDefaults(); err != nil {\n\t\t\treturn nil, trace.Wrap(err)\n\t\t}\n\t\tif cfg.ID != 0 {\n\t\t\ts.SetResourceID(cfg.ID)\n\t\t}\n\t\tif !cfg.Expires.IsZero() {\n\t\t\ts.SetExpiry(cfg.Expires)\n\t\t}\n\t\treturn &s, nil\n\t}\n\treturn nil, trace.BadParameter(\"windows desktop resource version %q is not supported\", h.Version)\n}", "func (api API) AppList() (list AppList, err error) {\n\n\tbearer, err := api.Authenticator.GetToken(\"code:all\")\n\tif err != nil {\n\t\treturn\n\t}\n\tpath := api.Authenticator.GetHostPath() + api.DesignAutomationPath\n\tlist, err = listApps(path, bearer.AccessToken)\n\n\treturn\n}", "func (cache *LedisCacheStorage) GetApp(appID string) *core.App {\n\tdata, err := cache.db.Get([]byte(\"app:\" + appID))\n\n\tif err != nil {\n\t\t_, _ = fmt.Fprintf(os.Stderr, \"Ledis Cache: failed to parse cached app %v\\n\", err)\n\t\treturn nil\n\t}\n\n\tif data == nil {\n\t\treturn nil\n\t}\n\n\treturn &core.App{\n\t\tAppID: appID,\n\t\tName: string(data),\n\t}\n}", "func (o OpenSignal) ViewAnApp(appID string) (App, error) {\n\tstrResponse := []App{}\n\n\tURL := f(viewAnAppURL, appID)\n\tres, body, errs := o.Client.Get(URL).\n\t\tSet(\"Authorization\", \"Basic \"+o.AuthKey).\n\t\tEndStruct(&strResponse)\n\terr := catch(res, body)\n\tif err == nil {\n\t\tfor _, e := range errs {\n\t\t\tif e != nil {\n\t\t\t\terr = e\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tout := App{}\n\tif len(strResponse) > 0 {\n\t\tout = strResponse[0]\n\t}\n\treturn out, err\n}", "func AppGetByName(ctx *Context, name string) (*Application, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(\"application\")\n\tparams := make(url.Values)\n\tparams.Set(\"filter\", \"app_name\")\n\tparams.Set(\"eq\", name)\n\tb, err := doJSON(ctx, \"GET\", uri, h, params, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar appRes = struct {\n\t\tD []*Application `json:\"d\"`\n\t}{}\n\terr = json.Unmarshal(b, &appRes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(appRes.D) > 0 {\n\t\treturn appRes.D[0], nil\n\t}\n\treturn nil, errors.New(\"application not found\")\n}", "func parseEntry(r io.Reader, lang string) (*Entry, error) {\n\tvar err error\n\trv := &Entry{}\n\n\tb := bufio.NewScanner(r)\n\tfor b.Scan() {\n\t\tl := b.Text()\n\t\tif l == \"\" && len(l) < 5 {\n\t\t\tcontinue\n\t\t}\n\n\t\tif strings.HasPrefix(l, \"[Desktop Action\") {\n\t\t\tbreak\n\t\t}\n\n\t\tswitch l[0] {\n\t\tcase ' ', '#', '[', 'C', 'G', 'I', 'K', 'M', 'S', 'V', 'X':\n\t\t\tcontinue\n\t\tdefault:\n\t\t\tif err := parseLine(l, lang, rv); err == ErrHiddenEntry {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := b.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn rv, err\n}", "func GetAppInfo() model.App {\n\tvar err error\n\n\tconfigDir, err := os.UserConfigDir()\n\tif err != nil {\n\t\tlogrus.Fatalln(\"unable to read user configuration directory\\n%v\", err)\n\t}\n\n\tsep := string(os.PathSeparator)\n\n\tvar app model.App\n\tapp.Name = \"clencli\"\n\tapp.ConfigurationsDir = configDir + sep + app.Name\n\tapp.ConfigurationsName = \"configurations\"\n\tapp.ConfigurationsType = \"yaml\"\n\tapp.ConfigurationsPath = app.ConfigurationsDir + sep + app.ConfigurationsName + \".\" + app.ConfigurationsType\n\tapp.ConfigurationsPermissions = os.ModePerm\n\tapp.CredentialsName = \"credentials\"\n\tapp.CredentialsType = \"yaml\"\n\tapp.CredentialsPath = app.ConfigurationsDir + sep + app.CredentialsName + \".\" + app.CredentialsType\n\tapp.CredentialsPermissions = os.ModePerm\n\tapp.LogsDir = app.ConfigurationsDir\n\tapp.LogsName = \"logs\"\n\tapp.LogsType = \"json\"\n\tapp.LogsPath = app.LogsDir + sep + app.LogsName + \".\" + app.LogsType\n\tapp.LogsPermissions = os.ModePerm\n\n\tapp.WorkingDir, err = os.Getwd()\n\tif err != nil {\n\t\tfmt.Printf(\"Unable to detect the current directory\\n%v\", err)\n\t\tos.Exit(1)\n\t}\n\n\treturn app\n}", "func (m *IosiPadOSWebClip) GetAppUrl()(*string) {\n val, err := m.GetBackingStore().Get(\"appUrl\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func ReadApplicationConfig(d *schema.ResourceData, meta interface{}) error {\n\tinstanaAPI := meta.(restapi.InstanaAPI)\n\tapplicationConfigID := d.Id()\n\tif len(applicationConfigID) == 0 {\n\t\treturn errors.New(\"ID of application config is missing\")\n\t}\n\tapplicationConfig, err := instanaAPI.ApplicationConfigs().GetOne(applicationConfigID)\n\tif err != nil {\n\t\tif err == restapi.ErrEntityNotFound {\n\t\t\td.SetId(\"\")\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t}\n\treturn updateApplicationConfigState(d, applicationConfig)\n}", "func (m *Application) GetInfo()(InformationalUrlable) {\n return m.info\n}", "func GetApp() *cli.App {\n\tglobalFlags := map[string]cli.Flag{\n\t\t\"no-color\": &cli.BoolFlag{\n\t\t\tName: \"no-color\",\n\t\t\tUsage: \"Disable coloured output.\",\n\t\t},\n\t}\n\n\ttimerFlags := []cli.Flag{\n\t\t&cli.BoolFlag{\n\t\t\tName: \"disable-notifications\",\n\t\t\tAliases: []string{\"d\"},\n\t\t\tUsage: \"Disable the system notification after a session is completed.\",\n\t\t},\n\t\tglobalFlags[\"no-color\"],\n\t\t&cli.StringFlag{\n\t\t\tName: \"sound\",\n\t\t\tUsage: \"Play ambient sounds continuously during a session. Default options: coffee_shop, fireplace, rain,\\n\\t\\t\\t\\twind, summer_night, playground. Disable sound by setting to 'off'\",\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"sound-on-break\",\n\t\t\tAliases: []string{\"sob\"},\n\t\t\tUsage: \"Play ambient sounds during a break sessions.\",\n\t\t},\n\t}\n\n\tapp := &cli.App{\n\t\tName: \"Focus\",\n\t\tAuthors: []*cli.Author{\n\t\t\t{\n\t\t\t\tName: \"Ayooluwa Isaiah\",\n\t\t\t\tEmail: \"[email protected]\",\n\t\t\t},\n\t\t},\n\t\tUsage: \"Focus is a cross-platform productivity timer for the command-line. It is based on the Pomodoro Technique,\\n\\t\\ta time management method developed by Francesco Cirillo in the late 1980s.\",\n\t\tUsageText: \"[COMMAND] [OPTIONS]\",\n\t\tVersion: \"v1.2.0\",\n\t\tEnableBashCompletion: true,\n\t\tCommands: []*cli.Command{\n\t\t\t{\n\t\t\t\tName: \"resume\",\n\t\t\t\tUsage: \"Resume a previously interrupted work session\",\n\t\t\t\tFlags: timerFlags,\n\t\t\t\tAction: func(ctx *cli.Context) error {\n\t\t\t\t\tif ctx.Bool(\"no-color\") {\n\t\t\t\t\t\tdisableStyling()\n\t\t\t\t\t}\n\n\t\t\t\t\tstore, err := focus.NewStore()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tt := &focus.Timer{\n\t\t\t\t\t\tStore: store,\n\t\t\t\t\t}\n\n\t\t\t\t\terr = t.Resume()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tt.SetResumeOptions(ctx)\n\n\t\t\t\t\treturn t.Run()\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"stats\",\n\t\t\t\tUsage: \"Track your progress with detailed statistics reporting. Defaults to a reporting period of 7 days.\",\n\t\t\t\tAction: func(ctx *cli.Context) error {\n\t\t\t\t\tif ctx.Bool(\"no-color\") {\n\t\t\t\t\t\tpterm.DisableColor()\n\t\t\t\t\t}\n\n\t\t\t\t\tstore, err := focus.NewStore()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tstats, err := focus.NewStats(ctx, store)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tif ctx.Bool(\"delete\") {\n\t\t\t\t\t\treturn stats.Delete(os.Stdout, os.Stdin)\n\t\t\t\t\t}\n\n\t\t\t\t\tif ctx.Bool(\"list\") {\n\t\t\t\t\t\treturn stats.List(os.Stdout)\n\t\t\t\t\t}\n\n\t\t\t\t\tif len(stats.Tags) != 0 {\n\t\t\t\t\t\treturn stats.EditTag(os.Stdout, os.Stdin)\n\t\t\t\t\t}\n\n\t\t\t\t\treturn stats.Show(os.Stdout)\n\t\t\t\t},\n\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t&cli.BoolFlag{\n\t\t\t\t\t\tName: \"delete\",\n\t\t\t\t\t\tAliases: []string{\"d\"},\n\t\t\t\t\t\tUsage: \"Delete the all work sessions within the specified time period.\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.BoolFlag{\n\t\t\t\t\t\tName: \"list\",\n\t\t\t\t\t\tAliases: []string{\"l\"},\n\t\t\t\t\t\tUsage: \"List all the work sessions within the specified time period.\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"tag\",\n\t\t\t\t\t\tAliases: []string{\"t\"},\n\t\t\t\t\t\tUsage: \"Match only sessions with a specific tag\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"period\",\n\t\t\t\t\t\tAliases: []string{\"p\"},\n\t\t\t\t\t\tUsage: \"Specify a time period for (defaults to 7days). Possible values are: today, yesterday, 7days, 14days, 30days, 90days, 180days, 365days, all-time.\",\n\t\t\t\t\t\tValue: \"7days\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"start\",\n\t\t\t\t\t\tAliases: []string{\"s\"},\n\t\t\t\t\t\tUsage: \"Specify a start date in the following format: YYYY-MM-DD [HH:MM:SS PM].\",\n\t\t\t\t\t},\n\t\t\t\t\t&cli.StringFlag{\n\t\t\t\t\t\tName: \"end\",\n\t\t\t\t\t\tAliases: []string{\"e\"},\n\t\t\t\t\t\tUsage: \"Specify an end date in the following format: YYYY-MM-DD [HH:MM:SS PM] (defaults to the current time).\",\n\t\t\t\t\t},\n\t\t\t\t\tglobalFlags[\"no-color\"],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"max-sessions\",\n\t\t\t\tAliases: []string{\"max\"},\n\t\t\t\tUsage: \"The maximum number of work sessions (unlimited by default).\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"short-break\",\n\t\t\t\tAliases: []string{\"s\"},\n\t\t\t\tUsage: \"Short break duration in minutes (default: 5).\",\n\t\t\t},\n\t\t\t&cli.StringFlag{\n\t\t\t\tName: \"tag\",\n\t\t\t\tAliases: []string{\"t\"},\n\t\t\t\tUsage: \"Add a tag to a session\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"long-break\",\n\t\t\t\tAliases: []string{\"l\"},\n\t\t\t\tUsage: \"Long break duration in minutes (default: 15).\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"long-break-interval\",\n\t\t\t\tAliases: []string{\"int\"},\n\t\t\t\tUsage: \"The number of work sessions before a long break (default: 4).\",\n\t\t\t},\n\t\t\t&cli.UintFlag{\n\t\t\t\tName: \"work\",\n\t\t\t\tAliases: []string{\"w\"},\n\t\t\t\tUsage: \"Work duration in minutes (default: 25).\",\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx *cli.Context) error {\n\t\t\tif ctx.Bool(\"no-color\") {\n\t\t\t\tdisableStyling()\n\t\t\t}\n\n\t\t\tstore, err := focus.NewStore()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tconfig, err := focus.NewConfig()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tt := focus.NewTimer(ctx, config, store)\n\n\t\t\treturn t.Run()\n\t\t},\n\t}\n\n\tapp.Flags = append(app.Flags, timerFlags...)\n\n\treturn app\n}", "func RRReadConfig() {\n\tfolderPath, err := osext.ExecutableFolder()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t// fmt.Printf(\"Executable folder = %s\\n\", folderPath)\n\tfname := folderPath + \"/conf.json\"\n\t_, err = os.Stat(fname)\n\tif nil != err {\n\t\tfmt.Printf(\"RRReadConfig: error reading %s: %v\\n\", fname, err)\n\t\tos.Exit(1)\n\t}\n\tcontent, err := ioutil.ReadFile(fname)\n\tErrcheck(err)\n\tErrcheck(json.Unmarshal(content, &AppConfig))\n\t// fmt.Printf(\"RRReadConfig: AppConfig = %#v\\n\", AppConfig)\n}", "func (i *API) Read(kind, key string) ([]byte, error) {\n\treturn i.primaryStore.RawRead(kind, key)\n}", "func (tc TeresaClient) GetAppDetail(teamID, appID int64) (app *models.App, err error) {\n\tparams := apps.NewGetAppDetailsParams().WithTeamID(teamID).WithAppID(appID)\n\tr, err := tc.teresa.Apps.GetAppDetails(params, tc.apiKeyAuthFunc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn r.Payload, nil\n}", "func ReadMain(r io.Reader) (Main, error) {\n\tcfg := MakeDefault()\n\n\t_, err := toml.DecodeReader(r, &cfg)\n\tif err != nil {\n\t\treturn cfg, errors.Wrap(err, \"parsing error\")\n\t}\n\tif cfg.PprofPort == cfg.PromPort {\n\t\treturn cfg, errors.New(\"PromPort and PprofPort can't have the same value\")\n\t}\n\treturn cfg, nil\n}", "func (app *App) Get(uuid gocql.UUID) (a *teoapi.Application, err error) {\n\ta = &teoapi.Application{UUID: uuid}\n\tstmt, names := qb.Select(\"applications\").Where(qb.Eq(\"uuid\")).Limit(1).ToCql()\n\tq := gocqlx.Query(app.tre.session.Query(stmt), names).BindMap(qb.M{\n\t\t\"uuid\": uuid,\n\t})\n\tif err = q.GetRelease(a); err != nil {\n\t\tfmt.Printf(\"Get Error: %s\\n\", err.Error())\n\t\treturn\n\t}\n\ta.Com, err = app.tre.com.List(uuid)\n\treturn\n}", "func (c *Config) GetApp(name string) *ConfigApplication {\n\tfor _, ca := range c.Applications {\n\t\tif ca.Name == name {\n\t\t\treturn &ca\n\t\t}\n\t}\n\treturn nil\n}", "func ReadManifest(name string) (Manifest, error) {\n\tf, err := os.Open(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\n\tvar m Manifest\n\tif err := json.NewDecoder(f).Decode(&m); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m, nil\n}", "func GetFlinkApplication(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *FlinkApplicationState, opts ...pulumi.ResourceOption) (*FlinkApplication, error) {\n\tvar resource FlinkApplication\n\terr := ctx.ReadResource(\"aiven:index/flinkApplication:FlinkApplication\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func AppGetByID(ctx *Context, id int64) (*Application, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(fmt.Sprintf(\"application(%d)\", id))\n\tb, err := doJSON(ctx, \"GET\", uri, h, nil, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar appRes = struct {\n\t\tD []*Application `json:\"d\"`\n\t}{}\n\terr = json.Unmarshal(b, &appRes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(appRes.D) > 0 {\n\t\treturn appRes.D[0], nil\n\t}\n\treturn nil, errors.New(\"application not found\")\n}", "func (h *provider) Read(ctx wfContext.Context, v *value.Value, act types.Action) error {\n\tobj := new(unstructured.Unstructured)\n\tif err := v.UnmarshalTo(obj); err != nil {\n\t\treturn err\n\t}\n\tkey, err := client.ObjectKeyFromObject(obj)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif key.Namespace == \"\" {\n\t\tkey.Namespace = \"default\"\n\t}\n\tif err := h.cli.Get(context.Background(), key, obj); err != nil {\n\t\treturn err\n\t}\n\treturn v.FillObject(obj.Object, \"result\")\n}", "func (s Store) GetApplicationWithVersion(title, version string) (utils.Metadata, error) {\n\tvar metadata utils.Metadata\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\tif exists, err := s.isApplicationPresent(title, version); !exists {\n\t\treturn metadata, err\n\t}\n\n\treturn s.appToDetails[title][version], nil\n\n}", "func Open(peFile []byte) ([]byte, error) {\n\tportableExecutable, err := windows.GetPortableExecutable(peFile)\n\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tvar targetExecutable = windows.TargetExecutable{*portableExecutable}\n\t_, rawPayload, err := targetExecutable.GetPayload()\n\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\treturn rawPayload, nil\n}", "func (m *WindowsInformationProtectionAppLearningSummary) GetApplicationName()(*string) {\n return m.applicationName\n}", "func Get(c *deis.Client, appID string) (api.App, error) {\n\tu := fmt.Sprintf(\"/v2/apps/%s/\", appID)\n\n\tres, reqErr := c.Request(\"GET\", u, nil)\n\tif reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {\n\t\treturn api.App{}, reqErr\n\t}\n\tdefer res.Body.Close()\n\n\tapp := api.App{}\n\n\tif err := json.NewDecoder(res.Body).Decode(&app); err != nil {\n\t\treturn api.App{}, err\n\t}\n\n\treturn app, reqErr\n}", "func GetApplication(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *ApplicationState, opts ...pulumi.ResourceOption) (*Application, error) {\n\tvar resource Application\n\terr := ctx.ReadResource(\"alicloud:edas/application:Application\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func ReadConfiAppNum(filenamePath string) int {\n\n\tvar appNum int\n\tflag, flag1 := true, true\n\tfile, err := os.Open(filenamePath)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\tscanner.Split(bufio.ScanWords)\n\n\tfor flag {\n\t\tscanner.Scan()\n\t\tif scanner.Text() != \"END\" {\n\t\t\tif scanner.Text() == \"Application\" {\n\n\t\t\t\tfor flag1 {\n\t\t\t\t\tscanner.Scan()\n\t\t\t\t\tif scanner.Text() == \"number\" {\n\t\t\t\t\t\tscanner.Scan()\n\t\t\t\t\t\tflag1 = false\n\t\t\t\t\t\tnum := scanner.Text()\n\n\t\t\t\t\t\tappNum, err = strconv.Atoi(num)\n\t\t\t\t\t} else if scanner.Text() == \"END\" {\n\t\t\t\t\t\tflag1 = false\n\t\t\t\t\t\tflag = false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if scanner.Text() == \"END\" {\n\t\t\t\tflag1 = false\n\t\t\t\tflag = false\n\t\t\t}\n\t\t} else if scanner.Text() == \"END\" {\n\t\t\tflag1 = false\n\t\t\tflag = false\n\t\t}\n\n\t\tflag = false\n\t}\n\treturn appNum\n\n}", "func (d *swiftDriver) ReadManifest(account keppel.Account, repoName string, manifestDigest digest.Digest) ([]byte, error) {\n\tc, _, err := d.getBackendConnection(account)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\to := manifestObject(c, repoName, manifestDigest)\n\treturn o.Download(nil).AsByteSlice()\n}", "func Read(stub *shim.ChaincodeStub, args []string) ([]byte, error) {\r\n\tvar key, jsonResp string\r\n\tvar err error\r\n\t\r\n\tif len(args) != 1 {\r\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting name of the key to query\")\r\n\t}\r\n\r\n\tkey = args[0]\r\n\tvalAsbytes, err := stub.GetState(key)\r\n\t\r\n\tif err != nil {\r\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + key + \"\\\"}\"\r\n\t\treturn []byte(jsonResp), err\r\n\t}\r\n\t\r\n\tif valAsbytes == nil {\r\n\t\treturn []byte(\"Did not find entry for key: \" + key), nil\r\n\t}\r\n\treturn valAsbytes, nil\r\n}", "func (ar AppResource) Get(ctx context.Context, r *http.Request) (int, interface{}) {\n\terr := requireScope(ctx, \"read:app\")\n\tif err != nil {\n\t\treturn http.StatusUnauthorized, err\n\t}\n\tu := getCurrentUser(ctx)\n\tmctx := getModelContext(ctx)\n\taId := params(ctx, \"id\")\n\tif aId == \"\" {\n\t\treturn http.StatusBadRequest, \"app id not given\"\n\t}\n\tid, err := strconv.Atoi(aId)\n\tif err != nil {\n\t\treturn http.StatusBadRequest, err\n\t}\n\tqueryApp, err := app.GetApp(mctx, id)\n\tif err != nil {\n\t\tif err == app.ErrAppNotFound {\n\t\t\treturn http.StatusBadRequest, \"app doesn't exist\"\n\t\t}\n\t\treturn http.StatusBadRequest, err\n\t}\n\trole, err := group.GetRoleOfUser(mctx, u.GetId(), queryApp.AdminGroupId)\n\tif role != group.ADMIN {\n\t\treturn http.StatusForbidden, \"only admins of the app can read it\"\n\t}\n\tresp := &App{\n\t\tId: queryApp.Id,\n\t\tFullName: queryApp.FullName,\n\t\tSecret: queryApp.Secret,\n\t\tRedirectUri: queryApp.RedirectUri,\n\t}\n\treturn http.StatusOK, resp\n}", "func Parse(r io.Reader) (Application, error) {\n\tcfg := Application{}\n\tif err := yaml.NewDecoder(r).Decode(&cfg); err != nil {\n\t\treturn Application{}, err\n\t}\n\tapp := Application{\n\t\tGracefulWait: cfg.GracefulWait * time.Second,\n\t\tReadTimeout: cfg.ReadTimeout * time.Second,\n\t\tWriteTimeout: cfg.WriteTimeout * time.Second,\n\t\tIdleTimeout: cfg.IdleTimeout * time.Second,\n\t\tHost: cfg.Host,\n\t\tPort: cfg.Port,\n\t\tPostgres: cfg.Postgres,\n\t}\n\treturn app, nil\n}", "func (rp *Ringpop) App() string {\n\treturn rp.app\n}", "func GetApplication(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *ApplicationState, opts ...pulumi.ResourceOption) (*Application, error) {\n\tvar resource Application\n\terr := ctx.ReadResource(\"aws:kinesisanalyticsv2/application:Application\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (c Client) FetchApp() (*Identity, error) {\n\treturn c.fetchApp()\n}", "func ApplicationShow(w http.ResponseWriter, r *http.Request) {\n\tdb, err := database.Connect()\n\tdefer db.Close()\n\tif err != nil {\n\t\tlog.Printf(\"Database error: '%s'\\n\", err)\n\t\tjre := jsonutil.NewJSONResponseError(\n\t\t\thttp.StatusInternalServerError,\n\t\t\t\"there was an error when attempting to connect to the database\")\n\t\tjsonutil.RespondJSONError(w, jre)\n\t\treturn\n\t}\n\n\tid := bone.GetValue(r, \"uuid\")\n\tapp, err := resources.GetApplication(db, id, resources.GetApplicationPods)\n\tif err != nil {\n\t\tlog.Printf(\"Error when retrieving application: '%s'\\n\", err)\n\t\tjre := jsonutil.NewJSONResponseError(\n\t\t\thttp.StatusInternalServerError,\n\t\t\t\"there was an error when retrieving application\")\n\t\tjsonutil.RespondJSONError(w, jre)\n\t\treturn\n\t}\n\n\tjson.NewEncoder(w).Encode(app)\n}", "func (s *AppStorage) GetByName(ctx context.Context, name string) (*types.App, error) {\n\n\tlog.V(logLevel).Debugf(\"Storage: App: get by name: %s\", name)\n\n\tif len(name) == 0 {\n\t\terr := errors.New(\"name can not be empty\")\n\t\tlog.V(logLevel).Errorf(\"Storage: App: get app err: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\tclient, destroy, err := s.Client()\n\tif err != nil {\n\t\tlog.V(logLevel).Errorf(\"Storage: App: create client err: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\tdefer destroy()\n\n\tapp := new(types.App)\n\tkeyMeta := keyCreate(appStorage, name, \"meta\")\n\tif err := client.Get(ctx, keyMeta, &app.Meta); err != nil {\n\t\tlog.V(logLevel).Errorf(\"Storage: App: get app `%s` meta err: %s\", name, err.Error())\n\t\treturn nil, err\n\t}\n\n\treturn app, nil\n}", "func ReadAppAndDepnConfi(dependold [][]int, appNumOld int) ([]appproperties.ApplProperty, [][]int, int, int) {\n\tvar appfile, appfileConstraint, depndfile string\n\tif appNumOld < 200 {\n\t\t//fmt.Println(\"/Users/abdullah/go/src/github.com/appSchedul/souceFile/depndConfiNewArrive20.cog\")\n\t\tappfile = \"/Users/abdullah/go/src/github.com/appSchedul/souceFile/appConfiNewArrive20.cog\"\n\t\tappfileConstraint = \"/Users/abdullah/go/src/github.com/appSchedul/souceFile/appConstNewArrive20.cog\"\n\t\tdepndfile = \"/Users/abdullah/go/src/github.com/appSchedul/souceFile/depndConfiNewArrive20.cog\"\n\t} else {\n\t\t//fmt.Println(\"/Users/abdullah/go/src/github.com/appSchedul/souceFile/depndConfiNewArrive200.cog\")\n\t\tappfile = \"/Users/abdullah/go/src/github.com/appSchedul/souceFile/appConfiNewArrive20.cog\"\n\t\tappfileConstraint = \"/Users/abdullah/go/src/github.com/appSchedul/souceFile/appConstNewArrive20.cog\"\n\t\tdepndfile = \"/Users/abdullah/go/src/github.com/appSchedul/souceFile/depndConfiNewArrive200.cog\"\n\t}\n\tvar ap string // application name fill the struct\n\tvar apCPU int // application cpu fill the struct\n\tvar apRAM int // application ram fill the struct\n\tvar apIO string // application io fill the struct\n\tj := 0\n\tappNum := readappnum.ReadConfiAppNum(appfile) //read application number form the file\n\tappName := make([]string, appNum)\n\tappName = readappname.ReadConfiAppname(appfile) //read application name form the file\n\tvar applic = make([]appproperties.ApplProperty, appNum) //build applications infromation calss\n\tfor i := appNumOld; i < appNumOld+appNum; i++ { //fill application from config file\n\n\t\tap = \"A\" + strconv.Itoa(j)\n\t\tapCPU = appfillconstraints.ReadAppConstraintsCPU(appfileConstraint, ap)\n\t\tapRAM = appfillconstraints.ReadAppConstraintsRAM(appfileConstraint, ap)\n\t\tapIO = appfillconstraints.ReadAppConstraintsIO(appfileConstraint, ap)\n\t\tap = \"A\" + strconv.Itoa(i)\n\t\tapplic[j].ApplPropertyFu(appName[j], ap, 1, apCPU, apRAM, apIO) //fill the application spicification array\n\t\tj++\n\t}\n\t//finsh reading application informations\n\n\t//start reading applications dependencies\n\tvar depen = make([][]int, appNum)\n\tvar newAppDepen = make([][]int, appNum)\n\tdepen = appdepe.ReadConfiAppDep(appfile, depndfile, appNumOld)\n\t//m := 0\n\tfor i := 0; i < appNum; i++ {\n\t\tnewAppDepen[i] = depen[i] //this the dependencies of the new arrival applications\n\t}\n\n\t// comaining the dependencies matrix old application dependencies and new arrival applications dependencies\n\tcompAppdepen := make([][]int, appNum+appNumOld)\n\n\tfor i := 0; i < appNum+appNumOld; i++ {\n\t\tcompAppdepen[i] = make([]int, appNum+appNumOld)\n\n\t\tfor j := 0; j < appNum+appNumOld; j++ {\n\n\t\t\tif i < appNumOld {\n\t\t\t\tif j < appNumOld {\n\t\t\t\t\tcompAppdepen[i][j] = dependold[i][j]\n\t\t\t\t} else {\n\t\t\t\t\tcompAppdepen[i][j] = 0\n\t\t\t\t}\n\t\t\t} else {\n\n\t\t\t\tcompAppdepen[i][j] = newAppDepen[i-appNumOld][j]\n\n\t\t\t}\n\t\t}\n\n\t}\n\n\tdepndNum := appdepe.ReadDependNum(compAppdepen, appNum+appNumOld) //count the dpendentst number\n\treturn applic, compAppdepen, depndNum, appNum + appNumOld\n}", "func (m *ServicePrincipalRiskDetection) GetAppId()(*string) {\n val, err := m.GetBackingStore().Get(\"appId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (m *ProgramControl) GetProgram()(Programable) {\n val, err := m.GetBackingStore().Get(\"program\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(Programable)\n }\n return nil\n}", "func extractAppDefinition(jsonContent []byte) (*v2.ApplicationDefinition, error) {\n\tapplication := &v2.ApplicationDefinition{}\n\terr := json.Unmarshal(jsonContent, &application)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn application, nil\n}", "func nativeFromApp(app interface{}) *gobject.GValue {\n\targapp, ok := app.(*Application)\n\tif ok {\n\t\tgv := gobject.CreateCGValue(GtkType.APPLICATION, argapp.ToNative())\n\t\treturn gv\n\t}\n\n\treturn nil\n}", "func (am *ArtifactMap) GetRandomApp(sessionState *State) (ArtifactEntry, error) {\n\tam.mu.Lock()\n\tdefer am.mu.Unlock()\n\n\tn := len(am.AppList)\n\tif n < 1 {\n\t\treturn ArtifactEntry{}, errors.New(\"cannot select random app: ArtifactMap is empty\")\n\t}\n\trandomIndex := sessionState.Randomizer().Rand(n)\n\tselectedKVP := am.AppList[randomIndex]\n\treturn *selectedKVP, nil\n}", "func GetProgram(pid int64) (string, error) {\n\t// Readlink needs root permission\n\t// return os.Readlink(fmt.Sprintf(\"/proc/%d/exe\", pid))\n\n\trs, err := rawProcStatus(pid)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn rs.Name, nil\n}", "func (t *SimpleChaincode) read(stub *shim.ChaincodeStub, args []string) ([]byte, error) {\n\tvar key, jsonResp string\n\tvar err error\n\n\tif len(args) != 1 {\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting name of the key to query\")\n\t}\n\n\tkey = args[0]\n\tvalAsbytes, err := stub.GetState(key)\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + key + \"\\\"}\"\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\n\treturn valAsbytes, nil\n}", "func (a *InformationAPIService) GetApp(ctx context.Context, pkg string) (AppInfo, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue AppInfo\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/info/getapp\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\tlocalVarQueryParams.Add(\"package\", parameterToString(pkg, \"\"))\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\", \"application/xml\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\n\t\t\tlocalVarQueryParams.Add(\"apikey\", key)\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode < 300 {\n\t\t// If we succeed, return the data, otherwise pass on to decode error.\n\t\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\tif err == nil {\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t\t}\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\n\t\tif localVarHTTPResponse.StatusCode == 200 {\n\t\t\tvar v AppInfo\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\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "func (d *Activity) ARead() error {\n\treturn nil\n}", "func (l *localLinker) Read(ctx context.Context, req *pbd.ReadRequest) (*pbd.ReadResponse, error) {\n\tif val, ok := l.store[req.Key]; ok {\n\t\treturn &pbd.ReadResponse{Payload: val}, nil\n\t}\n\treturn nil, status.Error(codes.InvalidArgument, fmt.Sprintf(\"Unable to locate %v\", req.Key))\n}", "func (m *Application) GetDescription()(*string) {\n return m.description\n}", "func readInput() (src string, err error) {\n\tin := os.Args\n\tsrc = in[1]\n\tif src == \"\" {\n\t\treturn src, errors.New(\"missing string to match\")\n\t}\n\treturn src, nil\n}", "func (k Keeper) GetApp(ctx sdk.Ctx, address sdk.Address) (a exported.ApplicationI, found bool) {\n\ta = k.appKeeper.Application(ctx, address)\n\tif a == nil {\n\t\treturn a, false\n\t}\n\treturn a, true\n}", "func (a *API) GetApplication(appEUI lorawan.EUI64, app *Application) error {\n\tvar err error\n\t*app, err = GetApplication(a.ctx.DB, appEUI)\n\treturn err\n}", "func GetApp(c echo.Context) error {\n\tid := c.Param(\"id\")\n\tfmt.Println(\"id passed in : \", id)\n\tvar app models.App\n\tsqlStatment := `SELECT id, appname, disabled, globaldisablemessage FROM apps WHERE id=$1;`\n\trow := d.QueryRow(sqlStatment, id)\n\terr := row.Scan(&app.ID, &app.Appname, &app.Disabled, &app.GlobalDisableMessage)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.JSON(http.StatusOK, app)\n}", "func AppCreate(ctx *Context, name string, typ DeviceType) (*Application, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(\"application\")\n\tdata := make(map[string]interface{})\n\tdata[\"app_name\"] = name\n\tdata[\"device_type\"] = typ.String()\n\tbody, err := marhsalReader(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb, err := doJSON(ctx, \"POST\", uri, h, nil, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trst := &Application{}\n\terr = json.Unmarshal(b, rst)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn rst, nil\n}", "func available_apps_list(av_app bool){\n\tapp_data := json_parser.ParseApplications(\"test/application.json\")\n\tfor k, _ := range app_data {\n\t\tfmt.Println(k)\n\t}\n}", "func (m *metaObject) readMetadata(pth string) ([]byte, error) {\n\trdr, err := m.meta.Get(m.contexter(), pth)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ioutil.ReadAll(rdr)\n}", "func (obj *Doc) GetAppPropertiesRaw(ctx context.Context) (json.RawMessage, error) {\n\tresult := &struct {\n\t\tProp json.RawMessage `json:\"qProp\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetAppProperties\", result)\n\treturn result.Prop, err\n}", "func (c *Configs) App() *AppConfig {\n\treturn c.chassixConfigs[KeyAppConfig].(*AppConfig)\n}", "func readConfig() (*whatphone.API, error) {\n\tconfigFile, err := getConfigFile()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tf, err := os.Open(configFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\n\treturn loadConfig(f)\n}", "func (t *SimpleChaincode) read(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\tvar key, jsonResp string\n\tvar err error\n\n\tif len(args) != 1 {\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting name of the key to query\")\n\t}\n\n\tkey = args[0]\n\tvalAsbytes, err := stub.GetState(key)\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + key + \"\\\"}\"\n\n\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\n\treturn valAsbytes, nil\n}", "func (t *SimpleChaincode) read(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\tvar key, jsonResp string\n\tvar err error\n\n\tif len(args) != 1 {\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting name of the key to query\")\n\t}\n\n\tkey = args[0]\n\tvalAsbytes, err := stub.GetState(key)\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + key + \"\\\"}\"\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\n\treturn valAsbytes, nil\n}", "func (t *SimpleChaincode) read(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\tvar key, jsonResp string\n\tvar err error\n\n\tif len(args) != 1 {\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting name of the key to query\")\n\t}\n\n\tkey = args[0]\n\tvalAsbytes, err := stub.GetState(key)\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + key + \"\\\"}\"\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\n\treturn valAsbytes, nil\n}", "func GetApp(host string, port int, configPath string, debug bool, logger zap.Logger, fast, test bool) *App {\n\tapp := &App{\n\t\tID: \"default\",\n\t\tTest: test,\n\t\tFast: fast,\n\t\tHost: host,\n\t\tPort: port,\n\t\tConfigPath: configPath,\n\t\tConfig: viper.New(),\n\t\tDebug: debug,\n\t\tLogger: logger,\n\t\tReadBufferSize: 30000,\n\t}\n\n\tapp.Configure()\n\treturn app\n}", "func (a *App) Metadata() map[string]string { return a.opts.metadata }", "func makeApp(def pchannel.App, data pchannel.Data) perun.App {\n\treturn perun.App{\n\t\tDef: def,\n\t\tData: data,\n\t}\n}", "func (t *SimpleChaincode) read(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n var name, jsonResp string\n var err error\n\n if len(args) != 1 {\n return nil, errors.New(\"Incorrect number of arguments. Expecting name of the var to query\")\n }\n\n name = args[0]\n valAsbytes, err := stub.GetState(name)\n if err != nil {\n jsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + name + \"\\\"}\"\n return nil, errors.New(jsonResp)\n }\n\n return valAsbytes, nil\n}", "func ReadText(text string) (*il.Program, error) {\n\tp := il.NewProgram()\n\tif err := MergeText(text, p); err != nil {\n\t\treturn nil, err\n\t}\n\treturn p, nil\n}", "func (app *App) List() (listApp []Applist, err error) {\n\tstmt, names := qb.Select(\"applications\").Columns(\"uuid\", \"name\").ToCql()\n\tq := gocqlx.Query(app.tre.session.Query(stmt), names)\n\tif err = q.SelectRelease(&listApp); err != nil {\n\t\tfmt.Printf(\"List Commands Error: %s\\n\", err.Error())\n\t}\n\treturn\n}", "func Read(r io.Reader) (manifest *Manifest, err error) {\n\tmanifest = new(Manifest)\n\terr = xml.NewDecoder(r).Decode(&manifest)\n\treturn\n}", "func LoadFromSingleFile(path string, r io.Reader, ops ...func(*types.App) error) (*types.App, error) {\n\tdata, err := ioutil.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error reading single-file\")\n\t}\n\n\tparts := splitSingleFile(data)\n\tif len(parts) != 3 {\n\t\treturn nil, errors.Errorf(\"malformed single-file application: expected 3 documents, got %d\", len(parts))\n\t}\n\n\t// 0. is metadata\n\tmetadata := bytes.NewBuffer(parts[0])\n\t// 1. is compose\n\tcompose := bytes.NewBuffer(parts[1])\n\t// 2. is parameters\n\tparams := bytes.NewBuffer(parts[2])\n\n\tappOps := append([]func(*types.App) error{\n\t\ttypes.WithComposes(compose),\n\t\ttypes.WithParameters(params),\n\t\ttypes.Metadata(metadata),\n\t\ttypes.WithCRLF(useCRLF(data)),\n\t}, ops...)\n\treturn types.NewApp(path, appOps...)\n}", "func NewApp(reader reader.Reader) (*App, error) {\n\tapp := &App{}\n\terr := app.configure(reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn app, nil\n}", "func ReadPipeOrFile(fileName string) (*AppInputData, error) {\n\tres := AppInputData{}\n\tif !isatty.IsTerminal(os.Stdin.Fd()) {\n\t\tres.Reader = os.Stdin\n\t\tres.IsPipe = true\n\t} else {\n\t\tif fileName == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"no piped data and no file provided\")\n\t\t}\n\t\tfile, _ := os.Open(fileName)\n\t\tres.Reader = io.Reader(file)\n\t}\n\treturn &res, nil\n}", "func (d *DB) LoadApp(ctx context.Context, key string) (*App, error) {\n\tlog := logger.FromContext(ctx)\n\n\tif d.verbose {\n\t\tlog.Log(\n\t\t\t\"msg\", \"loading app\",\n\t\t)\n\t}\n\n\tparts := strings.Split(key, \"-\")\n\tif len(parts) != 2 {\n\t\treturn nil, errors.New(\"invalid key\")\n\t}\n\n\tsql := `SELECT uid, app_name, scope, rate FROM applications WHERE uid = $1 AND key_hash = crypt($2, key_hash)`\n\n\tvar app App\n\n\terr := d.DB.Get(&app, sql, parts[0], parts[1])\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to get app from DB\")\n\t}\n\n\treturn &app, nil\n}", "func (app *App) ParseExtras(country string) error {\n\tif app == nil || app.ID == 0 {\n\t\treturn ErrParseFailed\n\t}\n\tif country == \"\" {\n\t\tcountry = \"cn\"\n\t}\n\n\turl := fmt.Sprintf(\"https://itunes.apple.com/%s/app/id%d\",\n\t\tstrings.ToLower(country),\n\t\tapp.ID,\n\t)\n\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\t_ = res.Body.Close()\n\t}()\n\tdoc, err := goquery.NewDocumentFromReader(res.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// quick selector\n\tleft := doc.Find(`#left-stack`)\n\tmid := doc.Find(`div.center-stack`)\n\tul := left.Find(`ul.list:first-of-type`)\n\n\t// app.Screenshots\n\tapp.Screenshots = merge(app.Screenshots,\n\t\tgetAttrList(mid.Find(`img[itemprop=\"screenshot\"]`), \"src\"))\n\n\t// app.Copyright\n\tapp.Copyright = getText(ul.Find(\"li.copyright\"))\n\n\t// app.Platforms\n\tplatform := make(map[string]bool, 6)\n\tif app.Kind == \"mac-software\" {\n\t\tplatform[\"macOS\"] = true\n\t}\n\n\t// app.Devices fill\n\tif systemStr := getText(left.Find(`span[itemprop=\"operatingSystem\"]`)); systemStr != \"\" {\n\t\tif strings.Contains(systemStr, \"OS X\") || strings.Contains(systemStr, \"macOS\") {\n\t\t\tplatform[\"macOS\"] = true\n\t\t\tif strings.Contains(systemStr, \"64\") {\n\t\t\t\tapp.Devices = append(app.Devices, \"x64\")\n\t\t\t} else if strings.Contains(systemStr, \"32\") {\n\t\t\t\tapp.Devices = append(app.Devices, \"x86\")\n\t\t\t} else {\n\t\t\t\tapp.Devices = append(app.Devices, \"mac\")\n\t\t\t}\n\t\t}\n\t\tif strings.Contains(systemStr, \"tvOS\") {\n\t\t\tplatform[\"AppleTV\"] = true\n\t\t}\n\t}\n\n\t// infer iPhone,iPad,iPod support from Device\n\tapp.Devices = merge(app.Devices)\n\tdeviceList := strings.Join(app.Devices, \",\")\n\tplatform[\"iPad\"] = strings.Contains(deviceList, \"iPad\")\n\tplatform[\"iPhone\"] = strings.Contains(deviceList, \"iPhone\")\n\tplatform[\"iPod\"] = strings.Contains(deviceList, \"iPod\")\n\tplatform[\"AppleTV\"] = strings.Contains(deviceList, \"AppleTV\")\n\n\t// infer iPhone, iPad support from left stack badge\n\tif PadnPhone := getText(left.Find(\"div.fat-binary-blurb span:last-of-type\")); PadnPhone != \"\" {\n\t\tif strings.Contains(PadnPhone, \"iPhone\") {\n\t\t\tplatform[\"iPhone\"] = true\n\t\t}\n\t\tif strings.Contains(PadnPhone, \"iPad\") {\n\t\t\tplatform[\"iPad\"] = true\n\t\t}\n\t}\n\n\t// infer iWatch supoort from iWatch badge or label\n\tif t := getText(left.Find(\"div.works-on-apple-watch span:last-of-type\")); t != \"\" {\n\t\tplatform[\"iWatch\"] = true\n\t} else if len(left.Find(\"span.works-on-apple-watch-badge\").Nodes) > 0 {\n\t\tplatform[\"iWatch\"] = true\n\t}\n\n\t// infer AppleTV from left stack label\n\tif !platform[\"AppleTv\"] {\n\t\tleft.Find(\"div.application span.label\").Map(func(ind int, s *goquery.Selection) string {\n\t\t\tif s.Text() == \"Apple TV: \" {\n\t\t\t\tplatform[\"AppleTV\"] = true\n\t\t\t}\n\t\t\treturn \"\"\n\t\t})\n\t}\n\n\t// infer iMessage support from left stack label\n\tif len(left.Find(\"offers-i-message-app-badge\").Nodes) > 0 {\n\t\tplatform[\"iMessage\"] = true\n\t}\n\n\t// sort platforms\n\tvar platformList []string\n\tfor k, ok := range platform {\n\t\tif ok {\n\t\t\tplatformList = append(platformList, k)\n\t\t}\n\t}\n\tsort.Strings(platformList)\n\tapp.Platforms = platformList\n\n\t// app.InAppPurchase\n\tapp.InAppPurchase = left.Find(\"div.in-app-purchases ol.list li\").Map(func(ind int, s *goquery.Selection) string {\n\t\titemTitle := s.Find(\"span.in-app-title\").Text()\n\t\titemPrice := s.Find(\"span.in-app-price\").Text()\n\t\treturn fmt.Sprintf(\"%d:%s:%s\", ind+1, itemPrice, itemTitle)\n\t})\n\n\t// app.SiblingApps\n\tapp.SiblingApps = stringSliceToInt(getAttrList(left.Find(\"div.more-by > ul.list > li > div\"), \"adam-id\"))\n\n\t// app.RelatedApps\n\tapp.RelatedApps = stringSliceToInt(getAttrList(mid.Find(\"div.lockup.application.small\"), \"adam-id\"))\n\n\t// app.SupportSites\n\tsupport := make(map[string]string, 0)\n\tmid.Find(`a.see-all[rel=\"nofollow\"]`).Map(func(ind int, s *goquery.Selection) string {\n\t\tsupport[s.Text()], _ = s.Attr(\"href\")\n\t\treturn \"\"\n\t})\n\tif len(support) == 0 {\n\t\tapp.SupportSites = \"\"\n\t} else {\n\t\tif body, err := json.MarshalIndent(support, \"\", \" \"); err == nil {\n\t\t\tif sb := string(body); sb != \"\" && sb != \"null\" {\n\t\t\t\tapp.SupportSites = sb\n\t\t\t}\n\t\t}\n\t}\n\n\t// app.Reviews:\tquad-tuple for `<user,rating,title,content>`\n\t// more detailed comment could be fetched from\n\t// https://itunes.apple.com/cn/rss/customerreviews/id=<appid>/sortBy=mostRecent/json\n\tvar reviews [][4]string\n\tmid.Find(\"div.customer-review\").Map(func(ind int, s *goquery.Selection) string {\n\t\ttitle := getText(s.Find(\"span.customerReviewTitle\"))\n\t\trating := getAttr(s.Find(\"div.rating\"), \"aria-label\")\n\t\tuser := getText(s.Find(\"span.user-info\"))\n\t\tif piece := strings.Split(user, \"\\n\"); len(piece) > 1 {\n\t\t\tuser = strings.TrimSpace(piece[len(piece)-1])\n\t\t}\n\t\tcontent := getRichText(s.Find(\"p.content\"))\n\t\tif user != \"\" {\n\t\t\treviews = append(reviews, [4]string{user, rating, title, content})\n\t\t}\n\t\treturn \"\"\n\t})\n\tif body, err := json.MarshalIndent(reviews, \"\", \" \"); err == nil {\n\t\tif sb := string(body); sb != \"\" && sb != \"null\" {\n\t\t\tapp.Reviews = sb\n\t\t}\n\t}\n\n\treturn nil\n}", "func (rc *RequiredCapability) Read(h http.Header, useIMS bool) ([]interface{}, error, error, int, *time.Time) {\n\ttenantIDs, err := rc.getTenantIDs()\n\tif err != nil {\n\t\treturn nil, nil, err, http.StatusInternalServerError, nil\n\t}\n\n\tcapabilities, userErr, sysErr, errCode, maxTime := rc.getCapabilities(h, tenantIDs, useIMS)\n\tif userErr != nil || sysErr != nil {\n\t\treturn nil, userErr, sysErr, errCode, nil\n\t}\n\n\tresults := []interface{}{}\n\tfor _, capability := range capabilities {\n\t\tresults = append(results, capability)\n\t}\n\n\treturn results, nil, nil, errCode, maxTime\n}", "func (m *ApplicationModule) Read(fields ...string) error {\n\to := orm.NewOrm()\n\treturn o.Read(m, fields...)\n}", "func (ai *AppInteractor) Get(id string) (domain.App, error) {\n\treturn ai.AppRepository.Get(id)\n}", "func (d *dbApplicationStorage) GetByEUI(eui protocol.EUI, userID model.UserID) (model.Application, error) {\n\tvar rows *sql.Rows\n\tvar err error\n\tif userID == model.SystemUserID {\n\t\trows, err = d.systemGetStatement.Query(eui.String())\n\t} else {\n\t\trows, err = d.getStatement.Query(eui.String(), string(userID))\n\t}\n\tret := model.NewApplication()\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tdefer rows.Close()\n\tif !rows.Next() {\n\t\treturn ret, storage.ErrNotFound\n\t}\n\tapp, err := d.readApplication(rows)\n\treturn app, err\n}", "func (o *Object) readEntry(ctx context.Context) (*files.FileMetadata, error) {\n\treturn o.fs.getFileMetadata(ctx, o.remotePath())\n}", "func (p *NoteStoreClient) GetResourceApplicationData(ctx context.Context, authenticationToken string, guid GUID) (r *LazyMap, err error) {\n var _args137 NoteStoreGetResourceApplicationDataArgs\n _args137.AuthenticationToken = authenticationToken\n _args137.GUID = guid\n var _result138 NoteStoreGetResourceApplicationDataResult\n if err = p.Client_().Call(ctx, \"getResourceApplicationData\", &_args137, &_result138); err != nil {\n return\n }\n switch {\n case _result138.UserException!= nil:\n return r, _result138.UserException\n case _result138.SystemException!= nil:\n return r, _result138.SystemException\n case _result138.NotFoundException!= nil:\n return r, _result138.NotFoundException\n }\n\n return _result138.GetSuccess(), nil\n}" ]
[ "0.5668806", "0.5593288", "0.5444834", "0.53778654", "0.5353353", "0.5259754", "0.5245159", "0.51499933", "0.5140241", "0.5134525", "0.51081663", "0.50886697", "0.5061541", "0.5054451", "0.50369155", "0.5032618", "0.50098276", "0.49908748", "0.49253199", "0.49178293", "0.49132994", "0.49128556", "0.48908544", "0.4887575", "0.486322", "0.485828", "0.4838587", "0.47989258", "0.47953978", "0.47886565", "0.47675428", "0.47526518", "0.47514087", "0.46856925", "0.46779305", "0.4657934", "0.4655895", "0.4648549", "0.46423212", "0.4634165", "0.4609268", "0.46023738", "0.4594836", "0.45811415", "0.45809358", "0.4575714", "0.45753068", "0.45678577", "0.4566673", "0.45660928", "0.45583162", "0.455705", "0.45532414", "0.45495388", "0.45487776", "0.45381272", "0.45352092", "0.45176747", "0.45137212", "0.45012346", "0.4500787", "0.44986704", "0.4498088", "0.44974217", "0.44966653", "0.44941878", "0.44851115", "0.44841748", "0.44755626", "0.44674534", "0.44652674", "0.4455902", "0.44509667", "0.4447873", "0.44453484", "0.4442673", "0.44420707", "0.44409266", "0.44394422", "0.44373846", "0.4435081", "0.4435081", "0.44331947", "0.44302732", "0.4429931", "0.44289213", "0.44159326", "0.44120365", "0.44114116", "0.4404085", "0.4395385", "0.43876913", "0.43860453", "0.4378766", "0.4375687", "0.4374676", "0.43675965", "0.4363753", "0.4363247", "0.43611345" ]
0.69884974
0
Create function creates a new DesktopApp and returns a map that contains creation result
func (o *DesktopApp) Create() (*restapi.SliceResponse, error) { var queryArg = make(map[string]interface{}) queryArg["ID"] = []string{o.TemplateName} LogD.Printf("Generated Map for Create(): %+v", queryArg) resp, err := o.client.CallSliceAPI(o.apiCreate, queryArg) if err != nil { return nil, err } if !resp.Success { return nil, errors.New(resp.Message) } return resp, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CreateApp(appoptions *options.App) (*App, error) {\n\tvar err error\n\n\tctx := context.Background()\n\n\t// Merge default options\n\toptions.MergeDefaults(appoptions)\n\n\tdebug := IsDebug()\n\tdevtools := IsDevtoolsEnabled()\n\tctx = context.WithValue(ctx, \"debug\", debug)\n\tctx = context.WithValue(ctx, \"devtools\", devtools)\n\n\t// Set up logger\n\tmyLogger := logger.New(appoptions.Logger)\n\tif IsDebug() {\n\t\tmyLogger.SetLogLevel(appoptions.LogLevel)\n\t} else {\n\t\tmyLogger.SetLogLevel(appoptions.LogLevelProduction)\n\t}\n\tctx = context.WithValue(ctx, \"logger\", myLogger)\n\tctx = context.WithValue(ctx, \"obfuscated\", IsObfuscated())\n\n\t// Preflight Checks\n\terr = PreflightChecks(appoptions, myLogger)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create the menu manager\n\tmenuManager := menumanager.NewManager()\n\n\t// Process the application menu\n\tif appoptions.Menu != nil {\n\t\terr = menuManager.SetApplicationMenu(appoptions.Menu)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Create binding exemptions - Ugly hack. There must be a better way\n\tbindingExemptions := []interface{}{\n\t\tappoptions.OnStartup,\n\t\tappoptions.OnShutdown,\n\t\tappoptions.OnDomReady,\n\t\tappoptions.OnBeforeClose,\n\t}\n\tappBindings := binding.NewBindings(myLogger, appoptions.Bind, bindingExemptions, IsObfuscated())\n\teventHandler := runtime.NewEvents(myLogger)\n\tctx = context.WithValue(ctx, \"events\", eventHandler)\n\t// Attach logger to context\n\tif debug {\n\t\tctx = context.WithValue(ctx, \"buildtype\", \"debug\")\n\t} else {\n\t\tctx = context.WithValue(ctx, \"buildtype\", \"production\")\n\t}\n\n\tmessageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler, appoptions.ErrorFormatter)\n\tappFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher)\n\teventHandler.AddFrontend(appFrontend)\n\n\tctx = context.WithValue(ctx, \"frontend\", appFrontend)\n\tresult := &App{\n\t\tctx: ctx,\n\t\tfrontend: appFrontend,\n\t\tlogger: myLogger,\n\t\tmenuManager: menuManager,\n\t\tstartupCallback: appoptions.OnStartup,\n\t\tshutdownCallback: appoptions.OnShutdown,\n\t\tdebug: debug,\n\t\tdevtools: devtools,\n\t\toptions: appoptions,\n\t}\n\n\treturn result, nil\n\n}", "func CreateApplication(pid int) *UIElement {\n\tref := C.AXUIElementCreateApplication(C.pid_t(pid))\n\treturn newUIElement(ref)\n}", "func Create (appName string) {\n\n checkGopath ()\n checkContainer (appName)\n\n app := Application { Name: appName }\n\n app.createContainer ()\n\n err := app.copyFileTree (\n GOPATH + slash + applicationTemplatesPath,\n GOPATH_SRC + app.Name,\n )\n\n if err != nil {\n log.Fatal (err)\n }\n}", "func (c Client) createApp(body io.Reader) (*App, error) {\n\treq, err := http.NewRequest(\"POST\", c.getURL(\"/apps\"), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar marshalled map[string]*App\n\terr = c.executeRequestAndMarshal(req, &marshalled)\n\treturn marshalled[\"app\"], err\n}", "func makeApp(def pchannel.App, data pchannel.Data) perun.App {\n\treturn perun.App{\n\t\tDef: def,\n\t\tData: data,\n\t}\n}", "func AppCreate(ctx *Context, name string, typ DeviceType) (*Application, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(\"application\")\n\tdata := make(map[string]interface{})\n\tdata[\"app_name\"] = name\n\tdata[\"device_type\"] = typ.String()\n\tbody, err := marhsalReader(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb, err := doJSON(ctx, \"POST\", uri, h, nil, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trst := &Application{}\n\terr = json.Unmarshal(b, rst)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn rst, nil\n}", "func CreateApplication() *Alpha {\n app := &Alpha{}\n app.Request = &Request{}\n app.Response = &Response{}\n app.init()\n return app\n}", "func (c Client) CreateApp() (*App, error) {\n\treturn c.createApp(nil)\n}", "func newApp(name string) (app *App, err error) {\n\tapp = &App{\n\t\tName: name,\n\t\tID: uuid.NewV5(namespace, \"org.homealone.\"+name).String(),\n\t\thandler: make(map[queue.Topic]message.Handler),\n\t\tdebug: *debug,\n\t\tfilterMessages: true,\n\t}\n\tapp.Log = log.NewLogger().With(log.Fields{\"app\": name, \"id\": app.ID})\n\treturn app, errors.Wrap(err, \"newApp failed\")\n}", "func (api API) CreateApp(name, engine string) (app AppBundle, err error) {\n\n\tbearer, err := api.Authenticator.GetToken(\"code:all\")\n\tif err != nil {\n\t\treturn\n\t}\n\tpath := api.Authenticator.GetHostPath() + api.DesignAutomationPath\n\tapp, err = createApp(path, name, engine, bearer.AccessToken)\n\n\tapp.authenticator = api.Authenticator\n\tapp.path = path\n\tapp.name = name\n\tapp.uploadURL = api.UploadAppURL\n\n\t//WARNING: when an AppBundle is created, it is assigned an '$LATEST' alias\n\t// but this alias is not usable and if no other alias is created for this\n\t// appBundle, then the alias listing will fail.\n\t// Thus I decided to autoasign a \"default\" alias upon app creation\n\tgo app.CreateAlias(\"default\", 1)\n\n\treturn\n}", "func CreateApp(conf *config.Config) *TelegramBotApp {\n\n\t// Init the telegram bot\n\tbot, err := botFactory.BotFactory(conf)\n\tif err != nil {\n\t\tlog.Fatal(\"Can't create a telegram bot: \", err)\n\t}\n\n\t// Init the database\n\tdb, err := dbFactory.DatabaseFactory(conf)\n\tif err != nil {\n\t\tlog.Fatal(\"Couldn't create database: \", err)\n\t}\n\n\t// Init the database storage\n\tstorage, err := storages.CreateStorages(db)\n\tif err != nil {\n\t\tlog.Fatal(\"Couldn't setup database: \", err)\n\t}\n\n\t// Init the database Repository\n\trepository, err := repositories.CreateRepository(db)\n\tif err != nil {\n\t\tlog.Fatal(\"Couldn't setup database: \", err)\n\t}\n\n\treturn &TelegramBotApp{conf, bot, storage, repository}\n}", "func (winMap tWinMap) createMap (hwnd W.HWND) {\n\t_, ok := winMap[hwnd]\n\tif !ok {\n\t\twinMap[hwnd] = make(map[uint32]TWinProc)\n\t}\n}", "func newManifestApp() *types.App {\n\treturn &types.App{\n\t\tUser: \"0\",\n\t\tGroup: \"0\",\n\t}\n}", "func newManifestApp() *types.App {\n\treturn &types.App{\n\t\tUser: \"0\",\n\t\tGroup: \"0\",\n\t}\n}", "func (c *Client) CreateApp(user, name string) (*App, error) {\n\tlog.Printf(\"[INFO] creating application %s/%s\", user, name)\n\n\tbody, err := json.Marshal(&appWrapper{&App{\n\t\tUser: user,\n\t\tName: name,\n\t}})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tendpoint := \"/api/v1/vagrant/applications\"\n\trequest, err := c.Request(\"POST\", endpoint, &RequestOptions{\n\t\tBody: bytes.NewReader(body),\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse, err := checkResp(c.HTTPClient.Do(request))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar app App\n\tif err := decodeJSON(response, &app); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &app, nil\n}", "func (c *Container) CreateApp(appName string) (*Application, error) {\n\tappDataPath := fmt.Sprintf(\"%s/%s\", c.config.DataDir, util.SafeFilename(appName))\n\n\tif err := os.MkdirAll(appDataPath, 0700); err != nil {\n\t\treturn nil, errors.Wrap(err, \"create data dir\")\n\t}\n\tlevelDBStore, err := store.NewLevelDBStore(appDataPath)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"create data store dir\")\n\t}\n\n\tjsStore, err := store.NewJetstreamStore(c.clusterConn, fmt.Sprintf(\"%s_%s\", c.config.ClusterNatsPrefix, appName), levelDBStore)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"create jetstream store\")\n\t}\n\n\tif err := jsStore.Connect(c.config.DatastoreSyncTimeout); err != nil {\n\t\treturn nil, errors.Wrap(err, \"jetstream store connect\")\n\t}\n\n\tapp, err := NewApplication(c.config, appName, jsStore, cluster.NewClusterEventBus(c.clusterConn, fmt.Sprintf(\"%s.%s\", c.config.ClusterNatsPrefix, appName)))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.apps[appName] = app\n\n\treturn app, nil\n}", "func (ai *AppInteractor) Create(app domain.App) (string, error) {\n\treturn ai.AppRepository.Create(app)\n}", "func (a *appHandler) CreateApp(w http.ResponseWriter, r *http.Request) {\n\tvar app model.App\n\terr := json.NewDecoder(r.Body).Decode(&app)\n\tif err != nil {\n\t\ta.httpUtil.WriteJSONBadRequestResponse(w, err)\n\t\treturn\n\t}\n\n\t// TODO : Create\n\n\tjsonR, err := json.Marshal(app)\n\tif err != nil {\n\t\ta.httpUtil.WriteJSONInternalServerErrorResponse(w, err)\n\t}\n\n\ta.httpUtil.WriteJSONSuccessResponse(w, jsonR)\n}", "func (r *Resolver) CreateApp(ctx context.Context, args struct {\n\tName string\n\tIcon string\n\tIntro string\n\tURL string\n}) (*AppResolver, error) {\n\ttoken := ctx.Value(meta.KeyTokenPayload).(*pb.TokenPayload)\n\tacl := utils.NewACL(token, meta.SrvSelf)\n\tif !acl.Check() {\n\t\treturn nil, meta.ErrAccessDenied\n\t}\n\n\tservice := ctx.Value(meta.KeyService).(*client.MicroClient)\n\tres, err := service.SelfApp.Create(ctx, &selfPb.AppModify{\n\t\tVisitor: acl.Visitor(),\n\t\tName: args.Name,\n\t\tIcon: args.Icon,\n\t\tIntro: args.Intro,\n\t\tURL: args.URL,\n\t})\n\tif err != nil {\n\t\treturn nil, utils.MicroError(err)\n\t}\n\treturn &AppResolver{ctx, acl, res}, nil\n}", "func (app *exitBuilder) Create() ExitBuilder {\n\treturn createExitBuilder()\n}", "func create_app() (string) {\n\t// Create a new LUIS app\n\t// Get the context, which is required by the SDK methods.\n\tctx := context.Background()\n\n\tclient := authoring.NewAppsClient(authoring_endpoint)\n\t// Set the subscription key on the client.\n\tclient.Authorizer = autorest.NewCognitiveServicesAuthorizer(authoring_key)\n\n\tdomain_name := \"HomeAutomation\"\n\tculture := \"en-us\"\n\n\tcreate_app_payload := authoring.PrebuiltDomainCreateObject { DomainName: &domain_name, Culture: &culture }\n\n\tresult, err := client.AddCustomPrebuiltDomain(ctx, create_app_payload)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"Created LUIS app %s with ID %s\\n\", domain_name, (*result.Value).String())\n\treturn (*result.Value).String()\n}", "func CreateMap(args ...interface{}) map[string]interface{} {\n\tm := make(map[string]interface{}, 0)\n\tkey := \"\"\n\tfor _, v := range args {\n\t\tif len(key) == 0 {\n\t\t\tkey = string(v.(string))\n\t\t} else {\n\t\t\tm[key] = v\n\t\t}\n\t}\n\treturn m\n}", "func (c *RestClient) CreateApp(name string, memory int) (string, error) {\n\t// Ensure that app name is unique for this user. We do this as\n\t// unfortunately the server doesn't enforce it.\n\tapps, err := c.ListApps()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tfor _, app := range apps {\n\t\tif app.Name == name {\n\t\t\treturn \"\", fmt.Errorf(\"App by that name (%s) already exists\", name)\n\t\t}\n\t}\n\n\t// The CC requires that a POST on /apps sends, at minimum, these\n\t// fields. The values for framework/runtime doesn't matter for our\n\t// purpose (they will get overwritten by a subsequent app push).\n\tcreateArgs := map[string]interface{}{\n\t\t\"name\": name,\n\t\t\"space_guid\": c.Space,\n\t\t\"memory\": memory,\n\t}\n\n\tvar resp struct {\n\t\tMetadata struct {\n\t\t\tGUID string\n\t\t}\n\t}\n\terr = c.MakeRequest(\"POST\", \"/v2/apps\", createArgs, &resp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resp.Metadata.GUID == \"\" {\n\t\treturn \"\", fmt.Errorf(\"Missing App GUID from CC\")\n\t}\n\n\treturn resp.Metadata.GUID, nil\n}", "func (o OpenSignal) CreateAnApp(app App) (App, error) {\n\tstrResponse := App{}\n\n\tres, body, errs := o.Client.Post(createApp).\n\t\tSend(app).\n\t\tSet(\"Authorization\", \"Basic \"+o.AuthKey).\n\t\tEndStruct(&strResponse)\n\terr := catch(res, body)\n\tif err == nil {\n\t\tfor _, e := range errs {\n\t\t\tif e != nil {\n\t\t\t\terr = e\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn strResponse, err\n}", "func CreateApp(debug bool, config *Config, swaggerInfo *swag.Spec) *App {\n\tif !config.Static {\n\t\tf, err := os.Open(config.DocFile)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"open doc file error: %s\", err)\n\t\t\tlog.Infof(\"fallback to static mode\")\n\t\t\tconfig.Static = true\n\t\t}\n\t\tf.Close()\n\t}\n\n\tif config.Static {\n\t\tif swaggerInfo != nil {\n\t\t\tswaggerInfo.Host = config.Host\n\t\t}\n\t\tif _, err := swag.ReadDoc(); err != nil {\n\t\t\tpanic(\"no swagger registered, can't use static mode\")\n\t\t}\n\t}\n\n\tapp := &App{config, echo.New()}\n\n\tapp.e.Debug = debug\n\n\tapp.e.Use(middleware.Logger())\n\tapp.e.Use(middleware.Recover())\n\tapp.e.Use(middleware.CORS())\n\n\t// routers\n\tapp.e.GET(\"/\", func(c echo.Context) error {\n\t\treturn c.Redirect(http.StatusMovedPermanently, config.SwaggerPath+\"index.html\")\n\t})\n\n\tg := app.e.Group(\"\")\n\tRegister(g, config)\n\n\treturn app\n}", "func New(\n\tfactories config.Factories,\n\tappInfo ApplicationStartInfo,\n) (*Application, error) {\n\n\tif err := configcheck.ValidateConfigFromFactories(factories); err != nil {\n\t\treturn nil, err\n\t}\n\n\tapp := &Application{\n\t\tinfo: appInfo,\n\t\tv: viper.New(),\n\t\treadyChan: make(chan struct{}),\n\t\tfactories: factories,\n\t}\n\n\trootCmd := &cobra.Command{\n\t\tUse: appInfo.ExeName,\n\t\tLong: appInfo.LongName,\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tapp.init()\n\t\t\tapp.execute()\n\t\t},\n\t}\n\n\t// TODO: coalesce this code and expose this information to other components.\n\tflagSet := new(flag.FlagSet)\n\taddFlagsFns := []func(*flag.FlagSet){\n\t\ttelemetryFlags,\n\t\tbuilder.Flags,\n\t\tloggerFlags,\n\t}\n\tfor _, addFlags := range addFlagsFns {\n\t\taddFlags(flagSet)\n\t}\n\trootCmd.Flags().AddGoFlagSet(flagSet)\n\n\tapp.rootCmd = rootCmd\n\n\treturn app, nil\n}", "func ApplicationCreate(w http.ResponseWriter, r *http.Request) {\n\tdb, err := database.Connect()\n\tdefer db.Close()\n\tif err != nil {\n\t\tlog.Printf(\"Database error: '%s'\\n\", err)\n\t\thttp.Error(w, \"there was an error when attempting to connect to the database\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar createForm struct {\n\t\tName string\n\t}\n\tdecoder := json.NewDecoder(r.Body)\n\terr = decoder.Decode(&createForm)\n\tdefer r.Body.Close()\n\tif err != nil {\n\t\tlog.Printf(\"decoding error: '%s'\\n\", err)\n\t\thttp.Error(w, \"there was an error when attempting to parse the form\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tapp := resources.Application{\n\t\tName: createForm.Name,\n\t}\n\t_, err = resources.CreateApplication(db, &app)\n\t// @todo handle failed save w/out error?\n\tif err != nil {\n\t\tlog.Printf(\"Error when retrieving application: '%s'\\n\", err)\n\t\thttp.Error(w, \"there was an error when retrieving application\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// @todo return some sort of content?\n\tw.WriteHeader(http.StatusCreated)\n\treturn\n}", "func CreateVcapApplication(app *v1alpha1.App) map[string]interface{} {\n\t// You can find a list of values here:\n\t// https://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html\n\n\turls := sets.NewString()\n\tfor _, r := range app.Status.Routes {\n\t\turls.Insert(r.URL)\n\t}\n\n\tvalues := map[string]interface{}{\n\t\t// application_id The GUID identifying the app.\n\t\t\"application_id\": app.UID,\n\t\t// application_name The name assigned to the app when it was pushed.\n\t\t\"application_name\": app.Name,\n\t\t// application_uris The URIs assigned to the app.\n\t\t\"application_uris\": urls.List(),\n\t\t// name Identical to application_name.\n\t\t\"name\": app.Name,\n\t\t// process_id The UID identifying the process. Only present in running app containers.\n\t\t\"process_id\": app.UID,\n\t\t// process_type The type of process. Only present in running app containers.\n\t\t\"process_type\": \"web\",\n\t\t// space_name Human-readable name of the space where the app is deployed.\n\t\t\"space_name\": app.Namespace,\n\t\t// uris Identical to application_uris.\n\t\t\"uris\": urls.List(),\n\t}\n\n\treturn values\n}", "func NewApp() *App {\n\tv := new(App)\n\tv.opened = false\n\tv.simType = \"runreset\"\n\tv.status = \"Stopped\"\n\tv.mode = \"Main\"\n\tv.incSize = 10.0\n\tv.decSize = 10.0\n\tv.keyMaps = make([]IKeyMap, 10)\n\tv.keyMaps[0] = NewKeyMap0(v)\n\tv.keyMaps[1] = NewKeyMap1(v)\n\n\treturn v\n}", "func (f *DMAClient) Create(obj *dm.M4DApplication) (*dm.M4DApplication, error) {\n\tvar result dm.M4DApplication\n\terr := f.client.Post().\n\t\tNamespace(f.namespace).Resource(f.plural).\n\t\tBody(obj).Do(context.Background()).Into(&result)\n\treturn &result, err\n}", "func (app *managerFactory) Create() Manager {\n\treturn createManager(map[string]Bridge{})\n}", "func CreateApp(appoptions *options.App) (*App, error) {\n\tvar err error\n\n\tctx := context.WithValue(context.Background(), \"debug\", true)\n\n\t// Set up logger\n\tmyLogger := logger.New(appoptions.Logger)\n\tmyLogger.SetLogLevel(appoptions.LogLevel)\n\n\t// Check for CLI Flags\n\tvar assetdirFlag *string\n\tvar devServerURLFlag *string\n\tvar loglevelFlag *string\n\n\tassetdir := os.Getenv(\"assetdir\")\n\tif assetdir == \"\" {\n\t\tassetdirFlag = flag.String(\"assetdir\", \"\", \"Directory to serve assets\")\n\t}\n\tdevServerURL := os.Getenv(\"devserverurl\")\n\tif devServerURL == \"\" {\n\t\tdevServerURLFlag = flag.String(\"devserverurl\", \"\", \"URL of development server\")\n\t}\n\n\tloglevel := os.Getenv(\"loglevel\")\n\tif loglevel == \"\" {\n\t\tloglevelFlag = flag.String(\"loglevel\", \"debug\", \"Loglevel to use - Trace, Debug, Info, Warning, Error\")\n\t}\n\n\t// If we weren't given the assetdir in the environment variables\n\tif assetdir == \"\" {\n\t\tflag.Parse()\n\t\tif assetdirFlag != nil {\n\t\t\tassetdir = *assetdirFlag\n\t\t}\n\t\tif devServerURLFlag != nil {\n\t\t\tdevServerURL = *devServerURLFlag\n\t\t}\n\t\tif loglevelFlag != nil {\n\t\t\tloglevel = *loglevelFlag\n\t\t}\n\t}\n\n\tif devServerURL != \"\" {\n\t\tctx = context.WithValue(ctx, \"devserverurl\", devServerURL)\n\t}\n\tif assetdir != \"\" {\n\t\tctx = context.WithValue(ctx, \"assetdir\", assetdir)\n\t}\n\n\tif loglevel != \"\" {\n\t\tlevel, err := pkglogger.StringToLogLevel(loglevel)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tmyLogger.SetLogLevel(level)\n\t}\n\n\t// Attach logger to context\n\tctx = context.WithValue(ctx, \"logger\", myLogger)\n\n\t// Preflight checks\n\terr = PreflightChecks(appoptions, myLogger)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Merge default options\n\toptions.MergeDefaults(appoptions)\n\n\tvar menuManager *menumanager.Manager\n\n\t// Process the application menu\n\tif appoptions.Menu != nil {\n\t\t// Create the menu manager\n\t\tmenuManager = menumanager.NewManager()\n\t\terr = menuManager.SetApplicationMenu(appoptions.Menu)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Create binding exemptions - Ugly hack. There must be a better way\n\tbindingExemptions := []interface{}{appoptions.OnStartup, appoptions.OnShutdown, appoptions.OnDomReady}\n\tappBindings := binding.NewBindings(myLogger, appoptions.Bind, bindingExemptions)\n\n\terr = generateBindings(appBindings)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\teventHandler := runtime.NewEvents(myLogger)\n\tctx = context.WithValue(ctx, \"events\", eventHandler)\n\tmessageDispatcher := dispatcher.NewDispatcher(myLogger, appBindings, eventHandler)\n\n\t// Create the frontends and register to event handler\n\tdesktopFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher)\n\tappFrontend := devserver.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher, menuManager, desktopFrontend)\n\teventHandler.AddFrontend(appFrontend)\n\teventHandler.AddFrontend(desktopFrontend)\n\n\tresult := &App{\n\t\tctx: ctx,\n\t\tfrontend: appFrontend,\n\t\tlogger: myLogger,\n\t\tmenuManager: menuManager,\n\t\tstartupCallback: appoptions.OnStartup,\n\t\tshutdownCallback: appoptions.OnShutdown,\n\t\tdebug: true,\n\t}\n\n\tresult.options = appoptions\n\n\treturn result, nil\n\n}", "func (c *applicationOperator) createApp(app *v1alpha1.HelmApplication, iconData string) (*v1alpha1.HelmApplication, error) {\n\texists, err := c.getHelmAppByName(app.GetWorkspace(), app.GetTrueName())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif exists != nil {\n\t\treturn nil, appItemExists\n\t}\n\tif strings.HasPrefix(iconData, \"http://\") || strings.HasPrefix(iconData, \"https://\") {\n\t\tapp.Spec.Icon = iconData\n\t} else if len(iconData) != 0 {\n\t\t// save icon attachment\n\t\ticonId := idutils.GetUuid(v1alpha1.HelmAttachmentPrefix)\n\t\tdecodeString, err := base64.StdEncoding.DecodeString(iconData)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"decodeString icon failed, error: %s\", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\terr = c.backingStoreClient.Upload(iconId, iconId, bytes.NewBuffer(decodeString), len(iconData))\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"save icon attachment failed, error: %s\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tapp.Spec.Icon = iconId\n\t}\n\n\tapp, err = c.appClient.Create(context.TODO(), app, metav1.CreateOptions{})\n\treturn app, err\n}", "func New() App {\n\treturn App{}\n}", "func (client *Client) CreateAppInfo(request *CreateAppInfoRequest) (_result *CreateAppInfoResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &CreateAppInfoResponse{}\n\t_body, _err := client.CreateAppInfoWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "func (r *app) Create(appPayload AppRequest, opts ...bool) (*AppFields, error) {\n\tasync := true\n\tif len(opts) > 0 {\n\t\tasync = opts[0]\n\t}\n\trawURL := fmt.Sprintf(\"/v2/apps?async=%t\", async)\n\tappFields := AppFields{}\n\t_, err := r.client.Post(rawURL, appPayload, &appFields)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &appFields, nil\n}", "func New(descr string) App {\n\treturn &app{descr: descr}\n}", "func (handler *applicationHandler) create(app *types.ApplicationConfig) types.ResponseError {\n\tapp.SetDockerImage(handler.image)\n\tapp.SetConfGenerator(handler.confGenerator)\n\treturn api.SetupApplication(app)\n}", "func NewApp(f interface{}, args Arguments, info *debug.Info) App {\n\treturn App{f, args, info}\n}", "func CreateDesktopShortcut(\n\toutpath,\n\texepath,\n\targs,\n\ticonpath,\n\tname,\n\tcomment string,\n\tstartup bool) error {\n\n\t// Build command with args\n\tcmd := exepath\n\tif args != \"\" {\n\t\tcmd += \" \" + args\n\t}\n\n\t// Create desktop entry\n\ttext := `[Desktop Entry]\nType=Application\nVersion=1.0\nTerminal=false`\n\n\ttext += fmt.Sprintf(\"\\nName=%s\", name)\n\ttext += fmt.Sprintf(\"\\nComment=%s\", comment)\n\ttext += fmt.Sprintf(\"\\nExec=%s\", cmd)\n\ttext += fmt.Sprintf(\"\\nIcon=%s\", iconpath)\n\ttext += \"\\n\"\n\n\tmode := os.FileMode(0755)\n\tif startup {\n\t\tmode = 0644\n\t}\n\n\treturn ioutil.WriteFile(outpath, []byte(text), mode)\n}", "func (a *API) CreateApplication(app Application, appEUI *lorawan.EUI64) error {\n\tif err := CreateApplication(a.ctx.DB, app); err != nil {\n\t\treturn err\n\t}\n\t*appEUI = app.AppEUI\n\treturn nil\n}", "func createApp() *menta.MentaApp {\n\t// runs tendermint init if needed\n\tmenta.InitTendermint(homeDir)\n\t// setup the app\n\tapp := menta.NewApp(\"counter-example\", homeDir)\n\t// Register the service\n\tapp.AddService(counter.Service{})\n\n\treturn app\n}", "func NewApp(name string) *App {\n\treturn &App{Name: name, Labels: make(map[string]string)}\n}", "func (as *AppStorage) CreateApp(app model.AppData) (model.AppData, error) {\n\tres, ok := app.(*AppData)\n\tif !ok || res == nil {\n\t\treturn nil, model.ErrorWrongDataFormat\n\t}\n\tresult, err := as.addNewApp(res)\n\treturn result, err\n}", "func CreateApp(env env.Project, appJson, appDir, appName, vendorDir, constraints string) error {\n\treturn doCreate(env, appJson, appDir, appName, vendorDir, constraints)\n}", "func (s *server) Create(ctx context.Context, body *pb.RequestBody) (*pb.ResponseBody, error) {\n\tlanguage := body.GetLanguage()\n\tapp := &types.ApplicationConfig{}\n\n\terr := json.Unmarshal(body.GetData(), app)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuser, err := mongo.FetchSingleUser(body.GetOwner())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmaxCount := configs.ServiceConfig.AppMaker.AppLimit\n\trateCount := configs.ServiceConfig.RateLimit\n\ttimeInterval := configs.ServiceConfig.RateInterval\n\tif !user.IsAdmin() && maxCount >= 0 {\n\t\trateLimitCount := mongo.CountInstanceInTimeFrame(body.GetOwner(), mongo.AppInstance, timeInterval)\n\t\ttotalCount := mongo.CountInstancesByUser(body.GetOwner(), mongo.AppInstance)\n\t\tif totalCount < maxCount {\n\t\t\tif rateLimitCount >= rateCount && rateCount >= 0 {\n\t\t\t\treturn nil, fmt.Errorf(\"cannot deploy more than %d app instances in %d hours\", rateCount, timeInterval)\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"cannot deploy more than %d app instances\", maxCount)\n\t\t}\n\t}\n\n\tapp.SetLanguage(language)\n\tapp.SetOwner(body.GetOwner())\n\tapp.SetInstanceType(mongo.AppInstance)\n\tapp.SetHostIP(utils.HostIP)\n\tapp.SetNameServers(configs.GasperConfig.DNSServers)\n\tapp.SetDateTime()\n\n\tgendnsNameServers, _ := redis.FetchServiceInstances(types.GenDNS)\n\tfor _, nameServer := range gendnsNameServers {\n\t\tif strings.Contains(nameServer, \":\") {\n\t\t\tapp.AddNameServers(strings.Split(nameServer, \":\")[0])\n\t\t} else {\n\t\t\tutils.LogError(\"AppMaker-Controller-1\", fmt.Errorf(\"GenDNS instance %s is of invalid format\", nameServer))\n\t\t}\n\t}\n\n\tif pipeline[language] == nil {\n\t\treturn nil, fmt.Errorf(\"language `%s` is not supported\", language)\n\t}\n\tresErr := pipeline[language].create(app)\n\tif resErr != nil {\n\t\tif resErr.Message() != \"repository already exists\" && resErr.Message() != \"container already exists\" {\n\t\t\tgo diskCleanup(app.GetName())\n\t\t}\n\t\treturn nil, fmt.Errorf(resErr.Error())\n\t}\n\n\tsshEntrypointIP := configs.ServiceConfig.GenSSH.EntrypointIP\n\tif len(sshEntrypointIP) == 0 {\n\t\tsshEntrypointIP = utils.HostIP\n\t}\n\tapp.SetSSHCmd(configs.ServiceConfig.GenSSH.Port, app.GetName(), sshEntrypointIP)\n\n\tapp.SetAppURL(fmt.Sprintf(\"%s.%s.%s\", app.GetName(), cloudflare.ApplicationInstance, configs.GasperConfig.Domain))\n\n\tif configs.CloudflareConfig.PlugIn {\n\t\tresp, err := cloudflare.CreateApplicationRecord(app.GetName())\n\t\tif err != nil {\n\t\t\tgo diskCleanup(app.GetName())\n\t\t\treturn nil, err\n\t\t}\n\t\tapp.SetCloudflareID(resp.Result.ID)\n\t\tapp.SetPublicIP(configs.CloudflareConfig.PublicIP)\n\t}\n\n\terr = mongo.UpsertInstance(\n\t\ttypes.M{\n\t\t\tmongo.NameKey: app.GetName(),\n\t\t\tmongo.InstanceTypeKey: mongo.AppInstance,\n\t\t}, app)\n\n\tif err != nil && err != mongo.ErrNoDocuments {\n\t\tgo diskCleanup(app.GetName())\n\t\tgo stateCleanup(app.GetName())\n\t\treturn nil, err\n\t}\n\n\terr = redis.RegisterApp(\n\t\tapp.GetName(),\n\t\tfmt.Sprintf(\"%s:%d\", utils.HostIP, configs.ServiceConfig.AppMaker.Port),\n\t\tfmt.Sprintf(\"%s:%d\", utils.HostIP, app.GetContainerPort()),\n\t)\n\n\tif err != nil {\n\t\tgo diskCleanup(app.GetName())\n\t\tgo stateCleanup(app.GetName())\n\t\treturn nil, err\n\t}\n\n\terr = redis.IncrementServiceLoad(\n\t\tServiceName,\n\t\tfmt.Sprintf(\"%s:%d\", utils.HostIP, configs.ServiceConfig.AppMaker.Port),\n\t)\n\n\tif err != nil {\n\t\tgo diskCleanup(app.GetName())\n\t\tgo stateCleanup(app.GetName())\n\t\treturn nil, err\n\t}\n\n\tapp.SetSuccess(true)\n\n\tresponse, err := json.Marshal(app)\n\treturn &pb.ResponseBody{Data: response}, err\n}", "func (app *applicationBuilder) Create() ApplicationBuilder {\n\treturn createApplicationBuilder()\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.hashAdapter, app.minPubKeysInOwner)\n}", "func NewDesktopApp(c *restapi.RestClient) *DesktopApp {\n\ts := DesktopApp{}\n\ts.client = c\n\ts.apiRead = \"/SaasManage/GetApplication\"\n\ts.apiCreate = \"/SaasManage/ImportAppFromTemplate\"\n\ts.apiDelete = \"/SaasManage/DeleteApplication\"\n\ts.apiUpdate = \"/SaasManage/UpdateApplicationDE\"\n\ts.apiPermissions = \"/SaasManage/SetApplicationPermissions\"\n\n\treturn &s\n}", "func createApp() *cli.App {\n\tapp := cli.NewApp()\n\tapp.EnableBashCompletion = true\n\tapp.Name = \"iSulad-img\"\n\tif gitCommit != \"\" {\n\t\tapp.Version = fmt.Sprintf(\"%s commit: %s\", Version, gitCommit)\n\t} else {\n\t\tapp.Version = Version\n\t}\n\tapp.Usage = \"Various operations with container images and container image registries\"\n\tapp.Flags = []cli.Flag{\n\t\tcli.BoolFlag{\n\t\t\tName: \"debug\",\n\t\t\tUsage: \"enable debug output\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"log-level, l\",\n\t\t\tUsage: \"Set the logging level\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"run-root\",\n\t\t\tValue: defaultRunRoot,\n\t\t\tUsage: \"use `PATH` as the root directory for execution state files\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"graph-root\",\n\t\t\tValue: defaultGraphRoot,\n\t\t\tUsage: \"use `PATH` as the graph driver's root directory for execution state files\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"driver-name\",\n\t\t\tValue: defaultGraphDriverName,\n\t\t\tUsage: \"use `NAME` as the graph driver\",\n\t\t},\n\t\tcli.StringSliceFlag{\n\t\t\tName: \"driver-options\",\n\t\t\tUsage: \"Options of the graph driver\",\n\t\t},\n\t\tcli.StringSliceFlag{\n\t\t\tName: \"storage-opt\",\n\t\t\tUsage: \"Options of the storage when mount container rootfs\",\n\t\t},\n\t\tcli.StringSliceFlag{\n\t\t\tName: \"insecure-registry\",\n\t\t\tUsage: \"whether to disable TLS verification for the given registry\",\n\t\t},\n\t\tcli.StringSliceFlag{\n\t\t\tName: \"registry\",\n\t\t\tUsage: \"registry to be prepended when pulling unqualified images, can be specified multiple times\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"policy\",\n\t\t\tValue: \"\",\n\t\t\tUsage: \"Path to a trust policy file\",\n\t\t},\n\t\tcli.BoolFlag{\n\t\t\tName: \"insecure-policy\",\n\t\t\tUsage: \"run the tool without any policy check\",\n\t\t},\n\t\tcli.DurationFlag{\n\t\t\tName: \"command-timeout\",\n\t\t\tUsage: \"timeout for the command execution\",\n\t\t},\n\t}\n\tapp.Before = func(c *cli.Context) error {\n\t\tif c.GlobalBool(\"debug\") {\n\t\t\tlogrus.SetLevel(logrus.DebugLevel)\n\t\t} else {\n\t\t\tsetLogLevel(c.GlobalString(\"log-level\"))\n\t\t}\n\t\treturn nil\n\t}\n\tapp.Commands = []cli.Command{\n\t\tinfoCmd,\n\t\timagesCmd,\n\t\tdaemonCmd,\n\t}\n\treturn app\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder()\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder()\n}", "func CreateAppConfigmap(name, trainingType, namespace, configFileName, appInfoFileName, chartName, chartVersion string) (err error) {\n\tif _, err = os.Stat(configFileName); os.IsNotExist(err) {\n\t\treturn err\n\t}\n\n\tif _, err = os.Stat(appInfoFileName); os.IsNotExist(err) {\n\t\treturn err\n\t}\n\n\targs := []string{\"create\", \"configmap\", fmt.Sprintf(\"%s-%s\", name, trainingType),\n\t\t\"--namespace\", namespace,\n\t\tfmt.Sprintf(\"--from-file=%s=%s\", \"values\", configFileName),\n\t\tfmt.Sprintf(\"--from-file=%s=%s\", \"app\", appInfoFileName),\n\t\tfmt.Sprintf(\"--from-literal=%s=%s\", chartName, chartVersion)}\n\t// \"--overrides='{\\\"metadata\\\":{\\\"label\\\":\\\"createdBy\\\": \\\"arena\\\"}}'\"}\n\tout, err := kubectl(args)\n\n\tfmt.Printf(\"%s\", string(out))\n\tif err != nil {\n\t\tlog.Debugf(\"Failed to execute %s, %v with %v\", \"kubectl\", args, err)\n\t}\n\n\treturn err\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.hashAdapter, app.immutableBuilder)\n}", "func (webType WebType) Create() error {\n\tlog.WithFields(log.Fields{}).Debug(\"Creating client app\")\n\n\terr := webType.Client.Create()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !webType.includeBackend {\n\t\treturn nil\n\t}\n\tlog.WithFields(log.Fields{}).Debug(\"Creating backend app\")\n\n\treturn webType.Server.Create()\n}", "func (tc TeresaClient) CreateApp(name string, scale int64, teamID int64) (app *models.App, err error) {\n\tparams := apps.NewCreateAppParams()\n\tparams.TeamID = teamID\n\tparams.WithBody(&models.App{Name: &name, Scale: &scale})\n\tr, err := tc.teresa.Apps.CreateApp(params, tc.apiKeyAuthFunc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn r.Payload, nil\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.immutableBuilder)\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.immutableBuilder)\n}", "func (p *ProgramData) Create() (err error) {\n\tlogging.Debugf(\"Creating server %s\", p.Id())\n\tp.Environment.DisplayToConsole(\"Allocating server\\n\")\n\terr = p.Environment.Create()\n\tp.Environment.DisplayToConsole(\"Server allocated\\n\")\n\tp.Environment.DisplayToConsole(\"Ready to be installed\\n\")\n\treturn\n}", "func (p *ProgramData) Create() (err error) {\n\tlogging.Debugf(\"Creating server %s\", p.Id())\n\tp.Environment.DisplayToConsole(\"Allocating server\\n\")\n\terr = p.Environment.Create()\n\tp.Environment.DisplayToConsole(\"Server allocated\\n\")\n\tp.Environment.DisplayToConsole(\"Ready to be installed\\n\")\n\treturn\n}", "func NewWindowsKioskProfile()(*WindowsKioskProfile) {\n m := &WindowsKioskProfile{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func NewApp() App {\n\treturn App{}\n}", "func NewApp() App {\n\treturn App{}\n}", "func Create() *MapUtil {\n\treturn &MapUtil{\n\t\tm: make(map[string]string),\n\t}\n}", "func NewCmdNewApplication(f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {\n\to := NewAppOptions(streams)\n\n\tcmd := &cobra.Command{\n\t\tUse: \"new-app (IMAGE | IMAGESTREAM | TEMPLATE | PATH | URL ...)\",\n\t\tShort: \"Create a new application\",\n\t\tLong: newAppLong,\n\t\tExample: newAppExample,\n\t\tSuggestFor: []string{\"app\", \"application\"},\n\t\tRun: func(c *cobra.Command, args []string) {\n\t\t\tkcmdutil.CheckErr(o.Complete(f, c, args))\n\t\t\tkcmdutil.CheckErr(o.RunNewApp())\n\t\t},\n\t}\n\n\to.PrintFlags.AddFlags(cmd)\n\n\tcmd.Flags().BoolVar(&o.Config.AsTestDeployment, \"as-test\", o.Config.AsTestDeployment, \"If true create this application as a test deployment, which validates that the deployment succeeds and then scales down.\")\n\tcmd.Flags().BoolVar(&o.Config.DeploymentConfig, \"as-deployment-config\", o.Config.DeploymentConfig, \"If true create this application as a deployment config, which allows for hooks and custom strategies.\")\n\tcmd.Flags().StringSliceVar(&o.Config.SourceRepositories, \"code\", o.Config.SourceRepositories, \"Source code to use to build this application.\")\n\tcmd.Flags().StringVar(&o.Config.ContextDir, \"context-dir\", o.Config.ContextDir, \"Context directory to be used for the build.\")\n\tcmd.Flags().StringSliceVarP(&o.Config.ImageStreams, \"image-stream\", \"i\", o.Config.ImageStreams, \"Name of an existing image stream to use to deploy an app.\")\n\tcmd.Flags().StringSliceVar(&o.Config.DockerImages, \"image\", o.Config.DockerImages, \"Name of a container image to include in the app. Note: not specifying a registry or repository means defaults in place for client image pulls are employed.\")\n\tcmd.Flags().StringSliceVar(&o.Config.DockerImages, \"docker-image\", o.Config.DockerImages, \"\")\n\tcmd.Flags().MarkDeprecated(\"docker-image\", \"Deprecated flag use --image\")\n\tcmd.Flags().StringSliceVar(&o.Config.Templates, \"template\", o.Config.Templates, \"Name of a stored template to use in the app.\")\n\tcmd.Flags().StringSliceVarP(&o.Config.TemplateFiles, \"file\", \"f\", o.Config.TemplateFiles, \"Path to a template file to use for the app.\")\n\tcmd.MarkFlagFilename(\"file\", \"yaml\", \"yml\", \"json\")\n\tcmd.Flags().StringArrayVarP(&o.Config.TemplateParameters, \"param\", \"p\", o.Config.TemplateParameters, \"Specify a key-value pair (e.g., -p FOO=BAR) to set/override a parameter value in the template.\")\n\tcmd.Flags().StringArrayVar(&o.Config.TemplateParameterFiles, \"param-file\", o.Config.TemplateParameterFiles, \"File containing parameter values to set/override in the template.\")\n\tcmd.MarkFlagFilename(\"param-file\")\n\tcmd.Flags().StringSliceVar(&o.Config.Groups, \"group\", o.Config.Groups, \"Indicate components that should be grouped together as <comp1>+<comp2>.\")\n\tcmd.Flags().StringArrayVarP(&o.Config.Environment, \"env\", \"e\", o.Config.Environment, \"Specify a key-value pair for an environment variable to set into each container.\")\n\tcmd.Flags().StringArrayVar(&o.Config.EnvironmentFiles, \"env-file\", o.Config.EnvironmentFiles, \"File containing key-value pairs of environment variables to set into each container.\")\n\tcmd.MarkFlagFilename(\"env-file\")\n\tcmd.Flags().StringArrayVar(&o.Config.BuildEnvironment, \"build-env\", o.Config.BuildEnvironment, \"Specify a key-value pair for an environment variable to set into each build image.\")\n\tcmd.Flags().StringArrayVar(&o.Config.BuildEnvironmentFiles, \"build-env-file\", o.Config.BuildEnvironmentFiles, \"File containing key-value pairs of environment variables to set into each build image.\")\n\tcmd.MarkFlagFilename(\"build-env-file\")\n\tcmd.Flags().StringVar(&o.Config.Name, \"name\", o.Config.Name, \"Set name to use for generated application artifacts\")\n\tcmd.Flags().Var(&o.Config.Strategy, \"strategy\", \"Specify the build strategy to use if you don't want to detect (docker|pipeline|source). NOTICE: the pipeline strategy is deprecated; consider using Jenkinsfiles directly on Jenkins or OpenShift Pipelines.\")\n\tcmd.Flags().StringP(\"labels\", \"l\", \"\", \"Label to set in all resources for this application.\")\n\tcmd.Flags().BoolVar(&o.Config.IgnoreUnknownParameters, \"ignore-unknown-parameters\", o.Config.IgnoreUnknownParameters, \"If true, will not stop processing if a provided parameter does not exist in the template.\")\n\tcmd.Flags().BoolVar(&o.Config.InsecureRegistry, \"insecure-registry\", o.Config.InsecureRegistry, \"If true, indicates that the referenced container images are on insecure registries and should bypass certificate checking\")\n\tcmd.Flags().BoolVarP(&o.Config.AsList, \"list\", \"L\", o.Config.AsList, \"List all local templates and image streams that can be used to create.\")\n\tcmd.Flags().BoolVarP(&o.Config.AsSearch, \"search\", \"S\", o.Config.AsSearch, \"Search all templates, image streams, and container images that match the arguments provided. Note: the container images search is run on the OpenShift cluster via the ImageStreamImport API.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowMissingImages, \"allow-missing-images\", o.Config.AllowMissingImages, \"If true, indicates that referenced container images that cannot be found locally or in a registry should still be used.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowMissingImageStreamTags, \"allow-missing-imagestream-tags\", o.Config.AllowMissingImageStreamTags, \"If true, indicates that image stream tags that don't exist should still be used.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowSecretUse, \"grant-install-rights\", o.Config.AllowSecretUse, \"If true, a component that requires access to your account may use your token to install software into your project. Only grant images you trust the right to run with your token.\")\n\tcmd.Flags().StringVar(&o.Config.SourceSecret, \"source-secret\", o.Config.SourceSecret, \"The name of an existing secret that should be used for cloning a private git repository.\")\n\tcmd.Flags().BoolVar(&o.Config.SkipGeneration, \"no-install\", o.Config.SkipGeneration, \"Do not attempt to run images that describe themselves as being installable\")\n\tcmd.Flags().BoolVar(&o.Config.BinaryBuild, \"binary\", o.Config.BinaryBuild, \"Instead of expecting a source URL, set the build to expect binary contents. Will disable triggers.\")\n\tcmd.Flags().StringVar(&o.Config.ImportMode, \"import-mode\", o.Config.ImportMode, \"Imports the full manifest list of a tag when set to 'PreserveOriginal'. Defaults to 'Legacy'.\")\n\n\to.Action.BindForOutput(cmd.Flags(), \"output\", \"template\")\n\tcmd.Flags().String(\"output-version\", \"\", \"The preferred API versions of the output objects\")\n\n\treturn cmd\n}", "func NewWindowsUniversalAppX()(*WindowsUniversalAppX) {\n m := &WindowsUniversalAppX{\n MobileLobApp: *NewMobileLobApp(),\n }\n odataTypeValue := \"#microsoft.graph.windowsUniversalAppX\";\n m.SetOdataType(&odataTypeValue);\n return m\n}", "func New() *App {\n\treturn &App{}\n}", "func (c *AppsServices) Create(opt *AppsOpt) (interface{}, error) {\n\tu, err := url.Parse(c.client.BaseURL.String() + \"apps\")\n\tif err != nil {\n\t\treturn Success{}, err\n\t}\n\n\tb, err := EncodeBody(opt)\n\tif err != nil {\n\t\treturn Success{}, err\n\t}\n\n\tc.client.UseAuthKey = true\n\tresp, err := POST(u.String(), b, c.client)\n\tif err != nil {\n\t\treturn Success{}, err\n\t}\n\n\treturn resp, nil\n}", "func CreateApp(\n\tctx context.Context,\n\tt *testing.T,\n\tf *framework.Framework,\n\tcleanupOpts *framework.CleanupOptions,\n\tnamespacedName types.NamespacedName,\n\tmatchLabels map[string]string,\n) appsv1.Deployment {\n\tt.Logf(\"Creating Deployment mock object '%#v'...\", namespacedName)\n\tns := namespacedName.Namespace\n\tappName := namespacedName.Name\n\n\td := mocks.DeploymentMock(ns, appName, matchLabels)\n\trequire.NoError(t, f.Client.Create(ctx, &d, cleanupOpts))\n\n\t// waiting for application deployment to reach one replica\n\tt.Log(\"Waiting for application deployment reach one replica...\")\n\trequire.NoError(\n\t\tt,\n\t\te2eutil.WaitForDeployment(t, f.KubeClient, ns, appName, 1, retryInterval, timeout),\n\t)\n\n\t// retrieveing deployment, to inspect its contents\n\tt.Logf(\"Reading application deployment '%s'\", appName)\n\trequire.NoError(t, f.Client.Get(ctx, namespacedName, &d))\n\n\treturn d\n}", "func (client ApplicationsClient) Create(ctx context.Context, parameters ApplicationCreateParameters) (result Application, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ApplicationsClient.Create\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response.Response != nil {\n\t\t\t\tsc = result.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: parameters,\n\t\t\tConstraints: []validation.Constraint{{Target: \"parameters.DisplayName\", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {\n\t\treturn result, validation.NewError(\"graphrbac.ApplicationsClient\", \"Create\", err.Error())\n\t}\n\n\treq, err := client.CreatePreparer(ctx, parameters)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"graphrbac.ApplicationsClient\", \"Create\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.CreateSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"graphrbac.ApplicationsClient\", \"Create\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.CreateResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"graphrbac.ApplicationsClient\", \"Create\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\n\treturn\n}", "func New(c Config) *App {\n\treturn &App{\n\t\tName: c.Name,\n\t}\n}", "func New(name string, ts Templates, o ...Option) *xpworkloadv1alpha1.KubernetesApplication {\n\topts := &options{\n\t\tnamespace: corev1.NamespaceDefault,\n\t\tcs: &metav1.LabelSelector{}, // The empty selector selects all clusters.\n\t}\n\n\tfor _, apply := range o {\n\t\tapply(opts)\n\t}\n\n\ta := &xpworkloadv1alpha1.KubernetesApplication{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tNamespace: opts.namespace,\n\t\t\tName: name,\n\t\t\tLabels: opts.labels,\n\t\t\tAnnotations: opts.annotations,\n\t\t\tOwnerReferences: opts.owners,\n\t\t},\n\t\tSpec: xpworkloadv1alpha1.KubernetesApplicationSpec{\n\t\t\tResourceSelector: &metav1.LabelSelector{MatchLabels: opts.labels},\n\t\t\tClusterSelector: opts.cs,\n\t\t\tResourceTemplates: make([]xpworkloadv1alpha1.KubernetesApplicationResourceTemplate, len(ts)),\n\t\t},\n\t\tStatus: xpworkloadv1alpha1.KubernetesApplicationStatus{\n\t\t\tCluster: opts.cluster,\n\t\t},\n\t}\n\n\tfor i, t := range ts {\n\t\tsecrets := opts.secrets.Get(t)\n\t\trt := xpworkloadv1alpha1.KubernetesApplicationResourceTemplate{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t// TODO(negz): Handle the case in which we have templates for\n\t\t\t\t// two resources with the same kind and name but different API\n\t\t\t\t// versions. The below format string will result in a name\n\t\t\t\t// conflict.\n\t\t\t\tName: strings.ToLower(fmt.Sprintf(\"%s-%s-%s\", name, t.GetKind(), t.GetName())),\n\t\t\t\tLabels: opts.labels,\n\t\t\t\tAnnotations: opts.annotations,\n\t\t\t},\n\t\t\tSpec: xpworkloadv1alpha1.KubernetesApplicationResourceSpec{\n\t\t\t\tTemplate: t,\n\t\t\t\tSecrets: make([]corev1.LocalObjectReference, len(secrets)),\n\t\t\t},\n\t\t}\n\n\t\tfor i, name := range secrets {\n\t\t\trt.Spec.Secrets[i] = corev1.LocalObjectReference{Name: name}\n\t\t}\n\n\t\ta.Spec.ResourceTemplates[i] = rt\n\t}\n\n\treturn a\n}", "func newApp(desc string) *cli.App {\n\tapp := cli.NewApp()\n\tapp.Name = name\n\tapp.HelpName = filepath.Base(os.Args[0])\n\tapp.Author = author\n\tapp.Version = version\n\tapp.Description = desc\n\tapp.Writer = os.Stdout\n\treturn app\n}", "func App() *Application {\r\n\r\n\t// Return singleton if already created\r\n\tif a != nil {\r\n\t\treturn a\r\n\t}\r\n\ta = new(Application)\r\n\t// Initialize window\r\n\terr := window.Init(width, height, title)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\ta.IWindow = window.Get()\r\n\ta.openDefaultAudioDevice() // Set up audio\r\n\ta.keyState = window.NewKeyState(a) // Create KeyState\r\n\t// Create renderer and add default shaders\r\n\ta.renderer = renderer.NewRenderer(a.Gls())\r\n\terr = a.renderer.AddDefaultShaders()\r\n\tif err != nil {\r\n\t\tpanic(fmt.Errorf(\"AddDefaultShaders:%v\", err))\r\n\t}\r\n\treturn a\r\n}", "func NewMicrosoftManagedDesktop()(*MicrosoftManagedDesktop) {\n m := &MicrosoftManagedDesktop{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func StartApp(info string) {\n\tvar k8sJcascApp = app.NewWithID(\"k8s_jcasc_mgmt_go_ui\")\n\tk8sJcascApp.SetIcon(resources.K8sJcascMgmtIcon())\n\n\t// set theme\n\tsetTheme(k8sJcascApp)\n\n\tvar k8sJcascWindow = k8sJcascApp.NewWindow(uiconstants.K8sJcasCMgmtTitle + kubernetesactions.GetKubernetesConfig().CurrentContext())\n\tk8sJcascWindow.SetIcon(resources.K8sJcascMgmtIcon())\n\tvar mainMenu = menu.CreateMainMenu(k8sJcascApp, k8sJcascWindow)\n\n\tk8sJcascWindow.SetMainMenu(mainMenu)\n\tk8sJcascWindow.SetMaster()\n\n\ttabs = menu.CreateTabMenu(k8sJcascApp, k8sJcascWindow, info)\n\n\tk8sJcascWindow.SetContent(tabs)\n\tk8sJcascWindow.Resize(fyne.Size{\n\t\tWidth: 980,\n\t\tHeight: 400,\n\t})\n\tk8sJcascWindow.ShowAndRun()\n}", "func CreateApplication(iq IQ, name, id, organizationID string) (string, error) {\n\tif name == \"\" || id == \"\" || organizationID == \"\" {\n\t\treturn \"\", fmt.Errorf(\"cannot create application with empty values\")\n\t}\n\n\tdoError := func(err error) (string, error) {\n\t\treturn \"\", fmt.Errorf(\"application '%s' not created: %v\", name, err)\n\t}\n\n\trequest, err := json.Marshal(iqNewAppRequest{Name: name, PublicID: id, OrganizationID: organizationID})\n\tif err != nil {\n\t\treturn doError(err)\n\t}\n\n\tbody, _, err := iq.Post(restApplication, bytes.NewBuffer(request))\n\tif err != nil {\n\t\treturn doError(err)\n\t}\n\n\tvar resp Application\n\tif err = json.Unmarshal(body, &resp); err != nil {\n\t\treturn doError(err)\n\t}\n\n\treturn resp.ID, nil\n}", "func New(opts ...Option) *App {\n\toptions := options{\n\t\tctx: context.Background(),\n\t\tsigns: []os.Signal{syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT},\n\t}\n\n\tif id, err := uuid.NewUUID(); err == nil {\n\t\toptions.id = id.String()\n\t}\n\n\tfor _, o := range opts {\n\t\to(&options)\n\t}\n\tctx, cancel := context.WithCancel(options.ctx)\n\treturn &App{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t\topts: options,\n\t}\n}", "func NewApp(name string, basename string, opts ...Option) *App {\n\ta := &App{\n\t\tname: name,\n\t\tbasename: basename,\n\t}\n\n\tfor _, o := range opts {\n\t\to(a)\n\t}\n\n\treturn a\n}", "func Create(app string, flags string, extensions string, tpl string) Wrapper {\n\tw := Wrapper{\n\t\tNoHighlight: true,\n\t\tDoTOC: true,\n\t\tDoStandalone: false,\n\t\tDoNumericalHeadings: false,\n\t}\n\tw.create(app, flags, extensions, tpl)\n\treturn w\n}", "func (c Client) CreateAppWithName(name string) (*App, error) {\n\treturn c.createApp(\n\t\tbytes.NewBuffer([]byte(fmt.Sprintf(`{\"name\":\"%s\"}`, name))),\n\t)\n}", "func New() *App {\n\treturn NewApp(newDefaultApp())\n}", "func CreateApp(a *App, units uint) error {\n\tif units == 0 {\n\t\treturn &ValidationError{Message: \"Cannot create app with 0 units.\"}\n\t}\n\tif !a.isValid() {\n\t\tmsg := \"Invalid app name, your app should have at most 63 \" +\n\t\t\t\"characters, containing only lower case letters or numbers, \" +\n\t\t\t\"starting with a letter.\"\n\t\treturn &ValidationError{Message: msg}\n\t}\n\tactions := []action{\n\t\tnew(insertApp),\n\t\tnew(createBucketIam),\n\t\tnew(createRepository),\n\t\tnew(provisionApp),\n\t}\n\treturn execute(a, actions, units)\n}", "func (srv *Server) Create(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != \"PUT\" {\n\t\thttp.Error(w, \"Please use a PUT request to create an application.\", http.StatusBadRequest)\n\t\treturn\n\t}\n\t// Read in body\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\thttp.Error(w, \"Failed to read body of request\", http.StatusInternalServerError)\n\t}\n\t// Try to parse the metadata content\n\tmetadata := &types.ApplicationMetadata{}\n\terr = yaml.Unmarshal(body, metadata)\n\tif err != nil {\n\t\thttp.Error(w, \"Failed to parse YAML input. This likely indicates malformed request body. Verify the payload fields and parameter types are correct.\", http.StatusBadRequest)\n\t\tlog.Info(\"YAML parse error\")\n\t\treturn\n\t}\n\n\t// Validate input\n\terr = srv.Validate.Struct(metadata)\n\tif err != nil {\n\t\t// If we fail to validate, automatically return 400\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(\"Failed to validate input of the following parameters:\\n\"))\n\n\t\t// Be helpful and tell users what fails in their request\n\t\tfor _, err := range err.(validator.ValidationErrors) {\n\t\t\tfmt.Fprintf(w, \"%s has invalid value %s\\n\", err.Namespace(), err.Value())\n\t\t}\n\t\tlog.Info(\"Rejected invalid input.\")\n\t\treturn\n\t}\n\n\t// Check if a conflicting application already exists\n\tif util.CheckTitle(srv.Applications, metadata.Title) {\n\t\tw.WriteHeader(http.StatusConflict)\n\t\tfmt.Fprintf(w, \"An application with title %s already exists, please use a unique title.\", metadata.Title)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusCreated)\n\tsrv.Applications = append(srv.Applications, metadata)\n\tlog.WithFields(log.Fields{\"name\": metadata.Title}).Info(\"Object added\")\n\treturn\n}", "func NewApp() App {\n\n\tvar err error\n\tvar app *appmgr\n\n\tconst appname = \"app\"\n\n\tapp = &appmgr{\n\t\tstate: fsm.Undefined,\n\t\tname: appname,\n\t\tprops: make(map[string]map[string]interface{}),\n\t\tdflow: nil,\n\t\tstore: nil,\n\t\tmsg: newMsgStream(\n\t\t\tappname,\n\t\t\tLvlInfo,\n\t\t\t//LvlDebug,\n\t\t\t//LvlError,\n\t\t\tnil,\n\t\t),\n\t\tevtmax: -1,\n\t\tnprocs: -1,\n\t\tcomps: make(map[string]Component),\n\t\ttsks: make([]Task, 0),\n\t\tsvcs: make([]Svc, 0),\n\t}\n\n\tsvc, err := app.New(\"go-hep.org/x/hep/fwk.datastore\", \"evtstore\")\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create evtstore: %w\\n\", err)\n\t\treturn nil\n\t}\n\tapp.store = svc.(*datastore)\n\n\terr = app.AddSvc(app.store)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create evtstore: %w\\n\", err)\n\t\treturn nil\n\t}\n\n\tsvc, err = app.New(\"go-hep.org/x/hep/fwk.dflowsvc\", \"dataflow\")\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create dataflow svc: %w\\n\", err)\n\t\treturn nil\n\t}\n\tapp.dflow = svc.(*dflowsvc)\n\n\terr = app.AddSvc(app.dflow)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not create dataflow svc: %w\\n\", err)\n\t\treturn nil\n\t}\n\n\terr = app.DeclProp(app, \"EvtMax\", &app.evtmax)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not declare property 'EvtMax': %w\\n\", err)\n\t\treturn nil\n\t}\n\n\terr = app.DeclProp(app, \"NProcs\", &app.nprocs)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not declare property 'NProcs': %w\\n\", err)\n\t\treturn nil\n\t}\n\n\terr = app.DeclProp(app, \"MsgLevel\", &app.msg.lvl)\n\tif err != nil {\n\t\tapp.msg.Errorf(\"fwk.NewApp: could not declare property 'MsgLevel': %w\\n\", err)\n\t\treturn nil\n\t}\n\n\treturn app\n}", "func NewApp(ctx *pulumi.Context,\n\tname string, args *AppArgs, opts ...pulumi.ResourceOption) (*App, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.AppType == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'AppType'\")\n\t}\n\tif args.DomainId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'DomainId'\")\n\t}\n\tif args.UserProfileName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'UserProfileName'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource App\n\terr := ctx.RegisterResource(\"aws-native:sagemaker:App\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewApp(entry *Entry) (app *App) {\n\tapp = new(App)\n\tapp.ID = entry.TrackID\n\tapp.Name = entry.TrackName\n\tapp.URL = entry.TrackViewURL\n\n\tapp.Icon = entry.ArtworkURL512\n\tapp.Kind = entry.Kind\n\tapp.Version = entry.Version\n\tapp.BundleID = entry.BundleID\n\n\tapp.AuthorID = entry.ArtistID\n\tapp.AuthorName = entry.ArtistName\n\tapp.AuthorURL = entry.ArtistViewURL\n\tapp.VendorName = entry.SellerName\n\tapp.VendorURL = entry.SellerURL\n\n\tapp.GenreID = entry.PrimaryGenreID\n\tapp.GenreIDList = stringSliceToInt(entry.GenreIDs)\n\tapp.Genre = entry.PrimaryGenreName\n\tapp.GenreList = entry.Genres\n\n\tapp.Icon60 = entry.ArtworkURL60\n\tapp.Icon100 = entry.ArtworkURL100\n\tapp.Price = int64(math.Ceil(entry.Price))\n\tapp.Currency = entry.Currency\n\n\tapp.System = entry.MinimumOsVersion\n\tapp.Features = entry.Features\n\tapp.Devices = entry.SupportedDevices\n\tapp.Languages = entry.LanguageCodesISO2A\n\n\tapp.Rating = entry.TrackContentRating\n\tif app.Rating == \"\" {\n\t\tapp.Rating = entry.ContentAdvisoryRating\n\t}\n\tapp.Reasons = entry.Advisories\n\n\tapp.Size, _ = strconv.ParseInt(entry.FileSizeBytes, 10, 64)\n\tapp.CntRating = entry.UserRatingCount\n\tapp.AvgRating = entry.AverageUserRating\n\tapp.CntRatingCurrent = entry.UserRatingCountForCurrentVersion\n\tapp.AvgRatingCurrent = entry.AverageUserRatingForCurrentVersion\n\tapp.VppDevice = entry.IsVppDeviceBasedLicensingEnabled\n\tapp.GameCenter = entry.IsGameCenterEnabled\n\n\tapp.Screenshots = merge(entry.ScreenshotURLs, entry.AppletvScreenshotURLs, entry.IpadScreenshotURLs)\n\n\t// Reserved fields: these fields should be fetched from iTunes page\n\t// app.Copyright\n\t// app.Platforms\n\t// app.InAppPurchase\n\t// app.SiblingApps\n\t// app.RelatedApps\n\t// app.SupportSites\n\t// app.Reviews\n\n\tapp.Description = entry.Description\n\tapp.ReleaseNotes = entry.ReleaseNotes\n\tapp.ReleaseTime, _ = time.Parse(time.RFC3339, entry.CurrentVersionReleaseDate)\n\tapp.PublishTime, _ = time.Parse(time.RFC3339, entry.ReleaseDate)\n\tapp.CrawledTime = time.Now()\n\tsort.Strings(app.Devices)\n\tsort.Strings(app.Languages)\n\n\treturn app\n}", "func createHelp() *cli.App {\n\ta := cli.NewApp()\n\ta.Name = appname\n\ta.Author = \"tanaike [ https://github.com/tanaikech/\" + appname + \" ] \"\n\ta.Email = \"[email protected]\"\n\ta.Usage = \"Download shared files on Google Drive.\"\n\ta.Version = \"1.0.2\"\n\ta.Flags = []cli.Flag{\n\t\tcli.StringFlag{\n\t\t\tName: \"url, u\",\n\t\t\tUsage: \"URL of shared file on Google Drive. This is a required parameter.\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"extension, e\",\n\t\t\tUsage: \"Extension of output file. This is for only Google Docs (Spreadsheet, Document, Presentation).\",\n\t\t\tValue: \"pdf\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"filename, f\",\n\t\t\tUsage: \"Filename of file which is output. When this was not used, the original filename on Google Drive is used.\",\n\t\t},\n\t}\n\treturn a\n}", "func NewApp(listenAddr string, ghClient *githubclient.Client, cache cache.Cache, objTTL time.Duration) App {\n\treturn App{\n\t\tlistenAddr: listenAddr,\n\t\tghClient: ghClient,\n\t\tcache: cache,\n\t\tcacheObjTTL: objTTL,\n\t}\n}", "func Create(name string) *Registry {\n\treturn &Registry{name: name, registrants: map[string]Registrant{}}\n}", "func NewApplication()(*Application) {\n m := &Application{\n DirectoryObject: *NewDirectoryObject(),\n }\n odataTypeValue := \"#microsoft.graph.application\";\n m.SetOdataType(&odataTypeValue);\n return m\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.hashAdapter)\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.hashAdapter)\n}", "func (m *ApplicationResource) CreateApplication(ctx context.Context, body App, qp *query.Params) (App, *Response, error) {\n\turl := fmt.Sprintf(\"/api/v1/apps\")\n\tif qp != nil {\n\t\turl = url + qp.String()\n\t}\n\n\trq := m.client.CloneRequestExecutor()\n\n\treq, err := rq.WithAccept(\"application/json\").WithContentType(\"application/json\").NewRequest(\"POST\", url, body)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tapplication := body\n\n\tresp, err := rq.Do(ctx, req, &application)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn application, resp, nil\n}", "func NewApp() *App {\n\treturn &App{\n\t\tName: filepath.Base(os.Args[0]),\n\t\tUsage: \"A new cli application\",\n\t\tVersion: \"0.0.0\",\n\t\tShowHelp: showHelp,\n\t\tShowVersion: showVersion,\n\t}\n}", "func NewApp(cfg *Config) *App {\n\treturn &App{\n\t\tl: log.With().Str(\"m\", \"app\").Logger(),\n\t\tcfg: cfg,\n\t\tgui: gui.NewGui(&cfg.Gui),\n\t}\n}", "func (app *externalBuilder) Create() ExternalBuilder {\n\treturn createExternalBuilder()\n}", "func NewApp() *App {\n\tpages := ui.NewPageHandler()\n\n\tapp := tview.NewApplication().\n\t\tSetInputCapture(pages.InputCapture()).\n\t\tSetRoot(pages, true)\n\n\treturn &App{\n\t\tPageHandler: pages,\n\t\tapp: app,\n\t}\n}", "func (app *folderNameBuilder) Create() FolderNameBuilder {\n\treturn createFolderNameBuilder()\n}", "func newApp(infile, outfile string) *App {\n\treturn &App{\n\t\tAddressFile: infile,\n\t\tGeoDecodeFile: outfile,\n\t\tClient: &http.Client{},\n\t}\n}" ]
[ "0.66225415", "0.654446", "0.6375472", "0.6223953", "0.61807823", "0.6058937", "0.60041124", "0.599074", "0.59359264", "0.58941877", "0.5833043", "0.5830877", "0.58298594", "0.58298594", "0.58147323", "0.5808668", "0.5769868", "0.5695114", "0.5672025", "0.5667319", "0.5640489", "0.56045645", "0.55995286", "0.55675364", "0.55620486", "0.55526495", "0.55285", "0.55276096", "0.5520376", "0.55183125", "0.54909366", "0.5486082", "0.54814446", "0.5475956", "0.5475837", "0.54758066", "0.5469234", "0.54557455", "0.5435438", "0.5433353", "0.5431241", "0.54212236", "0.54178107", "0.54109186", "0.5409645", "0.5398908", "0.5398321", "0.5392061", "0.5382898", "0.537364", "0.53627473", "0.53627473", "0.5360419", "0.5324575", "0.5323526", "0.5323346", "0.53216934", "0.53216934", "0.53165257", "0.53165257", "0.53050804", "0.5302653", "0.5302653", "0.53023964", "0.5292166", "0.5286455", "0.5286107", "0.5281834", "0.527448", "0.5265968", "0.5247186", "0.5246372", "0.52452654", "0.5241887", "0.5234337", "0.52328306", "0.52276707", "0.5206625", "0.520149", "0.51997733", "0.5189702", "0.5185107", "0.5183995", "0.5172573", "0.51667947", "0.5162251", "0.51595664", "0.5156629", "0.515465", "0.5151358", "0.5147868", "0.51452506", "0.51452506", "0.51344055", "0.5113974", "0.51137584", "0.510831", "0.5092578", "0.50897807", "0.50867397" ]
0.7543266
0
Update function updates an existing DesktopApp and returns a map that contains update result
func (o *DesktopApp) Update() (*restapi.GenericMapResponse, error) { if o.ID == "" { return nil, errors.New("error: ID is empty") } var queryArg = make(map[string]interface{}) queryArg, err := generateRequestMap(o) if err != nil { return nil, err } queryArg["_RowKey"] = o.ID LogD.Printf("Generated Map for Update(): %+v", queryArg) resp, err := o.client.CallGenericMapAPI(o.apiUpdate, queryArg) if err != nil { return nil, err } if !resp.Success { return nil, errors.New(resp.Message) } return resp, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (a *DesktopAppState) Update(mctx MetaContext, event string, provider rpc.Transporter) {\n\tmctx.Debug(\"DesktopAppState.Update(%v)\", event)\n\ta.Lock()\n\tdefer a.Unlock()\n\ta.provider = provider\n\tswitch event {\n\tcase \"suspend\":\n\t\ta.suspended = true\n\tcase \"resume\":\n\t\ta.suspended = false\n\tcase \"shutdown\":\n\tcase \"lock-screen\":\n\t\ta.locked = true\n\tcase \"unlock-screen\":\n\t\ta.suspended = false\n\t\ta.locked = false\n\t}\n\tfor _, ch := range a.updateSuspendChs {\n\t\tch <- a.suspended\n\t}\n\ta.updateSuspendChs = nil\n}", "func (a *Appwidgets) Update(code string, pType string) (resp objects.BaseOkResponse, err error) {\n\tparams := map[string]interface{}{}\n\n\tparams[\"code\"] = code\n\n\tparams[\"type\"] = pType\n\n\terr = a.SendObjRequest(\"appWidgets.update\", params, &resp)\n\n\treturn\n}", "func (s *APIServer) UpdateApps(c *gin.Context) {\n}", "func (p *Pvr) UpdateApplication(app AppData) error {\n\tappManifest, err := p.GetApplicationManifest(app.Appname)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !app.DoOverlay && (appManifest.Base == \"\" || appManifest.Base == app.Appname) {\n\t\tapp.SquashFile = SQUASH_FILE\n\t\tapp.DoOverlay = false\n\t\tfmt.Println(\"Update base: \" + app.SquashFile)\n\t\tappManifest.DockerOvlDigest = \"\"\n\t} else {\n\t\tapp.DoOverlay = true\n\t\tapp.SquashFile = SQUASH_OVL_FILE\n\t\tfmt.Println(\"Update ovl: \" + app.SquashFile)\n\t}\n\tswitch app.SourceType {\n\tcase models.SourceTypeDocker:\n\t\terr = UpdateDockerApp(p, &app, appManifest)\n\tcase models.SourceTypeRootFs:\n\t\terr = UpdateRootFSApp(p, &app, appManifest)\n\tcase models.SourceTypePvr:\n\t\terr = UpdatePvApp(p, &app, appManifest)\n\tdefault:\n\t\terr = fmt.Errorf(\"type %s not supported yet\", models.SourceTypePvr)\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = p.InstallApplication(&app)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tapps, err := p.GetApplications()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"Searching for dependencies of %s\\n\", app.Appname)\n\tfor _, a := range apps {\n\t\tif appManifest.Base == app.Appname {\n\t\t\tfmt.Printf(\"Updating dependency %s\\n\", a.Appname)\n\t\t\tif err := UpdateDockerApp(p, &a, appManifest); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Printf(\"%s is up to date\\n\", a.Appname)\n\t\t}\n\t}\n\n\treturn err\n}", "func Update(options types.Options, config config.Store) error {\n\tapp, err := update(options, config)\n\tif err != nil {\n\t\tif err.Error() == \"up-to-date\" {\n\t\t\tfmt.Printf(\"%s already up to date.\\n\", tui.Blue(\"[update]\"))\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfmt.Printf(\"⚡️ AppImage saved as %s \\n\", tui.Green(app.Filepath))\n\n\tfmt.Println(\"🚀 Done.\")\n\treturn nil\n}", "func AlertmanagerUpdate(alertm *Alertmanager, m *map[string]string) {\n\t//targetStat := \"10.3.21.14\"\n\tlog.Print(\"Updating map ...\")\n\tfor i := range alertm.Alerts {\n\t\talert := alertm.Alerts[i]\n\t\ttarget := (alert.Labels.(map[string]interface{})[\"instance\"]).(string)\n\t\tif alertm.Status == \"resolved\" {\n\t\t\t(*m)[target] = \"ok\"\n\t\t} else {\n\t\t\t(*m)[target] = (alert.Labels.(map[string]interface{})[\"severity\"]).(string)\n\t\t}\n\t}\n\tlog.Print(\"Map updated:\")\n\tlog.Println(*m)\n\tSendArduinoMap(&status)\n}", "func (r *app) Update(appGUID string, appPayload AppRequest, opts ...bool) (*AppFields, error) {\n\tasync := true\n\tif len(opts) > 0 {\n\t\tasync = opts[0]\n\t}\n\trawURL := fmt.Sprintf(\"/v2/apps/%s?async=%t\", appGUID, async)\n\tappFields := AppFields{}\n\t_, err := r.client.Put(rawURL, appPayload, &appFields)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &appFields, nil\n}", "func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationState) ImageUpdaterResult {\n\tvar needUpdate bool = false\n\n\tresult := ImageUpdaterResult{}\n\tapp := updateConf.UpdateApp.Application.GetName()\n\tchangeList := make([]ChangeEntry, 0)\n\n\t// Get all images that are deployed with the current application\n\tapplicationImages := GetImagesFromApplication(&updateConf.UpdateApp.Application)\n\n\tresult.NumApplicationsProcessed += 1\n\n\t// Loop through all images of current application, and check whether one of\n\t// its images is eligible for updating.\n\t//\n\t// Whether an image qualifies for update is dependent on semantic version\n\t// constraints which are part of the application's annotation values.\n\t//\n\tfor _, applicationImage := range updateConf.UpdateApp.Images {\n\t\tupdateableImage := applicationImages.ContainsImage(applicationImage, false)\n\t\tif updateableImage == nil {\n\t\t\tlog.WithContext().AddField(\"application\", app).Debugf(\"Image '%s' seems not to be live in this application, skipping\", applicationImage.ImageName)\n\t\t\tresult.NumSkipped += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// In some cases, the running image has no tag set. We create a dummy\n\t\t// tag, without name, digest and a timestamp of zero. This dummy tag\n\t\t// will trigger an update on the first run.\n\t\tif updateableImage.ImageTag == nil {\n\t\t\tupdateableImage.ImageTag = tag.NewImageTag(\"\", time.Unix(0, 0), \"\")\n\t\t}\n\n\t\tresult.NumImagesConsidered += 1\n\n\t\timgCtx := log.WithContext().\n\t\t\tAddField(\"application\", app).\n\t\t\tAddField(\"registry\", updateableImage.RegistryURL).\n\t\t\tAddField(\"image_name\", updateableImage.ImageName).\n\t\t\tAddField(\"image_tag\", updateableImage.ImageTag).\n\t\t\tAddField(\"alias\", applicationImage.ImageAlias)\n\n\t\tif updateableImage.KustomizeImage != nil {\n\t\t\timgCtx.AddField(\"kustomize_image\", updateableImage.KustomizeImage)\n\t\t}\n\n\t\timgCtx.Debugf(\"Considering this image for update\")\n\n\t\trep, err := registry.GetRegistryEndpoint(applicationImage.RegistryURL)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not get registry endpoint from configuration: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\tvar vc image.VersionConstraint\n\t\tif applicationImage.ImageTag != nil {\n\t\t\tvc.Constraint = applicationImage.ImageTag.TagName\n\t\t\timgCtx.Debugf(\"Using version constraint '%s' when looking for a new tag\", vc.Constraint)\n\t\t} else {\n\t\t\timgCtx.Debugf(\"Using no version constraint when looking for a new tag\")\n\t\t}\n\n\t\tvc.SortMode = applicationImage.GetParameterUpdateStrategy(updateConf.UpdateApp.Application.Annotations)\n\t\tvc.MatchFunc, vc.MatchArgs = applicationImage.GetParameterMatch(updateConf.UpdateApp.Application.Annotations)\n\t\tvc.IgnoreList = applicationImage.GetParameterIgnoreTags(updateConf.UpdateApp.Application.Annotations)\n\n\t\t// The endpoint can provide default credentials for pulling images\n\t\terr = rep.SetEndpointCredentials(updateConf.KubeClient)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not set registry endpoint credentials: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\timgCredSrc := applicationImage.GetParameterPullSecret(updateConf.UpdateApp.Application.Annotations)\n\t\tvar creds *image.Credential = &image.Credential{}\n\t\tif imgCredSrc != nil {\n\t\t\tcreds, err = imgCredSrc.FetchCredentials(rep.RegistryAPI, updateConf.KubeClient)\n\t\t\tif err != nil {\n\t\t\t\timgCtx.Warnf(\"Could not fetch credentials: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tregClient, err := updateConf.NewRegFN(rep, creds.Username, creds.Password)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not create registry client: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// Get list of available image tags from the repository\n\t\ttags, err := rep.GetTags(applicationImage, regClient, &vc)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not get tags from registry: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\timgCtx.Tracef(\"List of available tags found: %v\", tags.Tags())\n\n\t\t// Get the latest available tag matching any constraint that might be set\n\t\t// for allowed updates.\n\t\tlatest, err := updateableImage.GetNewestVersionFromTags(&vc, tags)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Unable to find newest version from available tags: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// If we have no latest tag information, it means there was no tag which\n\t\t// has met our version constraint (or there was no semantic versioned tag\n\t\t// at all in the repository)\n\t\tif latest == nil {\n\t\t\timgCtx.Debugf(\"No suitable image tag for upgrade found in list of available tags.\")\n\t\t\tresult.NumSkipped += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// If the user has specified digest as update strategy, but the running\n\t\t// image is configured to use a tag and no digest, we need to set an\n\t\t// initial dummy digest, so that tag.Equals() will return false.\n\t\t// TODO: Fix this. This is just a workaround.\n\t\tif vc.SortMode == image.VersionSortDigest {\n\t\t\tif !updateableImage.ImageTag.IsDigest() {\n\t\t\t\tlog.Tracef(\"Setting dummy digest for image %s\", updateableImage.GetFullNameWithTag())\n\t\t\t\tupdateableImage.ImageTag.TagDigest = \"dummy\"\n\t\t\t}\n\t\t}\n\n\t\tif needsUpdate(updateableImage, applicationImage, latest) {\n\n\t\t\timgCtx.Infof(\"Setting new image to %s\", applicationImage.WithTag(latest).GetFullNameWithTag())\n\t\t\tneedUpdate = true\n\n\t\t\terr = setAppImage(&updateConf.UpdateApp.Application, applicationImage.WithTag(latest))\n\n\t\t\tif err != nil {\n\t\t\t\timgCtx.Errorf(\"Error while trying to update image: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tcontainerImageNew := applicationImage.WithTag(latest)\n\t\t\t\timgCtx.Infof(\"Successfully updated image '%s' to '%s', but pending spec update (dry run=%v)\", updateableImage.GetFullNameWithTag(), containerImageNew.GetFullNameWithTag(), updateConf.DryRun)\n\t\t\t\tchangeList = append(changeList, ChangeEntry{containerImageNew, updateableImage.ImageTag, containerImageNew.ImageTag})\n\t\t\t}\n\t\t} else {\n\t\t\t// We need to explicitly set the up-to-date images in the spec too, so\n\t\t\t// that we correctly marshal out the parameter overrides to include all\n\t\t\t// images, regardless of those were updated or not.\n\t\t\terr = setAppImage(&updateConf.UpdateApp.Application, applicationImage.WithTag(updateableImage.ImageTag))\n\t\t\tif err != nil {\n\t\t\t\timgCtx.Errorf(\"Error while trying to update image: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t}\n\t\t\timgCtx.Debugf(\"Image '%s' already on latest allowed version\", updateableImage.GetFullNameWithTag())\n\t\t}\n\t}\n\n\twbc, err := getWriteBackConfig(&updateConf.UpdateApp.Application, updateConf.KubeClient, updateConf.ArgoClient)\n\tif err != nil {\n\t\treturn result\n\t}\n\n\tif wbc.Method == WriteBackGit {\n\t\tif updateConf.GitCommitUser != \"\" {\n\t\t\twbc.GitCommitUser = updateConf.GitCommitUser\n\t\t}\n\t\tif updateConf.GitCommitEmail != \"\" {\n\t\t\twbc.GitCommitEmail = updateConf.GitCommitEmail\n\t\t}\n\t\tif len(changeList) > 0 && updateConf.GitCommitMessage != nil {\n\t\t\twbc.GitCommitMessage = TemplateCommitMessage(updateConf.GitCommitMessage, updateConf.UpdateApp.Application.Name, changeList)\n\t\t}\n\t}\n\n\tif needUpdate {\n\t\tlogCtx := log.WithContext().AddField(\"application\", app)\n\t\tlog.Debugf(\"Using commit message: %s\", wbc.GitCommitMessage)\n\t\tif !updateConf.DryRun {\n\t\t\tlogCtx.Infof(\"Committing %d parameter update(s) for application %s\", result.NumImagesUpdated, app)\n\t\t\terr := commitChangesLocked(&updateConf.UpdateApp.Application, wbc, state)\n\t\t\tif err != nil {\n\t\t\t\tlogCtx.Errorf(\"Could not update application spec: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t\tresult.NumImagesUpdated = 0\n\t\t\t} else {\n\t\t\t\tlogCtx.Infof(\"Successfully updated the live application spec\")\n\t\t\t\tresult.NumImagesUpdated += 1\n\t\t\t\tif !updateConf.DisableKubeEvents && updateConf.KubeClient != nil {\n\t\t\t\t\tannotations := map[string]string{}\n\t\t\t\t\tfor i, c := range changeList {\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/full-image-name\", i)] = c.Image.GetFullNameWithoutTag()\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/image-name\", i)] = c.Image.ImageName\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/old-tag\", i)] = c.OldTag.String()\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/new-tag\", i)] = c.NewTag.String()\n\t\t\t\t\t}\n\t\t\t\t\tmessage := fmt.Sprintf(\"Successfully updated application '%s'\", app)\n\t\t\t\t\t_, err = updateConf.KubeClient.CreateApplicationEvent(&updateConf.UpdateApp.Application, \"ImagesUpdated\", message, annotations)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlogCtx.Warnf(\"Event could not be sent: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlogCtx.Infof(\"Dry run - not commiting %d changes to application\", result.NumImagesUpdated)\n\t\t}\n\t}\n\n\treturn result\n}", "func (o OpenSignal) UpdateAnApp(app App) (App, error) {\n\tstrResponse := App{}\n\n\tURL := f(updateAnApp, app.ID)\n\tres, body, errs := o.Client.Put(URL).\n\t\tSend(app).\n\t\tSet(\"Authorization\", \"Basic \"+o.AuthKey).\n\t\tEndStruct(&strResponse)\n\terr := catch(res, body)\n\tif err == nil {\n\t\tfor _, e := range errs {\n\t\t\tif e != nil {\n\t\t\t\terr = e\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn strResponse, err\n}", "func (d *Dev) Update() error {\n\tif err := d.sendCommand([]byte{enterRMWMode}); err != nil {\n\t\treturn err\n\t}\n\tfor i := 0; i < 8; i++ {\n\t\toffset := i * pageSize\n\t\tif err := d.sendCommand([]byte{setPageStart | byte(i), setColl, setCollH}); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := d.sendData(d.pixels[offset : offset+pageSize]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := d.sendCommand([]byte{exitRMWMode}); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func update(w http.ResponseWriter, req *http.Request) {\n\tresponse := \"\"\n\tswitch req.RequestURI {\n\tcase \"/get/accounts\":\n\t\tmapD := map[string]int{\"apple\": 5, \"lettuce\": 7}\n\t\tmapB, _ := json.Marshal(mapD)\n\t\tresponse = string(mapB)\n\t\tbreak\n\tdefault:\n\t\tr, _ := json.Marshal(\"Request not found\")\n\t\tresponse = string(r)\n\t\tbreak\n\t}\n\n\tcontext := Context{Title: response}\n\trender(w, \"api\", context)\n}", "func (a *Application) StartUpdate() {\n\told := *a\n\ta.old = &old\n}", "func (a *API) UpdateApplication(app Application, appEUI *lorawan.EUI64) error {\n\tif err := UpdateApplication(a.ctx.DB, app); err != nil {\n\t\treturn err\n\t}\n\t*appEUI = app.AppEUI\n\treturn nil\n}", "func (a *App) Update(patch *App) {\n\toriginal := a.Clone()\n\n\tif patch.Config != nil {\n\t\tif a.Config == nil {\n\t\t\ta.Config = make(Config)\n\t\t}\n\t\tfor k, v := range patch.Config {\n\t\t\tif v == \"\" {\n\t\t\t\tdelete(a.Config, k)\n\t\t\t} else {\n\t\t\t\ta.Config[k] = v\n\t\t\t}\n\t\t}\n\t}\n\n\tif patch.SyslogURL != nil {\n\t\tif *patch.SyslogURL == \"\" {\n\t\t\ta.SyslogURL = nil // hides it from jason\n\t\t} else {\n\t\t\ta.SyslogURL = patch.SyslogURL\n\t\t}\n\t}\n\n\ta.Annotations = a.Annotations.MergeChange(patch.Annotations)\n\n\tif !a.Equals(original) {\n\t\ta.UpdatedAt = common.DateTime(time.Now())\n\t}\n}", "func (client *Client) UpdateMessageApp(request *UpdateMessageAppRequest) (response *UpdateMessageAppResponse, err error) {\n\tresponse = CreateUpdateMessageAppResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func updateApp(c *corev1.Container, sfs api.StatefulApp, podSpec *api.PodSpec, cr *api.PerconaXtraDBCluster) (corev1.Container, error) {\n\tres, err := sfs.Resources(podSpec.Resources)\n\tif err != nil {\n\t\treturn *c, fmt.Errorf(\"create resources error: %v\", err)\n\t}\n\n\tif c == nil {\n\t\tappC := sfs.AppContainer(podSpec, cr.Spec.SecretsName)\n\t\tappC.Resources = res\n\t\treturn appC, nil\n\t}\n\n\tif !reflect.DeepEqual(c.Resources, res) {\n\t\tc.Resources = res\n\t}\n\tc.Image = podSpec.Image\n\n\treturn *c, nil\n}", "func (s HelpAppUpdateArray) ToMap() map[int]HelpAppUpdate {\n\tr := make(map[int]HelpAppUpdate, len(s))\n\ts.FillMap(r)\n\treturn r\n}", "func (c *common) update() error {\n\tif len(c.flags.update) == 0 {\n\t\treturn nil\n\t}\n\n\targs := append(c.flags.global, c.flags.update...)\n\n\treturn shared.RunCommand(c.ctx, nil, nil, c.commands.update, args...)\n}", "func RunAppsUpdate(c *CmdConfig) error {\n\tif len(c.Args) < 1 {\n\t\treturn doctl.NewMissingArgsErr(c.NS)\n\t}\n\tid := c.Args[0]\n\n\tspecPath, err := c.Doit.GetString(c.NS, doctl.ArgAppSpec)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tappSpec, err := apps.ReadAppSpec(os.Stdin, specPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tapp, err := c.Apps().Update(id, &godo.AppUpdateRequest{Spec: appSpec})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\twait, err := c.Doit.GetBool(c.NS, doctl.ArgCommandWait)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar errs error\n\n\tif wait {\n\t\tapps := c.Apps()\n\t\tnotice(\"App update is in progress, waiting for app to be running\")\n\t\terr := waitForActiveDeployment(apps, app.ID, app.GetPendingDeployment().GetID())\n\t\tif err != nil {\n\t\t\terrs = multierror.Append(errs, fmt.Errorf(\"app deployment couldn't enter `running` state: %v\", err))\n\t\t\tif err := c.Display(displayers.Apps{app}); err != nil {\n\t\t\t\terrs = multierror.Append(errs, err)\n\t\t\t}\n\t\t\treturn errs\n\t\t}\n\t\tapp, _ = c.Apps().Get(app.ID)\n\t}\n\n\tnotice(\"App updated\")\n\n\treturn c.Display(displayers.Apps{app})\n}", "func (f *DMAClient) Update(name string, obj *dm.M4DApplication) (*dm.M4DApplication, error) {\n\tvar result dm.M4DApplication\n\terr := f.client.Put().\n\t\tNamespace(f.namespace).Resource(f.plural).Name(name).\n\t\tBody(obj).Do(context.Background()).Into(&result)\n\treturn &result, err\n}", "func (controller AppsController) Update(c *gin.Context) {\n\tid := c.Params.ByName(\"id\")\n\tobjectID, _ := primitive.ObjectIDFromHex(id)\n\n\tvar app entities.App\n\terr := c.BindJSON(&app)\n\tif err != nil {\n\t\tfmt.Printf(\"error %v\", err)\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"message\": \"Invalid Parameters\"})\n\t\treturn\n\t}\n\tvar setElements bson.D\n\tif len(app.Name) > 0 {\n\t\tsetElements = append(setElements, bson.E{Key: \"name\", Value: app.Name})\n\t}\n\tif len(app.Icon) > 0 {\n\t\tsetElements = append(setElements, bson.E{Key: \"icon\", Value: app.Icon})\n\t}\n\tif len(app.Package) > 0 {\n\t\tsetElements = append(setElements, bson.E{Key: \"package\", Value: app.Package})\n\t}\n\tif len(app.BundleID) > 0 {\n\t\tsetElements = append(setElements, bson.E{Key: \"bundle_id\", Value: app.BundleID})\n\t}\n\tif len(app.Description) > 0 {\n\t\tsetElements = append(setElements, bson.E{Key: \"description\", Value: app.Description})\n\t}\n\n\tupdatedConfig, err := mongodb.UpdateOne(controller.MongoDBClient, Collections[\"apps\"],\n\t\tbson.M{\"_id\": objectID}, setElements, app)\n\tc.JSON(http.StatusOK, gin.H{\"app\": updatedConfig})\n}", "func updateAppHelm(root, profile, unit, application string) error {\n\tparser := yaml.NewParser()\n\terr := parser.Parse(profile)\n\tif err != nil {\n\t\tlog.Fatalf(\"parser.Parse profile error: err=%s\", err)\n\t}\n\texec := exec.NewExec(root)\n\tfor _, su := range parser.Profile.ServiceUnits {\n\t\tif !strings.EqualFold(su.Name, unit) {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, app := range su.Applications {\n\t\t\tif !strings.EqualFold(app.Name, application) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tshell := exec.Update(su.Name, parser.Profile.Namespace, app.Name)\n\t\t\tlog.Infof(\"Update application: su=%s, app=%s, shell=%s\", su.Name, application, shell)\n\t\t\terr := exec.Do(shell)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Helm install error: err=%s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (r *ApplicationRequest) Update(ctx context.Context, reqObj *Application) error {\n\treturn r.JSONRequest(ctx, \"PATCH\", \"\", reqObj, nil)\n}", "func (client *Client) UpdateAppInfo(request *UpdateAppInfoRequest) (_result *UpdateAppInfoResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &UpdateAppInfoResponse{}\n\t_body, _err := client.UpdateAppInfoWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "func AppUpdateHandler(context utils.Context, w http.ResponseWriter, r *http.Request) {\n\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.LogInfo.Printf(\"Error reading body: %v\", err)\n\t\thttp.Error(w, \"unable to read request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tlog.LogInfo.Printf(\"Attempting to update : %s\\n\", string(body))\n\n\t//use decode here instead of unmarshal\n\tapplication, err := utils.ParseJson(body)\n\n\tif err != nil {\n\t\tlog.LogError.Println(err)\n\t\thttp.Error(w, \"unable to parse JSON\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tdbConn := context.DBConn\n\tdbBucket := context.DBBucketApp\n\n\tkey := []byte(application.Environment + \"_\" + application.Name)\n\tvalue := []byte(body)\n\n\tif err := database.InsertDBValue(dbConn, dbBucket, key, value); err != nil {\n\t\tlog.LogInfo.Printf(\"Failed to update DB: %v\", err)\n\t}\n\n\tlog.LogInfo.Printf(\"application environment: %s\\n\", application.Environment)\n\n}", "func (pm *basePackageManager) Update() error {\n\t_, _, err := RunCommandWithRetry(pm.cmder.UpdateCmd(), nil)\n\treturn err\n}", "func EnvAppUpdate(ctx *Context, id int64, value string) error {\n\th := authHeader(ctx.Config.AuthToken)\n\ts := fmt.Sprintf(\"environment_variable(%d)\", id)\n\turi := ctx.Config.APIEndpoint(s)\n\tdata := make(map[string]interface{})\n\tdata[\"value\"] = value\n\tbody, err := marhsalReader(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\tb, err := doJSON(ctx, \"PATCH\", uri, h, nil, body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif string(b) != \"OK\" {\n\t\treturn errors.New(\"bad response\")\n\t}\n\treturn nil\n}", "func (marketApp *MarketPlaceApp) Update(tpl string, appendTemplate int) error {\n\t_, err := client.Call(\"one.marketapp.update\", marketApp.ID, tpl, appendTemplate)\n\treturn err\n}", "func (marketApp *MarketPlaceApp) Update(tpl string, appendTemplate int) error {\n\t_, err := client.Call(\"one.marketapp.update\", marketApp.ID, tpl, appendTemplate)\n\treturn err\n}", "func (ds *MySQLDatastore) UpdateApp(ctx context.Context, newapp *models.App) (*models.App, error) {\n\tapp := &models.App{Name: newapp.Name}\n\terr := ds.Tx(func(tx *sql.Tx) error {\n\t\trow := ds.db.QueryRow(`SELECT config FROM apps WHERE name=?`, app.Name)\n\n\t\tvar config string\n\t\tif err := row.Scan(&config); err != nil {\n\t\t\tif err == sql.ErrNoRows {\n\t\t\t\treturn models.ErrAppsNotFound\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t\tif config != \"\" {\n\t\t\terr := json.Unmarshal([]byte(config), &app.Config)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tapp.UpdateConfig(newapp.Config)\n\n\t\tcbyte, err := json.Marshal(app.Config)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tstmt, err := ds.db.Prepare(`UPDATE apps SET config=? WHERE name=?`)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tres, err := stmt.Exec(string(cbyte), app.Name)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif n, err := res.RowsAffected(); err != nil {\n\t\t\treturn err\n\t\t} else if n == 0 {\n\t\t\treturn models.ErrAppsNotFound\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn app, nil\n}", "func (o *DesktopApp) Query() (map[string]interface{}, error) {\n\tquery := \"SELECT * FROM Application WHERE 1=1 AND AppType='Desktop'\"\n\tif o.Name != \"\" {\n\t\tquery += \" AND Name='\" + o.Name + \"'\"\n\t}\n\n\treturn queryVaultObject(o.client, query)\n}", "func (set *Beatmaps) Update() error {\n\ttemp, err := set.session.FetchBeatmaps(set.apiCall)\n\t*set = temp\n\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\n\t// Allows for the updating of individual beatmaps\n\tfor i := 0; i < len(set.Beatmaps); i++ {\n\t\tv := url.Values{}\n\t\tv.Add(endpointAPIKey, set.session.key)\n\n\t\tif set.Converted != \"\" {\n\t\t\tv.Add(endpointParamConverted, set.Converted)\n\t\t}\n\n\t\tv.Add(endpointParamBeatmapID, set.Beatmaps[i].BeatmapID)\n\t\tv.Add(endpointParamMode, set.Beatmaps[i].Mode)\n\t\tset.Beatmaps[i].apiURL = set.session.buildCall(endpointBeatmaps, v)\n\t\tset.Beatmaps[i].session = set.session\n\t}\n\n\treturn nil\n}", "func Upgrade(config config.Store, silent bool) ([]string, error) {\n\tapps, err := List(config, false)\n\tvar updatedApps []string\n\tif err != nil {\n\t\treturn updatedApps, err\n\t}\n\tfor i := range apps {\n\t\tappsFormatted := fmt.Sprintf(\"[%s]\", apps[i])\n\t\tfmt.Printf(\"%s%s Checking for updates\\n\", tui.Blue(\"[update]\"), tui.Yellow(appsFormatted))\n\t\toptions := types.Options{\n\t\t\tName: apps[i],\n\t\t\tExecutable: apps[i],\n\t\t\tSilent: silent,\n\t\t}\n\t\t_, err := update(options, config)\n\n\t\tif err != nil {\n\t\t\tif err.Error() == \"up-to-date\" {\n\t\t\t\tfmt.Printf(\"%s%s AppImage is up to date.\\n\", tui.Blue(\"[update]\"), tui.Green(appsFormatted))\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"%s%s failed to update, %s\\n\", tui.Blue(\"[update]\"),\n\t\t\t\t\ttui.Red(appsFormatted), tui.Yellow(err))\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Printf(\"%s%s Updated.\\n\", tui.Blue(\"[update]\"), tui.Green(appsFormatted))\n\t\t\tupdatedApps = append(updatedApps, apps[i])\n\t\t}\n\n\t}\n\n\tfmt.Println(\"🚀 Done.\")\n\treturn updatedApps, nil\n}", "func (ch *ClickHouse) Update(object map[string]interface{}) error {\n\treturn ch.SyncStore(nil, []map[string]interface{}{object}, \"\", true)\n}", "func (sm *Statemgr) updateAttachedApps(sgp *security.NetworkSecurityPolicy) error {\n\tfor _, rule := range sgp.Spec.Rules {\n\t\tif len(rule.Apps) != 0 {\n\t\t\tfor _, appName := range rule.Apps {\n\t\t\t\tapp, err := sm.FindApp(sgp.Tenant, appName)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"Error finding app %v for policy %v, rule {%v}\", appName, sgp.Name, rule)\n\t\t\t\t\treturn fmt.Errorf(\"Error finding app %v for policy %v, rule {%v}\", appName, sgp.Name, rule)\n\t\t\t\t\t//return kvstore.NewKeyNotFoundError(appName, 0)\n\t\t\t\t}\n\n\t\t\t\tapp.attachPolicy(sgp.Name)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *PromptManager) Update(p *Prompt, opts ...RequestOption) error {\n\treturn m.Request(\"PATCH\", m.URI(\"prompts\"), p, opts...)\n}", "func (srv *Server) Update() {\n\tsrv.mu.Lock()\n\tdefer srv.mu.Unlock()\n\tsrv.statusBar.ActiveTabIndex = srv.windows.ActiveIndex()\n\twin := srv.windows.Active()\n\tif win == nil {\n\t\treturn\n\t}\n\twin.Touch()\n\tsrv.statusBar.TabNames, srv.statusBar.TabsWithActivity = srv.windows.TabNames()\n\tsrv.chatPane.SelectedRow = win.CurrentLine()\n\tsrv.chatPane.Rows = win.Lines()\n\tsrv.chatPane.Title = win.Title()\n\n\tif ch, ok := win.(*Channel); ok {\n\t\tsrv.chatPane.SubTitle = ch.Topic()\n\t\tsrv.chatPane.ModeText = ch.Modes()\n\t} else {\n\t\tsrv.chatPane.SubTitle = \"\"\n\t\tsrv.chatPane.ModeText = \"\"\n\t}\n\tsrv.chatPane.LeftPadding = win.padding() + 7\n\tif srv.statusBar.ActiveTabIndex == 0 {\n\t\tsrv.chatPane.ModeText = srv.currentNick\n\t}\n\tsrv.mainWindow.Items = nil\n\tif v, ok := win.(WindowWithUserList); ok {\n\t\tsrv.userListPane.Rows = v.UserList()\n\t\tsuff := \"s\"\n\t\tif len(srv.userListPane.Rows) == 1 {\n\t\t\tsuff = \"\"\n\t\t}\n\t\tsrv.userListPane.Title = fmt.Sprintf(\"%d user%s\", len(srv.userListPane.Rows), suff)\n\t\tsrv.mainWindow.Set(\n\t\t\tui.NewCol(.85, srv.chatPane),\n\t\t\tui.NewCol(.15, srv.userListPane),\n\t\t)\n\t} else {\n\t\tsrv.mainWindow.Set(\n\t\t\tui.NewCol(1, srv.chatPane),\n\t\t)\n\t}\n}", "func (e *Exec) Update(su, namespace, name string) []string {\n\tcommand := \"/usr/local/bin/helm update \" + e.Path + \"/\" + su + \"/\" + name + \" --name=\" + name + \" --namespace=\" + namespace\n\treturn strings.Split(command, \" \")\n}", "func (actor Actor) UpdateApplication(app Application) (Application, Warnings, error) {\n\tccApp := ccv3.Application{\n\t\tGUID: app.GUID,\n\t\tStackName: app.StackName,\n\t\tLifecycleType: app.LifecycleType,\n\t\tLifecycleBuildpacks: app.LifecycleBuildpacks,\n\t}\n\n\tupdatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccApp)\n\tif err != nil {\n\t\treturn Application{}, Warnings(warnings), err\n\t}\n\n\treturn actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil\n}", "func (em envmap) update(o envmap) {\n\tfor k, v := range o {\n\t\tem[k] = v\n\t}\n}", "func (r *DeviceAppManagementRequest) Update(ctx context.Context, reqObj *DeviceAppManagement) error {\n\treturn r.JSONRequest(ctx, \"PATCH\", \"\", reqObj, nil)\n}", "func (s *Server) Update(ctx context.Context, q *ProjectUpdateRequest) (*v1alpha1.AppProject, error) {\n\tif q.Project.Name == common.DefaultAppProjectName {\n\t\treturn nil, grpc.ErrPermissionDenied\n\t}\n\tif !s.enf.EnforceClaims(ctx.Value(\"claims\"), \"projects\", \"update\", q.Project.Name) {\n\t\treturn nil, grpc.ErrPermissionDenied\n\t}\n\terr := validateProject(q.Project)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts.projectLock.Lock(q.Project.Name)\n\tdefer s.projectLock.Unlock(q.Project.Name)\n\n\toldProj, err := s.appclientset.ArgoprojV1alpha1().AppProjects(s.ns).Get(q.Project.Name, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tappsList, err := s.appclientset.ArgoprojV1alpha1().Applications(s.ns).List(metav1.ListOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tremovedDst := getRemovedDestination(oldProj, q.Project)\n\tremovedSrc := getRemovedSources(oldProj, q.Project)\n\n\tremovedDstUsed := make([]v1alpha1.ApplicationDestination, 0)\n\tremovedSrcUsed := make([]string, 0)\n\n\tfor _, a := range argo.FilterByProjects(appsList.Items, []string{q.Project.Name}) {\n\t\tif dest, ok := removedDst[fmt.Sprintf(\"%s/%s\", a.Spec.Destination.Server, a.Spec.Destination.Namespace)]; ok {\n\t\t\tremovedDstUsed = append(removedDstUsed, dest)\n\t\t}\n\t\tif _, ok := removedSrc[a.Spec.Source.RepoURL]; ok {\n\t\t\tremovedSrcUsed = append(removedSrcUsed, a.Spec.Source.RepoURL)\n\t\t}\n\t}\n\tif len(removedDstUsed) > 0 {\n\t\tformattedRemovedUsedList := make([]string, len(removedDstUsed))\n\t\tfor i := 0; i < len(removedDstUsed); i++ {\n\t\t\tformattedRemovedUsedList[i] = fmt.Sprintf(\"server: %s, namespace: %s\", removedDstUsed[i].Server, removedDstUsed[i].Namespace)\n\t\t}\n\t\treturn nil, status.Errorf(\n\t\t\tcodes.InvalidArgument, \"following destinations are used by one or more application and cannot be removed: %s\", strings.Join(formattedRemovedUsedList, \";\"))\n\t}\n\tif len(removedSrcUsed) > 0 {\n\t\treturn nil, status.Errorf(\n\t\t\tcodes.InvalidArgument, \"following source repos are used by one or more application and cannot be removed: %s\", strings.Join(removedSrcUsed, \";\"))\n\t}\n\n\tres, err := s.appclientset.ArgoprojV1alpha1().AppProjects(s.ns).Update(q.Project)\n\tif err == nil {\n\t\ts.logEvent(res, ctx, argo.EventReasonResourceUpdated, \"update\")\n\t}\n\treturn res, err\n}", "func update(vs *ViewServer, primary string, backup string){\n\tvs.currentView.Viewnum += 1\n\tvs.currentView.Primary = primary\n\tvs.currentView.Backup = backup\n\tvs.idleServer = \"\"\n\tvs.primaryACK = false\n\tvs.backupACK = false\n}", "func (s *HelloSystem) Update(ctx core.UpdateCtx) {}", "func (c *CmdEvent) GetRadarrApplicationUpdate() (output RadarrApplicationUpdate, err error) {\n\treturn output, c.get(EventApplicationUpdate, &output)\n}", "func (s Store) UpdateApplicationForVersion(metadata utils.Metadata) error {\n\ttitle := metadata.Title\n\tversion := metadata.Version\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\tif exists, err := s.isApplicationPresent(title, version); !exists {\n\t\treturn err\n\t}\n\ts.appToDetails[title][version] = metadata\n\n\treturn nil\n}", "func (s *Sysinfo) Update() {\n\tinfo := syscall.Sysinfo_t{}\n\terr := syscall.Sysinfo(&info)\n\tif err != nil {\n\t\tlog.Printf(\"Sysinfo call failed: %s\", err.Error())\n\t\treturn\n\t}\n\n\ts.uptime = uint64(info.Uptime)\n\ts.memTotal = info.Totalram\n\ts.memFree = info.Freeram\n\ts.memShared = info.Sharedram\n\ts.memBuffer = info.Bufferram\n\ts.swapTotal = info.Totalswap\n\ts.swapFree = info.Freeswap\n\ts.load = info.Loads\n\ts.procs = uint64(info.Procs)\n}", "func ExampleApplicationsClient_Update() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armmanagedapplications.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewApplicationsClient().Update(ctx, \"rg\", \"myManagedApplication\", &armmanagedapplications.ApplicationsClientUpdateOptions{Parameters: &armmanagedapplications.ApplicationPatchable{\n\t\tKind: to.Ptr(\"ServiceCatalog\"),\n\t\tProperties: &armmanagedapplications.ApplicationPropertiesPatchable{\n\t\t\tApplicationDefinitionID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef\"),\n\t\t\tManagedResourceGroupID: to.Ptr(\"/subscriptions/subid/resourceGroups/myManagedRG\"),\n\t\t},\n\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.Application = armmanagedapplications.Application{\n\t// \tName: to.Ptr(\"myManagedApplication\"),\n\t// \tType: to.Ptr(\"Microsoft.Solutions/applications\"),\n\t// \tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication\"),\n\t// \tKind: to.Ptr(\"ServiceCatalog\"),\n\t// \tProperties: &armmanagedapplications.ApplicationProperties{\n\t// \t\tApplicationDefinitionID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef\"),\n\t// \t\tManagedResourceGroupID: to.Ptr(\"/subscriptions/subid/resourceGroups/myManagedRG\"),\n\t// \t\tProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded),\n\t// \t},\n\t// }\n}", "func ExampleApplicationsClient_Update() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armmanagedapplications.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewApplicationsClient().Update(ctx, \"rg\", \"myManagedApplication\", &armmanagedapplications.ApplicationsClientUpdateOptions{Parameters: &armmanagedapplications.ApplicationPatchable{\n\t\tKind: to.Ptr(\"ServiceCatalog\"),\n\t\tProperties: &armmanagedapplications.ApplicationProperties{\n\t\t\tApplicationDefinitionID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef\"),\n\t\t\tManagedResourceGroupID: to.Ptr(\"/subscriptions/subid/resourceGroups/myManagedRG\"),\n\t\t},\n\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.Application = armmanagedapplications.Application{\n\t// \tName: to.Ptr(\"myManagedApplication\"),\n\t// \tType: to.Ptr(\"Microsoft.Solutions/applications\"),\n\t// \tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication\"),\n\t// \tKind: to.Ptr(\"ServiceCatalog\"),\n\t// \tProperties: &armmanagedapplications.ApplicationProperties{\n\t// \t\tApplicationDefinitionID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef\"),\n\t// \t\tManagedResourceGroupID: to.Ptr(\"/subscriptions/subid/resourceGroups/myManagedRG\"),\n\t// \t\tProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded),\n\t// \t},\n\t// }\n}", "func (c *AppsServices) Update(id string, opt *AppsOpt) (interface{}, error) {\n\tu, err := url.Parse(c.client.BaseURL.String() + \"apps/\" + id)\n\tif err != nil {\n\t\treturn Success{}, err\n\t}\n\n\tb, err := EncodeBody(opt)\n\tif err != nil {\n\t\treturn Success{}, err\n\t}\n\n\tc.client.UseAuthKey = true\n\tresp, err := PUT(u.String(), b, c.client)\n\tif err != nil {\n\t\treturn Success{}, err\n\t}\n\n\treturn resp, nil\n}", "func (c *Client) upgradeWindows(update *update.Update) {\n\tyes, _ := ui.Question(Title, \"An Update is available! Upgrade Now?\\n\\n\"+\n\t\t\"Your Version: \"+update.Version+\"\\n\"+\n\t\t\"New Version: \"+update.Current+\"\\n\"+\n\t\t\"Date: \"+update.RelDate.Format(\"Jan 2, 2006\")+\" (\"+\n\t\tdurafmt.Parse(time.Since(update.RelDate).Round(time.Hour)).String()+\" ago)\", false)\n\tif yes {\n\t\tif err := c.updateNow(update, \"user requested\"); err != nil {\n\t\t\tc.Errorf(\"Update Failed: %v\", err)\n\t\t\t_, _ = ui.Error(Title+\" ERROR\", \"Updating Notifiarr:\\n\"+err.Error()+\"\\n\")\n\t\t}\n\t}\n}", "func (throttler *Throttler) RecentAppsMap() (result map[string](*base.RecentApp)) {\n\tresult = make(map[string](*base.RecentApp))\n\n\tfor recentAppKey, item := range throttler.recentApps.Items() {\n\t\trecentApp := base.NewRecentApp(item.Object.(time.Time))\n\t\tresult[recentAppKey] = recentApp\n\t}\n\treturn result\n}", "func (a *MobileAppState) Update(state keybase1.MobileAppState) {\n\tdefer a.G().Trace(fmt.Sprintf(\"MobileAppState.Update(%v)\", state), nil)()\n\ta.Lock()\n\tdefer a.Unlock()\n\ta.updateLocked(state)\n}", "func (appPortProfile *NsxtAppPortProfile) Update(appPortProfileConfig *types.NsxtAppPortProfile) (*NsxtAppPortProfile, error) {\n\tendpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointAppPortProfiles\n\tminimumApiVersion, err := appPortProfile.client.checkOpenApiEndpointCompatibility(endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif appPortProfileConfig.ID == \"\" {\n\t\treturn nil, fmt.Errorf(\"cannot update NSX-T Application Port Profile without ID\")\n\t}\n\n\turlRef, err := appPortProfile.client.OpenApiBuildEndpoint(endpoint, appPortProfileConfig.ID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturnObject := &NsxtAppPortProfile{\n\t\tNsxtAppPortProfile: &types.NsxtAppPortProfile{},\n\t\tclient: appPortProfile.client,\n\t}\n\n\terr = appPortProfile.client.OpenApiPutItem(minimumApiVersion, urlRef, nil, appPortProfileConfig, returnObject.NsxtAppPortProfile, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error updating NSX-T Application Port Profile : %s\", err)\n\t}\n\n\treturn returnObject, nil\n}", "func (as *AppStorage) UpdateApp(appID string, newApp model.AppData) (model.AppData, error) {\n\tif _, err := xid.FromString(appID); err != nil {\n\t\tlog.Println(\"Incorrect appID: \", appID)\n\t\treturn nil, model.ErrorWrongDataFormat\n\t}\n\n\tres, ok := newApp.(*AppData)\n\tif !ok || res == nil {\n\t\treturn nil, model.ErrorWrongDataFormat\n\t}\n\n\t// use ID from the request if it's not set\n\tif len(newApp.ID()) == 0 {\n\t\tres.appData.ID = appID\n\t}\n\n\toldAppData := &AppData{appData: appData{ID: appID}}\n\tif err := as.DisableApp(oldAppData); err != nil {\n\t\tlog.Println(\"Error disabling old app:\", err)\n\t\treturn nil, err\n\t}\n\n\tupdatedApp, err := as.addNewApp(res)\n\treturn updatedApp, err\n}", "func (c *Context) UpdateGamepadMappings(mappings string) bool {\n\tcMappings := C.CString(mappings)\n\tdefer C.free(unsafe.Pointer(cMappings))\n\treturn int(C.glfwUpdateGamepadMappings(cMappings)) == int(True)\n}", "func (md *MockDisplay) Update(*[64][32]uint8, *[64][32]bool) {}", "func (plugin *ipamPlugin) Update(args *cniSkel.CmdArgs) error {\n\treturn nil\n}", "func (e *Environment) Update(a [][]string) {\n\tfor _, keyvalue := range a {\n\t\te.Add(keyvalue[0], keyvalue[1])\n\t}\n}", "func (s HelpAppUpdateArray) FillMap(to map[int]HelpAppUpdate) {\n\tfor _, value := range s {\n\t\tto[value.GetID()] = value\n\t}\n}", "func (opt *MainOpt) UpdateObjects() {\n\n\t// With GtkApplicationWindow (does not happen with GtkWindow) I have strange behavior\n\t// when updating window size and position, sometimes width, height is not restored\n\t// successfully, I have tried to figure it out but after a few (long) times I resigned\n\t// myself to using a workaround method, right now I am using a timer that runs 'count'\n\t// times the same commands to finally get the desired result (set window's size with\n\t// the previously saved values).\n\t// count := 5\n\t// glib.TimeoutAdd(uint(64), func() bool {\n\n\tmainObjects.MainWindow.Resize(opt.MainWinWidth, opt.MainWinHeight)\n\tmainObjects.MainWindow.Move(opt.MainWinPosX, opt.MainWinPosY)\n\n\t// count--\n\t// return count > 0\n\t// })\n\n\tmainObjects.CheckbuttonAddReminder.SetActive(opt.Reminder)\n\tmainObjects.CheckbuttonMd4.SetActive(opt.Md4)\n\tmainObjects.CheckbuttonMd5.SetActive(opt.Md5)\n\tmainObjects.CheckbuttonSha1.SetActive(opt.Sha1)\n\tmainObjects.CheckbuttonSha256.SetActive(opt.Sha256)\n\tmainObjects.CheckbuttonSha384.SetActive(opt.Sha384)\n\tmainObjects.CheckbuttonSha512.SetActive(opt.Sha512)\n\tmainObjects.CheckbuttonSha3_256.SetActive(opt.Sha3_256)\n\tmainObjects.CheckbuttonSha3_384.SetActive(opt.Sha3_384)\n\tmainObjects.CheckbuttonSha3_512.SetActive(opt.Sha3_512)\n\tmainObjects.CheckbuttonBlake2b256.SetActive(opt.Blake2b256)\n\tmainObjects.CheckbuttonBlake2b384.SetActive(opt.Blake2b384)\n\tmainObjects.CheckbuttonBlake2b512.SetActive(opt.Blake2b512)\n\tmainObjects.CheckbuttonShowFilename.SetActive(opt.ShowFilename)\n\tmainObjects.CheckbuttonAppendFiles.SetActive(opt.AppendDroppedFiles)\n\tmainObjects.CheckbuttonUseDecimal.SetActive(opt.UseDecimal)\n\tmainObjects.CheckbuttonConcurrentOp.SetActive(opt.ConcurrentOp)\n\tmainObjects.CheckbuttonRecursiveScan.SetActive(opt.RecursiveScan)\n\tmainObjects.CheckbuttonCreateFile.SetActive(opt.MakeOutputFile)\n\n\tif len(opt.CurrentStackPage) > 0 {\n\t\tmainObjects.Stack.SetVisibleChildName(opt.CurrentStackPage)\n\t}\n\tmainObjects.SwitchTreeView.SetActive(opt.SwitchStackPage)\n\tmainObjects.SwitchExpand.SetActive(opt.SwitchExpandState)\n\tSwitchExpandStateSet(mainObjects.SwitchExpand)\n\n\tmainObjects.CheckbuttonShowSplash.SetActive(opt.ShowSplash)\n}", "func (a *AppController) UpdateWorlds() {\n\ta.handleResult(models.UpdateRandomWorlds(a.getCount()))\n}", "func Update(ctx *fasthttp.RequestCtx) {\n\tqueries := queriesParam(ctx)\n\tworlds := acquireWorlds()\n\tworlds.W = worlds.W[:queries]\n\n\tfor i := range worlds.W {\n\t\tw := &worlds.W[i]\n\t\tid := randomWorldNum()\n\n\t\tdb.QueryRow(ctx, worldSelectSQL, id).Scan(&w.ID, &w.RandomNumber) // nolint:errcheck\n\t\tw.RandomNumber = int32(randomWorldNum())\n\t}\n\n\t// against deadlocks\n\tsort.Slice(worlds.W, func(i, j int) bool {\n\t\treturn worlds.W[i].ID < worlds.W[j].ID\n\t})\n\n\tbatch := &pgx.Batch{}\n\n\tfor i := range worlds.W {\n\t\tw := &worlds.W[i]\n\t\tbatch.Queue(worldUpdateSQL, w.RandomNumber, w.ID)\n\t}\n\n\tdb.SendBatch(ctx, batch).Close()\n\n\tdata, _ := json.Marshal(worlds.W)\n\n\tctx.Response.Header.SetContentType(contentTypeJSON)\n\tctx.Response.SetBody(data)\n\n\treleaseWorlds(worlds)\n}", "func (gc *GlobalConfig) getUpdateEntries() map[string]*EntryValue {\n\treturn gc.UpdateEntries\n}", "func (d Device) ApplyUpdate(u api.UpdatePackage) error {\n\tif err := os.WriteFile(d.bundlePath, u.ProofBundle, os.ModePerm); err != nil {\n\t\treturn fmt.Errorf(\"failed to write proof bundle to %q: %w\", d.bundlePath, err)\n\t}\n\n\tfw := u.FirmwareImage\n\tif err := os.WriteFile(d.fwDevPath, fw, os.ModePerm); err != nil {\n\t\treturn fmt.Errorf(\"failed to write firmware image to %q: %w\", d.fwDevPath, err)\n\t}\n\n\treturn nil\n}", "func (a *DefaultApiService) UpdateApplication(ctx _context.Context, id string) ApiUpdateApplicationRequest {\n\treturn ApiUpdateApplicationRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tid: id,\n\t}\n}", "func (a *ApplicationsApiService) ListApplicationToUpdateExecute(r ApiListApplicationToUpdateRequest) (ApplicationResponseList, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue ApplicationResponseList\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"ApplicationsApiService.ListApplicationToUpdate\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/environment/{environmentId}/application/to-update\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"environmentId\"+\"}\", _neturl.PathEscape(parameterToString(r.environmentId, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\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\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\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 := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = _ioutil.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\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 (au *AppUpdate) Exec(ctx context.Context) error {\n\t_, err := au.Save(ctx)\n\treturn err\n}", "func (a *AppAQI) Update(completed_tasks []common.TaskData, time int) {\n\t// record measurements\n\tfor _, t := range completed_tasks {\n\t\tm := utils.MeasurementKey{Location: t.Location}\n\t\tif _, ok := a.ground_truth[m]; !ok {\n\t\t\tlog.Fatalf(\"[app] could not index aqi measurement at %v\", m)\n\t\t}\n\t\tlog.Debugf(\n\t\t\t\"[app] measured aqi %v at %v, time %v\",\n\t\t\ta.ground_truth[m],\n\t\t\tt.Location,\n\t\t\tt.FulfillTime,\n\t\t)\n\t\ta.add_measurement(t.Location, t.FulfillTime, a.ground_truth[m])\n\t}\n\n\t// run GP fit, update interestmap\n\tif len(a.measurements) > 0 {\n\t\tuncertain := a.run_gp_fit(time)\n\t\tlog.Debugf(\"uncertainty: %+v\", uncertain)\n\t\ta.interest_map = make(common.InterestMap)\n\t\tfor _, t := range a.tasks {\n\t\t\tif _, exists := uncertain[t.Location]; exists {\n\t\t\t\ta.interest_map[t.GetTask()] = t\n\t\t\t}\n\t\t}\n\t}\n}", "func update(screen *ebiten.Image) error {\n\tif currentScreen == gameScreen {\n\t\treturn game(screen)\n\t}\n\treturn menu(screen)\n\n}", "func (r *SettingsSearchapplicationsService) Update(name string, searchapplication *SearchApplication) *SettingsSearchapplicationsUpdateCall {\n\tc := &SettingsSearchapplicationsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.name = name\n\tc.searchapplication = searchapplication\n\treturn c\n}", "func (db *AppDB) Update() error {\n\tq := query.NewQuery().Insert(\"results\", allFields)\n\n\tstmt, err := db.Prepare(q.SQL.String())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor res := range Scrape() {\n\t\tif db.Exists(res.Date) {\n\t\t\treturn fmt.Errorf(\"update done\")\n\t\t}\n\n\t\tif _, err := stmt.Exec(res.Date, res.Set, res.Machine, res.Balls[0], res.Balls[1], res.Balls[2], res.Balls[3], res.Balls[4], res.Balls[5], res.Bonus); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlog.Printf(\"Inserted: %+v \\n\", res)\n\t}\n\n\treturn nil\n}", "func (a *PushKeyAPI) update(params interface{}) (resp *rpc.Response) {\n\treturn rpc.Success(a.mods.PushKey.Update(cast.ToStringMap(params)))\n}", "func (a *ApplicationsApiService) ListApplicationToUpdate(ctx _context.Context, environmentId string) ApiListApplicationToUpdateRequest {\n\treturn ApiListApplicationToUpdateRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tenvironmentId: environmentId,\n\t}\n}", "func (client *Client) UpdateAppInfoWithOptions(request *UpdateAppInfoRequest, runtime *util.RuntimeOptions) (_result *UpdateAppInfoResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.AppId)) {\n\t\tquery[\"AppId\"] = request.AppId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.AppName)) {\n\t\tquery[\"AppName\"] = request.AppName\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Description)) {\n\t\tquery[\"Description\"] = request.Description\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Status)) {\n\t\tquery[\"Status\"] = request.Status\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"UpdateAppInfo\"),\n\t\tVersion: tea.String(\"2017-03-21\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &UpdateAppInfoResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "func JSONUpdate(js *JSONReq, m *map[string]string) {\n\tlog.Print(\"Updating map ...\")\n\t(*m)[js.Target] = js.Status\n\tlog.Print(\"Map updated:\")\n\tlog.Println(*m)\n\tSendArduinoMap(&status)\n}", "func getLocaleUpdate(localeId string) (map[string]interface{}, error) {\n\tresp := map[string]interface{}{}\n\n\tentities, err := model.GetEntitiesAtLocale(localeId)\n\tif err != nil {\n\t\treturn resp, fmt.Errorf(\"error retrieving entities to broadcast for locale %v: %v\", localeId, err)\n\t}\n\n\tresp[\"entities\"] = entities\n\tif err != nil {\n\t\treturn resp, fmt.Errorf(\"error marshalling response: %v\", err)\n\t}\n\n\treturn resp, nil\n}", "func updateKeyValues(w http.ResponseWriter, r *http.Request) {\n\titems := make(map[string]*Item, 10)\n\terr := json.NewDecoder(r.Body).Decode(&items)\n\tif err != nil {\n\t\tsendResponse(w, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\terr = updater.Update(items)\n\tif err != nil {\n\t\tsendResponse(w, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\tsendResponse(w, http.StatusOK, \"OK\")\n}", "func (g GaugeMaps) Update(resources Resources) {\n\tg[cpu].Update(resources.GetCPU())\n\tg[mem].Update(resources.GetMem())\n\tg[disk].Update(resources.GetDisk())\n\tg[gpu].Update(resources.GetGPU())\n}", "func unmarshalUpdateAppAppsPayload(ctx context.Context, service *goa.Service, req *http.Request) error {\n\tpayload := &appPayload{}\n\tif err := service.DecodeRequest(req, payload); err != nil {\n\t\treturn err\n\t}\n\tif err := payload.Validate(); err != nil {\n\t\t// Initialize payload with private data structure so it can be logged\n\t\tgoa.ContextRequest(ctx).Payload = payload\n\t\treturn err\n\t}\n\tgoa.ContextRequest(ctx).Payload = payload.Publicize()\n\treturn nil\n}", "func (m *Application) UpdateApp(app Application) error {\n\treturn Update(db, collection, bson.M{\"_id\": app.ID}, app)\n}", "func (m *MainWindow) UpdateServers() {\n\tif m.servers_already_updating {\n\t\treturn\n\t}\n\tm.servers_already_updating = true\n\n\tctx.Eventer.LaunchEvent(\"setToolbarLabelText\", map[string]string{\"text\": \"<markup><span foreground=\\\"red\\\" font_weight=\\\"bold\\\">\" + ctx.Translator.Translate(\"Updating servers...\", nil) + \"</span></markup>\"})\n\tcurrent_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))\n\tfmt.Println(\"Updating servers on tab '\" + current_tab + \"'...\")\n\n\tif strings.Contains(current_tab, ctx.Translator.Translate(\"Servers\", nil)) {\n\t\tgo ctx.Requester.UpdateAllServers(false)\n\t} else if strings.Contains(current_tab, ctx.Translator.Translate(\"Favorites\", nil)) {\n\t\tgo ctx.Requester.UpdateFavoriteServers()\n\t}\n}", "func (tc TeresaClient) PartialUpdateApp(teamID, appID int64, operations []*models.PatchAppRequest) error {\n\tp := apps.NewPartialUpdateAppParams()\n\tp.TeamID = teamID\n\tp.AppID = appID\n\tp.Body = operations\n\n\t_, err := tc.teresa.Apps.PartialUpdateApp(p, tc.apiKeyAuthFunc)\n\treturn err\n}", "func (client AppsClient) Update(ctx context.Context, appID uuid.UUID, applicationUpdateObject ApplicationUpdateObject) (result OperationStatus, err error) {\n\treq, err := client.UpdatePreparer(ctx, appID, applicationUpdateObject)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"programmatic.AppsClient\", \"Update\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.UpdateSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"programmatic.AppsClient\", \"Update\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.UpdateResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"programmatic.AppsClient\", \"Update\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (o *DesktopApp) Read() error {\n\tif o.ID == \"\" {\n\t\treturn errors.New(\"error: ID is empty\")\n\t}\n\tvar queryArg = make(map[string]interface{})\n\tqueryArg[\"_RowKey\"] = o.ID\n\n\t// Attempt to read from an upstream API\n\tresp, err := o.client.CallGenericMapAPI(o.apiRead, queryArg)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !resp.Success {\n\t\treturn errors.New(resp.Message)\n\t}\n\n\tfillWithMap(o, resp.Result)\n\tLogD.Printf(\"Filled object: %+v\", o)\n\n\treturn nil\n}", "func (lc *LocalConfig) getUpdateEntries() map[string]*EntryValue {\n\treturn lc.UpdateEntries\n}", "func (m *store) Update(w ukjent.Word) error {\n\tdefer m.withWrite()()\n\tm.data[w.Word] = entry{w.Translation, w.Note}\n\treturn nil\n}", "func (a *prUserIdMapperApp) updateUserIdMapper(w http.ResponseWriter, r *http.Request) {\n\tuserIdMapper := prUserIdMapper{}\n\n\t// Read URI variables\n\t// vars := mux.Vars(r)\n\n\thtmlData, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(htmlData, &userIdMapper)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\tct := time.Now().UTC()\n\tuserIdMapper.Updated = ct.Format(time.RFC3339)\n\tuserIdMapper.LoginCount += 1\n\n\tif err := userIdMapper.updateUserIdMapper(a.DB); err != nil {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid request payload\")\n\t\treturn\n\t}\n\n\trespondWithJSON(w, http.StatusOK, userIdMapper)\n\n}", "func (d *MockDatastore) Update(ctx context.Context) (map[string][]byte, error) {\n\treturn d.server.Update(ctx)\n}", "func (c *Client) UpdateApp(ctx context.Context, params *UpdateAppInput, optFns ...func(*Options)) (*UpdateAppOutput, error) {\n\tif params == nil {\n\t\tparams = &UpdateAppInput{}\n\t}\n\n\tresult, metadata, err := c.invokeOperation(ctx, \"UpdateApp\", params, optFns, addOperationUpdateAppMiddlewares)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tout := result.(*UpdateAppOutput)\n\tout.ResultMetadata = metadata\n\treturn out, nil\n}", "func (a AppsApi) AppsAppPatch(app string, body AppWrapper) (*AppWrapper, *APIResponse, error) {\n\n\tvar localVarHttpMethod = strings.ToUpper(\"Patch\")\n\t// create path and map variables\n\tlocalVarPath := a.Configuration.BasePath + \"/apps/{app}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"app\"+\"}\", fmt.Sprintf(\"%v\", app), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := make(map[string]string)\n\tvar localVarPostBody interface{}\n\tvar localVarFileName string\n\tvar localVarFileBytes []byte\n\t// add default headers if any\n\tfor key := range a.Configuration.DefaultHeader {\n\t\tlocalVarHeaderParams[key] = a.Configuration.DefaultHeader[key]\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 := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = &body\n\tvar successPayload = new(AppWrapper)\n\tlocalVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\n\tvar localVarURL, _ = url.Parse(localVarPath)\n\tlocalVarURL.RawQuery = localVarQueryParams.Encode()\n\tvar localVarAPIResponse = &APIResponse{Operation: \"AppsAppPatch\", Method: localVarHttpMethod, RequestURL: localVarURL.String()}\n\tif localVarHttpResponse != nil {\n\t\tlocalVarAPIResponse.Response = localVarHttpResponse.RawResponse\n\t\tlocalVarAPIResponse.Payload = localVarHttpResponse.Body()\n\t}\n\n\tif err != nil {\n\t\treturn successPayload, localVarAPIResponse, err\n\t}\n\terr = json.Unmarshal(localVarHttpResponse.Body(), &successPayload)\n\treturn successPayload, localVarAPIResponse, err\n}", "func updateInputs(msg tea.Msg, m model) (model, tea.Cmd) {\n\tvar (\n\t\tcmd tea.Cmd\n\t\tcmds []tea.Cmd\n\t)\n\n\tfor i := 0; i < len(m.settingsInputsScreen.input); i++ {\n\t\tm.settingsInputsScreen.input[i], cmd = m.settingsInputsScreen.input[i].Update(msg)\n\t\tcmds = append(cmds, cmd)\n\t}\n\n\treturn m, tea.Batch(cmds...)\n}", "func ExampleUpdater() error {\n\tconf := updater.Config{\n\t\tOmahaURL: \"http://test.omahaserver.com/v1/update/\",\n\t\tAppID: \"application_id\",\n\t\tChannel: \"stable\",\n\t\tInstanceID: uuid.NewString(),\n\t\tInstanceVersion: \"0.0.1\",\n\t}\n\n\tappUpdater, err := updater.New(conf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"init updater: %w\", err)\n\t}\n\n\tctx := context.TODO()\n\n\tupdateInfo, err := appUpdater.CheckForUpdates(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"checking updates for app: %q, err: %w\", conf.AppID, err)\n\t}\n\n\tif !updateInfo.HasUpdate {\n\t\treturn fmt.Errorf(\"No update exists for the application\")\n\t}\n\n\t// So we got an update, let's report we'll start downloading it.\n\tif err := appUpdater.ReportProgress(ctx, updater.ProgressDownloadStarted); err != nil {\n\t\tif progressErr := appUpdater.ReportError(ctx, nil); progressErr != nil {\n\t\t\tfmt.Println(\"Reporting progress error:\", progressErr)\n\t\t}\n\t\treturn fmt.Errorf(\"reporting download started: %w\", err)\n\t}\n\n\t// This should be implemented by the caller.\n\tfilePath, err := someFunctionThatDownloadsAFile(ctx, updateInfo.URL())\n\tif err != nil {\n\t\t// Oops something went wrong.\n\t\tif progressErr := appUpdater.ReportError(ctx, nil); progressErr != nil {\n\t\t\tfmt.Println(\"reporting error:\", progressErr)\n\t\t}\n\t\treturn fmt.Errorf(\"downloading update: %w\", err)\n\t}\n\n\t// The download was successful, let's inform that to the Omaha server.\n\tif err := appUpdater.ReportProgress(ctx, updater.ProgressDownloadFinished); err != nil {\n\t\tif progressErr := appUpdater.ReportError(ctx, nil); progressErr != nil {\n\t\t\tfmt.Println(\"Reporting progress error:\", progressErr)\n\t\t}\n\t\treturn fmt.Errorf(\"reporting download finished: %w\", err)\n\t}\n\n\t// We got our update file, let's install it!\n\tif err := appUpdater.ReportProgress(ctx, updater.ProgressInstallationStarted); err != nil {\n\t\tif progressErr := appUpdater.ReportError(ctx, nil); progressErr != nil {\n\t\t\tfmt.Println(\"reporting progress error:\", progressErr)\n\t\t}\n\t\treturn fmt.Errorf(\"reporting installation started: %w\", err)\n\t}\n\n\t// This should be your own implementation.\n\tif err := someFunctionThatExtractsTheUpdateAndInstallIt(ctx, filePath); err != nil {\n\t\t// Oops something went wrong.\n\t\tif progressErr := appUpdater.ReportError(ctx, nil); progressErr != nil {\n\t\t\tfmt.Println(\"Reporting error:\", progressErr)\n\t\t}\n\t\treturn fmt.Errorf(\"applying update: %w\", err)\n\t}\n\n\tif err := appUpdater.CompleteUpdate(ctx, updateInfo); err != nil {\n\t\tif progressErr := appUpdater.ReportError(ctx, nil); progressErr != nil {\n\t\t\tfmt.Println(\"reporting progress error:\", progressErr)\n\t\t}\n\t\treturn fmt.Errorf(\"reporting complete update: %w\", err)\n\t}\n\n\treturn nil\n}", "func UpdateWindowSizes() {\n\t//ts1 := time.Now()\n\tfor runtime := range runtimes {\n\t\tif runtime != \"edge\" {\n\t\t\twindowSizes[runtime] = GetWindowSize(runtime)\n\t\t}\n\t}\n\t//fmt.Println(time.Now().Sub(ts1))\n}", "func (l *List) Update() {\n\tl.win.Update()\n}", "func (u *App) Update(c echo.Context, r *Update) (result *model.File, err error) {\n\tfile, err := u.udb.View(u.db, r.ID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := u.rbac.EnforceUser(c, file.UserID); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif file.Type == model.ResourceApplication {\n\t\tif err = u.rbac.EnforceRole(c, model.OperatorRole); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tfile.Comment = r.Comment\n\tfile.Status = r.Status\n\t// file.Public = r.Public\n\n\tif err = u.udb.Update(u.db, file); err != nil {\n\t\treturn\n\t}\n\treturn u.udb.View(u.db, r.ID)\n}", "func checkForUpdates(app *cli.App) {\n\tspinner, _ := pterm.DefaultSpinner.Start(\"Checking for updates...\")\n\tc := http.Client{Timeout: 10 * time.Second}\n\n\tresp, err := c.Get(\"https://github.com/ayoisaiah/focus/releases/latest\")\n\tif err != nil {\n\t\tpterm.Error.Println(\"HTTP Error: Failed to check for update\")\n\t\treturn\n\t}\n\n\tdefer resp.Body.Close()\n\n\tvar version string\n\n\t_, err = fmt.Sscanf(\n\t\tresp.Request.URL.String(),\n\t\t\"https://github.com/ayoisaiah/focus/releases/tag/%s\",\n\t\t&version,\n\t)\n\tif err != nil {\n\t\tpterm.Error.Println(\"Failed to get latest version\")\n\t\treturn\n\t}\n\n\tif version == app.Version {\n\t\ttext := pterm.Sprintf(\n\t\t\t\"Congratulations, you are using the latest version of %s\",\n\t\t\tapp.Name,\n\t\t)\n\t\tspinner.Success(text)\n\t} else {\n\t\tpterm.Warning.Prefix = pterm.Prefix{\n\t\t\tText: \"UPDATE AVAILABLE\",\n\t\t\tStyle: pterm.NewStyle(pterm.BgYellow, pterm.FgBlack),\n\t\t}\n\t\tpterm.Warning.Printfln(\"A new release of Focus is available: %s at %s\", version, resp.Request.URL.String())\n\t}\n}", "func Updates(ctx *fasthttp.RequestCtx) {\n\tqueries := queriesParam(ctx)\n\tworlds := acquireWorlds()\n\tworlds.W = worlds.W[:queries]\n\n\tfor i := 0; i < queries; i++ {\n\t\tw := &worlds.W[i]\n\t\tid := randomWorldNum()\n\n\t\tdb.QueryRow(context.Background(), worldSelectSQL, id).Scan(&w.ID, &w.RandomNumber) // nolint:errcheck\n\t\tw.RandomNumber = int32(randomWorldNum())\n\t}\n\n\t// against deadlocks\n\tsort.Slice(worlds.W, func(i, j int) bool {\n\t\treturn worlds.W[i].ID < worlds.W[j].ID\n\t})\n\n\tbatch := &pgx.Batch{}\n\n\tfor i := 0; i < queries; i++ {\n\t\tw := &worlds.W[i]\n\t\tbatch.Queue(worldUpdateSQL, w.RandomNumber, w.ID)\n\t}\n\n\tdb.SendBatch(context.Background(), batch).Close()\n\n\tdata, _ := json.Marshal(worlds.W)\n\n\tctx.Response.Header.SetContentType(contentTypeJSON)\n\tctx.Response.SetBody(data)\n\n\treleaseWorlds(worlds)\n}", "func (a *App) Update(w http.ResponseWriter, r *http.Request) {\n\tv := mux.Vars(r)\n\tidentifier := v[\"identifier\"]\n\n\tchange, err := parsebody(r)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err = change.InitChangeRequest(); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Generate the configuration.\n\tcfg, err := a.GenerateConfig(change)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tjsonpath := path.Join(a.ConfigDir, fmt.Sprintf(\"%s.json\", identifier))\n\tconfigpath := path.Join(a.ConfigDir, fmt.Sprintf(\"%s.conf\", identifier))\n\tif _, err = os.Stat(jsonpath); os.IsNotExist(err) {\n\t\terr = errors.Wrapf(err, \"path does not exist: %s\", jsonpath)\n\t\thttp.Error(w, err.Error(), http.StatusNotFound)\n\t\treturn\n\t}\n\n\tif _, err = os.Stat(configpath); os.IsNotExist(err) {\n\t\terr = errors.Wrapf(err, \"path does not exist: %s\", configpath)\n\t\thttp.Error(w, err.Error(), http.StatusNotFound)\n\t\treturn\n\t}\n\n\t// Serialize the JSON file to the filesystem.\n\tjson, err := json.Marshal(change)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif err = ioutil.WriteFile(jsonpath, json, 0644); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Serialize the configuration file to the filesystem.\n\tif err = ioutil.WriteFile(configpath, cfg, 0644); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif err = a.SignalContainers(); err != nil {\n\t\terr = errors.Wrap(err, \"error HUPing container(s)\")\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func (c *APIClient) UpdateHomePage(hp string) error {\n\tlog.Printf(\"try to set homepage to %s\\n\", hp)\n\n\t//get specific dashboard id\n\tslugUrl := makeUrl(c.BaseUrl, fmt.Sprintf(\"%s%s\",\"/api/dashboards/db/\", hp))\n\tlog.Printf(\"homepage url %s\\n\", slugUrl)\n\tdbid, err := getDashboardId(slugUrl)\n\tif err != nil {\n\t\tlog.Printf(\"Get dashboardid %s failed %s \\n.\", hp, err)\n\t\treturn err\n\t}\n\n\t//star the dashboard.\n\tstarUrl := makeUrl(c.BaseUrl, fmt.Sprintf(\"%s/%d\", \"/api/user/stars/dashboard\", dbid))\n\terr = starDashboard(starUrl, c.HTTPClient)\n\tif err != nil {\n\t\tlog.Printf(\"Star dashboard %d failed %s \\n.\", dbid, err)\n\t\treturn err\n\t}\n\n\t//update preference home page to hp\n\tprefUrl := makeUrl(c.BaseUrl,\"/api/org/preferences\")\n\terr = c.updateHomeDashboard(prefUrl, dbid, c.HTTPClient)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"Set homepage to dashboard %s done\\n\", hp)\n\treturn nil\n}" ]
[ "0.6385493", "0.6043658", "0.5864704", "0.5800069", "0.5693987", "0.56730175", "0.56563413", "0.5626671", "0.56140643", "0.5547077", "0.55217266", "0.55096394", "0.54742914", "0.5469813", "0.54679286", "0.5461321", "0.54513216", "0.5429835", "0.54193294", "0.53887457", "0.53877586", "0.5370243", "0.5347481", "0.5310583", "0.5267889", "0.51992804", "0.5195019", "0.51928085", "0.51928085", "0.5182265", "0.5179781", "0.51658714", "0.51557285", "0.51285625", "0.5117217", "0.51110303", "0.5099492", "0.5097501", "0.50900596", "0.50847393", "0.5074975", "0.5072448", "0.5069244", "0.5028225", "0.5027918", "0.49988204", "0.49831247", "0.49797744", "0.49763954", "0.4965321", "0.4958853", "0.49574986", "0.4936751", "0.49328822", "0.49323106", "0.49189067", "0.49146912", "0.4908251", "0.48943976", "0.48840085", "0.48676103", "0.4863695", "0.4846535", "0.48394915", "0.48379064", "0.4827524", "0.4827149", "0.48202372", "0.48170972", "0.48141697", "0.4808069", "0.48031628", "0.47917432", "0.47884867", "0.47833353", "0.47817376", "0.47759858", "0.47744754", "0.47738862", "0.47726515", "0.47714862", "0.47712922", "0.47632736", "0.47564808", "0.47524056", "0.47465998", "0.47261152", "0.4711034", "0.47105712", "0.47011653", "0.47010288", "0.46962687", "0.46934235", "0.46905693", "0.46868053", "0.46827072", "0.46707648", "0.4669536", "0.4668564", "0.46674463" ]
0.75419784
0
Delete function deletes a DesktopApp and returns a map that contains deletion result
func (o *DesktopApp) Delete() (*restapi.SliceResponse, error) { if o.ID == "" { return nil, errors.New("error: ID is empty") } var queryArg = make(map[string]interface{}) queryArg["_RowKey"] = []string{o.ID} resp, err := o.client.CallSliceAPI(o.apiDelete, queryArg) if err != nil { return nil, err } if !resp.Success { return nil, errors.New(resp.Message) } return resp, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (am *ArtifactMap) DeleteApp(AppGUID string) {\n\tvar desiredApp *ArtifactEntry\n\tindex := 0\n\tfor i, app := range am.AppList {\n\t\tif app.GUID == AppGUID {\n\t\t\tdesiredApp = app\n\t\t\tindex = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif desiredApp != nil {\n\t\tam.AppList = append(am.AppList[:index], am.AppList[index+1:]...)\n\t\tam.appTitleToID.Delete(desiredApp.Title)\n\t\tam.appTitleToItemID.Delete(desiredApp.Title)\n\t}\n}", "func printDeleteAppInfo(client *occlient.Client, appName string, projectName string) error {\n\tcomponentList, err := component.List(client, appName)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get Component list\")\n\t}\n\n\tfor _, currentComponent := range componentList {\n\t\tcomponentDesc, err := component.GetComponentDesc(client, currentComponent.ComponentName, appName, projectName)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"unable to get component description\")\n\t\t}\n\t\tlog.Info(\"Component\", currentComponent.ComponentName, \"will be deleted.\")\n\n\t\tif len(componentDesc.URLs) != 0 {\n\t\t\tfmt.Println(\" Externally exposed URLs will be removed\")\n\t\t}\n\n\t\tfor _, store := range componentDesc.Storage {\n\t\t\tfmt.Println(\" Storage\", store.Name, \"of size\", store.Size, \"will be removed\")\n\t\t}\n\n\t}\n\treturn nil\n}", "func TestDeleteApp(t *testing.T) {\n\n\tvar err error\n\n\t// Use the configuration manager to get Algolia's keys to mock the app interactor\n\tconfigInteractor := interfaces.ConfigurationManager{}\n\tconfigInteractor.ConfigurationInteractor = infrastructure.NewViperConfig()\n\n\t// Instanciate the App interactor\n\tappInteractor := usecases.NewAppInteractor(\n\t\tinterfaces.NewAlgoliaRepository(\n\t\t\tconfigInteractor.GetConfigString(\"algolia.applicationID\", \"NOT_SET\"),\n\t\t\tconfigInteractor.GetConfigString(\"algolia.apiKey\", \"NOT_SET\"),\n\t\t\tconfigInteractor.GetConfigString(\"algolia.indexes.apps\", \"NOT_SET\"),\n\t\t),\n\t)\n\n\t// Single addition\n\t// Create a random app\n\ttestApp := domain.NewApp(\n\t\t\"Unit testing app interactor\",\n\t\t\"static.whatthetvshow.com:9000/media/snapshots/c4c3021b168ba93572d402e313f0f884_medium.png\",\n\t\t\"http://whatthetvshow.com/fe/snapshots/2205\",\n\t\t\"Quiz unit tests Benjamin\",\n\t\t223,\n\t)\n\t// Persist it\n\tres, err := appInteractor.Create(testApp)\n\n\t// Testing returns\n\t// No need to test returns here since they are already handled in TestAddApp test\n\n\t// Try to delete it\n\tres, err = appInteractor.Delete(res)\n\tif err != nil {\n\t\t// Error raised during the deletion\n\t\tt.Error(\"App was not properly delete : \", err)\n\t\treturn\n\t}\n\tif res == \"\" {\n\t\t// No identifier was passed to confirm deletion\n\t\tt.Error(\"App was not properly deleted : no identifier returned\")\n\t\treturn\n\t}\n\n\tt.Log(\"TestDeleteApp: Test Clear\")\n\treturn\n}", "func deleteAppHelm(root, profile, unit, application string) error {\n\tparser := yaml.NewParser()\n\terr := parser.Parse(profile)\n\tif err != nil {\n\t\tlog.Fatalf(\"parser.Parse profile error: err=%s\", err)\n\t}\n\texec := exec.NewExec(root)\n\tfor _, su := range parser.Profile.ServiceUnits {\n\t\tif !strings.EqualFold(su.Name, unit) {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, app := range su.Applications {\n\t\t\tif !strings.EqualFold(app.Name, application) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tshell := exec.Delete(app.Name)\n\t\t\tlog.Infof(\"Delete application: su=%s, app=%s, shell=%s\", su.Name, application, shell)\n\t\t\terr := exec.Do(shell)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Helm delete error: err=%s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (m *ServiceMgr) deletePrimaryStore(appName string) (info *runtimeInfo) {\n\tinfo = &runtimeInfo{}\n\tlogging.Infof(\"Deleting application %v from primary store\", appName)\n\n\tcheckIfDeployed := false\n\tfor _, app := range util.ListChildren(metakvAppsPath) {\n\t\tif app == appName {\n\t\t\tcheckIfDeployed = true\n\t\t}\n\t}\n\n\tif !checkIfDeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotDeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"App: %v not deployed\", appName)\n\t\treturn\n\t}\n\n\tappState := m.superSup.GetAppState(appName)\n\tif appState != common.AppStateUndeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotUndeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"Skipping delete request from primary store for app: %v as it hasn't been undeployed\", appName)\n\t\treturn\n\t}\n\n\tsettingPath := metakvAppSettingsPath + appName\n\terr := util.MetaKvDelete(settingPath, nil)\n\tif err != nil {\n\t\tinfo.Code = m.statusCodes.errDelAppSettingsPs.Code\n\t\tinfo.Info = fmt.Sprintf(\"Failed to delete setting for app: %v, err: %v\", appName, err)\n\t\treturn\n\t}\n\n\terr = util.DeleteAppContent(metakvAppsPath, metakvChecksumPath, appName)\n\tif err != nil {\n\t\tinfo.Code = m.statusCodes.errDelAppPs.Code\n\t\tinfo.Info = fmt.Sprintf(\"Failed to delete app: %v, err: %v\", appName, err)\n\t\treturn\n\t}\n\n\t// TODO : This must be changed to app not deployed / found\n\tinfo.Code = m.statusCodes.ok.Code\n\tinfo.Info = fmt.Sprintf(\"Deleting app: %v in the background\", appName)\n\treturn\n}", "func (r *app) Delete(appGUID string, opts ...bool) error {\n\tasync := true\n\trecursive := false\n\tif len(opts) > 0 {\n\t\tasync = opts[0]\n\t}\n\tif len(opts) > 1 {\n\t\trecursive = opts[1]\n\t}\n\trawURL := fmt.Sprintf(\"/v2/apps/%s?async=%t&recursive=%t\", appGUID, async, recursive)\n\t_, err := r.client.Delete(rawURL)\n\treturn err\n}", "func DeleteAppConfigMap(name, namespace string) (err error) {\n\targs := []string{\"delete\", \"configmap\", name, \"--namespace\", namespace}\n\tout, err := kubectl(args)\n\n\tif err != nil && !strings.Contains(string(out), \"Error from server (NotFound): \") {\n\t\tlog.Debugf(\"Failed to execute %s, %v with %v\", \"kubectl\", args, err)\n\t\tlog.Debugf(\"%s\", string(out))\n\t\treturn err\n\t} else {\n\t\tlog.Debugf(\"configmap %s has been deleted successfully\", name)\n\t}\n\n\treturn nil\n}", "func DeleteApp(c echo.Context) error {\n\tid := c.Param(\"id\")\n\tsqlStatment := \"DELETE FROM apps WHERE id = $1\"\n\tres, err := d.Query(sqlStatment, id)\n\tif err != nil{\n\t\tfmt.Println(err)\n\t} else {\n\t\tfmt.Println(res)\n\t\treturn c.JSON(http.StatusOK, \"Deleted\")\n\t}\n\treturn c.JSON(http.StatusOK, \"Deleted\")\n}", "func (m *ServiceMgr) deletePrimaryStore(appName string) (info *runtimeInfo) {\n\tlogPrefix := \"ServiceMgr::deletePrimaryStore\"\n\n\tinfo = &runtimeInfo{}\n\tlogging.Infof(\"%s Function: %s deleting from primary store\", logPrefix, appName)\n\n\tcheckIfDeployed := false\n\tfor _, app := range util.ListChildren(metakvAppsPath) {\n\t\tif app == appName {\n\t\t\tcheckIfDeployed = true\n\t\t}\n\t}\n\n\tif !checkIfDeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotDeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"Function: %s not deployed\", appName)\n\t\tlogging.Errorf(\"%s %s\", logPrefix, info.Info)\n\t\treturn\n\t}\n\n\tappState := m.superSup.GetAppState(appName)\n\tif appState != common.AppStateUndeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotUndeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"Function: %s skipping delete request from primary store, as it hasn't been undeployed\", appName)\n\t\tlogging.Errorf(\"%s %s\", logPrefix, info.Info)\n\t\treturn\n\t}\n\n\tsettingPath := metakvAppSettingsPath + appName\n\terr := util.MetaKvDelete(settingPath, nil)\n\tif err != nil {\n\t\tinfo.Code = m.statusCodes.errDelAppSettingsPs.Code\n\t\tinfo.Info = fmt.Sprintf(\"Function: %s failed to delete settings, err: %v\", appName, err)\n\t\tlogging.Errorf(\"%s %s\", logPrefix, info.Info)\n\t\treturn\n\t}\n\n\terr = util.DeleteAppContent(metakvAppsPath, metakvChecksumPath, appName)\n\tif err != nil {\n\t\tinfo.Code = m.statusCodes.errDelAppPs.Code\n\t\tinfo.Info = fmt.Sprintf(\"Function: %s failed to delete, err: %v\", appName, err)\n\t\tlogging.Errorf(\"%s %s\", logPrefix, info.Info)\n\t\treturn\n\t}\n\n\t// TODO : This must be changed to app not deployed / found\n\tinfo.Code = m.statusCodes.ok.Code\n\tinfo.Info = fmt.Sprintf(\"Function: %s deleting in the background\", appName)\n\tlogging.Infof(\"%s %s\", logPrefix, info.Info)\n\treturn\n}", "func AppDelete(ctx *Context, id int64) (bool, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(fmt.Sprintf(\"application(%d)\", id))\n\tb, err := doJSON(ctx, \"DELETE\", uri, h, nil, nil)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn string(b) == \"OK\", nil\n}", "func (appHandler *ApplicationApiHandler) DeleteApp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tid := ps.ByName(\"id\")\n\tidint, err := strconv.Atoi(id)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.Error(w, http.StatusText(404), 404)\n\t\treturn\n\t}\n\tapp, err := appHandler.appService.DeleteApplication(idint)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.Error(w, http.StatusText(404), 404)\n\t\treturn\n\t}\n\tresponse, err := json.Marshal(app)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.Error(w, http.StatusText(404), 404)\n\t\treturn\n\t}\n\tw.WriteHeader(http.StatusOK)\n\t_, err = w.Write(response)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.Error(w, http.StatusText(404), 404)\n\t\treturn\n\t}\n\n}", "func (r *DeviceAppManagementRequest) Delete(ctx context.Context) error {\n\treturn r.JSONRequest(ctx, \"DELETE\", \"\", nil, nil)\n}", "func (cleaner *RegistryCleaner) DeleteApplicationData(ctx context.Context, applicationList []string) error {\n\tfor _, ids := range applicationList {\n\t\tappIds, err := unique.ToApplicationID(ids)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tctx, err = unique.WithContext(ctx, ids)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\twebhooks, err := cleaner.WebRegistry.List(ctx, appIds, []string{\"ids\"})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor _, webhook := range webhooks {\n\t\t\t_, err := cleaner.WebRegistry.Set(ctx, webhook.GetIds(), nil,\n\t\t\t\tfunc(webhook *ttnpb.ApplicationWebhook) (*ttnpb.ApplicationWebhook, []string, error) {\n\t\t\t\t\treturn nil, nil, nil\n\t\t\t\t},\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func DeleteMapDB(ID int, env string) (retorno bool) {\n\tdb, err := sql.Open(\"mysql\", UserDB+\":\"+PassDB+\"@tcp(\"+HostDB+\":\"+PortDB+\")/\"+DatabaseDB+\"?charset=utf8\")\n\tcheckErr(err)\n\n\tdefer db.Close()\n\n\t// So deleta registro caso o mesmo esteja marcado para exclusao (aplicado=3) e aprovado (aprovado=1)\n\tstmt, err := db.Prepare(\"DELETE FROM mapeamentos WHERE id_mapeamento=? AND env=? AND aprovado=1 AND aplicado=3\")\n\tcheckErr(err)\n\n\tres, err := stmt.Exec(ID, env)\n\tcheckErr(err)\n\n\taffect, err := res.RowsAffected()\n\tcheckErr(err)\n\n\tif affect >= 1 {\n\t\tretorno = true\n\t} else {\n\t\tretorno = false\n\t}\n\n\treturn retorno\n}", "func (controller AppsController) Delete(c *gin.Context) {\n\t_, err := mongodb.DeleteByID(controller.MongoDBClient, Collections[\"apps\"], c.Params.ByName(\"id\"))\n\n\tif err != nil {\n\t\tfmt.Printf(\"error %v\", err)\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"message\": \"Unable to remove object\"})\n\t\treturn\n\t}\n\n\t// Remove all versions related\n\t/*_, err := mongodb.DeleteAll(controller.MongoDBClient, Collections[\"versions\"], bson.M{\"app_id\": c.Params.ByName(\"id\")})\n\tif err != nil {\n\t\tfmt.Printf(\"error %v\", err)\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"message\": \"Unable to remove object\"})\n\t\treturn\n\t}*/\n\n\tc.Status(http.StatusOK)\n}", "func (ai *AppInteractor) Delete(id string) (string, error) {\n\treturn ai.AppRepository.Delete(id)\n}", "func (a *App) delete(c *echo.Context) error {\n\tc.Set(\"deleted\", true)\n\treturn a.update(c)\n}", "func (m *ServiceMgr) deleteTempStore(appName string) (info *runtimeInfo) {\n\tinfo = &runtimeInfo{}\n\tlogging.Infof(\"Deleting drafts from temporary store: %v\", appName)\n\n\tcheckIfDeployed := false\n\tfor _, app := range util.ListChildren(metakvTempAppsPath) {\n\t\tif app == appName {\n\t\t\tcheckIfDeployed = true\n\t\t}\n\t}\n\n\tif !checkIfDeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotDeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"App: %v not deployed\", appName)\n\t\treturn\n\t}\n\n\tappState := m.superSup.GetAppState(appName)\n\tif appState != common.AppStateUndeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotUndeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"Skipping delete request from temp store for app: %v as it hasn't been undeployed\", appName)\n\t\treturn\n\t}\n\n\tif err := util.DeleteAppContent(metakvTempAppsPath, metakvTempChecksumPath, appName); err != nil {\n\t\tinfo.Code = m.statusCodes.errDelAppTs.Code\n\t\tinfo.Info = fmt.Sprintf(\"Failed to delete App definition : %v, err: %v\", appName, err)\n\t\treturn\n\t}\n\tinfo.Code = m.statusCodes.ok.Code\n\tinfo.Info = fmt.Sprintf(\"Deleting app: %v in the background\", appName)\n\treturn\n}", "func (s Store) DeleteApplication(title string) error {\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\tif !s.isTitlePresent(title) {\n\t\treturn messages.MetadataTitleAbsent\n\t}\n\n\tdelete(s.appToDetails, title)\n\treturn nil\n}", "func closeApp() {\n\tfor _, b := range mapBrush {\n\t\tw32.DeleteObject(w32.HGDIOBJ(b.pen))\n\t\tw32.DeleteObject(w32.HGDIOBJ(b.brush))\n\t}\n\tw32.PostQuitMessage(0)\n}", "func AppDeleteHandler(context utils.Context, w http.ResponseWriter, r *http.Request) {\n\n\tdbConn := context.DBConn\n\tdbBucket := context.DBBucketApp\n\n\tvars := mux.Vars(r)\n\n\tenv := vars[\"environment\"]\n\tapp := vars[\"application\"]\n\n\tkey := []byte(env + \"_\" + app)\n\n\tif err := database.DeleteDBValue(dbConn, dbBucket, key); err != nil {\n\t\tlog.LogInfo.Printf(\"Failed to read db value: %v\", err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(\"200 - OK: valued deleted or was not found\"))\n\n}", "func deletePathMap(pathMapsPtr *[]n.ApplicationGatewayURLPathMap, resourceID *string) *[]n.ApplicationGatewayURLPathMap {\n\tpathMaps := *pathMapsPtr\n\tdeleteIdx := -1\n\tfor idx, pathMap := range pathMaps {\n\t\tif *pathMap.ID == *resourceID {\n\t\t\tklog.V(5).Infof(\"[brownfield] Deleting %s\", *resourceID)\n\t\t\tdeleteIdx = idx\n\t\t}\n\t}\n\n\tif deleteIdx != -1 {\n\t\tpathMaps[deleteIdx] = pathMaps[len(pathMaps)-1]\n\t\t*pathMapsPtr = pathMaps[:len(pathMaps)-1]\n\t}\n\n\treturn pathMapsPtr\n}", "func TestDeleteApps(t *testing.T) {\n\n\tvar err error\n\n\t// Use the configuration manager to get Algolia's keys to mock the app interactor\n\tconfigInteractor := interfaces.ConfigurationManager{}\n\tconfigInteractor.ConfigurationInteractor = infrastructure.NewViperConfig()\n\n\t// Instanciate the App interactor\n\tappInteractor := usecases.NewAppInteractor(\n\t\tinterfaces.NewAlgoliaRepository(\n\t\t\tconfigInteractor.GetConfigString(\"algolia.applicationID\", \"NOT_SET\"),\n\t\t\tconfigInteractor.GetConfigString(\"algolia.apiKey\", \"NOT_SET\"),\n\t\t\tconfigInteractor.GetConfigString(\"algolia.indexes.apps\", \"NOT_SET\"),\n\t\t),\n\t)\n\n\t// Batch addition\n\t// Create a random app\n\ttestApps := []domain.App{\n\t\tdomain.NewApp(\n\t\t\t\"Unit testing app interactor\",\n\t\t\t\"static.whatthetvshow.com:9000/media/snapshots/c4c3021b168ba93572d402e313f0f884_medium.png\",\n\t\t\t\"http://whatthetvshow.com/fe/snapshots/2205\",\n\t\t\t\"Quiz unit tests Benjamin\",\n\t\t\t223,\n\t\t),\n\t\tdomain.NewApp(\n\t\t\t\"Unit testing app interactor 2\",\n\t\t\t\"static.whatthetvshow.com:9000/media/snapshots/c4c3021b168ba93572d402e313f0f884_medium.png\",\n\t\t\t\"http://whatthetvshow.com/fe/snapshots/2205\",\n\t\t\t\"Quiz unit tests Benjamin\",\n\t\t\t224,\n\t\t),\n\t\tdomain.NewApp(\n\t\t\t\"Unit testing app interactor 3\",\n\t\t\t\"static.whatthetvshow.com:9000/media/snapshots/c4c3021b168ba93572d402e313f0f884_medium.png\",\n\t\t\t\"http://whatthetvshow.com/fe/snapshots/2205\",\n\t\t\t\"Quiz unit tests Benjamin\",\n\t\t\t225,\n\t\t),\n\t\tdomain.NewApp(\n\t\t\t\"Unit testing app interactor 4\",\n\t\t\t\"static.whatthetvshow.com:9000/media/snapshots/c4c3021b168ba93572d402e313f0f884_medium.png\",\n\t\t\t\"http://whatthetvshow.com/fe/snapshots/2205\",\n\t\t\t\"Quiz unit tests Benjamin\",\n\t\t\t226,\n\t\t),\n\t}\n\t// Try to persist it\n\tres, err := appInteractor.CreateBatch(testApps)\n\n\t// Testing returns\n\t// No need to test returns here since they are already handled in TestAddApps test\n\tres, err = appInteractor.DeleteBatch(res)\n\n\t// Try to delete those apps\n\tif err != nil {\n\t\t// Error raised during the deletion\n\t\tt.Error(\"Apps were not properly delete : \", err)\n\t\treturn\n\t}\n\tif len(res) == 0 {\n\t\t// None of apps were deleted properly\n\t\tt.Error(\"Apps were not properly deleted : no identifiers returned\")\n\t\treturn\n\t}\n\tfor i := range testApps {\n\t\tif len(res) > 0 && res[i] == \"\" {\n\t\t\t// No object created\n\t\t\tt.Error(\"App number \", i, \" '\", testApps[i].Name, \" was not properly deleted : no identifier returned\")\n\t\t}\n\t}\n\n\tt.Log(\"TestDeleteApps: Test Clear\")\n\treturn\n}", "func (h appHandler) deleteAppHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tprojectName := vars[\"project-name\"]\n\tcompositeAppName := vars[\"composite-app-name\"]\n\tcompositeAppVersion := vars[\"version\"]\n\tname := vars[\"app-name\"]\n\n\terr := h.client.DeleteApp(name, projectName, compositeAppName, compositeAppVersion)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusNoContent)\n}", "func main () {\n\tvertices := make(map[string]int)\n\n\tvertices[\"triangle\"] = 2\n\tvertices[\"square\"] = 3\n\tvertices[\"dodecagon\"] = 12\n\n delete(vertices, \"square\")\n\n\tfmt.Println(vertices)\n\tfmt.Println(vertices[\"triangle\"])\n}", "func Delete(jsonMap map[string]string, deleteMap map[string]string) (newMap map[string]string, err error) {\n\ts := make(map[string]string)\n\ts = jsonMap\n\tfor key := range deleteMap {\n\t\tif jsonMap[key] != \"\" {\n\t\t\tif strings.Contains(deleteMap[key], \"json:array\") {\n\t\t\t\terr = errors.New(\"invalid value to delete: json:array\")\n\t\t\t\treturn jsonMap, err\n\t\t\t} else if strings.Contains(deleteMap[key], \"json:object\") {\n\t\t\t\terr = errors.New(\"invalid value to delete: json:object\")\n\t\t\t\treturn jsonMap, err\n\t\t\t}\n\t\t\tdeleteArray := strings.Split(strings.Trim(deleteMap[key], `\"`), \" \")\n\t\t\tfor i := 0; i < len(deleteArray); i++ {\n\t\t\t\ts[key] = strings.Replace(s[key], \" \"+deleteArray[i], \"\", 1)\n\t\t\t\tswitch s[key] {\n\t\t\t\tcase \"json:array\":\n\t\t\t\t\ts[key] = \"[]\"\n\t\t\t\tcase \"json:object\":\n\t\t\t\t\ts[key] = \"{}\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn s, nil\n}", "func Remove(options types.RemoveOptions, config config.Store) error {\n\tapp := &AppImage{}\n\n\tindexFile := fmt.Sprintf(\"%s.json\", path.Join(config.IndexStore, options.Executable))\n\tlogger.Debugf(\"Checking if %s exists\", indexFile)\n\tif !helpers.CheckIfFileExists(indexFile) {\n\t\tfmt.Printf(\"%s is not installed \\n\", tui.Yellow(options.Executable))\n\t\treturn nil\n\t}\n\n\tbar := tui.NewProgressBar(7, \"r\")\n\n\tlogger.Debugf(\"Unmarshalling JSON from %s\", indexFile)\n\tindexBytes, err := ioutil.ReadFile(indexFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbar.Add(1)\n\n\terr = json.Unmarshal(indexBytes, app)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif app.IconPath != \"\" {\n\t\tlogger.Debugf(\"Removing thumbnail, %s\", app.IconPath)\n\t\tos.Remove(app.IconPath)\n\t}\n\tbar.Add(1)\n\n\tif app.IconPathHicolor != \"\" {\n\t\tlogger.Debugf(\"Removing symlink to hicolor theme, %s\", app.IconPathHicolor)\n\t\tos.Remove(app.IconPathHicolor)\n\t}\n\tbar.Add(1)\n\n\tif app.DesktopFile != \"\" {\n\t\tlogger.Debugf(\"Removing desktop file, %s\", app.DesktopFile)\n\t\tos.Remove(app.DesktopFile)\n\t}\n\tbar.Add(1)\n\n\tbinDir := path.Join(xdg.Home, \".local\", \"bin\")\n\tbinFile := path.Join(binDir, options.Executable)\n\n\tif helpers.CheckIfFileExists(binFile) {\n\t\tbinAbsPath, err := filepath.EvalSymlinks(binFile)\n\t\tif err == nil && strings.HasPrefix(binAbsPath, config.LocalStore) {\n\t\t\t// this link points to config.LocalStore, where all AppImages are stored\n\t\t\t// I guess we need to remove them, no asking and all\n\t\t\t// make sure we remove the file first to prevent conflicts in future\n\t\t\t_ = os.Remove(binFile)\n\t\t}\n\t}\n\tbar.Add(1)\n\n\tlogger.Debugf(\"Removing appimage, %s\", app.Filepath)\n\t_ = os.Remove(app.Filepath)\n\tbar.Add(1)\n\n\tlogger.Debugf(\"Removing index file, %s\", indexFile)\n\t_ = os.Remove(indexFile)\n\tbar.Add(1)\n\n\tbar.Finish()\n\tfmt.Printf(\"\\n\")\n\tfmt.Printf(\"✅ %s removed successfully\\n\", app.Executable)\n\tlogger.Debugf(\"Removing all files completed successfully\")\n\n\treturn bar.Finish()\n}", "func (as *ApplicationStore) Delete(ctx context.Context, name string) error {\n\tif _, exists := as.items[name]; exists {\n\t\tdelete(as.items, name)\n\t}\n\treturn nil\n}", "func (a *App) Delete(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"need a definition of delete on our platform\"))\n}", "func RunAppsDelete(c *CmdConfig) error {\n\tif len(c.Args) < 1 {\n\t\treturn doctl.NewMissingArgsErr(c.NS)\n\t}\n\tid := c.Args[0]\n\n\tforce, err := c.Doit.GetBool(c.NS, doctl.ArgForce)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !force && AskForConfirmDelete(\"App\", 1) != nil {\n\t\treturn errOperationAborted\n\t}\n\n\terr = c.Apps().Delete(id)\n\tif err != nil {\n\t\treturn err\n\t}\n\tnotice(\"App deleted\")\n\n\treturn nil\n}", "func AppMarketItemsLocationsDelete(c *gin.Context) {\n\tu := user(c)\n\n\tid, _ := strconv.ParseInt(c.Param(\"id\"), 10, 64)\n\tlid, _ := strconv.ParseInt(c.Param(\"lid\"), 10, 64)\n\n\tservices.MarketItemsLocationsDelete(u.ID, id, lid)\n\n\tp := page(c)\n\tlist := services.MarketItemsList(u.ID, p)\n\tc.JSON(http.StatusOK, list)\n}", "func DeleteAllDevice() {\n\tmapMutex.Lock()\n\tdefer mapMutex.Unlock()\n\n\tfor _, value := range deviceMap {\n\t\tvalue.delete(context.Background())\n\t}\n\tdeviceMap = map[string]L2oamDevice{}\n\tdeviceMacMap = map[string]string{}\n}", "func (a *appRuntimeStore) DeleteAppServiceByKey(key v1.CacheKey) {\n\ta.appServices.Delete(key)\n\ta.appCount--\n\tlogrus.Debugf(\"current have %d app after delete \\n\", a.appCount)\n}", "func processConfigMapDelete(cc *configController, configMap *v1.ConfigMap) error {\n\tlogrus.Infof(\"Processing Delete configmap %s/%s\", configMap.ObjectMeta.Namespace, configMap.ObjectMeta.Name)\n\t// Drop all info from removed config map\n\tcc.vfs.vfs = map[string]*VF{}\n\tcc.configCh <- configMessage{op: operationDeleteAll, pciAddr: \"\", vf: VF{}}\n\n\treturn nil\n}", "func (r *ManagedAppRegistrationRequest) Delete(ctx context.Context) error {\n\treturn r.JSONRequest(ctx, \"DELETE\", \"\", nil, nil)\n}", "func (a *appRuntimeStore) DeleteAppService(app *v1.AppService) {\n\t//a.appServices.Delete(v1.GetCacheKeyOnlyServiceID(app.ServiceID))\n\t//a.appCount--\n\t//logrus.Debugf(\"current have %d app after delete \\n\", a.appCount)\n}", "func (handle Handler) DeleteAppAttributes(c echo.Context) error {\n\tid := c.Param(\"id\")\n\tif id != \"\" {\n\t\trows, err := controller.Controller{c, handle.RTDb}.DeleteAppAttributes(id)\n\n\t\t// check response\n\t\tif err != nil {\n\t\t\treturn c.JSON(http.StatusNotFound, err)\n\t\t}\n\t\treturn c.JSON(http.StatusOK, rows)\n\t}\n\treturn c.JSON(http.StatusBadRequest, echo.Map{\n\t\t\"message\": \"Bad Request\",\n\t})\n}", "func (u *App) Delete(c echo.Context, id string) error {\n\tif err := u.rbac.EnforceRole(c, model.AdminRole); err != nil {\n\t\treturn err\n\t}\n\n\tvar applications int\n\tif err := u.db.Model(&model.Application{}).Where(\"application_course_id = ?\", id).Count(&applications).Error; err == nil && applications > 0 {\n\t\treturn zaplog.ZLog(fmt.Errorf(\"Existem %d candidaturas associadas a este curso. Não é possível eliminar\", applications))\n\t}\n\n\treturn u.udb.Delete(u.db, id)\n}", "func (s *server) Delete(ctx context.Context, body *pb.NameHolder) (*pb.DeletionResponse, error) {\n\tappName := body.GetName()\n\tfilter := types.M{\n\t\tmongo.NameKey: appName,\n\t\tmongo.InstanceTypeKey: mongo.AppInstance,\n\t}\n\n\tnode, _ := redis.FetchAppNode(appName)\n\tgo redis.DecrementServiceLoad(ServiceName, node)\n\tgo redis.RemoveApp(appName)\n\tgo diskCleanup(appName)\n\n\tif configs.CloudflareConfig.PlugIn {\n\t\tgo cloudflare.DeleteRecord(appName, mongo.AppInstance)\n\t}\n\n\t_, err := mongo.DeleteInstance(filter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &pb.DeletionResponse{Success: true}, nil\n}", "func (sm safeMap) Delete(key string) {\n\tsm <- commandData{action: REMOVE, key: key}\n}", "func deleteRegistry(w http.ResponseWriter, req *http.Request) {\n\tvar sStore SpecificStore\n\t_ = json.NewDecoder(req.Body).Decode(&sStore)\n\n\tif len(array) == 0 {\n\t\tfmt.Println(\"$$$Primero debe llenar el arreglo con informacion\")\n\t\tjson.NewEncoder(w).Encode(\"Primero debe llenar el arreglo con informacion\")\n\t\treturn\n\t}\n\n\tfmt.Println(\"$$$Buscando tienda con los parametros especificados\")\n\tfor i := 0; i < len(array); i++ {\n\t\tif array[i].Department == sStore.Departament && array[i].Rating == sStore.Rating {\n\t\t\tfor j := 0; j < array[i].List.lenght; j++ {\n\t\t\t\ttempNode, _ := array[i].List.GetNodeAt(j)\n\t\t\t\ttempName := tempNode.data.Name\n\t\t\t\tif tempName == sStore.Name {\n\t\t\t\t\tarray[i].List.DeleteNode(j)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintArray(array)\n\n}", "func Delete(m Map, key Key) Map {\n\thash := key.Hash()\n\treturn m.dissoc(0, hash, key)\n}", "func (app *Application) Delete() (*Result, error) {\n\treturn delete(ApplicationsResource + \"/\" + app.ID)\n}", "func (DummyStore) DeleteMap(key string, fields ...string) error { return nil }", "func (a AppsApi) AppsAppDelete(app string) (*APIResponse, error) {\n\n\tvar localVarHttpMethod = strings.ToUpper(\"Delete\")\n\t// create path and map variables\n\tlocalVarPath := a.Configuration.BasePath + \"/apps/{app}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"app\"+\"}\", fmt.Sprintf(\"%v\", app), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := make(map[string]string)\n\tvar localVarPostBody interface{}\n\tvar localVarFileName string\n\tvar localVarFileBytes []byte\n\t// add default headers if any\n\tfor key := range a.Configuration.DefaultHeader {\n\t\tlocalVarHeaderParams[key] = a.Configuration.DefaultHeader[key]\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 := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tlocalVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\n\tvar localVarURL, _ = url.Parse(localVarPath)\n\tlocalVarURL.RawQuery = localVarQueryParams.Encode()\n\tvar localVarAPIResponse = &APIResponse{Operation: \"AppsAppDelete\", Method: localVarHttpMethod, RequestURL: localVarURL.String()}\n\tif localVarHttpResponse != nil {\n\t\tlocalVarAPIResponse.Response = localVarHttpResponse.RawResponse\n\t\tlocalVarAPIResponse.Payload = localVarHttpResponse.Body()\n\t}\n\n\tif err != nil {\n\t\treturn localVarAPIResponse, err\n\t}\n\treturn localVarAPIResponse, err\n}", "func Delete(ctx context.Context, isClient bool) {\n\tmetadata.Map(ctx, isClient).Delete(key{})\n}", "func (dm *DMap) Delete(ctx context.Context, keys ...string) (int, error) {\n\treturn dm.deleteKeys(ctx, keys...)\n}", "func (client AppsClient) Delete(ctx context.Context, appID uuid.UUID) (result OperationStatus, err error) {\n\treq, err := client.DeletePreparer(ctx, appID)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"programmatic.AppsClient\", \"Delete\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.DeleteSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"programmatic.AppsClient\", \"Delete\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.DeleteResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"programmatic.AppsClient\", \"Delete\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (r *ApplicationRequest) Delete(ctx context.Context) error {\n\treturn r.JSONRequest(ctx, \"DELETE\", \"\", nil, nil)\n}", "func buildAppDeleteCommand() *cobra.Command {\n\tvars := deleteAppVars{}\n\tcmd := &cobra.Command{\n\t\tUse: \"delete\",\n\t\tShort: \"Delete all resources associated with the application.\",\n\t\tExample: `\n Force delete the application with environments \"test\" and \"prod\".\n /code $ copilot app delete --yes`,\n\t\tRunE: runCmdE(func(cmd *cobra.Command, args []string) error {\n\t\t\topts, err := newDeleteAppOpts(vars)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn run(opts)\n\t\t}),\n\t}\n\n\tcmd.Flags().StringVarP(&vars.name, nameFlag, nameFlagShort, tryReadingAppName(), appFlagDescription)\n\tcmd.Flags().BoolVar(&vars.skipConfirmation, yesFlag, false, yesFlagDescription)\n\treturn cmd\n}", "func unregApp(cmd marcopolo.CmdMsg, srvConn *marcopolo.ServerConn) {\n\tappName := cmd.AppNameParam.AppName\n\tfmt.Println(\"unregister app \", appName)\n\n\t// lookup regd app w. this name\n\tprevApp, found := apps[appName]\n\t_ = prevApp\n\tif found {\n\t\tfmt.Printf(\"unregapp, removing @ %s\\n\", prevApp.appAddr)\n\n\t\t// remove app entry\n\t\tdelete(apps, appName)\n\n\t\t// send OK to caller\n\t\tsrvConn.SendRespUnregApp(cmd.UdpPacket.RemoteAddr)\n\t} else {\n\t\terr := fmt.Errorf(\"unregapp, not found : '%s'\", appName)\n\t\tfmt.Println(err)\n\n\t\t// send error back to app\n\t\tsrvConn.SendRespUnregAppErr(err, cmd.UdpPacket.RemoteAddr)\n\t}\n}", "func (m *ServiceMgr) deleteTempStore(appName string) (info *runtimeInfo) {\n\tlogPrefix := \"ServiceMgr::deleteTempStore\"\n\n\tinfo = &runtimeInfo{}\n\tlogging.Infof(\"%s Function: %s deleting drafts from temporary store\", logPrefix, appName)\n\n\tcheckIfDeployed := false\n\tfor _, app := range util.ListChildren(metakvTempAppsPath) {\n\t\tif app == appName {\n\t\t\tcheckIfDeployed = true\n\t\t}\n\t}\n\n\tif !checkIfDeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotDeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"Function: %s not deployed\", appName)\n\t\tlogging.Errorf(\"%s %s\", logPrefix, info.Info)\n\t\treturn\n\t}\n\n\tappState := m.superSup.GetAppState(appName)\n\tif appState != common.AppStateUndeployed {\n\t\tinfo.Code = m.statusCodes.errAppNotUndeployed.Code\n\t\tinfo.Info = fmt.Sprintf(\"Function: %s skipping delete request from temp store, as it hasn't been undeployed\", appName)\n\t\tlogging.Errorf(\"%s %s\", logPrefix, info.Info)\n\t\treturn\n\t}\n\n\tif err := util.DeleteAppContent(metakvTempAppsPath, metakvTempChecksumPath, appName); err != nil {\n\t\tinfo.Code = m.statusCodes.errDelAppTs.Code\n\t\tinfo.Info = fmt.Sprintf(\"Function: %s failed to delete, err: %v\", appName, err)\n\t\tlogging.Errorf(\"%s %s\", logPrefix, info.Info)\n\t\treturn\n\t}\n\tinfo.Code = m.statusCodes.ok.Code\n\tinfo.Info = fmt.Sprintf(\"Function: %s deleting in the background\", appName)\n\tlogging.Infof(\"%s %s\", logPrefix, info.Info)\n\treturn\n}", "func (as *AppStorage) DeleteApp(id string) error {\n\tinput := &dynamodb.DeleteItemInput{\n\t\tKey: map[string]*dynamodb.AttributeValue{\n\t\t\t\"id\": {S: aws.String(id)},\n\t\t},\n\t\tTableName: aws.String(appsTableName),\n\t}\n\t_, err := as.db.C.DeleteItem(input)\n\treturn err\n}", "func (du *DatsetUserMapping) Delete(a *config.AppContext) error {\n\treturn a.Db.Delete(du).Error\n}", "func BuildAppDeleteCmd() *cobra.Command {\n\tvars := deleteAppVars{\n\t\tGlobalOpts: NewGlobalOpts(),\n\t}\n\tcmd := &cobra.Command{\n\t\tUse: \"delete\",\n\t\tShort: \"Deletes an application from your project.\",\n\t\tExample: `\n Delete the \"test\" application.\n /code $ ecs-preview app delete --name test\n\n Delete the \"test\" application without prompting.\n\t/code $ ecs-preview app delete --name test --yes`,\n\t\tRunE: runCmdE(func(cmd *cobra.Command, args []string) error {\n\t\t\topts, err := newDeleteAppOpts(vars)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := opts.Validate(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := opts.Ask(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := opts.Execute(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tlog.Infoln(\"Recommended follow-up actions:\")\n\t\t\tfor _, followup := range opts.RecommendedActions() {\n\t\t\t\tlog.Infof(\"- %s\\n\", followup)\n\t\t\t}\n\t\t\treturn nil\n\t\t}),\n\t}\n\n\tcmd.Flags().StringVarP(&vars.AppName, nameFlag, nameFlagShort, \"\", appFlagDescription)\n\tcmd.Flags().StringVarP(&vars.EnvName, envFlag, envFlagShort, \"\", envFlagDescription)\n\tcmd.Flags().BoolVar(&vars.SkipConfirmation, yesFlag, false, yesFlagDescription)\n\n\treturn cmd\n}", "func (l *RemoteProvider) DeleteMesheryApplication(req *http.Request, applicationID string) ([]byte, error) {\n\tif !l.Capabilities.IsSupported(PersistMesheryApplications) {\n\t\tlogrus.Error(\"operation not available\")\n\t\treturn nil, ErrInvalidCapability(\"PersistMesheryApplications\", l.ProviderName)\n\t}\n\n\tep, _ := l.Capabilities.GetEndpointForFeature(PersistMesheryApplications)\n\n\tlogrus.Infof(\"attempting to fetch application from cloud for id: %s\", applicationID)\n\n\tremoteProviderURL, _ := url.Parse(fmt.Sprintf(\"%s%s/%s\", l.RemoteProviderURL, ep, applicationID))\n\tlogrus.Debugf(\"constructed application url: %s\", remoteProviderURL.String())\n\tcReq, _ := http.NewRequest(http.MethodDelete, remoteProviderURL.String(), nil)\n\n\ttokenString, err := l.GetToken(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp, err := l.DoRequest(cReq, tokenString)\n\tif err != nil {\n\t\treturn nil, ErrDelete(err, \"Application :\"+applicationID, resp.StatusCode)\n\t}\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\tbdr, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, ErrDataRead(err, \"Application :\"+applicationID)\n\t}\n\n\tif resp.StatusCode == http.StatusOK {\n\t\tlogrus.Infof(\"application successfully retrieved from remote provider\")\n\t\treturn bdr, nil\n\t}\n\treturn nil, ErrDelete(err, \"Application :\"+applicationID, resp.StatusCode)\n}", "func (app *App) Remove(uuid gocql.UUID) (err error) {\n\tif err = app.tre.session.Query(`DELETE FROM applications WHERE uuid = ?`,\n\t\tuuid).Exec(); err != nil {\n\t\tfmt.Printf(\"Remove Error: %s\\n\", err.Error())\n\t\treturn\n\t}\n\terr = app.tre.com.RemoveAll(uuid)\n\treturn\n}", "func RemoveApp(appName string) error {\n\t_, err := client.HDel(ApplicationKey, appName).Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (a *prUserIdMapperApp) deleteUserIdMapper(w http.ResponseWriter, r *http.Request) {\n\tUserIdMapper := prUserIdMapper{}\n\tvars := mux.Vars(r)\n\n\terr := UserIdMapper.deleteUserIdMapper(a.DB, vars[\"key\"])\n\tif err != nil {\n\t\trespondWithError(w, http.StatusNotFound, err.Error())\n\t\treturn\n\t}\n\n\trespondWithJSON(w, http.StatusOK, map[string]string{\"result\": \"success\"})\n}", "func (hm HashMap) Delete(ctx context.Context, fields ...string) (int64, error) {\n\treq := newRequestSize(2+len(fields), \"\\r\\n$4\\r\\nHDEL\\r\\n$\")\n\treq.addStringAndStrings(hm.name, fields)\n\treturn hm.c.cmdInt(ctx, req)\n}", "func (o *Service) Delete() (*restapi.GenericMapResponse, error) {\n\treturn o.deleteObjectMapAPI(\"\")\n}", "func (s *APIServer) DeleteApps(c *gin.Context) {\n\tenvName := c.Param(\"envName\")\n\tenvMeta, err := env.GetEnvByName(envName)\n\tif err != nil {\n\t\tutil.HandleError(c, util.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tappName := c.Param(\"appName\")\n\n\to := common.DeleteOptions{\n\t\tClient: s.KubeClient,\n\t\tEnv: envMeta,\n\t\tAppName: appName,\n\t}\n\tmessage, err := o.DeleteApp()\n\tutil.AssembleResponse(c, message, err)\n}", "func DeleteProgram(program uint32) {\n C.glowDeleteProgram(gpDeleteProgram, (C.GLuint)(program))\n}", "func (c *Dg) Delete(e ...interface{}) error {\n var err error\n\n if len(e) == 0 {\n return nil\n }\n\n names := make([]string, len(e))\n for i := range e {\n switch v := e[i].(type) {\n case string:\n names[i] = v\n case Entry:\n names[i] = v.Name\n default:\n return fmt.Errorf(\"Unknown type sent to delete: %s\", v)\n }\n }\n c.con.LogAction(\"(delete) device groups: %v\", names)\n\n // Remove the device groups.\n path := c.xpath(names)\n _, err = c.con.Delete(path, nil, nil)\n return err\n}", "func removeApp(search string, apps *applications) error {\n\tif i, found := stringInSlice(search, (*apps)[\"default\"]); found == true {\n\t\t(*apps)[\"default\"] = append((*apps)[\"default\"][:i], (*apps)[\"default\"][i+1:]...)\n\t\tmsg := fmt.Sprintf(\"Successfully removed %s from default opener group\", search)\n\t\terr := rewriteApps(apps, msg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tmsg := fmt.Sprintf(\"Could not find %s in configuration\\n\", search)\n\t\treturn errors.New(msg)\n\t}\n\n\treturn nil\n}", "func (u *UdMap) Del(key string) { delete(u.Data, key) }", "func delPatricia(ptr patricia, bucket string, cb db.CachedBatch) {\n\tkey := ptr.hash()\n\tlogger.Debug().Hex(\"key\", key[:8]).Msg(\"del\")\n\tcb.Delete(bucket, key[:], \"failed to delete key = %x\", key)\n}", "func (program Program) Delete() {\n\tgl.DeleteProgram(uint32(program))\n}", "func Delete(keys []string, db RedisDBClientInterface, group environment.EnvironmentGroup) error {\n\tkvals := make([]string, len(keys))\n\tfor i, k := range keys {\n\t\tkvals[i] = extract(k, group)\n\t}\n\n\t_, err := db.Del(kvals...).Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (j *JPNSoftwareMap) Del(ID string) (ok bool) {\n\tdelete(*j, ID)\n\tok = j.Has(ID) == false\n\treturn\n}", "func (a *App) Delete(w http.ResponseWriter, r *http.Request) {\n\tvar err error\n\n\tv := mux.Vars(r)\n\tidentifier := v[\"identifier\"]\n\n\tjsonpath := path.Join(a.ConfigDir, fmt.Sprintf(\"%s.json\", identifier))\n\tjsonpathexists := true\n\n\tconfigpath := path.Join(a.ConfigDir, fmt.Sprintf(\"%s.conf\", identifier))\n\tconfigpathexists := true\n\n\tif _, err = os.Stat(jsonpath); os.IsNotExist(err) {\n\t\tjsonpathexists = false\n\t}\n\tif err != nil && !os.IsNotExist(err) {\n\t\terr = errors.Wrapf(err, \"error checking file %s\", jsonpath)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif _, err = os.Stat(configpath); os.IsNotExist(err) {\n\t\tconfigpathexists = false\n\t}\n\tif err != nil && !os.IsNotExist(err) {\n\t\terr = errors.Wrapf(err, \"error checking file %s\", configpath)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif jsonpathexists {\n\t\tif err = os.Remove(jsonpath); err != nil {\n\t\t\terr = errors.Wrapf(err, \"error removing file %s\", jsonpath)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\tif configpathexists {\n\t\tif err = os.Remove(configpath); err != nil {\n\t\t\terr = errors.Wrapf(err, \"error removing file %s\", configpath)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\tif jsonpathexists || configpathexists {\n\t\tif err = a.SignalContainers(); err != nil {\n\t\t\terr = errors.Wrap(err, \"error HUPing container(s)\")\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n}", "func UninstallApps(fileName, namespace string) (err error) {\n\tif _, err = os.Stat(fileName); os.IsNotExist(err) {\n\t\treturn err\n\t}\n\n\targs := []string{\"delete\", \"--namespace\", namespace, \"-f\", fileName}\n\tout, err := kubectl(args)\n\n\tfmt.Printf(\"%s\\n\", string(out))\n\tif err != nil {\n\t\tlog.Debugf(\"Failed to execute %s, %v with %v\", \"kubectl\", args, err)\n\t}\n\n\treturn err\n}", "func (appPortProfile *NsxtAppPortProfile) Delete() error {\n\tendpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointAppPortProfiles\n\tminimumApiVersion, err := appPortProfile.client.checkOpenApiEndpointCompatibility(endpoint)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif appPortProfile.NsxtAppPortProfile.ID == \"\" {\n\t\treturn fmt.Errorf(\"cannot delete NSX-T Application Port Profile without ID\")\n\t}\n\n\turlRef, err := appPortProfile.client.OpenApiBuildEndpoint(endpoint, appPortProfile.NsxtAppPortProfile.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = appPortProfile.client.OpenApiDeleteItem(minimumApiVersion, urlRef, nil, nil)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error deleting NSX-T Application Port Profile: %s\", err)\n\t}\n\n\treturn nil\n}", "func (app *App) Delete(ctx context.Context) error {\n\terr := app.Authenticate(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn app.User().Extensions().ID(app.ExtensionName).Request().Delete(ctx)\n}", "func adminImagesDelete(w http.ResponseWriter, r *http.Request) {\n\ttype response struct {\n\t\tOk bool\n\t}\n\tid := r.URL.Path\n\tresp := response{}\n\n\t_, err := db.Exec(`DELETE FROM images WHERE appointment_id = $1`, id)\n\tif err != nil {\n\t\tjson.NewEncoder(w).Encode(resp)\n\t\treturn\n\t}\n\n\t// set ok and send\n\tresp.Ok = true\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Println(\"appointment img delete:\", err)\n\t}\n}", "func (app *application) Delete(listHashStr string) error {\n\t// retrieve the identity:\n\tidentity, err := app.identityRepository.Retrieve(app.name, app.seed, app.password)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlistHash, err := app.hashAdapter.FromString(listHashStr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn identity.Wallet().Lists().Delete(*listHash)\n}", "func main() {\n\n\t// To create an empty map, use the builtin make: make(map[key-type]val-type).\t\n\n\tnew_map := make(map[string]int)\n\tnew_map[\"a\"] = 1\n\tnew_map[\"b\"] = 2\n\tnew_map[\"c\"] = 3\n\n\tfmt.Println(\"Map\", new_map)\n\n\tv1 := new_map[\"a\"]\n\tfmt.Println(\"v1 : \", v1)\n\tfmt.Println(\"len is: \", len(new_map))\n\n\t// Delete\n\n\tdelete(new_map, \"b\")\n\tfmt.Println(new_map)\n\n}", "func (pm *PolicyMap) Delete(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection) error {\n\tk := newKey(id, dport, proto, trafficDirection)\n\treturn pm.Map.Delete(&k)\n}", "func DeleteHandler() {\n\tif wnd := webapp.KeyWindow(); wnd != nil && wnd.Browser != nil {\n\t\tif ff := wnd.Browser.GetFocusedFrame(); ff != nil {\n\t\t\tff.Del()\n\t\t}\n\t}\n}", "func (c *Configmap) Delete(keys ...string) {\n\tmapSI := map[string]interface{}(*c)\n\tfor _, key := range keys {\n\t\tdelete(mapSI, key)\n\t}\n}", "func (c newConfigMap) Delete() error {\n\treturn c.Client.Delete(c.ConfigMap.Name, &v1.DeleteOptions{})\n}", "func NewCmdDeleteApp(f Factory, in terminal.FileReader, out terminal.FileWriter, errOut io.Writer) *cobra.Command {\n\to := &DeleteAppOptions{\n\t\tCommonOptions: CommonOptions{\n\t\t\tFactory: f,\n\t\t\tIn: in,\n\t\t\tOut: out,\n\t\t\tErr: errOut,\n\t\t},\n\t}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"app\",\n\t\tShort: \"Deletes one or more apps from Jenkins X\",\n\t\tLong: deleteAppLong,\n\t\tExample: deleteAppExample,\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\to.Cmd = cmd\n\t\t\to.Args = args\n\t\t\terr := o.Run()\n\t\t\tCheckErr(err)\n\t\t},\n\t}\n\n\tcmd.Flags().StringVarP(&o.ReleaseName, optionRelease, \"r\", \"\",\n\t\t\"The chart release name (available when NOT using GitOps for your dev environment)\")\n\tcmd.Flags().BoolVarP(&o.Purge, optionPurge, \"\", true,\n\t\t\"Should we run helm update first to ensure we use the latest version (available when NOT using GitOps for your dev environment)\")\n\tcmd.Flags().StringVarP(&o.Namespace, optionNamespace, \"n\", defaultNamespace, \"The Namespace to install into (available when NOT using GitOps for your dev environment)\")\n\tcmd.Flags().StringVarP(&o.Alias, optionAlias, \"\", \"\",\n\t\t\"An alias to use for the app (available when using GitOps for your dev environment)\")\n\n\treturn cmd\n}", "func Delete(client *occlient.Client, kClient *kclient.Client, urlName string, applicationName string, urlType localConfigProvider.URLKind, isS2i bool) error {\n\tif urlType == localConfigProvider.INGRESS {\n\t\treturn kClient.DeleteIngress(urlName)\n\t} else if urlType == localConfigProvider.ROUTE {\n\t\tif isS2i {\n\t\t\t// Namespace the URL name\n\t\t\tvar err error\n\t\t\turlName, err = util.NamespaceOpenShiftObject(urlName, applicationName)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"unable to create namespaced name\")\n\t\t\t}\n\t\t}\n\n\t\treturn client.DeleteRoute(urlName)\n\t}\n\treturn errors.New(\"url type is not supported\")\n}", "func DeleteProgram(program uint32) {\n\tsyscall.Syscall(gpDeleteProgram, 1, uintptr(program), 0, 0)\n}", "func deleteDeviceHandler(devices map[string]*Device) http.HandlerFunc {\n\treturn func(respWriter http.ResponseWriter, request *http.Request) {\n\t\tmac := request.FormValue(\"physaddr\")\n\t\tif mac == \"\" {\n\t\t\thttp.Error(respWriter, \"Specify Physical device's address\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tdelete(devices, mac)\n\t\tresponse := StatusResponse{\n\t\t\tOK: true,\n\t\t\tMessage: \"Device successfully deleted.\",\n\t\t}\n\t\tbytes, err := json.Marshal(&response)\n\t\tif err != nil {\n\t\t\thttp.Error(respWriter, \"Can't marshall response json: \"+err.Error(), http.StatusInternalServerError)\n\t\t}\n\t\trespWriter.Header().Add(\"Content-Type\", \"application/json\")\n\t\trespWriter.Write(bytes)\n\t}\n}", "func EnvAppDelete(ctx *Context, id int64) error {\n\th := authHeader(ctx.Config.AuthToken)\n\ts := fmt.Sprintf(\"environment_variable(%d)\", id)\n\turi := ctx.Config.APIEndpoint(s)\n\tb, err := doJSON(ctx, \"DELETE\", uri, h, nil, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif string(b) != \"OK\" {\n\t\treturn errors.New(\"bad response\")\n\t}\n\treturn nil\n}", "func (h *FlinkApplicationQueryHandler) Delete(ctx context.Context, project, service, applicationId, queryId string) error {\n\tpath := buildPath(\"project\", project, \"service\", service, \"flink\", \"application\", applicationId, \"query\", queryId)\n\tbts, err := h.client.doDeleteRequest(ctx, path, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn checkAPIResponse(bts, nil)\n}", "func MDels(keys []string) map[uint16]Completed {\n\treturn slotMCMDs(\"DEL\", keys, 0)\n}", "func DeleteAll(){\nfor fwin!=nil{\nfwin.Del(true)\nfwin.Close()\n}\n}", "func deleteAppVersionsHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tappid := vars[\"appid\"]\n\tvar app App\n\terr := getApp(appid, &app)\n\tcheck(err)\n\tif deleteAppVersions(app) {\n\t\tresult := map[string]interface{}{\n\t\t\t\"message\": \"OK\",\n\t\t}\n\t\trespondWithResult(w, result)\n\t} else {\n\t\tresult := map[string]interface{}{\n\t\t\t\"message\": \"error: unable to delete versions\",\n\t\t}\n\t\trespondWithResult(w, result)\n\t}\n}", "func DeleteApps() bool {\n\ttext := os.Getenv(\"JX_DISABLE_DELETE_APP\")\n\treturn strings.ToLower(text) != \"true\"\n}", "func (this *mMap) Del(k string) (result int64, err error) {\n\tkey := this.Key(k)\n\tresult, err = this.Client.Del(key).Result()\n\treturn\n}", "func DeleteMachine(w http.ResponseWriter, r *http.Request) {\n id := chi.URLParam(r, \"id\")\n log.Printf(\"Uninstall Machine: id:%s %s\\n\", id, r.Body)\n respondwithJSON(w, http.StatusOK, map[string]string{\"message\": \"update successfully\"})\n\n}", "func Applications(cfg config.Config, suiteName string) error {\n\tlogger := log.WithFields(log.Fields{\"Suite\": suiteName})\n\treturn application.DeleteByImpersonatedUser(cfg, defaults.App3Name, logger)\n}", "func (client *Client) DeleteAppInfo(request *DeleteAppInfoRequest) (_result *DeleteAppInfoResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &DeleteAppInfoResponse{}\n\t_body, _err := client.DeleteAppInfoWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "func (mdb *db) DeleteFromSignalInfoMaps(\n\tctx context.Context,\n\tfilter sqlplugin.SignalInfoMapsFilter,\n) (sql.Result, error) {\n\tquery, args, err := sqlx.In(\n\t\tdeleteKeyInSignalInfoMapQry,\n\t\tfilter.ShardID,\n\t\tfilter.NamespaceID,\n\t\tfilter.WorkflowID,\n\t\tfilter.RunID,\n\t\tfilter.InitiatedIDs,\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn mdb.conn.ExecContext(ctx,\n\t\tmdb.conn.Rebind(query),\n\t\targs...,\n\t)\n}", "func (c *FwRouter) Delete(e ...interface{}) error {\n\tnames := make([]string, 0, len(e))\n\tfor i := range e {\n\t\tswitch v := e[i].(type) {\n\t\tcase string:\n\t\t\tnames = append(names, v)\n\t\tcase Entry:\n\t\t\tnames = append(names, v.Name)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"Unknown type to delete: %s\", v)\n\t\t}\n\t}\n\tpath := c.xpath(names)\n\n\t// Unimport virtual routers.\n\tif err := c.con.VsysUnimport(util.VirtualRouterImport, \"\", \"\", names); err != nil {\n\t\treturn err\n\t}\n\n\treturn c.ns.Delete(names, path)\n}", "func CleanApp(pkg string) {\n\tlog.Printf(\"正在清理软件包%s的数据……\\n\", pkg)\n\tcmd := exec.Command(\"adb\", \"shell\", \"pm\", \"clear\", pkg)\n\n\terr := cmd.Run()\n\tif err != nil {\n\t\tlog.Println(\"清除数据失败。请重试……\")\n\t}\n}", "func deleteConfigMapFunc(f *framework.Framework, tc *nodeConfigTestCase) error {\n\treturn f.ClientSet.CoreV1().ConfigMaps(tc.configMap.Namespace).Delete(tc.configMap.Name, &metav1.DeleteOptions{})\n}", "func delete(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\n\tfor i, mail := range postbox {\n\t\tif mail.ID == params[\"id\"] {\n\t\t\tpostbox[i] = postbox[len(postbox)-1]\n\t\t\tpostbox = postbox[:len(postbox)-1]\n\n\t\t\tjson.NewEncoder(w).Encode(postbox)\n\t\t\treturn\n\t\t}\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tjson.NewEncoder(w).Encode(ClientError{http.StatusNotFound,\n\t\t\t\"Not email with this ID found.\",\n\t\t\t\"Retrieve all mail to check existing IDs!\"})\n\t}\n}" ]
[ "0.6278572", "0.6178651", "0.5830268", "0.5773523", "0.56855094", "0.5678537", "0.56749743", "0.56497693", "0.5643732", "0.5613216", "0.55936193", "0.54953444", "0.5468976", "0.5435457", "0.54103154", "0.5401574", "0.53760886", "0.5356636", "0.53545827", "0.53500414", "0.5340822", "0.5321208", "0.53131384", "0.530966", "0.53028774", "0.529596", "0.5294821", "0.5274962", "0.52677745", "0.5249413", "0.5248032", "0.5229756", "0.5214689", "0.52109706", "0.52031744", "0.51993567", "0.51957387", "0.5194664", "0.51735556", "0.5172213", "0.51656973", "0.51562995", "0.5155094", "0.51450247", "0.51386094", "0.5136949", "0.51349103", "0.5123405", "0.5112356", "0.51063627", "0.5100285", "0.50982714", "0.5079027", "0.5072366", "0.5070313", "0.50639516", "0.505766", "0.5051568", "0.50504375", "0.5048869", "0.50483763", "0.50440526", "0.5043203", "0.50209385", "0.50035334", "0.4988379", "0.49797708", "0.4965902", "0.49600682", "0.4958048", "0.49532783", "0.4948888", "0.4940987", "0.49395302", "0.49361593", "0.49327254", "0.49290282", "0.49182293", "0.49140692", "0.49136528", "0.48608357", "0.4857804", "0.4856021", "0.4852156", "0.48491675", "0.48466992", "0.4842427", "0.48381832", "0.48352838", "0.48291054", "0.48251125", "0.48241577", "0.48227593", "0.4822635", "0.48103338", "0.48064777", "0.4799368", "0.4797172", "0.47970015", "0.47873938" ]
0.6713155
0
Query function returns a single DesktopApp object in map format
func (o *DesktopApp) Query() (map[string]interface{}, error) { query := "SELECT * FROM Application WHERE 1=1 AND AppType='Desktop'" if o.Name != "" { query += " AND Name='" + o.Name + "'" } return queryVaultObject(o.client, query) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func QueryAppComputer(appID interface{}, page, limit int, appName string) (result []services.ComputerData) {\n\tif limit == 0 {\n\t\tlimit = 50\n\t}\n\n\tvar oneAppID = 0\n\tvar appIDS []int\n\n\toneAppID, ok := appID.(int)\n\tif !ok {\n\t\tappIDS, ok = appID.([]int)\n\t}\n\n\t// select app.id as app_id, app.name, app.tag, computer.`cpu`, computer.ram,computer.private_ip, computer.public_ip,computer.host_id,computer_role.register_status\n\t// from app inner join `computer_role` on app.id = computer_role.app_id inner join computer on `computer_role`.host_id = computer.host_id;\n\tsql := db.Session().Table(\"app\").Select(\n\t\t`app.id as app_id, app.name, app.tag, app.port, computer.cpu, computer.ram,computer.private_ip,\n\t\tcomputer.public_ip,computer.host_id,computer_role.register_status`).Joins(\n\t\t`inner join computer_role on app.id = computer_role.app_id inner join computer on computer_role.host_id = computer.host_id`).Order(\n\t\t\"name desc\").Limit(limit).Offset((page - 1) * limit)\n\n\tif oneAppID != 0 {\n\t\tsql.Where(\"app.id = ?\", appID).Scan(&result)\n\t} else if len(appIDS) != 0 {\n\t\tsql.Where(\"app.id in (?)\", appIDS).Scan(&result)\n\t} else if appName != \"\" {\n\t\tsql.Where(\"app.name = ?\", appName).Scan(&result)\n\t} else {\n\t\tsql.Scan(&result)\n\t}\n\treturn\n}", "func (o *DesktopApp) Read() error {\n\tif o.ID == \"\" {\n\t\treturn errors.New(\"error: ID is empty\")\n\t}\n\tvar queryArg = make(map[string]interface{})\n\tqueryArg[\"_RowKey\"] = o.ID\n\n\t// Attempt to read from an upstream API\n\tresp, err := o.client.CallGenericMapAPI(o.apiRead, queryArg)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !resp.Success {\n\t\treturn errors.New(resp.Message)\n\t}\n\n\tfillWithMap(o, resp.Result)\n\tLogD.Printf(\"Filled object: %+v\", o)\n\n\treturn nil\n}", "func (c *ClubapplicationClient) Query() *ClubapplicationQuery {\n\treturn &ClubapplicationQuery{config: c.config}\n}", "func (app *App) Get(uuid gocql.UUID) (a *teoapi.Application, err error) {\n\ta = &teoapi.Application{UUID: uuid}\n\tstmt, names := qb.Select(\"applications\").Where(qb.Eq(\"uuid\")).Limit(1).ToCql()\n\tq := gocqlx.Query(app.tre.session.Query(stmt), names).BindMap(qb.M{\n\t\t\"uuid\": uuid,\n\t})\n\tif err = q.GetRelease(a); err != nil {\n\t\tfmt.Printf(\"Get Error: %s\\n\", err.Error())\n\t\treturn\n\t}\n\ta.Com, err = app.tre.com.List(uuid)\n\treturn\n}", "func (ds *MySQLDatastore) GetApp(ctx context.Context, name string) (*models.App, error) {\n\trow := ds.db.QueryRow(`SELECT name, config FROM apps WHERE name=?`, name)\n\n\tvar resName string\n\tvar config string\n\terr := row.Scan(&resName, &config)\n\n\tres := &models.App{\n\t\tName: resName,\n\t}\n\n\tjson.Unmarshal([]byte(config), &res.Config)\n\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil, models.ErrAppsNotFound\n\t\t}\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "func (app *App) List() (listApp []Applist, err error) {\n\tstmt, names := qb.Select(\"applications\").Columns(\"uuid\", \"name\").ToCql()\n\tq := gocqlx.Query(app.tre.session.Query(stmt), names)\n\tif err = q.SelectRelease(&listApp); err != nil {\n\t\tfmt.Printf(\"List Commands Error: %s\\n\", err.Error())\n\t}\n\treturn\n}", "func (c *AppointmentClient) Query() *AppointmentQuery {\n\treturn &AppointmentQuery{config: c.config}\n}", "func (app *KVStoreApplication) Query(reqQuery abcitypes.RequestQuery) (resQuery abcitypes.ResponseQuery) {\n\tresQuery.Key = reqQuery.Data\n\terr := app.db.View(func(txn *badger.Txn) error {\n\t\titem, err := txn.Get(reqQuery.Data)\n\t\tif err != nil && err != badger.ErrKeyNotFound {\n\t\t\treturn err\n\t\t}\n\t\tif err == badger.ErrKeyNotFound {\n\t\t\tresQuery.Log = \"does not exist\"\n\t\t} else {\n\t\t\treturn item.Value(func(val []byte) error {\n\t\t\t\tresQuery.Log = \"exists\"\n\t\t\t\tresQuery.Value = val\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn\n}", "func (c Client) Application(name string) (types.Application, error) {\n var app types.ApplicationResponse\n\n resp, err := c.get(\"/applications/\" + name, nil)\n defer ensureReaderClosed(resp)\n if err != nil {\n return app.Attributes, err\n }\n\n err = json.NewDecoder(resp.body).Decode(&app)\n\n if err != nil {\n return app.Attributes, err\n }\n return app.Attributes, err\n}", "func (app *JSONStoreApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) {\n\treturn types.ResponseQuery{Code: code.CodeTypeOK}\n}", "func (app *JSONStateApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) {\n\tswitch reqQuery.Path{\n\tcase \"patient\":\n\t\treturn getPatient(reqQuery.Data, app.db)\n\tcase \"doctor\":\n\t\treturn getDoctor(reqQuery.Data, app.db)\n\tcase \"account\":\n\t\t{\n\t\t\tvar (\n\t\t\t\tresult interface{}\n\t\t\t\terr error\n\t\t\t)\n\t\t\tif reqQuery.Data == nil {\n\t\t\t\tresult, err = app.store.ListAccounts()\n\t\t\t\tlog.Printf(\"got account list: %+v\", result)\n\t\t\t} else {\n\t\t\t\tresult, err = app.store.GetAccount(string(reqQuery.Data))\n\t\t\t\tlog.Printf(\"got account: %+v\", result)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tresQuery.Code = code.CodeTypeBadData\n\t\t\t\tresQuery.Log = err.Error()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tbs, _ := json.Marshal(result)\n\t\t\tresQuery.Value = bs\n\t\t}\n\tcase \"secret\":\n\t\t{\n\t\t\tvar (\n\t\t\t\tresult interface{}\n\t\t\t\terr error\n\t\t\t)\n\t\t\tif reqQuery.Data == nil {\n\t\t\t\tresult, err = app.store.ListSecrets()\n\t\t\t\tlog.Printf(\"got secret list: %+v\", result)\n\t\t\t} else {\n\t\t\t\tresult, err = app.store.GetSecret(string(reqQuery.Data))\n\t\t\t\tlog.Printf(\"got secret: %+v\", result)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tresQuery.Code = code.CodeTypeBadData\n\t\t\t\tresQuery.Log = err.Error()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tbs, _ := json.Marshal(result)\n\t\t\tresQuery.Value = bs\n\t\t}\n\tdefault:\n\t\t{\n\t\t\tresQuery.Code = code.CodeTypeBadData\n\t\t\tresQuery.Log = \"wrong path\"\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn\n}", "func (s Store) GetApplication(title string) ([]utils.Metadata, error) {\n\tvar listMetadata []utils.Metadata\n\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\tif !s.isTitlePresent(title) {\n\t\treturn listMetadata, messages.MetadataTitleAbsent\n\t}\n\n\tfor _, metadata := range s.appToDetails[title] {\n\t\tlistMetadata = append(listMetadata, metadata)\n\t}\n\n\treturn listMetadata, nil\n}", "func (ec *executionContext) _Application(ctx context.Context, sel ast.SelectionSet, obj *model.Application) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, applicationImplementors)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"Application\")\n\t\tcase \"id\":\n\t\t\tout.Values[i] = ec._Application_id(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"description\":\n\t\t\tout.Values[i] = ec._Application_description(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"appliedBy\":\n\t\t\tout.Values[i] = ec._Application_appliedBy(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"appliedAt\":\n\t\t\tout.Values[i] = ec._Application_appliedAt(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"verifiedBy\":\n\t\t\tout.Values[i] = ec._Application_verifiedBy(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tcase \"verifiedAt\":\n\t\t\tout.Values[i] = ec._Application_verifiedAt(ctx, field, obj)\n\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\tinvalid = true\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "func AppGetByName(ctx *Context, name string) (*Application, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(\"application\")\n\tparams := make(url.Values)\n\tparams.Set(\"filter\", \"app_name\")\n\tparams.Set(\"eq\", name)\n\tb, err := doJSON(ctx, \"GET\", uri, h, params, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar appRes = struct {\n\t\tD []*Application `json:\"d\"`\n\t}{}\n\terr = json.Unmarshal(b, &appRes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(appRes.D) > 0 {\n\t\treturn appRes.D[0], nil\n\t}\n\treturn nil, errors.New(\"application not found\")\n}", "func (c *Client) App(user, name string) (*App, error) {\n\tlog.Printf(\"[INFO] getting application %s/%s\", user, name)\n\n\tendpoint := fmt.Sprintf(\"/api/v1/vagrant/applications/%s/%s\", user, name)\n\trequest, err := c.Request(\"GET\", endpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse, err := checkResp(c.HTTPClient.Do(request))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar app App\n\tif err := decodeJSON(response, &app); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &app, nil\n}", "func FetchAllApps() (map[string]string, error) {\n\treturn client.HGetAll(ApplicationKey).Result()\n}", "func (c *ClubappStatusClient) Query() *ClubappStatusQuery {\n\treturn &ClubappStatusQuery{config: c.config}\n}", "func ApplicationShow(w http.ResponseWriter, r *http.Request) {\n\tdb, err := database.Connect()\n\tdefer db.Close()\n\tif err != nil {\n\t\tlog.Printf(\"Database error: '%s'\\n\", err)\n\t\tjre := jsonutil.NewJSONResponseError(\n\t\t\thttp.StatusInternalServerError,\n\t\t\t\"there was an error when attempting to connect to the database\")\n\t\tjsonutil.RespondJSONError(w, jre)\n\t\treturn\n\t}\n\n\tid := bone.GetValue(r, \"uuid\")\n\tapp, err := resources.GetApplication(db, id, resources.GetApplicationPods)\n\tif err != nil {\n\t\tlog.Printf(\"Error when retrieving application: '%s'\\n\", err)\n\t\tjre := jsonutil.NewJSONResponseError(\n\t\t\thttp.StatusInternalServerError,\n\t\t\t\"there was an error when retrieving application\")\n\t\tjsonutil.RespondJSONError(w, jre)\n\t\treturn\n\t}\n\n\tjson.NewEncoder(w).Encode(app)\n}", "func (app *BftApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) {\n\tif reqQuery.Prove {\n\t\tvalue := app.state.db.Get(prefixKey(reqQuery.Data))\n\t\tresQuery.Index = -1 // TODO make Proof return index\n\t\tresQuery.Key = reqQuery.Data\n\t\tresQuery.Value = value\n\t\tif value != nil {\n\t\t\tresQuery.Log = \"exists\"\n\t\t} else {\n\t\t\tresQuery.Log = \"does not exist\"\n\t\t}\n\t\treturn\n\t} else {\n\t\tvalue := app.state.db.Get(prefixKey(reqQuery.Data))\n\t\tresQuery.Value = value\n\t\tif value != nil {\n\t\t\tresQuery.Log = \"exists\"\n\t\t} else {\n\t\t\tresQuery.Log = \"does not exist\"\n\t\t}\n\t\treturn\n\t}\n}", "func (this *AppCollection) Get(identity interface{}) collection.Item {\n name := identity.(string)\n\n for _, a := range this.apps {\n if a.Info().Name() == name {\n return a\n }\n }\n\n return nil\n}", "func (h *FlinkApplicationQueryHandler) Get(ctx context.Context, project, service, applicationId, queryId string) (*GetFlinkApplicationQueryResponse, error) {\n\tpath := buildPath(\"project\", project, \"service\", service, \"flink\", \"application\", applicationId, \"query\", queryId)\n\tbts, err := h.client.doGetRequest(ctx, path, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar r GetFlinkApplicationQueryResponse\n\treturn &r, checkAPIResponse(bts, &r)\n}", "func (r *ApplicationRequest) Get(ctx context.Context) (resObj *Application, err error) {\n\tvar query string\n\tif r.query != nil {\n\t\tquery = \"?\" + r.query.Encode()\n\t}\n\terr = r.JSONRequest(ctx, \"GET\", query, nil, &resObj)\n\treturn\n}", "func (t *SmartLendingChaincode) Query(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\n\tif function == \"GetApplicationDetails\" {\n\t\tfmt.Println(\"Calling GetLoanApplicationDetails\")\n\t\treturn t.GetLoanApplicationDetails(stub, args[0])\n\t}\n\tfmt.Println(\"Function not found\")\n\treturn nil, errors.New(\"No query functions\")\n}", "func (h *FlinkApplicationQueryHandler) List(ctx context.Context, project, service, applicationId string) (*ListFlinkApplicationQueryResponse, error) {\n\tpath := buildPath(\"project\", project, \"service\", service, \"flink\", \"application\", applicationId, \"query\")\n\tbts, err := h.client.doGetRequest(ctx, path, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar r ListFlinkApplicationQueryResponse\n\treturn &r, checkAPIResponse(bts, &r)\n}", "func (store *managerStore) FetchApplication(runAs, appID string) (*types.Application, error) {\n\n\tpath := getApplicationRootPath() + runAs + \"/\" + appID\n\n\tdata, err := store.Db.Fetch(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapp := &types.Application{}\n\tif err := json.Unmarshal(data, app); err != nil {\n\t\tblog.Error(\"fail to unmarshal application(%s:%s) data(%s) err:%s\", runAs, appID, string(data), err.Error())\n\t\treturn nil, err\n\t}\n\n\treturn app, nil\n}", "func (a *appHandler) GetApp(w http.ResponseWriter, r *http.Request) {\n\tvar app model.App\n\n\t// TODO : QUERY\n\n\tjsonR, err := json.Marshal(app)\n\tif err != nil {\n\t\ta.httpUtil.WriteJSONInternalServerErrorResponse(w, err)\n\t}\n\n\ta.httpUtil.WriteJSONSuccessResponse(w, jsonR)\n}", "func (setup *FabricSetup) Query(key string) (string, error) {\n\tresponse, err := setup.QueryRaw(key)\n\treturn string(response), err\n}", "func AppGetByID(ctx *Context, id int64) (*Application, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(fmt.Sprintf(\"application(%d)\", id))\n\tb, err := doJSON(ctx, \"GET\", uri, h, nil, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar appRes = struct {\n\t\tD []*Application `json:\"d\"`\n\t}{}\n\terr = json.Unmarshal(b, &appRes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(appRes.D) > 0 {\n\t\treturn appRes.D[0], nil\n\t}\n\treturn nil, errors.New(\"application not found\")\n}", "func AppGetAll(ctx *Context) ([]*Application, error) {\n\th := authHeader(ctx.Config.AuthToken)\n\turi := ctx.Config.APIEndpoint(\"application\")\n\tb, err := doJSON(ctx, \"GET\", uri, h, nil, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar appRes = struct {\n\t\tD []*Application `json:\"d\"`\n\t}{}\n\terr = json.Unmarshal(b, &appRes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn appRes.D, nil\n}", "func (client *BaseClient) Query(filter map[string]interface{}) map[string]string {\n\ttmp := make(map[string]interface{})\n\tbyt, _ := json.Marshal(filter)\n\t_ = json.Unmarshal(byt, &tmp)\n\n\tresult := make(map[string]string)\n\tfor key, value := range tmp {\n\t\tfilterValue := reflect.ValueOf(value)\n\t\tflatRepeatedList(filterValue, result, key)\n\t}\n\n\treturn result\n}", "func GetApp(c echo.Context) error {\n\tid := c.Param(\"id\")\n\tfmt.Println(\"id passed in : \", id)\n\tvar app models.App\n\tsqlStatment := `SELECT id, appname, disabled, globaldisablemessage FROM apps WHERE id=$1;`\n\trow := d.QueryRow(sqlStatment, id)\n\terr := row.Scan(&app.ID, &app.Appname, &app.Disabled, &app.GlobalDisableMessage)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.JSON(http.StatusOK, app)\n}", "func (c *RoomdetailClient) Query() *RoomdetailQuery {\n\treturn &RoomdetailQuery{config: c.config}\n}", "func (as *ApplicationStore) Find(ctx context.Context, name string) *domain.Application {\n\treturn as.items[name]\n}", "func (am *AppManager) GetAppData(appGUID string) AppInfo {\n\t//logger.Printf(\"Searching for %s\\n\", appGUID)\n\treq := readRequest{appGUID, make(chan AppInfo)}\n\tam.readChannel <- req\n\tai := <-req.responseChan\n\t//logger.Printf(\"Recevied response for %s: %+v\", appGUID, ai)\n\treturn ai\n}", "func (c *applicationOperator) getHelmAppByName(workspace, name string) (*v1alpha1.HelmApplication, error) {\n\tls := map[string]string{\n\t\tconstants.WorkspaceLabelKey: workspace,\n\t}\n\n\tlist, err := c.appLister.List(labels.SelectorFromSet(ls))\n\n\tif err != nil && !apierrors.IsNotFound(err) {\n\t\treturn nil, err\n\t}\n\n\tif len(list) > 0 {\n\t\tfor _, a := range list {\n\t\t\tif a.GetTrueName() == name {\n\t\t\t\treturn a, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, nil\n}", "func (as *ApplicationStore) GetAll(ctx context.Context, applicationType *string, applicationWorkflow *string) ([]*domain.Application, error) {\n\tresult := make([]*domain.Application, 0, len(as.items))\n\tfor _, app := range as.items {\n\t\tif applicationWorkflow != nil && app.Workflow != *applicationWorkflow {\n\t\t\tcontinue\n\t\t}\n\t\tif applicationType != nil && app.Type != *applicationType {\n\t\t\tcontinue\n\t\t}\n\t\tresult = append(result, app)\n\t}\n\treturn result, nil\n}", "func (database *Database) Query(collection string, query string) (map[int]map[string]interface{}, error) {\n\t//log.Println(\"Executing query:\", query)\n\n\t// Switch to the collection\n\tobjects, collectionErr := database.GetCollection(collection)\n\tif collectionErr != nil {\n\t\treturn nil, collectionErr\n\t}\n\n\t// Convert the query string to a query object\n\tvar queryObject interface{}\n\tif err := json.Unmarshal([]byte(query), &queryObject); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Prepare the query results\n\tqueryResults := make(map[int]struct{}) // query result (document IDs) goes into map keys\n\n\t// Run the query\n\tif err := db.EvalQuery(queryObject, objects, &queryResults); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Construct a pre-populated map of the result objects\n\tresults := make(map[int]map[string]interface{})\n\tfor id := range queryResults {\n\t\to, err := objects.Read(id)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresults[id] = o\n\t}\n\n\t// Return the query results\n\treturn results, nil\n}", "func GetApplicationByPublicID(iq IQ, applicationPublicID string) (*Application, error) {\n\tdoError := func(err error) error {\n\t\treturn fmt.Errorf(\"application '%s' not found: %v\", applicationPublicID, err)\n\t}\n\tendpoint := fmt.Sprintf(restApplicationByPublic, applicationPublicID)\n\tbody, _, err := iq.Get(endpoint)\n\tif err != nil {\n\t\treturn nil, doError(err)\n\t}\n\n\tvar resp iqAppDetailsResponse\n\tif err = json.Unmarshal(body, &resp); err != nil {\n\t\treturn nil, doError(err)\n\t}\n\n\tif len(resp.Applications) == 0 {\n\t\treturn nil, fmt.Errorf(\"application %s not found\", applicationPublicID)\n\t}\n\n\treturn &resp.Applications[0], nil\n}", "func (app *Application) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery) {\n lib.Log.Notice(reqQuery)\n// \tif reqQuery.Prove {\n// \t lib.Log.Notice(string(reqQuery.Data))\n\t // 此处修改 value, err := app.state.db.Get(prefixKey(reqQuery.Data))\n// \t\tvalue, err := app.state.db.Get(reqQuery.Data)\n//\n// \t\tif err != nil {\n// \t\t\tpanic(err)\n// \t\t}\n// \t\tif value == nil {\n// \t\t\tresQuery.Log = \"does not exist\"\n// \t\t} else {\n// \t\t\tresQuery.Log = \"exists\"\n// \t\t}\n// \t\tresQuery.Index = -1 // TODO make Proof return index\n// \t\tresQuery.Key = reqQuery.Data\n// \t\tresQuery.Value = value\n// \t\tresQuery.Height = app.state.Height\n//\n// \t\treturn resQuery\n// \t}\n lib.Log.Notice(string(reqQuery.Path))\n if reqQuery.Path == \"\" {\n resQuery.Key = reqQuery.Data\n // 此处修改 value, err := app.state.db.Get(prefixKey(reqQuery.Data))\n value, err := app.state.db.Get(reqQuery.Data)\n\n if err != nil {\n panic(err)\n }\n if value == nil {\n resQuery.Log = \"does not exist\"\n } else {\n resQuery.Log = \"exists\"\n }\n resQuery.Value = value\n resQuery.Height = app.state.Height\n\n\n }else{\n // 迭代器\n itr, e := app.state.db.Iterator(nil, nil)\n // 查询kv获取对应数据\n var build strings.Builder\n build.WriteString(\"[\")\n for ; itr.Valid(); itr.Next() {\n key := itr.Key()\n value := itr.Value()\n if strings.Index(string(key), reqQuery.Path) != -1 && strings.Index(string(value), string(reqQuery.Data)) != -1 {\n build.WriteString(string(value))\n build.WriteString(\",\")\n }\n }\n result := build.String()\n result = strings.TrimRight(result, \",\")\n result = result + \"]\"\n lib.Log.Notice(result)\n lib.Log.Notice(e)\n resQuery.Key = reqQuery.Data\n resQuery.Value = []byte(result)\n }\n\n return resQuery\n}", "func (c Client) fetchApp() (*Identity, error) {\n\treq, err := http.NewRequest(\"GET\", c.getURL(\"/me\"), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar marshalled map[string]*Identity\n\terr = c.executeRequestAndMarshal(req, &marshalled)\n\treturn marshalled[\"identity\"], err\n}", "func (o *DesktopApp) Update() (*restapi.GenericMapResponse, error) {\n\tif o.ID == \"\" {\n\t\treturn nil, errors.New(\"error: ID is empty\")\n\t}\n\tvar queryArg = make(map[string]interface{})\n\tqueryArg, err := generateRequestMap(o)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tqueryArg[\"_RowKey\"] = o.ID\n\n\tLogD.Printf(\"Generated Map for Update(): %+v\", queryArg)\n\n\tresp, err := o.client.CallGenericMapAPI(o.apiUpdate, queryArg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !resp.Success {\n\t\treturn nil, errors.New(resp.Message)\n\t}\n\n\treturn resp, nil\n}", "func Query(c router.Context) (interface{}, error) {\n\treturn c.State().Get(OwnerStateKey)\n}", "func (ds *MySQLDatastore) GetApps(ctx context.Context, filter *models.AppFilter) ([]*models.App, error) {\n\tres := []*models.App{}\n\tfilterQuery, args := buildFilterAppQuery(filter)\n\trows, err := ds.db.Query(fmt.Sprintf(\"SELECT DISTINCT name, config FROM apps %s\", filterQuery), args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tvar app models.App\n\t\terr := scanApp(rows, &app)\n\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tres = append(res, &app)\n\t}\n\n\tif err := rows.Err(); err != nil {\n\t\treturn res, err\n\t}\n\treturn res, nil\n}", "func (e *EurekaConnection) GetApps() (map[string]*Application, error) {\n\tslug := EurekaURLSlugs[\"Apps\"]\n\treqURL := e.generateURL(slug)\n\tlog.Debugf(\"Getting all apps from url %s\", reqURL)\n\tbody, rcode, err := getBody(reqURL, e.UseJson)\n\tif err != nil {\n\t\tlog.Errorf(\"Couldn't get apps, error: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\tif rcode > 299 || rcode < 200 {\n\t\tlog.Warningf(\"Non-200 rcode of %d\", rcode)\n\t}\n\n\tvar r *GetAppsResponse\n\tif e.UseJson {\n\t\tvar rj GetAppsResponseJson\n\t\terr = json.Unmarshal(body, &rj)\n\t\tr = rj.Response\n\t} else {\n\t\terr = xml.Unmarshal(body, &r)\n\t}\n\tif err != nil {\n\t\tlog.Errorf(\"Unmarshalling error: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\tapps := map[string]*Application{}\n\tfor i, a := range r.Applications {\n\t\tapps[a.Name] = r.Applications[i]\n\t}\n\tfor name, app := range apps {\n\t\tlog.Debugf(\"Parsing metadata for app %s\", name)\n\t\tapp.ParseAllMetadata()\n\t}\n\treturn apps, nil\n}", "func qryApp(cmd marcopolo.CmdMsg, srvConn *marcopolo.ServerConn) {\n\tappName := cmd.AppNameParam.AppName\n\tfmt.Println(\"qry app \", appName)\n\n\t// look for a regd app w. this name\n\tfoundApp, found := apps[appName]\n\tif found {\n\t\t//TODO: ping app to confirm it is still there (&unreg if no answer)!\n\t\t// or do we leave this to caller ?\n\t\t// the problem I see w. pign here is that since we use UDP,\n\t\t// the caller might do a sendQry/tryToGetResp loop .. as we would do here !\n\t\t// Which would mean we would get multiple/dup queries from same caller,\n\t\t// which we would need to know how to hanle (recognize & skip,\n\t\t// or keep list of callers for an app name & send all answers back: not as clean but simpler)\n\t\tfmt.Printf(\"qryapp, found @ %s\\n\", foundApp.appAddr)\n\n\t\t// send back answer to caller\n\t\tsrvConn.SendRespQryApp(foundApp.appAddr, cmd.UdpPacket.RemoteAddr)\n\t} else {\n\t\t// send back error to caller\n\t\tfmt.Println(\"qryapp, not found\")\n\n\t\terrMsg := fmt.Errorf(\"qryapp, '%s' not found \", appName)\n\t\tsrvConn.SendRespQryAppErr(errMsg, cmd.UdpPacket.RemoteAddr)\n\t}\n}", "func (o *Service) Query() (map[string]interface{}, error) {\n\tquery := \"SELECT * FROM Subscriptions WHERE 1=1\"\n\tif o.Name != \"\" {\n\t\tquery += \" AND WindowsServiceName='\" + o.Name + \"'\"\n\t}\n\n\treturn queryVaultObject(o.client, query)\n}", "func (m MatchedResources) Query(client *ApiClient, namespace string) (map[string][]byte, error) {\n\tvar err error\n\tresult := make(map[string][]byte)\n\n\tfor res, object := range m.WantRes{\n\t\tfor namespaced, g := range m.Gvr {\n\t\t\tfor _, gvr := range g {\n\t\t\t\tif res != gvr.Resource {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tj := 0\n\t\t\t\tfor _, k := range object{\n\t\t\t\t\tif namespaced {\n\t\t\t\t\t\tf, err = client.DynClient.Resource(gvr).Namespace(namespace).Get(context.TODO(), k, metav1.GetOptions{})\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tf, err = client.DynClient.Resource(gvr).Get(context.TODO(), k, metav1.GetOptions{})\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\terr = deepCleaning(f)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\n\t\t\t\t\toutput, err := utils.GetPrettyYaml(f)\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\tresult[fmt.Sprintf(\"%s-%v\", res, j)] = output\n\n\t\t\t\t\tj++\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n\treturn result, nil\n\n}", "func (d *dbApplicationStorage) GetByEUI(eui protocol.EUI, userID model.UserID) (model.Application, error) {\n\tvar rows *sql.Rows\n\tvar err error\n\tif userID == model.SystemUserID {\n\t\trows, err = d.systemGetStatement.Query(eui.String())\n\t} else {\n\t\trows, err = d.getStatement.Query(eui.String(), string(userID))\n\t}\n\tret := model.NewApplication()\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tdefer rows.Close()\n\tif !rows.Next() {\n\t\treturn ret, storage.ErrNotFound\n\t}\n\tapp, err := d.readApplication(rows)\n\treturn app, err\n}", "func (self DataEngine) fetchAppDataConfig(appId int64, objName string) []models.MetaDataField{\r\n\tvar config []models.MetaDataField\r\n\r\n\t_, err := self.DbContext.Dbmap.Select(&config, sql.AppDataConfig(),appId, objName)\r\n\tif err != nil {panic(err)}\r\n\r\n\treturn config\r\n}", "func (c *PatientroomClient) Query() *PatientroomQuery {\n\treturn &PatientroomQuery{config: c.config}\n}", "func (i *IStoreService) GetAppList() (*geyser.Request, error) {\n\tsm, err := i.Interface.Methods.Get(schema.MethodKey{\n\t\tName: \"GetAppList\",\n\t\tVersion: 1,\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq := geyser.NewRequest(i.Interface, sm)\n\n\treturn req, nil\n}", "func (db *DB) getAppByAliasOrID(value interface{}) *SimpleApp {\n\tapp := &SimpleApp{}\n\tvar err error\n\n\tif id, ok := value.(int); ok {\n\t\terr = db.Get(app, \"select * from simple_app where id = $1\", id)\n\t} else if alias, ok := value.(string); ok {\n\t\terr = db.Get(app, \"select * from simple_app where alias = $1\", alias)\n\t} else {\n\t\tpanic(\"invalid value for getAppByAliasOrID\")\n\t}\n\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil\n\t\t} else {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\treturn app\n}", "func (c *ClubClient) QueryClubapplication(cl *Club) *ClubapplicationQuery {\n\tquery := &ClubapplicationQuery{config: c.config}\n\tquery.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {\n\t\tid := cl.ID\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(club.Table, club.FieldID, id),\n\t\t\tsqlgraph.To(clubapplication.Table, clubapplication.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.O2M, false, club.ClubapplicationTable, club.ClubapplicationColumn),\n\t\t)\n\t\tfromV = sqlgraph.Neighbors(cl.driver.Dialect(), step)\n\t\treturn fromV, nil\n\t}\n\treturn query\n}", "func (ai *AppInteractor) Get(id string) (domain.App, error) {\n\treturn ai.AppRepository.Get(id)\n}", "func (a *ArangoDb) Query(ctx context.Context, query string, bindVars map[string]interface{}, resObj interface{}) (string, error) {\n\tconst op = \"db.Query\"\n\tcursor, err := (*a.Db).Query(ctx, query, bindVars)\n\n\t//collection not found\n\tif arango.IsNotFound(err) {\n\t\treturn \"\", &e.Error{Code: e.ENOTFOUND, Op: op}\n\t} else if err != nil {\n\t\t// handle error\n\t\treturn \"\", &e.Error{Code: e.EINTERNAL, Op: op, Err: err}\n\t}\n\tdefer cursor.Close()\n\n\tmeta, err := cursor.ReadDocument(ctx, &resObj)\n\tif arango.IsNoMoreDocuments(err) {\n\t\treturn \"\", &e.Error{Code: e.ENOTFOUND, Op: op}\n\t} else if err != nil {\n\t\treturn \"\", &e.Error{Code: e.EINTERNAL, Op: op, Err: err}\n\t}\n\n\treturn meta.Key, nil\n}", "func (c *RoomClient) Query() *RoomQuery {\n\treturn &RoomQuery{config: c.config}\n}", "func (c *RoomClient) Query() *RoomQuery {\n\treturn &RoomQuery{config: c.config}\n}", "func (c *ToolClient) Query() *ToolQuery {\n\treturn &ToolQuery{config: c.config}\n}", "func (c *ClubapplicationClient) Get(ctx context.Context, id int) (*Clubapplication, error) {\n\treturn c.Query().Where(clubapplication.ID(id)).Only(ctx)\n}", "func (c *RoomuseClient) Query() *RoomuseQuery {\n\treturn &RoomuseQuery{config: c.config}\n}", "func ListApps() JsonApps {\n\tvar SClusterName string\n\tvar SNamespace string\n\tvar SAppName string\n\tvar SAppType string\n\tvar SHelmVersion string\n\tvar SHelmChart string\n\tvar SHelmAPPVersion string\n\tvar SHpaEnabled bool\n\tvar SVaultEnabled bool\n\n\tvar response JsonApps\n\n\tdb, err := sql.Open(\"mysql\", UserDB+\":\"+PassDB+\"@tcp(\"+HostDB+\":\"+PortDB+\")/\"+DatabaseDB+\"?charset=utf8\")\n\tcheckErr(err)\n\n\tdefer db.Close()\n\n\trows, err := db.Query(\"SELECT clusters.nome, apps.namespace, apps.app, apps.type, IFNULL(helm.helm_version, \\\"\\\"), IFNULL(helm.chart, \\\"\\\"), IFNULL(helm.app_version, \\\"\\\"), apps.hpa_enabled, apps.vault_enabled FROM apps INNER JOIN clusters ON (apps.id_cluster=clusters.id_cluster) LEFT JOIN helm ON (apps.app=helm.app AND apps.namespace=helm.namespace AND apps.id_cluster=helm.id_cluster) ORDER BY clusters.nome,apps.namespace,apps.app\")\n\tcheckErr(err)\n\n\tfor rows.Next() {\n\t\terr = rows.Scan(&SClusterName, &SNamespace, &SAppName, &SAppType, &SHelmVersion, &SHelmChart, &SHelmAPPVersion, &SHpaEnabled, &SVaultEnabled)\n\t\tcheckErr(err)\n\n\t\tresponse = append(\n\t\t\tresponse,\n\t\t\tjsonApps{\n\t\t\t\tClusterName: SClusterName,\n\t\t\t\tName: SAppName,\n\t\t\t\tNamespace: SNamespace,\n\t\t\t\tType: SAppType,\n\t\t\t\tHpaEnabled: SHpaEnabled,\n\t\t\t\tVaultEnabled: SVaultEnabled,\n\t\t\t\tHelm: Helm{\n\t\t\t\t\tVersion: SHelmVersion,\n\t\t\t\t\tChart: SHelmChart,\n\t\t\t\t\tAPPVersion: SHelmAPPVersion,\n\t\t\t\t},\n\t\t\t},\n\t\t)\n\t}\n\n\treturn response\n}", "func (s *AppStorage) GetByName(ctx context.Context, name string) (*types.App, error) {\n\n\tlog.V(logLevel).Debugf(\"Storage: App: get by name: %s\", name)\n\n\tif len(name) == 0 {\n\t\terr := errors.New(\"name can not be empty\")\n\t\tlog.V(logLevel).Errorf(\"Storage: App: get app err: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\tclient, destroy, err := s.Client()\n\tif err != nil {\n\t\tlog.V(logLevel).Errorf(\"Storage: App: create client err: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\tdefer destroy()\n\n\tapp := new(types.App)\n\tkeyMeta := keyCreate(appStorage, name, \"meta\")\n\tif err := client.Get(ctx, keyMeta, &app.Meta); err != nil {\n\t\tlog.V(logLevel).Errorf(\"Storage: App: get app `%s` meta err: %s\", name, err.Error())\n\t\treturn nil, err\n\t}\n\n\treturn app, nil\n}", "func (controller AppsController) GetBy(c *gin.Context) {\n\tname := c.Params.ByName(\"fieldname\")\n\tvalue := c.Params.ByName(\"fieldvalue\")\n\tvar bsonQuery bson.M\n\tif name == \"id\" {\n\t\tobjectID, _ := primitive.ObjectIDFromHex(value)\n\t\tbsonQuery = bson.M{\"_id\": objectID}\n\t} else {\n\t\tbsonQuery = bson.M{name: value}\n\t}\n\tvar config entities.App\n\tconfigs, err := mongodb.GetAll(controller.MongoDBClient, Collections[\"apps\"], bsonQuery, config)\n\tif err != nil {\n\t\tfmt.Printf(\"error %v\", err)\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"message\": \"Invalid Parameters\"})\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\"apps\": configs})\n}", "func (k Keeper) GetApp(ctx sdk.Ctx, address sdk.Address) (a exported.ApplicationI, found bool) {\n\ta = k.appKeeper.Application(ctx, address)\n\tif a == nil {\n\t\treturn a, false\n\t}\n\treturn a, true\n}", "func (c *PharmacistClient) Query() *PharmacistQuery {\n\treturn &PharmacistQuery{config: c.config}\n}", "func (c *PatientInfoClient) Query() *PatientInfoQuery {\n\treturn &PatientInfoQuery{config: c.config}\n}", "func (c *DeviceClient) Query() *DeviceQuery {\n\treturn &DeviceQuery{config: c.config}\n}", "func (m *MicrosoftStoreForBusinessApp) GetContainedApps()([]MobileContainedAppable) {\n val, err := m.GetBackingStore().Get(\"containedApps\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]MobileContainedAppable)\n }\n return nil\n}", "func (c *ActivitiesClient) Query() *ActivitiesQuery {\n\treturn &ActivitiesQuery{config: c.config}\n}", "func (c *CleaningroomClient) Query() *CleaningroomQuery {\n\treturn &CleaningroomQuery{config: c.config}\n}", "func (c *VeterinarianClient) QueryAppointments(v *Veterinarian) *AppointmentQuery {\n\tquery := &AppointmentQuery{config: c.config}\n\tquery.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {\n\t\tid := v.ID\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(veterinarian.Table, veterinarian.FieldID, id),\n\t\t\tsqlgraph.To(appointment.Table, appointment.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.O2M, false, veterinarian.AppointmentsTable, veterinarian.AppointmentsColumn),\n\t\t)\n\t\tfromV = sqlgraph.Neighbors(v.driver.Dialect(), step)\n\t\treturn fromV, nil\n\t}\n\treturn query\n}", "func (db *DB) QueryMap(query string, mp interface{}) (*Rows, error) {\n\treturn db.QueryMapContext(context.Background(), query, mp)\n}", "func (client ManagementClient) GetApps(hostName string, filter string, top *int32, selectParameter string) (result ApplicationCollection, err error) {\n\treq, err := client.GetAppsPreparer(hostName, filter, top, selectParameter)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"intune.ManagementClient\", \"GetApps\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.GetAppsSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"intune.ManagementClient\", \"GetApps\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.GetAppsResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"intune.ManagementClient\", \"GetApps\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (a *API) GetApplication(appEUI lorawan.EUI64, app *Application) error {\n\tvar err error\n\t*app, err = GetApplication(a.ctx.DB, appEUI)\n\treturn err\n}", "func (t *RoamingSolutionChaincode) Query(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\n\tfmt.Println(\"Query RoamingSolution Chaincode... start\") \n\t\n\t\n\tif function == \"EntitlementFromVPMNQuery\" {\n\t\treturn t.EntitlementFromVPMNQuery(stub, args)\n\t} \n\tif function == \"EntitlementFromHPMNQuery\" {\n\t\treturn t.EntitlementFromHPMNQuery(stub, args)\n\t} \n\tif function == \"GetALLQuery\" {\n\t\treturn t.GetALLQuery(stub, args)\n\t} \n\t\n\n\tkey := args[0]\n\n \n valAsbytes, err := stub.GetState(key)\n if err != nil {\n jsonResp := \"{\\\"Error\\\":\\\"Failed to get state for \" + key + \"\\\"}\"\n return nil, errors.New(jsonResp)\n } else if len(valAsbytes) == 0{\n\t jsonResp := \"{\\\"Error\\\":\\\"Failed to get Query for \" + key + \"\\\"}\"\n return nil, errors.New(jsonResp)\n\t}\n\n\tfmt.Println(\"Query RoamingSolution Chaincode... end\") \n return valAsbytes, nil \n \n\t\n}", "func (as *ApplicationStore) GetByName(name string) (*model.Application, error) {\n\tvar application model.Application\n\tif err := as.db.\n\t\tPreload(clause.Associations).\n\t\tFirst(&application, &model.Application{Name: name}).\n\t\tError; err != nil {\n\t\tif errors.Is(err, gorm.ErrRecordNotFound) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn &application, nil\n}", "func (app *Application) Get() (*Result, error) {\n\tbody, _, err := get(ApplicationsResource + \"/\" + app.ID)\n\tif err != nil {\n\t\tresult := &Result{}\n\t\tjson.Unmarshal(body, result)\n\t\treturn result, err\n\t}\n\terr = json.Unmarshal(body, app)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn nil, nil\n}", "func (c *ExaminationroomClient) Query() *ExaminationroomQuery {\n\treturn &ExaminationroomQuery{config: c.config}\n}", "func (c *OperationroomClient) Query() *OperationroomQuery {\n\treturn &OperationroomQuery{config: c.config}\n}", "func QueryGen(query string, columns []string, connectServerArgs ...interface{}) ([]map[string]interface{}, error) {\n\tvar res []map[string]interface{}\n\tole.CoInitializeEx(0, 0)\n\tunknown, err := oleutil.CreateObject(\"WbemScripting.SWbemLocator\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer unknown.Release()\n\n\twmi, err := unknown.QueryInterface(ole.IID_IDispatch)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer wmi.Release()\n\n\t// service is a SWbemServices\n\tserviceRaw, err := oleutil.CallMethod(wmi, \"ConnectServer\", connectServerArgs...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tservice := serviceRaw.ToIDispatch()\n\tdefer service.Release()\n\n\t// result is a SWBemObjectSet\n\tresultRaw, err := oleutil.CallMethod(service, \"ExecQuery\", query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult := resultRaw.ToIDispatch()\n\tdefer result.Release()\n\n\tcount, err := oleInt64(result, \"Count\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor i := int64(0); i < count; i++ {\n\t\t// item is a SWbemObject, but really a Win32_Process\n\t\titemRaw, err := oleutil.CallMethod(result, \"ItemIndex\", i)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\titem := itemRaw.ToIDispatch()\n\t\tdefer item.Release()\n\t\tm := make(map[string]interface{})\n\t\tfor _, c := range columns {\n\t\t\tprop, err := oleutil.GetProperty(item, c)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tm[c] = prop.Value()\n\t\t}\n\t\tres = append(res, m)\n\t}\n\treturn res, nil\n}", "func (svc V2Service) Query(query *UserMappingsQuery) ([]UserMapping, error) {\n\tresp, err := svc.Repository.Read(olhttp.OLHTTPRequest{\n\t\tURL: svc.Endpoint,\n\t\tHeaders: map[string]string{\"Content-Type\": \"userMappinglication/json\"},\n\t\tAuthMethod: \"bearer\",\n\t\tPayload: query,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar userMappings []UserMapping\n\tjson.Unmarshal(resp, &userMappings)\n\n\treturn userMappings, nil\n}", "func (e *EurekaConnection) GetApp(name string) (*Application, error) {\n\tslug := fmt.Sprintf(\"%s/%s\", EurekaURLSlugs[\"Apps\"], name)\n\treqURL := e.generateURL(slug)\n\tlog.Debugf(\"Getting app %s from url %s\", name, reqURL)\n\tout, rcode, err := getBody(reqURL, e.UseJson)\n\tif err != nil {\n\t\tlog.Errorf(\"Couldn't get app %s, error: %s\", name, err.Error())\n\t\treturn nil, err\n\t}\n\tif rcode == 404 {\n\t\tlog.Errorf(\"App %s not found (received 404)\", name)\n\t\treturn nil, AppNotFoundError{specific: name}\n\t}\n\tif rcode > 299 || rcode < 200 {\n\t\tlog.Warningf(\"Non-200 rcode of %d\", rcode)\n\t}\n\n\tvar v *Application\n\tif e.UseJson {\n\t\tvar r GetAppResponseJson\n\t\terr = json.Unmarshal(out, &r)\n\t\tv = &r.Application\n\t} else {\n\t\terr = xml.Unmarshal(out, &v)\n\t}\n\tif err != nil {\n\t\tlog.Errorf(\"Unmarshalling error: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\tv.ParseAllMetadata()\n\treturn v, nil\n}", "func (am *ArtifactMap) GetRandomApp(sessionState *State) (ArtifactEntry, error) {\n\tam.mu.Lock()\n\tdefer am.mu.Unlock()\n\n\tn := len(am.AppList)\n\tif n < 1 {\n\t\treturn ArtifactEntry{}, errors.New(\"cannot select random app: ArtifactMap is empty\")\n\t}\n\trandomIndex := sessionState.Randomizer().Rand(n)\n\tselectedKVP := am.AppList[randomIndex]\n\treturn *selectedKVP, nil\n}", "func (this *Device) Query(query api.IQuery) error {\n if this.queryProcessor == nil {\n return errors.New(fmt.Sprintf(ERR_NO_QUERY_PROCESSOR, this.Info().String()))\n }\n\n var err error\n var queryString string\n\n if queryString, err = this.queryProcessor(this.Info().Mapify(), query); err == nil {\n err = this.Send([]byte(queryString))\n }\n\n return err\n}", "func Get(c *deis.Client, appID string) (api.App, error) {\n\tu := fmt.Sprintf(\"/v2/apps/%s/\", appID)\n\n\tres, reqErr := c.Request(\"GET\", u, nil)\n\tif reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {\n\t\treturn api.App{}, reqErr\n\t}\n\tdefer res.Body.Close()\n\n\tapp := api.App{}\n\n\tif err := json.NewDecoder(res.Body).Decode(&app); err != nil {\n\t\treturn api.App{}, err\n\t}\n\n\treturn app, reqErr\n}", "func (svc *V2Service) Query(query *UserMappingsQuery) ([]UserMapping, error) {\n\tresp, err := svc.Repository.Read(olhttp.OLHTTPRequest{\n\t\tURL: svc.Endpoint,\n\t\tHeaders: map[string]string{\"Content-Type\": \"userMappinglication/json\"},\n\t\tAuthMethod: \"bearer\",\n\t\tPayload: query,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar userMappings []UserMapping\n\tjson.Unmarshal(resp, &userMappings)\n\n\treturn userMappings, nil\n}", "func (c *ClubappStatusClient) QueryClubapplication(cs *ClubappStatus) *ClubapplicationQuery {\n\tquery := &ClubapplicationQuery{config: c.config}\n\tquery.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {\n\t\tid := cs.ID\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(clubappstatus.Table, clubappstatus.FieldID, id),\n\t\t\tsqlgraph.To(clubapplication.Table, clubapplication.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.O2M, false, clubappstatus.ClubapplicationTable, clubappstatus.ClubapplicationColumn),\n\t\t)\n\t\tfromV = sqlgraph.Neighbors(cs.driver.Dialect(), step)\n\t\treturn fromV, nil\n\t}\n\treturn query\n}", "func GetAllApps(c echo.Context) error {\n\t// returning static apps array\n\tsqlStatment := \"SELECT id, appname, disabled, globaldisablemessage FROM apps order by id\"\n\trows, err := d.Query(sqlStatment)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tdefer rows.Close()\n\n\t// creates a new object from return from postgres\n\tvar result []models.App\n\tfor rows.Next() {\n\t\tvar app models.App\n\t\terr2 := rows.Scan(&app.ID, &app.Appname, &app.Disabled, &app.GlobalDisableMessage)\n\t\tif err2 != nil {\n\t\t\treturn err2\n\t\t}\n\t\tresult = append(result, app)\n\t}\n\t// returns new object\n\treturn c.JSON(http.StatusOK, result)\n}", "func (s *store) Query(query string) ([]*api.KeyValue, error) {\n\tpanic(\"not implemented\")\n}", "func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {\n\tpath := splitPath(req.Path)\n\tif len(path) == 0 {\n\t\tmsg := \"no query path provided\"\n\t\treturn types.ErrUnknownRequest(msg).QueryResult()\n\t}\n\tswitch path[0] {\n\tcase \"app\":\n\t\treturn handleQueryApp(app, path, req)\n\tcase \"store\":\n\t\treturn handleQueryStore(app, path, req)\n\tcase \"custom\":\n\t\treturn handlerCustomQuery(app, path, req)\n\t}\n\n\tmsg := \"unknown query path\"\n\treturn types.ErrUnknownRequest(msg).QueryResult()\n}", "func (c *PetClient) QueryAppointments(pe *Pet) *AppointmentQuery {\n\tquery := &AppointmentQuery{config: c.config}\n\tquery.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {\n\t\tid := pe.ID\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(pet.Table, pet.FieldID, id),\n\t\t\tsqlgraph.To(appointment.Table, appointment.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.O2M, false, pet.AppointmentsTable, pet.AppointmentsColumn),\n\t\t)\n\t\tfromV = sqlgraph.Neighbors(pe.driver.Dialect(), step)\n\t\treturn fromV, nil\n\t}\n\treturn query\n}", "func (as *ApplicationStore) GetAll() ([]model.Application, error) {\n\tvar applications []model.Application\n\tif err := as.db.Preload(clause.Associations).Find(&applications).Error; err != nil {\n\t\tif errors.Is(err, gorm.ErrRecordNotFound) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn applications, nil\n}", "func (ar AppResource) Get(ctx context.Context, r *http.Request) (int, interface{}) {\n\terr := requireScope(ctx, \"read:app\")\n\tif err != nil {\n\t\treturn http.StatusUnauthorized, err\n\t}\n\tu := getCurrentUser(ctx)\n\tmctx := getModelContext(ctx)\n\taId := params(ctx, \"id\")\n\tif aId == \"\" {\n\t\treturn http.StatusBadRequest, \"app id not given\"\n\t}\n\tid, err := strconv.Atoi(aId)\n\tif err != nil {\n\t\treturn http.StatusBadRequest, err\n\t}\n\tqueryApp, err := app.GetApp(mctx, id)\n\tif err != nil {\n\t\tif err == app.ErrAppNotFound {\n\t\t\treturn http.StatusBadRequest, \"app doesn't exist\"\n\t\t}\n\t\treturn http.StatusBadRequest, err\n\t}\n\trole, err := group.GetRoleOfUser(mctx, u.GetId(), queryApp.AdminGroupId)\n\tif role != group.ADMIN {\n\t\treturn http.StatusForbidden, \"only admins of the app can read it\"\n\t}\n\tresp := &App{\n\t\tId: queryApp.Id,\n\t\tFullName: queryApp.FullName,\n\t\tSecret: queryApp.Secret,\n\t\tRedirectUri: queryApp.RedirectUri,\n\t}\n\treturn http.StatusOK, resp\n}", "func (o *Avi) FetchApplicationPersistenceProfile() (r map[string]string, err error) {\r\n\tr = make(map[string]string)\r\n\tavi := new(tmavi.Avi)\r\n\tavi.Client = o.Client\r\n\tresp, err := avi.GetAllApplicationPersistenceProfile()\r\n\tif err != nil {\r\n\t\treturn\r\n\t}\r\n\tfor _, v := range resp {\r\n\t\tr[*v.Name] = *v.UUID\r\n\t}\r\n\treturn\r\n}", "func (api API) AppList() (list AppList, err error) {\n\n\tbearer, err := api.Authenticator.GetToken(\"code:all\")\n\tif err != nil {\n\t\treturn\n\t}\n\tpath := api.Authenticator.GetHostPath() + api.DesignAutomationPath\n\tlist, err = listApps(path, bearer.AccessToken)\n\n\treturn\n}", "func (c *FoodmenuClient) Query() *FoodmenuQuery {\n\treturn &FoodmenuQuery{config: c.config}\n}", "func (objx *Coder) Query(property int) (*Code, error) {\n\n\tif obj, ok := objx.aliveCodes[property]; ok {\n\t\tobk := new(Code)\n\t\t*obk = *obj\n\t\treturn (obk), nil\n\t}\n\n\tobj := new(Code)\n\tobj.ID = property\n\thas, err := x.Get(obj)\n\tif has {\n\t\treturn obj, nil\n\t}\n\treturn nil, err\n}", "func (c *directorClient) GetApplicationsByNameRequest(appName string) *gcli.Request {\n\treturn gcli.NewRequest(fmt.Sprintf(`query {\n\t\t\tresult: applications(filter: {key:\"%s\", query: \"\\\"%s\\\"\"}) {\n\t\t\t\t\t%s\n\t\t\t}\n\t}`, nameKey, appName, c.gqlFieldsProvider.Page(c.gqlFieldsProvider.ForApplication())))\n}", "func (session *Session) Query(sqlOrArgs ...interface{}) ([]map[string][]byte, error) {\n\treturn HookQuery(func() ([]map[string][]byte, error) {\n\t\treturn session.Session.Query(sqlOrArgs...)\n\t})\n}", "func (c Client) Applications() ([]types.Application, error) {\n resp, err := c.get(\"/applications\", nil)\n defer ensureReaderClosed(resp)\n if err != nil {\n return nil, err\n }\n\n var apps []types.Application\n err = json.NewDecoder(resp.body).Decode(&apps)\n return apps, err\n}" ]
[ "0.6097737", "0.60779285", "0.58480924", "0.57571447", "0.57378846", "0.5686214", "0.5626677", "0.55896246", "0.5573494", "0.5558356", "0.55174613", "0.5502187", "0.54962736", "0.54962695", "0.5467324", "0.54668546", "0.5459671", "0.5443265", "0.54386073", "0.5380653", "0.5379248", "0.5323982", "0.53034896", "0.5252189", "0.5249731", "0.52306515", "0.5227793", "0.52271736", "0.5220783", "0.52099633", "0.5203338", "0.51814026", "0.51751566", "0.5173571", "0.516639", "0.5155579", "0.5144053", "0.5138307", "0.5138235", "0.51253366", "0.5122601", "0.51009345", "0.5099784", "0.50966436", "0.5095359", "0.5093808", "0.508174", "0.50756377", "0.5072579", "0.50722927", "0.50701845", "0.50693876", "0.50679564", "0.50672174", "0.506589", "0.5045185", "0.5045185", "0.50427955", "0.50377625", "0.50353175", "0.50257605", "0.50249934", "0.50218964", "0.50122654", "0.5011323", "0.50107986", "0.5002286", "0.4999239", "0.49935198", "0.49907103", "0.49904293", "0.49872586", "0.49856383", "0.4977867", "0.49692184", "0.496693", "0.49583334", "0.49556655", "0.49483693", "0.49464604", "0.49464548", "0.49398693", "0.4932436", "0.4922953", "0.4922601", "0.49222088", "0.4920032", "0.49185422", "0.49132678", "0.49082023", "0.4907688", "0.49061212", "0.49052987", "0.48980272", "0.48976457", "0.48973253", "0.4890619", "0.48745668", "0.48723105", "0.48672992" ]
0.81131613
0
Inject add db and repository in mediator container
func Inject(container mediator.Container, db *gorm.DB) { container.Inject("db", db) container.Inject("repository", repository.NewRepository(db)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Inject(builder ConfigBuilder) {\n\n\t//load the env into the object\n\tbuilder.SetEnvConfigs()\n\n\t//setup dynamo library\n\tdynamoClient := builder.SetDynamoDBConfigsAndBuild()\n\t//connect to the instance\n\tlog.Println(\"Connecting to dynamo client\")\n\tdynamoClient.DefaultConnect()\n\n\t//dependency injection to our resource\n\t//we inject the dynamo client\n\t//shared client, therefore shared in between all the repos\n\tLoadAdvertRepo(&repo_builder.AdvertWrapper{\n\t\tDC: dynamoClient,\n\t})\n\n\trabbitMQClient := builder.SetRabbitMQConfigsAndBuild()\n\n\tInjectRabbitMQClient(rabbitMQClient)\n}", "func Inject(db *sql.DB) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tc.Set(\"db\", db)\n\t\tc.Next()\n\t}\n}", "func injectDBGorm(db *gorm.DB) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tc.Set(\"dbConnection\", db)\n\n\t\tc.Next()\n\t}\n}", "func init() {\n\taspect.RegisterDialect(\"postgres\", &PostGres{})\n}", "func Inject(builder ConfigBuilder) {\n\n\t//load the env into the object\n\tbuilder.LoadEnvConfigs()\n\n\t//dependency injection to our resource\n\t//we inject the rabbitmq client\n\trabbitMQClient := builder.LoadRabbitMQConfigs()\n\tloadRabbitMQClient(rabbitMQClient)\n\n\tsubscribeToChannels()\n\n\tlog.Println(\"Setting up message handler...\")\n\t//initialise our message handler\n\tmh := &ed.MsgHandler{}\n\n\tes := &service.EmailService{EB: &templates.EmailBuilder{}}\n\tes.SetupTemplates()\n\t//inject the hermes service into it\n\tmh.InjectService(es)\n\n\tlog.Println(\"Loading endpoints...\")\n\teb := api.EndpointBuilder{}\n\n\teb.SetupRouter(mux.NewRouter())\n\teb.SetupEndpoints()\n\n\teb.SetQueueClient(rabbitMQClient)\n\t// we use the message handler here\n\teb.SetupMsgHandler(mh)\n\teb.SetupSubscriptionEndpoint()\n}", "func init() {\n\tRepoCreateDatabaseConnection(DatabaseConnection{Name: \"Write presentation\"})\n\tRepoCreateDatabaseConnection(DatabaseConnection{Name: \"Host meetup\"})\n}", "func DBMiddlware(db *gorm.DB) func(c *gin.Context) {\n\treturn func(c *gin.Context) {\n\t\tc.Set(\"db\", db)\n\t\tc.Next()\n\t}\n\n}", "func addDatabaseMiddleware(r *gin.Engine) {\n\tdb := initDB()\n\t// Add database to our context\n\tr.Use(func(c *gin.Context) {\n\t\tc.Set(ContextKeyDB, db)\n\t})\n}", "func InjectHandlers(sc datatype.ServiceContainer, rg *gin.RouterGroup) {\n\tauthenticator := routermiddleware.SessionMustAuth()\n\trg.POST(\"/load-repo-details\", authenticator, LoadRepoDetails(sc))\n}", "func ProviderGORM(ctx context.Context, log logger.Logger, cfg *Config) (*gorm.DB, func(), error) {\n\tlog = log.WithFields(logger.Fields{\"service\": Prefix})\n\tdb, err := gorm.Open(\"postgres\", cfg.Dsn)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tdb.DB().SetMaxOpenConns(cfg.MaxOpenConns)\n\tdb.DB().SetMaxIdleConns(cfg.MaxIdleConns)\n\tdb.DB().SetConnMaxLifetime(cfg.ConnMaxLifetime)\n\tif cfg.Debug {\n\t\tdb.LogMode(true)\n\t}\n\tdb.SetLogger(NewLoggerAdapter(log, logger.LevelDebug))\n\tcleanup := func() {\n\t\t_ = db.Close()\n\t}\n\treturn db, cleanup, nil\n}", "func (announceRepo *mockAnnounceRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func InjectDBConnector() db.Connector {\n\twire.Build(\n\t\twire.Bind(new(db.Connector), new(db.PostgresConnector)),\n\t\tdb.NewPostgresConnector,\n\t)\n\treturn db.PostgresConnector{}\n}", "func DB() martini.Handler {\n session, err := mgo.Dial(\"mongodb://localhost\")\n if err != nil {\n panic(err)\n }\n\n return func(c martini.Context) {\n s := session.Clone()\n c.Map(s.DB(\"buildnumber\"))\n defer s.Close()\n c.Next()\n }\n}", "func setupMeddler(driver string) {\n\tswitch driver {\n\tcase \"sqlite3\":\n\t\tmeddler.Default = meddler.SQLite\n\tcase \"mysql\":\n\t\tmeddler.Default = meddler.MySQL\n\tcase \"postgres\":\n\t\tmeddler.Default = meddler.PostgreSQL\n\t}\n}", "func init() {\n\t//orm.RegisterDriver(\"mysql\", orm.DRMySQL)\n\n\tmysqlReg := beego.AppConfig.String(\"mysqluser\") + \":\" +\n\t\tbeego.AppConfig.String(\"mysqlpass\") + \"@tcp(127.0.0.1:3306)/\" +\n\t\tbeego.AppConfig.String(\"mysqldb\") + \"?charset=utf8&parseTime=true&loc=Australia%2FSydney\"\n\torm.RegisterDataBase(\"default\", \"mysql\", mysqlReg)\n}", "func (achieveRepo *mockAchieveRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func init() {\n\tRepoCreateCatalog(Catalog{Id: \"Nanaimo Lidar\"})\n\tRepoCreateCatalog(Catalog{Id: \"sample\"})\n}", "func (programRepo *mockProgramRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func DB() martini.Handler {\n\tsession, err := mgo.Dial(os.Getenv(\"PAM_MONGO_URL\"))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn func(c martini.Context) {\n\t\ts := session.Clone()\n\t\tc.Map(s.DB(\"pam\"))\n\t\tdefer s.Close()\n\t\tc.Next()\n\t}\n}", "func (sessionRepo *mockSessionRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func Setup(c config.Config) error {\n\n\tlog.Info(\"storage: setting up storage module\")\n\n\tlog.Info(\"storage: setting up Redis connection pool\")\n\n\tredisPool = &redis.Pool{\n\t\tMaxIdle: c.Redis.MaxIdle,\n\t\tMaxActive: c.Redis.MaxActive,\n\t\tIdleTimeout: c.Redis.IdleTimeout,\n\t\tWait: true,\n\t\tDial: func() (redis.Conn, error) {\n\t\t\tc, err := redis.DialURL(c.Redis.URL,\n\t\t\t\tredis.DialReadTimeout(time.Minute),\n\t\t\t\tredis.DialWriteTimeout(time.Minute),\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"redis connection error: %s\", err)\n\t\t\t}\n\t\t\treturn c, err\n\t\t},\n\t\tTestOnBorrow: func(c redis.Conn, t time.Time) error {\n\t\t\tif time.Now().Sub(t) < time.Minute {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t_, err := c.Do(\"PING\")\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"ping redis error: %s\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\n\tlog.Info(\"storage: connecting to database\")\n\td, err := gorm.Open(\"mysql\", c.MySQL.DSN)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"storage: mariadb connectionerror\")\n\t}\n\td.DB().SetMaxOpenConns(c.MySQL.MaxOpenConnections)\n\td.DB().SetMaxIdleConns(c.MySQL.MaxIdleConnections)\n\tfor {\n\t\tif err := d.DB().Ping(); err != nil {\n\t\t\tlog.WithError(err).Warning(\"storage: ping mariadb error, will retry in 2s\")\n\t\t\ttime.Sleep(2 * time.Second)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tdb = d\n\n\treturn nil\n}", "func (transactionRepo *mockTransactionRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func LoadAdvertRepo (r repo_builder.AdvertBuilder){\n\tlog.Println(\"Injecting Advert Repo\")\n\trepo_builder.Advert = r\n}", "func Init(e *configs.Env) *JourneyRepository {\n\t// log.Println(e.DbConnectionString)\n\tdb, err := gorm.Open(\"mysql\", e.DbConnectionString)\n\tdb.LogMode(true)\n\n\tif err != nil {\n\t\tlog.Panicf(\"failed to connect database %s\", err.Error())\n\t}\n\n\t// Migrate the schema\n\tdb.AutoMigrate(&models.Statement{}, &models.Sequence{}, &models.Parallel{}, &models.ActivityInvocation{}, &models.Journey{}, &models.Argument{}, &models.Journey{})\n\n\thr := &JourneyRepository{\n\t\tEnv: e,\n\t\tDb: db,\n\t}\n\n\treturn hr\n\n}", "func InjectGraphQLService(\n\truntime env.Runtime,\n\tprefix provider.LogPrefix,\n\tlogLevel logger.LogLevel,\n\tsqlDB *sql.DB,\n\tgraphqlPath provider.GraphQLPath,\n\tsecret provider.ReCaptchaSecret,\n\tjwtSecret provider.JwtSecret,\n\tbufferSize provider.KeyGenBufferSize,\n\tkgsRPCConfig provider.KgsRPCConfig,\n\ttokenValidDuration provider.TokenValidDuration,\n\tdataDogAPIKey provider.DataDogAPIKey,\n\tsegmentAPIKey provider.SegmentAPIKey,\n\tipStackAPIKey provider.IPStackAPIKey,\n\tgoogleAPIKey provider.GoogleAPIKey,\n) (service.GraphQL, error) {\n\twire.Build(\n\t\twire.Bind(new(timer.Timer), new(timer.System)),\n\t\twire.Bind(new(graphql.API), new(gqlapi.Short)),\n\t\twire.Bind(new(graphql.Handler), new(graphql.GraphGopherHandler)),\n\n\t\twire.Bind(new(risk.BlackList), new(google.SafeBrowsing)),\n\t\twire.Bind(new(repository.UserURLRelation), new(sqldb.UserURLRelationSQL)),\n\t\twire.Bind(new(repository.ChangeLog), new(sqldb.ChangeLogSQL)),\n\t\twire.Bind(new(repository.URL), new(*sqldb.URLSql)),\n\n\t\twire.Bind(new(changelog.ChangeLog), new(changelog.Persist)),\n\t\twire.Bind(new(url.Retriever), new(url.RetrieverPersist)),\n\t\twire.Bind(new(url.Creator), new(url.CreatorPersist)),\n\n\t\tobservabilitySet,\n\t\tauthSet,\n\t\tkeyGenSet,\n\n\t\tenv.NewDeployment,\n\t\tprovider.NewGraphQLService,\n\t\tgraphql.NewGraphGopherHandler,\n\t\twebreq.NewHTTPClient,\n\t\twebreq.NewHTTP,\n\t\ttimer.NewSystem,\n\n\t\tgqlapi.NewShort,\n\t\tprovider.NewSafeBrowsing,\n\t\trisk.NewDetector,\n\t\tprovider.NewReCaptchaService,\n\t\tsqldb.NewChangeLogSQL,\n\t\tsqldb.NewURLSql,\n\t\tsqldb.NewUserURLRelationSQL,\n\n\t\tvalidator.NewLongLink,\n\t\tvalidator.NewCustomAlias,\n\t\tchangelog.NewPersist,\n\t\turl.NewRetrieverPersist,\n\t\turl.NewCreatorPersist,\n\t\trequester.NewVerifier,\n\t)\n\treturn service.GraphQL{}, nil\n}", "func (handler *InitHandler) addRepositoriesinDB(owner, repo, description, t string) error {\n\t// add repository\n\taddrepo := database.Repositories{\n\t\tOwner: owner,\n\t\tRepo: repo,\n\t\tDescription: description,\n\t\tType: t,\n\t}\n\n\t// create repository\n\terr := database.DBConnection.Create(&addrepo).Error\n\tif err != nil {\n\t\tglog.Errorf(\"unable to create repository: %v\", err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func init() {\n\tcollectors.Register(\"db_logs\", func() (collectors.Collector, error) {\n\t\treturn &DBLogsCollector{\n\t\t\tresourceManager: platform.GetResourceManager(),\n\t\t}, nil\n\t})\n}", "func (classRepo *mockClassRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func withDB(s *mgo.Session, h http.Handler) http.Handler {\n\treturn &dbwrapper{dbSession: s, h: h}\n}", "func init() {\n\tgoPaths := strings.Split(filepath.Join(os.Getenv(\"GOPATH\"), \"src/github.com/databrary/databrary-backend-go/\"), \":\")\n\t// if there's a vendor directory then there will be two gopaths (that's how vendoring works). we want the second one\n\t// which is the actual gopath\n\tif len(goPaths) == 2 {\n\t\tprojRoot = goPaths[1]\n\t} else if len(goPaths) == 1 {\n\t\tprojRoot = goPaths[0]\n\t} else {\n\t\tpanic(fmt.Sprintf(\"unexpected gopath %#v\", goPaths))\n\t}\n\n\tconfigPath = kingpin.Flag(\"config\", \"Path to config file\").\n\t\tDefault(filepath.Join(projRoot, \"config/databrary_dev.toml\")).\n\t\tShort('c').\n\t\tString()\n\n\t// parse command line flags\n\tkingpin.Version(\"0.0.0\")\n\tkingpin.Parse()\n\n\tif configPath, err := filepath.Abs(*configPath); err != nil {\n\t\tpanic(\"command line config file path error\")\n\t} else {\n\t\tlog.InitLgr(config.InitConf(configPath))\n\t}\n\n\t// initialize db connection\n\terr := db.InitDB(config.GetConf())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\t// initialize redis connection\n\tredis.InitRedisStore(config.GetConf())\n\n\tif config.GetConf().GetString(\"log.level\") == \"DEBUG\" {\n\t\t// print to stdout the sql generated by sqlboiler\n\t\tboil.DebugMode = true\n\t}\n}", "func New() Mediator {\n\treturn Mediator{Database:make(map[string]dbRecord)}\n}", "func (meta *Meta) init() {\n\tmeta.client = utils.CreateMongoDB(dbConfig.Str(\"address\"), log)\n\tmeta.database = meta.client.Database(dbConfig.Str(\"db\"))\n\tmeta.collection = meta.database.Collection(metaCollection)\n}", "func ProvideRepo(deps BaseDependencies) (db repo.Repository, cleanup func(), err error) {\n\tvar (\n\t\tctx = context.Background()\n\t\tdbCfg = deps.DB\n\t\trepolg = log.NewZapLogger(\"Repo\", dbCfg.Log) // Logger for Repo Layer\n\t)\n\n\tdb, err = repo.NewPostgres(dbCfg.PostgresStr(), repolg, // Postgres\n\t\trepo.SetMaxPostgresConn(dbCfg.MaxConns),\n\t\trepo.SetTracer(deps.OTTracer),\n\t\trepo.EnableMetrics(deps.DBMetrics))\n\tif err != nil {\n\t\trepolg.Error(ctx, \"Error creating repo\", err) // Service exits on any error creating repo\n\t\treturn\n\t}\n\tcleanup = func() {\n\t\tdb.Close()\n\t}\n\treturn\n}", "func DB(host, port, user, password, name string, log logger.Logger, debug bool) (*gorm.DB, error) {\n dataSource := fmt.Sprintf(\n \"%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True\", user, password, host, port, name,\n )\n\n db, err := gorm.Open(\"mysql\", dataSource)\n if err != nil {\n return nil, err\n }\n\n fmt.Printf(\"DB: %+v\\n\", db)\n db.SingularTable(true)\n //db.SetLogger(log)\n if debug {\n db.LogMode(debug)\n }\n\n return db, nil\n}", "func (app *manager) Register(bridge Bridge) {\n\t// hydrated:\n\thydrated := bridge.Hydrated()\n\n\t// hydrated pointer:\n\thydratedPtrType := reflect.Indirect(reflect.ValueOf(hydrated.Pointer())).Type()\n\thydratedPtrName := fmt.Sprintf(doubleStringPattern, hydratedPtrType.PkgPath(), hydratedPtrType.Name())\n\tapp.mp[hydratedPtrName] = bridge\n\n\t// dehydrated:\n\tdehyrated := bridge.Dehydrated()\n\n\t// dehydrated interface:\n\tdehyratedInterfaceType := reflect.TypeOf(dehyrated.Interface())\n\tdehyratedInterfaceName := fmt.Sprintf(doubleStringPattern, dehyratedInterfaceType.PkgPath(), dehyratedInterfaceType.Name())\n\tapp.mp[dehyratedInterfaceName] = bridge\n\n\t// dehydrated pointer:\n\tdehydratedPtrType := reflect.Indirect(reflect.ValueOf(dehyrated.Pointer())).Type()\n\tdehydratedPtrName := fmt.Sprintf(doubleStringPattern, dehydratedPtrType.PkgPath(), dehydratedPtrType.Name())\n\tapp.mp[dehydratedPtrName] = bridge\n}", "func SetupDomain(\n\tctx context.Context,\n\teventStore eh.EventStore,\n\teventBus eh.EventBus,\n\ttodoRepo eh.ReadWriteRepo,\n) (eh.CommandHandler, error) {\n\n\t// Set the entity factory if the repo is a memory repo.\n\tif memoryRepo, ok := todoRepo.(*memory.Repo); ok {\n\t\tmemoryRepo.SetEntityFactory(func() eh.Entity { return &TodoList{} })\n\t} else if memoryRepo, ok := todoRepo.Parent().(*memory.Repo); ok {\n\t\tmemoryRepo.SetEntityFactory(func() eh.Entity { return &TodoList{} })\n\t}\n\n\t// Set the entity factory if the repo is a MongoDB repo.\n\tif mongoRepo, ok := todoRepo.(*mongodb.Repo); ok {\n\t\tmongoRepo.SetEntityFactory(func() eh.Entity { return &TodoList{} })\n\t} else if mongoRepo, ok := todoRepo.Parent().(*mongodb.Repo); ok {\n\t\tmongoRepo.SetEntityFactory(func() eh.Entity { return &TodoList{} })\n\t}\n\n\t// Create the read model projector.\n\tprojector := projector.NewEventHandler(&Projector{}, todoRepo)\n\tprojector.SetEntityFactory(func() eh.Entity { return &TodoList{} })\n\teventBus.AddHandler(ctx, eh.MatchEvents{\n\t\tCreated,\n\t\tDeleted,\n\t\tItemAdded,\n\t\tItemRemoved,\n\t\tItemDescriptionSet,\n\t\tItemChecked,\n\t}, projector)\n\n\t// Create the event sourced aggregate repository.\n\taggregateStore, err := events.NewAggregateStore(eventStore, eventBus)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not create aggregate store: %w\", err)\n\t}\n\n\t// Create the aggregate command handler.\n\tcommandHandler, err := aggregate.NewCommandHandler(AggregateType, aggregateStore)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not create command handler: %w\", err)\n\t}\n\n\treturn commandHandler, nil\n}", "func init() {\n\tmart.Register(&client{})\n}", "func init() {\n\tconfig.Read()\n\tdao.DialInfo = &mgo.DialInfo{\n\t\tAddrs: []string{config.Server},\n\t\tDatabase: config.Database,\n\t\tUsername: config.Username,\n\t\tPassword: config.Password,\n\t}\n\n\tdao.Server = config.Server\n\tdao.Database = config.Database\n\tdao.Connect()\n\n}", "func Inject(ctx context.Context, metadata *metadata.MD) {\n\tpropagator.Inject(ctx, &metadataSupplier{\n\t\tmetadata: metadata,\n\t})\n}", "func init() {\n\t// Open a connection to GORM\n\tdb, err := gorm.Open(\"sqlite3\", \"shop.db\")\n\tif err != nil {\n\t\tpanic(\"Failed to connect database\")\n\t}\n\n\tDB = db\n\n\tDB.AutoMigrate(models.Supply{})\n}", "func (influxdb Influxdb) Setup(db string, duration string, rp string) error {\n\tglog.Info(\"DEBUG:: Influxdb setup \", db+\":\"+rp)\n\t// If no retention policy is defined, use \"autogen\"\n\tif rp == \"\" {\n\t\trp = \"autogen\"\n\t}\n\t// If no duration is defined, use \"1h\" (original hardcoded value, to reduce regression risk)\n\tif duration == \"\" {\n\t\tduration = \"1h\"\n\t}\n\tq := \"q=CREATE DATABASE \\\"\"+db+\"\\\" WITH DURATION \"+duration+\" REPLICATION 1 NAME \\\"\"+rp+\"\\\"\"\n\tbaseUrl := influxdb.Host + \"/query\"\n\t_, err := influxdb.Client.Post(baseUrl, \"application/x-www-form-urlencoded\",\n\t\tbytes.NewBuffer([]byte(q)))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err2 := influxdb.MonitorCreate(db); err2 != nil {\n\t\treturn err2\n\t}\n\treturn nil\n}", "func init() {\n\tconfig.Read()\n\n\tdao.Server = config.Server\n\tdao.Database = config.Database\n\tdao.Connect()\n}", "func init() {\n\tconfig.Read()\n\n\tdao.Server = config.Server\n\tdao.Database = config.Database\n\tdao.Connect()\n}", "func Instance() *gorm.DB {\n return database\n}", "func main() {\n\t// Parse command line flags\n\tflag.Parse()\n\n\tif !*flagQuiet {\n\t\tstartupmsg.Output(os.Stdout)\n\t}\n\n\t// Initialize dependency injection builder\n\tdiBuilder, _ := di.NewBuilder()\n\n\t// Setup config parser\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiConfigParser,\n\t\tBuild: func(ctn di.Container) (p interface{}, err error) {\n\t\t\text := strings.ToLower(filepath.Ext(*flagConfig))\n\t\t\tswitch ext {\n\t\t\tcase \".yml\", \".yaml\":\n\t\t\t\tp = new(config.YAMLConfigParser)\n\t\t\tcase \".json\":\n\t\t\t\tp = new(config.JSONConfigParser)\n\t\t\tdefault:\n\t\t\t\terr = errors.New(\"unsupported configuration file\")\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t})\n\n\t// Initialize config\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiConfig,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitConfig(*flagConfig, ctn), nil\n\t\t},\n\t})\n\n\t// Initialize metrics server\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiMetrics,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitMetrics(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize redis client\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiRedis,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\tconfig := ctn.Get(static.DiConfig).(*config.Config)\n\t\t\treturn redis.NewClient(&redis.Options{\n\t\t\t\tAddr: config.Database.Redis.Addr,\n\t\t\t\tPassword: config.Database.Redis.Password,\n\t\t\t\tDB: config.Database.Redis.Type,\n\t\t\t}), nil\n\t\t},\n\t})\n\n\t// Initialize database middleware and shutdown routine\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiDatabase,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitDatabase(ctn), nil\n\t\t},\n\t\tClose: func(obj interface{}) error {\n\t\t\tdatabase := obj.(database.Database)\n\t\t\tlogrus.Info(\"Shutting down database connection...\")\n\t\t\tdatabase.Close()\n\t\t\treturn nil\n\t\t},\n\t})\n\n\t// Initialize twitch notification listener\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiTwitchNotifyListener,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn listeners.NewListenerTwitchNotify(ctn), nil\n\t\t},\n\t\tClose: func(obj interface{}) error {\n\t\t\tlistener := obj.(*listeners.ListenerTwitchNotify)\n\t\t\tlogrus.Info(\"Shutting down twitch notify listener...\")\n\t\t\tlistener.TearDown()\n\t\t\treturn nil\n\t\t},\n\t})\n\n\t// Initialize twitch notification worker\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiTwitchNotifyWorker,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitTwitchNotifyWorker(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize life cycle timer\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiLifecycleTimer,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitLTCTimer(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize storage middleware\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiObjectStorage,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitStorage(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize permissions command handler middleware\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiPermissionMiddleware,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn middleware.NewPermissionMiddleware(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize ghost ping ignore command handler middleware\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiGhostpingIgnoreMiddleware,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn middleware.NewGhostPingIgnoreMiddleware(), nil\n\t\t},\n\t})\n\n\t// Initialize discord bot session and shutdown routine\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiDiscordSession,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn discordgo.New()\n\t\t},\n\t\tClose: func(obj interface{}) error {\n\t\t\tsession := obj.(*discordgo.Session)\n\t\t\tlogrus.Info(\"Shutting down bot session...\")\n\t\t\tsession.Close()\n\t\t\treturn nil\n\t\t},\n\t})\n\n\t// Initialize Discord OAuth Module\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiDiscordOAuthModule,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitDiscordOAuth(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize auth refresh token handler\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiAuthRefreshTokenHandler,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn auth.NewDatabaseRefreshTokenHandler(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize auth access token handler\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiAuthAccessTokenHandler,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn auth.NewJWTAccessTokenHandler(ctn)\n\t\t},\n\t})\n\n\t// Initialize auth API token handler\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiAuthAPITokenHandler,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn auth.NewDatabaseAPITokenHandler(ctn)\n\t\t},\n\t})\n\n\t// Initialize OAuth API handler implementation\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiOAuthHandler,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn auth.NewRefreshTokenRequestHandler(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize access token authorization middleware\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiAuthMiddleware,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn auth.NewAccessTokenMiddleware(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize OTA generator\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiOneTimeAuth,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn onetimeauth.NewJwt(&onetimeauth.JwtOptions{\n\t\t\t\tIssuer: \"shinpuru v.\" + embedded.AppVersion,\n\t\t\t})\n\t\t},\n\t})\n\n\t// Initialize backup handler\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiBackupHandler,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn backup.New(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize command handler\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiCommandHandler,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitCommandHandler(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize web server\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiWebserver,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitWebServer(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize code execution factroy\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiCodeExecFactory,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitCodeExec(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize karma service\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiKarma,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn karma.NewKarmaService(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize report service\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiReport,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn report.New(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize guild logger\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiGuildLog,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn guildlog.New(ctn), nil\n\t\t},\n\t})\n\n\t// Initialize KV cache\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiKVCache,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn kvcache.NewTimedmapCache(10 * time.Minute), nil\n\t\t},\n\t})\n\n\tdiBuilder.Add(di.Def{\n\t\tName: static.DiState,\n\t\tBuild: func(ctn di.Container) (interface{}, error) {\n\t\t\treturn inits.InitState(ctn)\n\t\t},\n\t})\n\n\t// Build dependency injection container\n\tctn := diBuilder.Build()\n\n\t// Setting log level from config\n\tcfg := ctn.Get(static.DiConfig).(*config.Config)\n\tlogrus.SetLevel(logrus.Level(cfg.Logging.LogLevel))\n\tlogrus.SetFormatter(&logrus.TextFormatter{\n\t\tForceColors: true,\n\t\tFullTimestamp: true,\n\t\tTimestampFormat: \"2006/01/02 15:04:05 MST\",\n\t})\n\n\t// Initial log output\n\tlogrus.Info(\"Starting up...\")\n\n\tif profLoc := util.GetEnv(envKeyProfile, *flagProfile); profLoc != \"\" {\n\t\tsetupProfiler(profLoc)\n\t}\n\n\tif *flagDevMode {\n\t\tsetupDevMode()\n\t}\n\n\t// Initialize discord session and event\n\t// handlers\n\tinits.InitDiscordBotSession(ctn)\n\n\t// This is currently the really hacky workaround\n\t// to bypass the di.Container when trying to get\n\t// the Command handler instance inside a command\n\t// context, because the handler can not resolve\n\t// itself on build, so it is bypassed here using\n\t// shireikans object map. Maybe I find a better\n\t// solution for that at some time.\n\thandler := ctn.Get(static.DiCommandHandler).(shireikan.Handler)\n\thandler.SetObject(static.DiCommandHandler, handler)\n\n\t// Get Web WebServer instance to start web\n\t// server listener\n\tctn.Get(static.DiWebserver)\n\t// Get Backup Handler to ensure backup\n\t// timer is running.\n\tctn.Get(static.DiBackupHandler)\n\t// Get Metrics Server to start metrics\n\t// endpoint.\n\tctn.Get(static.DiMetrics)\n\n\t// Block main go routine until one of the following\n\t// specified exit syscalls occure.\n\tlogrus.Info(\"Started event loop. Stop with CTRL-C...\")\n\n\tlogrus.WithField(\"took\", startuptime.Took().String()).Info(\"Initialization finished\")\n\tsc := make(chan os.Signal, 1)\n\tsignal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)\n\t<-sc\n\n\t// Tear down dependency instances\n\tctn.DeleteWithSubContainers()\n}", "func ProvideRepo(engine engine.Engine) Repo {\n\treturn Repo{Engine: engine}\n}", "func Inject(c *gin.Context) {\n\tc.Set(\"cfg\", Config)\n\tc.Next()\n}", "func InjectDBMigrationTool() db.MigrationTool {\n\twire.Build(\n\t\twire.Bind(new(db.MigrationTool), new(db.PostgresMigrationTool)),\n\t\tdb.NewPostgresMigrationTool,\n\t)\n\treturn db.PostgresMigrationTool{}\n}", "func DI() proto.RoomServicesServer {\n\tiulidGenerator := util.NewULIDGenerator()\n\tiFactory := room.NewFactory(iulidGenerator)\n\tdb := mysql.ConnectGorm()\n\tiRepository := room2.NewRepositoryImpl(db)\n\tiDomainService := room3.NewDomainService(iRepository)\n\tiInputPort := room4.NewInteractor(iFactory, iRepository, iDomainService)\n\troomIInputPort := room5.NewInteractor(iRepository)\n\tclient := redis.NewClient()\n\tmessageIRepository := message.NewRepositoryImpl(db, client)\n\tmessageIInputPort := message2.NewInteractor(messageIRepository)\n\tmessageIFactory := message3.NewFactory(iulidGenerator)\n\tiInputPort2 := room6.NewInteractor(messageIFactory, messageIRepository, iRepository)\n\troomServicesServer := room7.NewController(iInputPort, roomIInputPort, messageIInputPort, iInputPort2)\n\treturn roomServicesServer\n}", "func ProviderGORMTest() (*gorm.DB, func(), error) {\n\tvar db *gorm.DB\n\tmocket.Catcher.Register()\n\tsqlDB, err := sql.Open(mocket.DriverName, \"gorm\")\n\tif err != nil {\n\t\treturn db, nil, err\n\t}\n\tdb, err = gorm.Open(\"postgres\", sqlDB)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tcleanup := func() {\n\t\t_ = db.Close()\n\t}\n\tdb.LogMode(false)\n\treturn db, cleanup, nil\n}", "func (s *MetaStore) Use(_ context.Context, log logger.Logger, _ *db.Store) (*MetaStore, error) {\n\t// Set configuration\n\ts.setConfig()\n\n\t// Subscribe to Event\n\tnotify.Subscribe(v1.METHOD_ADD, s)\n\tnotify.Subscribe(v1.METHOD_GET, s)\n\t// notify.Subscribe(api_type.METHOD_LIST, store)\n\t// notify.Subscribe(api_domain.METHOD_UPDATE, store)\n\t// notify.Subscribe(api_domain.METHOD_DELETE, store)\n\n\tswitch s.typeStore {\n\tcase \"ram\":\n\t\ts.Store = &ram.Store{}\n\tdefault:\n\t\ts.Store = &ram.Store{}\n\t}\n\n\tlog.Info(\"init metaStore\", field.Fields{\n\t\t\"db\": s.typeStore,\n\t})\n\n\treturn s, nil\n}", "func newDBDaoWithParams(host string, driver string) (Db *DBDao) {\n\tDb = new(DBDao)\n\t//Initialize a dbdao engine\n\teng, err := xorm.NewEngine(driver, host)\n\tengine := &Engine{Engine: eng}\n\n\tDb.Engine = engine\n\t//TODO: 增加存活检查\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tDb.Engine.SetMaxOpenConns(maxConn)\n\tDb.Engine.SetMaxIdleConns(maxIdle)\n\t//最大超时时间\n\tDb.Engine.SetConnMaxLifetime(time.Second * 3000)\n\tDb.Engine.ShowSQL(showSql)\n\tDb.Engine.ShowExecTime(showExecTime)\n\t//set logger Plug-in\n\tDb.Engine.SetLogger(dbLogger)\n\treturn\n}", "func Provide(in ManagerIn) (*Manager, error) {\n\tm, err := NewManager(in.DispatcherConfig, in.Transport, in.Logger, in.Measures)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m, nil\n}", "func add(mgr manager.Manager, r reconcile.Reconciler) error {\n\t// Create a new controller\n\tc, err := controller.New(\"sqldb-controller\", mgr, controller.Options{Reconciler: r})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Watch for changes to SqlDB\n\terr = c.Watch(&source.Kind{Type: &infrav1alpha1.SqlDB{}}, &handler.EnqueueRequestForObject{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Watch a StatefulSet created by SqlDB\n\terr = c.Watch(&source.Kind{Type: &appsv1.StatefulSet{}}, &handler.EnqueueRequestForOwner{\n\t\tIsController: true,\n\t\tOwnerType: &infrav1alpha1.SqlDB{},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Watch a Service created by SqlDB\n\terr = c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{\n\t\tIsController: true,\n\t\tOwnerType: &infrav1alpha1.SqlDB{},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func Init(backend *backendpb.BackendDetail) DataStoreAdapter {\n\tvar StoreAdapter DataStoreAdapter\n\n\tswitch backend.Type {\n\tcase \"aliyun\":\n\t\t//DbAdapter = mongo.Init(strings.Split(db.Endpoint, \",\"))\n\t\tStoreAdapter = aliyun.Init(backend)\n\t\treturn StoreAdapter\n\tcase \"obs\":\n\t\t//DbAdapter = mongo.Init(strings.Split(db.Endpoint, \",\"))\n\t\tStoreAdapter = hws.Init(backend)\n\t\treturn StoreAdapter\n\tcase \"aws\":\n\t\t//DbAdapter = mongo.Init(strings.Split(db.Endpoint, \",\"))\n\t\tStoreAdapter = aws.Init(backend)\n\t\treturn StoreAdapter\n\tdefault:\n\t\tfmt.Printf(\"Can't find datastore driver %s!\\n\", backend.Type)\n\t}\n\treturn nil\n}", "func (askForHelpRepo *mockAskForHelpRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func ProvideMigrator(logger *Logger, conn *Connection) (*Migrator, error) {\n\treturn &Migrator{Logger: logger, Connection: conn}, nil\n}", "func (g *Gateway) init(bootstrap bool) error {\n\tlogger.Debugf(\"Initializing database gateway\")\n\tg.stopCh = make(chan struct{})\n\n\tinfo, err := loadInfo(g.db, g.networkCert)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to create raft factory: %w\", err)\n\t}\n\n\tdir := filepath.Join(g.db.Dir(), \"global\")\n\tif shared.PathExists(filepath.Join(dir, \"logs.db\")) {\n\t\treturn fmt.Errorf(\"Unsupported upgrade path, please first upgrade to LXD 4.0\")\n\t}\n\n\t// If the resulting raft instance is not nil, it means that this node\n\t// should serve as database node, so create a dqlite driver possibly\n\t// exposing it over the network.\n\tif info != nil {\n\t\t// Use the autobind feature of abstract unix sockets to get a\n\t\t// random unused address.\n\t\tlistener, err := net.Listen(\"unix\", \"\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to autobind unix socket: %w\", err)\n\t\t}\n\n\t\tg.bindAddress = listener.Addr().String()\n\t\t_ = listener.Close()\n\n\t\toptions := []dqlite.Option{\n\t\t\tdqlite.WithBindAddress(g.bindAddress),\n\t\t}\n\n\t\tif info.Address == \"1\" {\n\t\t\tif info.ID != 1 {\n\t\t\t\tpanic(\"unexpected server ID\")\n\t\t\t}\n\n\t\t\tg.memoryDial = dqliteMemoryDial(g.bindAddress)\n\t\t\tg.store.inMemory = client.NewInmemNodeStore()\n\t\t\terr = g.store.Set(context.Background(), []client.NodeInfo{info.NodeInfo})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Failed setting node info in store: %w\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tgo runDqliteProxy(g.stopCh, g.bindAddress, g.acceptCh)\n\t\t\tg.store.inMemory = nil\n\t\t\toptions = append(options, dqlite.WithDialFunc(g.raftDial()))\n\t\t}\n\n\t\tserver, err := dqlite.New(\n\t\t\tinfo.ID,\n\t\t\tinfo.Address,\n\t\t\tdir,\n\t\t\toptions...,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to create dqlite server: %w\", err)\n\t\t}\n\n\t\t// Force the correct configuration into the bootstrap node, this is needed\n\t\t// when the raft node already has log entries, in which case a regular\n\t\t// bootstrap fails, resulting in the node containing outdated configuration.\n\t\tif bootstrap {\n\t\t\tlogger.Debugf(\"Bootstrap database gateway ID:%v Address:%v\",\n\t\t\t\tinfo.ID, info.Address)\n\t\t\tcluster := []dqlite.NodeInfo{\n\t\t\t\t{ID: uint64(info.ID), Address: info.Address},\n\t\t\t}\n\n\t\t\terr = server.Recover(cluster)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Failed to recover database state: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\terr = server.Start()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to start dqlite server: %w\", err)\n\t\t}\n\n\t\tg.lock.Lock()\n\t\tg.server = server\n\t\tg.info = info\n\t\tg.lock.Unlock()\n\t} else {\n\t\tg.lock.Lock()\n\t\tg.server = nil\n\t\tg.info = nil\n\t\tg.store.inMemory = nil\n\t\tg.lock.Unlock()\n\t}\n\n\tg.lock.Lock()\n\tg.store.onDisk = client.NewNodeStore(\n\t\tg.db.DB(), \"main\", \"raft_nodes\", \"address\")\n\tg.lock.Unlock()\n\n\treturn nil\n}", "func (em *entityManager) Use(mw ...MiddlewareFunc) {\n\tem.mwStack = append(em.mwStack, mw...)\n}", "func init() {\n // parser config\n var confFile string\n flag.StringVar(&confFile, \"c\", \"conf/tcpserver.yaml\", \"config file\")\n flag.Parse()\n\n err := utils.ConfParser(confFile, &config)\n if err != nil {\n fmt.Println(\"parser config failed:\", err.Error())\n os.Exit(-1)\n }\n\n // init db\n conninfo := fmt.Sprintf(\"%s:%s@tcp(%s)/%s?charset=utf8\", config.Db.User, config.Db.Passwd, config.Db.Host, config.Db.Db)\n db, err = gorm.Open(\"mysql\", conninfo)\n if err != nil {\n fmt.Println(\"connect to db failed:\", err.Error())\n os.Exit(-1)\n }\n db.DB().SetMaxIdleConns(config.Db.Conn.Maxidle)\n db.DB().SetMaxOpenConns(config.Db.Conn.Maxopen)\n db.LogMode(true)\n}", "func add(mgr manager.Manager, r reconcile.Reconciler) error {\n\t// Create a new controller\n\tc, err := controller.New(\"mongodbatlasdatabase-controller\", mgr, controller.Options{Reconciler: r})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Watch for changes to primary resource MongoDBAtlasDatabase\n\terr = c.Watch(&source.Kind{Type: &knappekv1alpha1.MongoDBAtlasDatabase{}}, &handler.EnqueueRequestForObject{})\n// err = c.Watch(&source.Kind{Type: &MongoDBAtlasDatabase{}}, &handler.EnqueueRequestForObject{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (r *DatabaseReconciler) SetupWithManager(mgr ctrl.Manager) error {\n\teventFilter := predicate.Funcs{\n\t\tCreateFunc: func(e event.CreateEvent) bool {\n\t\t\treturn isWatchedNamespace(r.WatchNamespaces, e.Object) && isDatabase(e.Object)\n\t\t}, // Reconcile only Database Create Event\n\t\tDeleteFunc: func(e event.DeleteEvent) bool {\n\t\t\treturn isWatchedNamespace(r.WatchNamespaces, e.Object) && isDatabase(e.Object)\n\t\t}, // Reconcile only Database Delete Event\n\t\tUpdateFunc: func(e event.UpdateEvent) bool {\n\t\t\treturn isWatchedNamespace(r.WatchNamespaces, e.ObjectNew) && isObjectUpdated(e)\n\t\t}, // Reconcile Database and Secret Update Events\n\t\tGenericFunc: func(e event.GenericEvent) bool { return true }, // Reconcile any Generic Events (operator POD or cluster restarted)\n\t}\n\n\treturn ctrl.NewControllerManagedBy(mgr).\n\t\tFor(&kciv1beta1.Database{}).\n\t\tWithEventFilter(eventFilter).\n\t\tWatches(&source.Kind{Type: &corev1.Secret{}}, &secretEventHandler{r.Client}).\n\t\tComplete(r)\n}", "func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {\n\t// sdr[types.StoreKey] = simulation.NewDecodeStore(am.keeper)\n}", "func Provide.Provide(RecordStore.Store, Blocks.Key, Net.Host) error {}", "func (userAfhRepo *mockUserAfhRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func (semesterRepo *mockSemesterRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func init() {\n\tdao.Server = \"mongodb://shivam:[email protected]:25294/shayona-store\"\n\tdao.Database = \"shayona-store\"\n\tdao.Connect()\n}", "func (accountRepo *mockAccountRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func add(mgr manager.Manager, r reconcile.Reconciler) error {\n\t// Create a new controller\n\tc, err := controller.New(\"mattermostrestoredb-controller\", mgr, controller.Options{Reconciler: r})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Watch for changes to primary resource MattermostRestoreDB\n\terr = c.Watch(&source.Kind{Type: &mattermostv1alpha1.MattermostRestoreDB{}}, &handler.EnqueueRequestForObject{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (userRepo *mockUserRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func (self *Mediator) OnRegister() {\n\n}", "func SetupDB() {\n\n\t// sqlite \"gorm.io/driver/sqlite\"\n\t//database, err := gorm.Open(sqlite.Open(\"database.db\"), &gorm.Config{})\n\n\t// mysql \"gorm.io/driver/mysql\"\n\t// dsn := \"root:@tcp(127.0.0.1:3306)/cmgostock?charset=utf8mb4&parseTime=True&loc=Local\"\n\t// database, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n\n\t// postgresql \t\"gorm.io/driver/postgres\"\n\tdsn := \"host=10.82.69.121 user=postgres password=1234 dbname=cmgostock port=5432 sslmode=disable TimeZone=Asia/Bangkok\"\n\t//dsn := \"host=localhost user=postgres password=1234 dbname=cmgostock port=5432 sslmode=disable TimeZone=Asia/Bangkok\"\n\t database, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})\n\tif err != nil {\n\t\tpanic(\"failed to connect database\")\n\t}\n\n\tdatabase.AutoMigrate(&model.User{})\n\tdatabase.AutoMigrate(&model.Product{})\n\tdatabase.AutoMigrate(&model.Transaction{})\n\n\tdb = database\n}", "func init() {\n\tsecretstores.Add(\"docker\", func(id string) telegraf.SecretStore {\n\t\treturn &Docker{ID: id}\n\t})\n}", "func (b *BadgerStore) init(dir string) error {\n\n\topts := badger.DefaultOptions(dir)\n\tif dir == \"\" {\n\t\topts = opts.WithInMemory(true)\n\t}\n\topts.Logger = &common.NoopLogger{}\n\tdb, err := badger.Open(opts)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to open database\")\n\t}\n\n\t// Set the database\n\tb.db = db\n\n\t// Initialize the default transaction that auto commits\n\t// on success ops or discards on failure.\n\t// It also enables the renewal of the underlying transaction\n\t// after executing a read/write operation\n\tb.Tx = NewTx(db, true, true)\n\n\treturn nil\n}", "func WithDatabase(db persistence.Service) Config {\n\treturn func(r *router) {\n\t\tr.db = db\n\t}\n}", "func Inject(key string, client *mongo.Client) {\n\tclientManager.Inject(key, &ClosableClient{client})\n}", "func serve(cfg *Config, log loggers.Contextual) {\n\turl := fmt.Sprintf(\"%s://%s:%s@%s/%s?%s\",\n\t\tcfg.DB.Driver,\n\t\tcfg.DB.User,\n\t\tcfg.DB.Password,\n\t\tcfg.DB.Addr,\n\t\tcfg.DB.Database,\n\t\tcfg.DB.Options,\n\t)\n\tlog.Debugf(\"Connect: %s\", url)\n\tdb, err := gorm.Open(cfg.DB.Driver, url)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to connect: %v\", err)\n\t}\n\tdefer db.Close()\n\tif cfg.LogLevel == \"debug\" {\n\t\tdb = db.Debug()\n\t}\n\tdb.SetLogger(log)\n\t// create a listener on TCP port\n\tlis, err := net.Listen(\"tcp\", cfg.Addr)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to listen: %v\", err)\n\t}\n\topts := []grpc_recovery.Option{\n\t\t// [email protected] does not have WithRecoveryHandlerContext\n\t\tgrpc_recovery.WithRecoveryHandlerContext(func(ctx context.Context, p interface{}) error {\n\t\t\terr := fmt.Errorf(\"PANIC: %s\", p)\n\t\t\treturn err\n\t\t}),\n\t}\n\tlogrusEntry := logrus.NewEntry(log.(*mapper.Logger).Logger)\n\t// create a server instance\n\ts := api.NewServer(&cfg.API, log, db)\n\t// create a gRPC server object\n\tgrpcServer := grpc.NewServer(\n\t\tgrpc.KeepaliveParams(keepalive.ServerParameters{\n\t\t\tMaxConnectionIdle: 5 * time.Minute,\n\t\t}),\n\t\tgrpc_middleware.WithUnaryServerChain(\n\t\t\tgrpc_prometheus.UnaryServerInterceptor,\n\t\t\tgrpc_logrus.UnaryServerInterceptor(logrusEntry),\n\t\t\tgrpc_recovery.UnaryServerInterceptor(opts...),\n\t\t),\n\t\tgrpc_middleware.WithStreamServerChain(\n\t\t\tgrpc_prometheus.StreamServerInterceptor,\n\t\t\tgrpc_logrus.StreamServerInterceptor(logrusEntry),\n\t\t\tgrpc_recovery.StreamServerInterceptor(opts...),\n\t\t),\n\t)\n\t// attach the service to the server\n\tpb.RegisterGreeterServer(grpcServer, s)\n\n\tgrpc_prometheus.Register(grpcServer)\n\thttp.Handle(cfg.MetricURL, promhttp.Handler())\n\tgo func() {\n\t\terr = http.ListenAndServe(cfg.MetricAddr, nil)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"ListenAndServe: \", err)\n\t\t}\n\n\t}()\n\t// start the server\n\tif err := grpcServer.Serve(lis); err != nil {\n\t\tlog.Fatalf(\"failed to serve: %s\", err)\n\t}\n}", "func InitRepositoryProvider(databaseProvider string) {\n\t// Modify the database statements if needed, for the given database type\n\tgetConsoleConfig = datastore.ModifySQLStatement(getConsoleConfig, databaseProvider)\n\tdeleteConsoleConfig = datastore.ModifySQLStatement(deleteConsoleConfig, databaseProvider)\n\n\tgetConfigValue = datastore.ModifySQLStatement(getConfigValue, databaseProvider)\n\tinsertConfigValue = datastore.ModifySQLStatement(insertConfigValue, databaseProvider)\n\tupdateConfigValue = datastore.ModifySQLStatement(updateConfigValue, databaseProvider)\n\tdeleteConfigValue = datastore.ModifySQLStatement(deleteConfigValue, databaseProvider)\n\tgetAllConfigValues = datastore.ModifySQLStatement(getAllConfigValues, databaseProvider)\n}", "func init() {\n\t// TODO: set logger\n\t// TODO: register storage plugin to plugin manager\n}", "func DBInit() *gorm.DB {\n\t//db, err := gorm.Open(\"mysql\", \"root:@tcp(128.199.211.144:3306)/godb?charset=utf8&parseTime=True&loc=Local\")\n\tdb, err := gorm.Open(\"mysql\",\"root:orion2402@tcp(localhost:3306)/popfren?charset=utf8&parseTime=True&loc=Local\")\n\tif err != nil {\n\t\tpanic(\"failed to connect to database\")\n\t}\n\n\tdb.AutoMigrate(structs.Person{})\n\treturn db\n}", "func Setup(r *gin.Engine, config bson.M, baseDir string) error {\n\tbiModule = &bi.BIModule{}\n\tbiConfig = config\n\n\tif config != nil {\n\t\tbiModule.Configure(config)\n\n\t\t// set up mongod connection\n\t\tvar err error\n\t\tmongoSession, err = mgo.DialWithInfo(&biModule.Connection)\n\t\tif err != nil {\n\t\t\tLog(ERROR, \"Error connecting to MongoDB: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tr.GET(\"/\", getMain)\n\tr.GET(\"/config\", getConfig)\n\tr.POST(\"/config\", postConfig)\n\tr.GET(\"/data/:ruleIndex/:granularity/:start/:end\", getMetric)\n\tr.GET(\"/data/:ruleIndex/:granularity/:start/:end/:value\", getMetric)\n\tr.GET(\"/tabular/:ruleIndex/:granularity/:start/:end\", getTabularMetric)\n\tr.GET(\"/tabular/:ruleIndex/:granularity/:start/:end/:value\", getTabularMetric)\n\tr.GET(\"/metadata/:ruleIndex/:granularity\", getMetadata)\n\n\tr.Static(\"/public\", baseDir+\"/public\")\n\treturn nil\n}", "func (locationRepo *mockLocationRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func (repoImpl *RepositoryImpl) Add(ctx context.Context, in *protoGen.Repository) (*protoGen.AddedRepoResponse, error) {\n\n\tlog.Println(\"Repository is being added to the storage\")\n\n\treturn &protoGen.AddedRepoResponse{\n\t\tAddedRepo: in,\n\t\tError: nil,\n\t}, nil\n}", "func Add(config configuration.Bundle, serveMux *http.ServeMux) error {\n\terr := metadata.Add(config, serveMux)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thelloworld.Add(serveMux)\n\thealth.Add(serveMux)\n\treturn nil\n}", "func (e *SqliteEndorsementStore) Init(args common.EndorsementStoreParams) error {\n\tdbPath := retrieveDbPath(args)\n\tif dbPath == \"\" {\n\t\treturn fmt.Errorf(\"dbPath not specified inside FetcherParams\")\n\t}\n\tdbConfig := fmt.Sprintf(\"file:%s?cache=shared\", dbPath)\n\tdb, err := sql.Open(\"sqlite3\", dbConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\te.db = db\n\te.path = dbPath\n\n\te.Queries = map[string]common.Query{\n\t\t\"hardware_id\": e.GetHardwareID,\n\t\t\"software_components\": e.GetSoftwareComponents,\n\t}\n\n\te.Adders = map[string]common.QueryAdder{\n\t\t\"hardware_id\": e.AddHardwareID,\n\t\t\"software_components\": e.AddSoftwareComponents,\n\t}\n\n\treturn nil\n}", "func init() {\n\tdb.RegisterInit(meterReader)\n}", "func NewDbHandlers(db *driver.DB) *DBRepo {\n\treturn &DBRepo{\n\t\tDB: dbRepo.NewSqliteRepo(db.SQL),\n\t}\n}", "func init() {\n\t_ = godotenv.Load()\n\n\thostname := os.Getenv(\"HOST\")\n\tdbname := os.Getenv(\"DBNAME\")\n\tusername := os.Getenv(\"DBUSER\")\n\tpassword := os.Getenv(\"PASSWORD\")\n\n\tdbString := \"host=\" + hostname + \" user=\" + username + \" dbname=\" + dbname + \" sslmode=disable password=\" + password\n\n\tvar err error\n\tdb, err = gorm.Open(\"postgres\", dbString)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\tpanic(\"Unable to connect to DB\")\n\t}\n\n\tdb.AutoMigrate(&QuestionModel{})\n\tdb.AutoMigrate(&AnswerModel{})\n\tdb.AutoMigrate(&UserModel{})\n\tdb.AutoMigrate(&Cohort{})\n}", "func WithDB(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tdatabase, err := model.NewDatabase()\n\t\tif err != nil {\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError),\n\t\t\t\thttp.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tdefer database.Close()\n\n\t\tctx := context.WithValue(r.Context(), BlogContext(\"database\"), database)\n\t\treq := r.WithContext(ctx)\n\n\t\tnext.ServeHTTP(w, req)\n\t})\n}", "func (s *BasePlSqlParserListener) EnterDatabase(ctx *DatabaseContext) {}", "func WrapDB(beaconDB storage.BeaconDB, cfg Config) storage.BeaconDB {\n\treturn &db{\n\t\tdb: beaconDB,\n\t\tmetrics: Observer{Cfg: cfg},\n\t}\n}", "func Connect() (contract.DataManager, error) {\n\trepo := new(data)\n\treturn &data{\n\t\tmysqlRepo: repo.MySQL(),\n\t}, nil\n}", "func add(mgr manager.Manager, r reconcile.Reconciler) error {\n\t// Create a new controller\n\tc, err := controller.New(\"database-controller\", mgr, controller.Options{Reconciler: r})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Watch for changes to primary resource Database\n\terr = c.Watch(&source.Kind{Type: &dbv1alpha1.Database{}}, &handler.EnqueueRequestForObject{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// TODO(user): Modify this to be the types you create that are owned by the primary resource\n\t// Watch for changes to secondary resource Pods and requeue the owner Database\n\terr = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &handler.EnqueueRequestForOwner{\n\t\tIsController: true,\n\t\tOwnerType: &dbv1alpha1.Database{},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func init() {\n\tdesign.Design = design.NewAPIDefinition()\n\tdesign.GeneratedMediaTypes = make(design.MediaTypeRoot)\n\tdesign.ProjectedMediaTypes = make(design.MediaTypeRoot)\n\tdslengine.Register(design.Design)\n\tdslengine.Register(design.GeneratedMediaTypes)\n}", "func newSenderDb(impl string, ip net.IPAddr, port uint16, user string, pass string, name string) db.DB {\n\tswitch impl {\n\tcase \"mysql\":\n\t\treturn db.NewMysql(impl, ip, port, user, pass, name, 0)\n\tcase \"postgres\":\n\t\t// pass\n\tdefault:\n\t\treturn nil\n\t}\n\treturn nil\n}", "func init() {\n\tcollectors.Register(\"zookeeper_db\", func() (collectors.Collector, error) {\n\t\treturn &ZookeeperCollector{\n\t\t\tresourceManager: platform.GetResourceManager(),\n\t\t}, nil\n\t})\n}", "func (s *Auth) Inject(authManager *application.AuthManager) {\n\ts.authManager = authManager\n}", "func newDBWrapper(settings *Settings, provider provider) *dbWrapper {\n\tw := &dbWrapper{\n\t\tSettings: settings,\n\t\tprovider: provider,\n\t}\n\tif pp, ok := w.provider.(placeholdersProvider); ok {\n\t\tw.placeholdersProvider = pp\n\t}\n\n\treturn w\n}", "func (w *DBInstance) connect() (req DBRequest, err error) {\n\treq.db, err = gorm.Open(\"mysql\", fmt.Sprintf(\"%v:%v@/%v?charset=utf8&parseTime=True&loc=Local\", w.sqlUser, w.sqlPass, w.sqlDBName))\n\treturn\n}", "func init() {\n\tvar err error\n\tDB, err = gorm.Open(config.MysqlConf.DriverName, config.MysqlConf.Conn)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tDB.DB().SetMaxOpenConns(config.MysqlConf.MaxOpenConns)\n\tDB.DB().SetMaxIdleConns(config.MysqlConf.MaxIdleConns)\n\tDB.DB().SetConnMaxLifetime(time.Duration(config.MysqlConf.ConnMaxLifetime))\n\t//DB.LogMode(true)\n}" ]
[ "0.62128794", "0.6069224", "0.60179096", "0.56158364", "0.5569465", "0.5566464", "0.5466895", "0.5295448", "0.5250882", "0.5194616", "0.518952", "0.5185271", "0.51505613", "0.5144981", "0.5142828", "0.510748", "0.5075509", "0.506949", "0.5014673", "0.49763554", "0.49588317", "0.4954829", "0.4951732", "0.49492675", "0.49355534", "0.49050942", "0.49041346", "0.48937827", "0.48835874", "0.4874592", "0.4867105", "0.4859529", "0.48558533", "0.48508194", "0.48482835", "0.48356393", "0.481715", "0.48122042", "0.480619", "0.48049945", "0.48048985", "0.47926426", "0.47926426", "0.47815368", "0.47802424", "0.47765958", "0.47687617", "0.47531715", "0.47531644", "0.47494578", "0.47437426", "0.47370487", "0.47361195", "0.47331235", "0.47246996", "0.47075924", "0.46935067", "0.46814215", "0.4668496", "0.46613872", "0.46525785", "0.46477658", "0.46450743", "0.4644729", "0.46414608", "0.46354175", "0.46304196", "0.4626596", "0.46225876", "0.46218476", "0.46203777", "0.46149206", "0.4614659", "0.45964593", "0.45910788", "0.45793205", "0.4577694", "0.45757407", "0.45674154", "0.4566216", "0.45623827", "0.45608667", "0.45578632", "0.4550639", "0.4548963", "0.45489407", "0.45473137", "0.45460397", "0.4542765", "0.45423412", "0.4540624", "0.4538913", "0.4535005", "0.45343062", "0.45340616", "0.4531128", "0.4520873", "0.45200625", "0.45150912", "0.45146918" ]
0.7495779
0
loadOrSelfSignCertificate loads TLS certificate from secret or creates a new one
func loadOrSelfSignCertificate(cli typedCore.CoreV1Interface, cfg ServerConfig) (string, string, error) { if cfg.TLSSecretName != "" { // Load TLS certificate from secret s, err := cli.Secrets(cfg.Namespace).Get(context.Background(), cfg.TLSSecretName, meta.GetOptions{}) if err != nil { return "", "", err } certBytes, found := s.Data[core.TLSCertKey] if !found { return "", "", errors.Newf("No %s found in secret %s", core.TLSCertKey, cfg.TLSSecretName) } keyBytes, found := s.Data[core.TLSPrivateKeyKey] if !found { return "", "", errors.Newf("No %s found in secret %s", core.TLSPrivateKeyKey, cfg.TLSSecretName) } return string(certBytes), string(keyBytes), nil } // Secret not specified, create our own TLS certificate options := certificates.CreateCertificateOptions{ CommonName: cfg.ServerName, Hosts: append([]string{cfg.ServerName}, cfg.ServerAltNames...), ValidFrom: time.Now(), ValidFor: time.Hour * 24 * 365 * 10, IsCA: false, ECDSACurve: "P256", } return certificates.CreateCertificate(options, nil) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (am *admissionManager) loadCertsFromSecret() {\n\tnamespace := utils.GetCurrentNamespace()\n\tcreate := false\n\tsecret, err := am.kubeClient.CoreV1().Secrets(namespace).Get(context.Background(),\n\t\tcertsSecretName, metav1.GetOptions{})\n\tif err != nil {\n\t\tif !errors.IsNotFound(err) {\n\t\t\tklog.Fatalf(\"get secret of %v/%v failed: %v\", namespace, certsSecretName, err)\n\t\t}\n\t\tcreate = true\n\t}\n\tvar serverCertBody, serverKeyBody, caCertBody []byte\n\tif secret == nil || secret.Data == nil || len(secret.Data[serverCert]) == 0 || len(secret.Data[serverKey]) == 0 ||\n\t\tlen(secret.Data[caCert]) == 0 {\n\t\tcaCertBody, serverCertBody, serverKeyBody, err = am.generateCerts(create)\n\t\tif err != nil {\n\t\t\tklog.Fatalf(\"generate certs failed: %v\", err)\n\t\t}\n\t} else {\n\t\tcaCertBody = secret.Data[caCert]\n\t\tserverCertBody = secret.Data[serverCert]\n\t\tserverKeyBody = secret.Data[serverKey]\n\t}\n\tam.caCertBody = caCertBody\n\tcert, err := tls.X509KeyPair(serverCertBody, serverKeyBody)\n\tif err != nil {\n\t\tklog.Fatalf(\"generate key pair error :%v\", err)\n\t}\n\tam.tlsConfig = &tls.Config{\n\t\tCertificates: []tls.Certificate{cert},\n\t}\n}", "func GetOrCreateTLSCertificate(ctx context.Context, d driver.Registry, iface config.ServeInterface, stopReload <-chan struct{}) func(*tls.ClientHelloInfo) (*tls.Certificate, error) {\n\tlock.Lock()\n\tdefer lock.Unlock()\n\n\t// check if certificates are configured\n\tcertFunc, err := d.Config().TLS(ctx, iface).GetCertificateFunc(stopReload, d.Logger())\n\tif err == nil {\n\t\treturn certFunc\n\t} else if !errors.Is(err, tlsx.ErrNoCertificatesConfigured) {\n\t\td.Logger().WithError(err).Fatal(\"Unable to load HTTPS TLS Certificate\")\n\t\treturn nil // in case Fatal is hooked\n\t}\n\n\t// no certificates configured: self-sign a new cert\n\tpriv, err := jwk.GetOrGenerateKeys(ctx, d, d.SoftwareKeyManager(), TlsKeyName, uuid.Must(uuid.NewV4()).String(), \"RS256\")\n\tif err != nil {\n\t\td.Logger().WithError(err).Fatal(\"Unable to fetch or generate HTTPS TLS key pair\")\n\t\treturn nil // in case Fatal is hooked\n\t}\n\n\tif len(priv.Certificates) == 0 {\n\t\tcert, err := tlsx.CreateSelfSignedCertificate(priv.Key)\n\t\tif err != nil {\n\t\t\td.Logger().WithError(err).Fatal(`Could not generate a self signed TLS certificate`)\n\t\t\treturn nil // in case Fatal is hooked\n\t\t}\n\n\t\tAttachCertificate(priv, cert)\n\t\tif err := d.SoftwareKeyManager().DeleteKey(ctx, TlsKeyName, priv.KeyID); err != nil {\n\t\t\td.Logger().WithError(err).Fatal(`Could not update (delete) the self signed TLS certificate`)\n\t\t\treturn nil // in case Fatal is hooked\n\t\t}\n\n\t\tif err := d.SoftwareKeyManager().AddKey(ctx, TlsKeyName, priv); err != nil {\n\t\t\td.Logger().WithError(err).Fatalf(`Could not update (add) the self signed TLS certificate: %s %x %d`, cert.SignatureAlgorithm, cert.Signature, len(cert.Signature))\n\t\t\treturn nil // in case Fatalf is hooked\n\t\t}\n\t}\n\n\tblock, err := jwk.PEMBlockForKey(priv.Key)\n\tif err != nil {\n\t\td.Logger().WithError(err).Fatal(\"Could not encode key to PEM\")\n\t\treturn nil // in case Fatal is hooked\n\t}\n\n\tif len(priv.Certificates) == 0 {\n\t\td.Logger().Fatal(\"TLS certificate chain can not be empty\")\n\t\treturn nil // in case Fatal is hooked\n\t}\n\n\tpemCert := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: priv.Certificates[0].Raw})\n\tpemKey := pem.EncodeToMemory(block)\n\tct, err := tls.X509KeyPair(pemCert, pemKey)\n\tif err != nil {\n\t\td.Logger().WithError(err).Fatal(\"Could not decode certificate\")\n\t\treturn nil // in case Fatal is hooked\n\t}\n\n\treturn func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {\n\t\treturn &ct, nil\n\t}\n}", "func selfSignedCert(t *testing.T, host string) (tls.Certificate, []byte, []byte) {\n\tprivKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to generate private key: %v\", err)\n\t}\n\tb, err := x509.MarshalECPrivateKey(privKey)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to marshal private key: %v\", err)\n\t}\n\tbk := pem.EncodeToMemory(&pem.Block{Type: \"EC PRIVATE KEY\", Bytes: b})\n\n\ttmpl := x509.Certificate{\n\t\tSerialNumber: big.NewInt(1),\n\t\tNotBefore: time.Now(),\n\t\tNotAfter: time.Now().Add(10 * time.Minute),\n\t\tIsCA: true,\n\t\tDNSNames: []string{host},\n\t}\n\n\tb, err = x509.CreateCertificate(rand.Reader, &tmpl, &tmpl, privKey.Public(), privKey)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create cert: %v\", err)\n\t}\n\tbc := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: b})\n\n\tcert, err := tls.X509KeyPair(bc, bk)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create TLS key pair: %v\", err)\n\t}\n\treturn cert, bc, bk\n}", "func validTlsSecret(t *testing.T) corev1.Secret {\n\tkey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\tt.Fatal(\"Private key cannot be created.\", err.Error())\n\t}\n\n\tcertTemplate := x509.Certificate{\n\t\tSerialNumber: big.NewInt(1337),\n\t}\n\tcert, err := x509.CreateCertificate(rand.Reader, &certTemplate, &certTemplate, &key.PublicKey, key)\n\tif err != nil {\n\t\tt.Fatal(\"Certificate cannot be created.\", err.Error())\n\t}\n\n\tca := &x509.Certificate{\n\t\tSerialNumber: big.NewInt(7331),\n\t\tIsCA: true,\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},\n\t\tKeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,\n\t}\n\n\tcaPrivKey, err := rsa.GenerateKey(rand.Reader, 4096)\n\tif err != nil {\n\t\tt.Fatal(\"CA private key cannot be created.\", err.Error())\n\t}\n\n\tcaBytes, err := x509.CreateCertificate(rand.Reader, ca, ca, &caPrivKey.PublicKey, caPrivKey)\n\tif err != nil {\n\t\tt.Fatal(\"CA certificate cannot be created.\", err.Error())\n\t}\n\n\tkeyPem := pem.EncodeToMemory(&pem.Block{\n\t\tType: \"RSA PRIVATE KEY\",\n\t\tBytes: x509.MarshalPKCS1PrivateKey(key),\n\t})\n\n\tcertPem := pem.EncodeToMemory(&pem.Block{\n\t\tType: \"CERTIFICATE\",\n\t\tBytes: cert,\n\t})\n\n\tcaPem := pem.EncodeToMemory(&pem.Block{\n\t\tType: \"CERTIFICATE\",\n\t\tBytes: caBytes,\n\t})\n\n\treturn corev1.Secret{\n\t\tData: map[string][]byte{\n\t\t\t\"certFile\": []byte(certPem),\n\t\t\t\"keyFile\": []byte(keyPem),\n\t\t\t\"caFile\": []byte(caPem),\n\t\t},\n\t}\n}", "func loadCertWithCreate(cfg *Config) (tls.Certificate, *x509.Certificate,\n\terror) {\n\n\t// Ensure we create TLS key and certificate if they don't exist.\n\tif !lnrpc.FileExists(cfg.TLSCertPath) &&\n\t\t!lnrpc.FileExists(cfg.TLSKeyPath) {\n\n\t\tlog.Infof(\"Generating TLS certificates...\")\n\t\tcertBytes, keyBytes, err := cert.GenCertPair(\n\t\t\tdefaultSelfSignedOrganization, cfg.TLSExtraIPs,\n\t\t\tcfg.TLSExtraDomains, cfg.TLSDisableAutofill,\n\t\t\tcfg.TLSValidity,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn tls.Certificate{}, nil, err\n\t\t}\n\n\t\terr = cert.WriteCertPair(\n\t\t\tcfg.TLSCertPath, cfg.TLSKeyPath, certBytes, keyBytes,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn tls.Certificate{}, nil, err\n\t\t}\n\n\t\tlog.Infof(\"Done generating TLS certificates\")\n\t}\n\n\treturn cert.LoadCert(cfg.TLSCertPath, cfg.TLSKeyPath)\n}", "func (connection *EsConnection) LoadCertificate(secretPath string) error {\n\tcertFile := path.Join(secretPath, \"cert\")\n\tkeyFile := path.Join(secretPath, \"key\")\n\tcaFile := path.Join(secretPath, \"ca\")\n\tvar err error\n\n\tlogrus.Debugln(\"cerFile: \", certFile)\n\tlogrus.Debugln(\"keyFile: \", keyFile)\n\tlogrus.Debugln(\"caFile: \", caFile)\n\n\tcertificate, err := tls.LoadX509KeyPair(certFile, keyFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"something failed while loading the x509 key pair: %s\", err)\n\t}\n\n\tcaCert, err := os.ReadFile(filepath.Clean(caFile))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"something failed while reading the CA file: %s\", err)\n\t}\n\n\trootCAs := x509.NewCertPool()\n\tok := rootCAs.AppendCertsFromPEM(caCert)\n\tif !ok {\n\t\treturn fmt.Errorf(\"something went wrong while appending the certificates from PEM\")\n\t}\n\n\tlogrus.Debugln(\"Certificate read properly from\", secretPath)\n\tconnection.RootCAs = rootCAs\n\tconnection.Certificate = certificate\n\treturn nil\n}", "func SetupSecret(certDir, namespace string) error {\n\t// generate the certificate to use when registering and serving the webhook\n\tsvc := fmt.Sprintf(\"%s.%s.svc\", serviceName, namespace)\n\tnow := time.Now()\n\tcrt := x509.Certificate{\n\t\tSubject: pkix.Name{CommonName: svc},\n\t\tNotBefore: now,\n\t\tNotAfter: now.Add(365 * 24 * time.Hour),\n\t\tSerialNumber: big.NewInt(now.Unix()),\n\t\tKeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},\n\t\tIsCA: true,\n\t\tBasicConstraintsValid: true,\n\t\tDNSNames: []string{svc},\n\t}\n\t// generate the private key to use when registering and serving the webhook\n\tkey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// pem-encode the private key\n\tkeyBytes := pem.EncodeToMemory(&pem.Block{\n\t\tType: keyutil.RSAPrivateKeyBlockType,\n\t\tBytes: x509.MarshalPKCS1PrivateKey(key),\n\t})\n\t// self-sign the generated certificate using the private key\n\tsig, err := x509.CreateCertificate(rand.Reader, &crt, &crt, key.Public(), key)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// pem-encode the signed certificate\n\tsigBytes := pem.EncodeToMemory(&pem.Block{\n\t\tType: cert.CertificateBlockType,\n\t\tBytes: sig,\n\t})\n\n\tcertFileName := filepath.Join(certDir, v1.TLSCertKey)\n\tkeyFileName := filepath.Join(certDir, v1.TLSPrivateKeyKey)\n\n\tos.MkdirAll(filepath.Dir(certFileName), os.FileMode(0777))\n\terr = ioutil.WriteFile(certFileName, sigBytes, os.FileMode(0777))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tos.MkdirAll(filepath.Dir(keyFileName), os.FileMode(0777))\n\terr = ioutil.WriteFile(keyFileName, keyBytes, os.FileMode(0777))\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func GetCertificate(cl *tls.ClientHelloInfo) (*tls.Certificate, error) {\n\tpriv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)\n\tserialNumber, err := rand.Int(rand.Reader, serialNumberLimit)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttpl := &x509.Certificate{\n\t\tSerialNumber: serialNumber,\n\t\tSubject: pkix.Name{\n\t\t\tOrganization: []string{\"shrubgateway local certificate\"},\n\t\t\tOrganizationalUnit: []string{userAndHostname},\n\t\t},\n\n\t\tNotAfter: time.Now().AddDate(0, 0, 20),\n\t\tNotBefore: time.Now().AddDate(0, 0, -1),\n\n\t\tKeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},\n\t\tBasicConstraintsValid: true,\n\t}\n\ttpl.DNSNames = append(tpl.DNSNames, cl.ServerName)\n\n\tpub := priv.PublicKey\n\tcert, err := x509.CreateCertificate(rand.Reader, tpl, caCert, &pub, caKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tprivDER, err := x509.MarshalPKCS8PrivateKey(priv)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tprivPEM := pem.EncodeToMemory(&pem.Block{Type: \"PRIVATE KEY\", Bytes: privDER})\n\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: cert})\n\n\tcertificate, err := tls.X509KeyPair(certPEM, privPEM)\n\treturn &certificate, err\n}", "func loadCertificate() {\n\tcertMutex.Lock()\n\tdefer certMutex.Unlock()\n\tif certificateData, err := ioutil.ReadFile(CertificateFile); err != nil {\n\t\tlog.Printf(\"Unable to read certificate file from disk: %s\", err)\n\t\tinitCertificate()\n\t} else {\n\t\tblock, _ := pem.Decode(certificateData)\n\t\tif block == nil {\n\t\t\tlog.Print(\"Unable to decode PEM encoded certificate\")\n\t\t\tinitCertificate()\n\t\t} else {\n\t\t\tcertificate, err = x509.ParseCertificate(block.Bytes)\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(\"Unable to decode X509 certificate data\")\n\t\t\t\tinitCertificate()\n\t\t\t}\n\t\t\tlog.Printf(\"Read certificate\")\n\t\t}\n\t}\n\n\t// Add ourselves to the trust store\n\tTrustedParents.AddCert(certificate)\n}", "func makeCertificate(t *testing.T) tls.Certificate {\n\tconst certPEM = `\n-----BEGIN CERTIFICATE-----\nMIID9DCCAtygAwIBAgIJAIX/1sxuqZKrMA0GCSqGSIb3DQEBCwUAMFkxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xNzA1MDYxNDIy\nMjVaFw0yNzA1MDQxNDIyMjVaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21l\nLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV\nBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALO4\nXVY5Kw9eNblqBenC03Wz6qemLFw8zLDNrehvjYuJPn5WVwvzLNP+3S02iqQD+Y1k\nvszqDIZLQdjWLiEZdtxfemyIr+RePIMclnceGYFx3Zgg5qeyvOWlJLM41ZU8YZb/\nzGj3RtXzuOZ5vePSLGS1nudjrKSBs7shRY8bYjkOqFujsSVnEK7s3Kb2Sf/rO+7N\nRZ1df3hhyKtyq4Pb5eC1mtQqcRjRSZdTxva8kO4vRQbvGgjLUakvBVrrnwbww5a4\n2wKbQPKIClEbSLyKQ62zR8gW1rPwBdokd8u9+rLbcmr7l0OuAsSn5Xi9x6VxXTNE\nbgCa1KVoE4bpoGG+KQsCAwEAAaOBvjCBuzAdBgNVHQ4EFgQUILso/fozIhaoyi05\nXNSWzP/ck+4wgYsGA1UdIwSBgzCBgIAUILso/fozIhaoyi05XNSWzP/ck+6hXaRb\nMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJ\nbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdIIJAIX/\n1sxuqZKrMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAIbzsvTZb8LA\nJqyaTttsMMA1szf4WBX88lVWbIk91k0nlTa0BiU/UocKrU6c9PySwJ6FOFJpgpdH\nz/kmJ+S+d4pvgqBzWbKMoMrNlMt6vL+H8Mbf/l/CN91eNM+gJZu2HgBIFGW1y4Wy\ngOzjEm9bw15Hgqqs0P4CSy7jcelWA285DJ7IG1qdPGhAKxT4/UuDin8L/u2oeYWH\n3DwTDO4kAUnKetcmNQFSX3Ge50uQypl8viYgFJ2axOfZ3imjQZrs7M1Og6Wnj/SD\nF414wVQibsZyZp8cqwR/OinvxloPkPVnf163jPRtftuqezEY8Nyj83O5u5sC1Azs\nX/Gm54QNk6w=\n-----END CERTIFICATE-----`\n\tconst keyPEM = `\n-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAs7hdVjkrD141uWoF6cLTdbPqp6YsXDzMsM2t6G+Ni4k+flZX\nC/Ms0/7dLTaKpAP5jWS+zOoMhktB2NYuIRl23F96bIiv5F48gxyWdx4ZgXHdmCDm\np7K85aUkszjVlTxhlv/MaPdG1fO45nm949IsZLWe52OspIGzuyFFjxtiOQ6oW6Ox\nJWcQruzcpvZJ/+s77s1FnV1/eGHIq3Krg9vl4LWa1CpxGNFJl1PG9ryQ7i9FBu8a\nCMtRqS8FWuufBvDDlrjbAptA8ogKURtIvIpDrbNHyBbWs/AF2iR3y736sttyavuX\nQ64CxKfleL3HpXFdM0RuAJrUpWgThumgYb4pCwIDAQABAoIBAHzvYntJPKTvUhu2\nF6w8kvHVBABNpbLtVUJniUj3G4fv/bCn5tVY1EX/e9QtgU2psbbYXUdoQRKuiHTr\n15+M6zMhcKK4lsYDuL9QhU0DcKmq9WgHHzFfMK/YEN5CWT/ofNMSuhASLn0Xc+dM\npHQWrGPKWk/y25Z0z/P7mjZ0y+BrJOKlxV53A2AWpj4JtjX2YO6s/eiraFX+RNlv\nGyWzeQ7Gynm2TD9VXhS+m40VVBmmbbeZYDlziDoWWNe9r26A+C8K65gZtjKdarMd\n0LN89jJvI1pUxcIuvZJnumWUenZ7JhfBGpkfAwLB+MogUo9ekAHv1IZv/m3uWq9f\nZml2dZECgYEA2OCI8kkLRa3+IodqQNFrb/uZ16YouQ71B7nBgAxls9nuhyELKO7d\nfzf1snPx6cbaCQKTyxrlYvck4gz8P09R7nVYwJuTmP0+QIgeCCc3Y9A2dyExaC6I\nuKkFzJEqIVZNLvdjBRWQs5AiD1w58oto+wOvbagAQM483WiJ/qFaHCMCgYEA1CPo\nzwI6pCn39RSYffK25HXM1q3i8ypkYdNsG6IVqS2FqHqj8XJSnDvLeIm7W1Rtw+uM\nQdZ5O6PH31XgolG6LrFkW9vtfH+QnXQA2AnZQEfn034YZubhcexLqAkS9r0FUUZp\na1WI2jSxBBeB+to6MdNABuQOL3NHjPUidUKnOfkCgYA+HvKbE7ka2F+23DrfHh08\nEkFat8lqWJJvCBIY73QiNAZSxnA/5UukqQ7DctqUL9U8R3S19JpH4qq55SZLrBi3\nyP0HDokUhVVTfqm7hCAlgvpW3TcdtFaNLjzu/5WlvuaU0V+XkTnFdT+MTsp6YtxL\nKh8RtdF8vpZIhS0htm3tKQKBgQDQXoUp79KRtPdsrtIpw+GI/Xw50Yp9tkHrJLOn\nYMlN5vzFw9CMM/KYqtLsjryMtJ0sN40IjhV+UxzbbYq7ZPMvMeaVo6vdAZ+WSH8b\ntHDEBtzai5yEVntSXvrhDiimWnuCnVqmptlJG0BT+JMfRoKqtgjJu++DBARfm9hA\nvTtsYQKBgE1ttTzd3HJoIhBBSvSMbyDWTED6jecKvsVypb7QeDxZCbIwCkoK9zn1\ntwPDHLBcUNhHJx6JWTR6BxI5DZoIA1tcKHtdO5smjLWNSKhXTsKWee2aNkZJkNIW\nTDHSaTMOxVUEzpx84xClf561BTiTgzQy2MULpg3AK0Cv9l0+Yrvz\n-----END RSA PRIVATE KEY-----`\n\n\tcert, err := tls.X509KeyPair([]byte(certPEM), []byte(keyPEM))\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to configure TLS certificate: %v\", err)\n\t}\n\n\treturn cert\n}", "func LoadPrivateCert(bytesCert []byte, keyBytes []byte) (*FullCert, error) {\n\tcert, err := x509.ParseCertificate(bytesCert)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpriv, err := x509.ParsePKCS1PrivateKey(keyBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &FullCert{\n\t\tCert: cert,\n\t\tKey: priv,\n\t\tDerBytes: bytesCert,\n\t}, nil\n}", "func certificate(authOpts *AuthOptions) (cert *tls.Certificate, err error) {\n\tvar c tls.Certificate\n\tswitch {\n\tcase authOpts.pemFile != \"\":\n\t\tc, err = apns.LoadPemFile(authOpts.pemFile)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tcert = &c\n\n\tcase authOpts.cerFile != \"\" && authOpts.keyFile != \"\":\n\t\tc, err = tls.LoadX509KeyPair(authOpts.cerFile, authOpts.keyFile)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tcert = &c\n\n\tdefault:\n\t\tcert, err = nil, nil\n\t}\n\treturn\n}", "func init() {\n\ttlsCert = `\n-----BEGIN CERTIFICATE-----\nMIIDUzCCAtmgAwIBAgIJAKTf/aVGhWkYMAkGByqGSM49BAEwgZExCzAJBgNVBAYT\nAlVTMREwDwYDVQQIEwhOZXcgWW9yazERMA8GA1UEBxMITmV3IFlvcmsxFzAVBgNV\nBAoTDkhvb2tsaWZ0LCBJbmMuMRQwEgYDVQQLEwtFbmdpbmVlcmluZzEKMAgGA1UE\nAxQBKjEhMB8GCSqGSIb3DQEJARYSY2FtaWxvQGhvb2tsaWZ0LmlvMCAXDTE2MTEx\nNDE0NTgwNFoYDzIxMTUwNjA5MTQ1ODA0WjCBkTELMAkGA1UEBhMCVVMxETAPBgNV\nBAgTCE5ldyBZb3JrMREwDwYDVQQHEwhOZXcgWW9yazEXMBUGA1UEChMOSG9va2xp\nZnQsIEluYy4xFDASBgNVBAsTC0VuZ2luZWVyaW5nMQowCAYDVQQDFAEqMSEwHwYJ\nKoZIhvcNAQkBFhJjYW1pbG9AaG9va2xpZnQuaW8wdjAQBgcqhkjOPQIBBgUrgQQA\nIgNiAASH3bmfhqPNDE2YdeBG15Yl13GVWlex0QDCh85koZ3kbKMGdDBqgb5gqgwZ\nF1rCCpjff+o3D3JaAMYosACOyHn8lnJOcpryqUkwCklxSQqleLJM4EGSitMm8119\ntzYhaCajgfkwgfYwHQYDVR0OBBYEFMNqnVpZOU6jIqWaiHr7AnMXpBwWMIHGBgNV\nHSMEgb4wgbuAFMNqnVpZOU6jIqWaiHr7AnMXpBwWoYGXpIGUMIGRMQswCQYDVQQG\nEwJVUzERMA8GA1UECBMITmV3IFlvcmsxETAPBgNVBAcTCE5ldyBZb3JrMRcwFQYD\nVQQKEw5Ib29rbGlmdCwgSW5jLjEUMBIGA1UECxMLRW5naW5lZXJpbmcxCjAIBgNV\nBAMUASoxITAfBgkqhkiG9w0BCQEWEmNhbWlsb0Bob29rbGlmdC5pb4IJAKTf/aVG\nhWkYMAwGA1UdEwQFMAMBAf8wCQYHKoZIzj0EAQNpADBmAjEAnvDrqcg7Sl2wK/bH\n+98IMGMiYdT1FpSqCT3YyVQeCPELlxmnXbzNesY/R+l8oY9bAjEAhya4BL+ingli\no9FuJqdUS5o9Rgii55nFhNdzQvT/p/ANGHBCfQyUNtAjPp92KvXC\n-----END CERTIFICATE-----\n`\n}", "func (c *config) loadCertificate() {\n\tif c.CertFile != \"\" && c.KeyFile != \"\" {\n\t\tcert, err := tls.LoadX509KeyPair(c.CertFile, c.KeyFile)\n\t\tif err != nil {\n\t\t\tlog.Println(\"Error loading TLS certificate:\", err)\n\t\t\treturn\n\t\t}\n\t\tc.TLSCert = cert\n\t\tparsed, err := x509.ParseCertificate(cert.Certificate[0])\n\t\tif err != nil {\n\t\t\tlog.Println(\"Error parsing X509 certificate:\", err)\n\t\t\treturn\n\t\t}\n\t\tc.ParsedTLSCert = parsed\n\t\tc.TLSReady = true\n\n\t\tc.ServeMux.HandleFunc(\"/cert.der\", func(w http.ResponseWriter, r *http.Request) {\n\t\t\ttlsCert := c.TLSCert\n\t\t\tw.Header().Set(\"Content-Type\", \"application/x-x509-ca-cert\")\n\t\t\tw.Write(tlsCert.Certificate[len(tlsCert.Certificate)-1])\n\t\t})\n\t}\n}", "func newSelfSignedCertificate() (tls.Certificate, error) {\n\tprivKey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\n\tprivPKCS1DERBytes := x509.MarshalPKCS1PrivateKey(privKey)\n\tprivPKCS1PEMBytes := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: privPKCS1DERBytes})\n\n\ttemplate := &x509.Certificate{\n\t\tSerialNumber: big.NewInt(1),\n\t\tNotBefore: time.Now().Add(-30 * time.Second),\n\t\tNotAfter: time.Now().Add(365 * 24 * time.Hour),\n\t}\n\tcertDERBytes, err := x509.CreateCertificate(rand.Reader, template, template, &privKey.PublicKey, privKey)\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\n\tcert, err := x509.ParseCertificate(certDERBytes)\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\n\tcertPEMBytes := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: cert.Raw})\n\treturn tls.X509KeyPair(certPEMBytes, privPKCS1PEMBytes)\n}", "func toTLSSecret(key *rsa.PrivateKey, cert *x509.Certificate, name string) *v1.Secret {\n\treturn &v1.Secret{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: name,\n\t\t},\n\t\tData: map[string][]byte{\n\t\t\tv1.TLSPrivateKeyKey: encodePrivateKeyPEM(key),\n\t\t\tv1.TLSCertKey: encodeCertificatePEM(cert),\n\t\t},\n\t\tType: v1.SecretTypeTLS,\n\t}\n}", "func toTLSSecret(key *rsa.PrivateKey, cert *x509.Certificate, name string) *v1.Secret {\n\treturn &v1.Secret{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: name,\n\t\t},\n\t\tData: map[string][]byte{\n\t\t\tv1.TLSPrivateKeyKey: EncodePrivateKeyPEM(key),\n\t\t\tv1.TLSCertKey: EncodeCertificatePEM(cert),\n\t\t},\n\t\tType: v1.SecretTypeTLS,\n\t}\n}", "func newSecret(name string) corev1.Secret {\n\tconst (\n\t\t// defaultCert is a PEM-encoded certificate.\n\t\tdefaultCert = `-----BEGIN CERTIFICATE-----\nMIIDIjCCAgqgAwIBAgIBBjANBgkqhkiG9w0BAQUFADCBoTELMAkGA1UEBhMCVVMx\nCzAJBgNVBAgMAlNDMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0Rl\nZmF1bHQgQ29tcGFueSBMdGQxEDAOBgNVBAsMB1Rlc3QgQ0ExGjAYBgNVBAMMEXd3\ndy5leGFtcGxlY2EuY29tMSIwIAYJKoZIhvcNAQkBFhNleGFtcGxlQGV4YW1wbGUu\nY29tMB4XDTE2MDExMzE5NDA1N1oXDTI2MDExMDE5NDA1N1owfDEYMBYGA1UEAxMP\nd3d3LmV4YW1wbGUuY29tMQswCQYDVQQIEwJTQzELMAkGA1UEBhMCVVMxIjAgBgkq\nhkiG9w0BCQEWE2V4YW1wbGVAZXhhbXBsZS5jb20xEDAOBgNVBAoTB0V4YW1wbGUx\nEDAOBgNVBAsTB0V4YW1wbGUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM0B\nu++oHV1wcphWRbMLUft8fD7nPG95xs7UeLPphFZuShIhhdAQMpvcsFeg+Bg9PWCu\nv3jZljmk06MLvuWLfwjYfo9q/V+qOZVfTVHHbaIO5RTXJMC2Nn+ACF0kHBmNcbth\nOOgF8L854a/P8tjm1iPR++vHnkex0NH7lyosVc/vAgMBAAGjDTALMAkGA1UdEwQC\nMAAwDQYJKoZIhvcNAQEFBQADggEBADjFm5AlNH3DNT1Uzx3m66fFjqqrHEs25geT\nyA3rvBuynflEHQO95M/8wCxYVyuAx4Z1i4YDC7tx0vmOn/2GXZHY9MAj1I8KCnwt\nJik7E2r1/yY0MrkawljOAxisXs821kJ+Z/51Ud2t5uhGxS6hJypbGspMS7OtBbw7\n8oThK7cWtCXOldNF6ruqY1agWnhRdAq5qSMnuBXuicOP0Kbtx51a1ugE3SnvQenJ\nnZxdtYUXvEsHZC/6bAtTfNh+/SwgxQJuL2ZM+VG3X2JIKY8xTDui+il7uTh422lq\nwED8uwKl+bOj6xFDyw4gWoBxRobsbFaME8pkykP1+GnKDberyAM=\n-----END CERTIFICATE-----\n`\n\t\t// defaultKey is a PEM-encoded private key.\n\t\tdefaultKey = `-----BEGIN RSA PRIVATE KEY-----\nMIICWwIBAAKBgQDNAbvvqB1dcHKYVkWzC1H7fHw+5zxvecbO1Hiz6YRWbkoSIYXQ\nEDKb3LBXoPgYPT1grr942ZY5pNOjC77li38I2H6Pav1fqjmVX01Rx22iDuUU1yTA\ntjZ/gAhdJBwZjXG7YTjoBfC/OeGvz/LY5tYj0fvrx55HsdDR+5cqLFXP7wIDAQAB\nAoGAfE7P4Zsj6zOzGPI/Izj7Bi5OvGnEeKfzyBiH9Dflue74VRQkqqwXs/DWsNv3\nc+M2Y3iyu5ncgKmUduo5X8D9To2ymPRLGuCdfZTxnBMpIDKSJ0FTwVPkr6cYyyBk\n5VCbc470pQPxTAAtl2eaO1sIrzR4PcgwqrSOjwBQQocsGAECQQD8QOra/mZmxPbt\nbRh8U5lhgZmirImk5RY3QMPI/1/f4k+fyjkU5FRq/yqSyin75aSAXg8IupAFRgyZ\nW7BT6zwBAkEA0A0ugAGorpCbuTa25SsIOMxkEzCiKYvh0O+GfGkzWG4lkSeJqGME\nkeuJGlXrZNKNoCYLluAKLPmnd72X2yTL7wJARM0kAXUP0wn324w8+HQIyqqBj/gF\nVt9Q7uMQQ3s72CGu3ANZDFS2nbRZFU5koxrggk6lRRk1fOq9NvrmHg10AQJABOea\npgfj+yGLmkUw8JwgGH6xCUbHO+WBUFSlPf+Y50fJeO+OrjqPXAVKeSV3ZCwWjKT4\n9viXJNJJ4WfF0bO/XwJAOMB1wQnEOSZ4v+laMwNtMq6hre5K8woqteXICoGcIWe8\nu3YLAbyW/lHhOCiZu2iAI8AbmXem9lW6Tr7p/97s0w==\n-----END RSA PRIVATE KEY-----\n`\n\t)\n\treturn corev1.Secret{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: name,\n\t\t},\n\t\tData: map[string][]byte{\n\t\t\t\"tls.crt\": []byte(defaultCert),\n\t\t\t\"tls.key\": []byte(defaultKey),\n\t\t},\n\t}\n}", "func fakeCertificate(sni string) (cert tls.Certificate, err error) {\n\tconf := getConfig()\n\tserial, err := rand.Int(rand.Reader, big.NewInt(1<<62))\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\ty, m, d := time.Now().Date()\n\n\ttemplate := &x509.Certificate{\n\t\tSerialNumber: serial,\n\t\tSubject: pkix.Name{CommonName: sni},\n\t\tNotBefore: time.Date(y, m, d, 0, 0, 0, 0, time.Local),\n\t\tNotAfter: time.Date(y, m+1, d, 0, 0, 0, 0, time.Local),\n\t\tKeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,\n\t\tDNSNames: []string{sni},\n\t\tSignatureAlgorithm: x509.UnknownSignatureAlgorithm,\n\t}\n\n\tnewCertBytes, err := x509.CreateCertificate(rand.Reader, template, conf.ParsedTLSCert, conf.ParsedTLSCert.PublicKey, conf.TLSCert.PrivateKey)\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\n\tnewCert := tls.Certificate{\n\t\tCertificate: [][]byte{newCertBytes},\n\t\tPrivateKey: conf.TLSCert.PrivateKey,\n\t}\n\n\tnewCert.Certificate = append(newCert.Certificate, conf.TLSCert.Certificate...)\n\treturn newCert, nil\n}", "func (l TLSCertificateLoader) Get(ctx context.Context) (*tls.Certificate, error) {\n\tsigner, err := l.SignerGen.Generate(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn toTLSCertificate(signer), nil\n}", "func generateSelfSignedCert() (keyPath string, certPath string) {\n\ttempdir, err := ioutil.TempDir(\"\", \"*\")\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to create tempdir for certs: %s\", err))\n\t}\n\n\tprivKey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\tpanic(\"Unable to create self-signed cert\")\n\t}\n\tb := x509.MarshalPKCS1PrivateKey(privKey)\n\tkeyBlock := pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: b}\n\n\tkeyPath = tempdir + \"/key.pem\"\n\tfile, err := os.Create(keyPath)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to create private key file: %s\", err))\n\t}\n\n\tif err := pem.Encode(file, &keyBlock); err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to encode private key: %s\", err))\n\t}\n\n\tfile.Close()\n\n\ttemplate := x509.Certificate{\n\t\tSerialNumber: big.NewInt(1),\n\t\tSubject: pkix.Name{\n\t\t\tOrganization: []string{\"Acme Co\"},\n\t\t},\n\t\tNotBefore: time.Now(),\n\t\tNotAfter: time.Now().Add(time.Hour * 24 * 180),\n\n\t\tKeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,\n\t\tBasicConstraintsValid: true,\n\t}\n\n\tcertBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Failed to create certificate: %s\", err))\n\t}\n\n\tcertPath = tempdir + \"/cert.pem\"\n\tfile, err = os.Create(certPath)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to create cert file: %s\", err))\n\t}\n\n\tif err := pem.Encode(file, &pem.Block{Type: \"CERTIFICATE\", Bytes: certBytes}); err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to encode cert: %s\", err))\n\t}\n\tfile.Close()\n\treturn\n}", "func (s SecretForTLSGeneratorV1) validate() error {\n\t// TODO: This is not strictly necessary. We can generate a self signed cert\n\t// if no key/cert is given. The only requiredment is that we either get both\n\t// or none. See test/e2e/ingress_utils for self signed cert generation.\n\tif len(s.Key) == 0 {\n\t\treturn fmt.Errorf(\"key must be specified.\")\n\t}\n\tif len(s.Cert) == 0 {\n\t\treturn fmt.Errorf(\"certificate must be specified.\")\n\t}\n\tif _, err := tls.LoadX509KeyPair(s.Cert, s.Key); err != nil {\n\t\treturn fmt.Errorf(\"failed to load key pair %v\", err)\n\t}\n\t// TODO: Add more validation.\n\t// 1. If the certificate contains intermediates, it is a valid chain.\n\t// 2. Format etc.\n\treturn nil\n}", "func createCertsSecret(\n\townerReference metav1.OwnerReference,\n\tsecretName string,\n\tserviceName string,\n\tnamespace string,\n) (*v1.Secret, error) {\n\n\t// Create a signing certificate\n\tcaKeyPair, err := triple.NewCA(fmt.Sprintf(\"%s-ca\", serviceName))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create root-ca: %v\", err)\n\t}\n\n\t// Create app certs signed through the certificate created above\n\tapiServerKeyPair, err := triple.NewServerKeyPair(\n\t\tcaKeyPair,\n\t\tstrings.Join([]string{serviceName, namespace, \"svc\"}, \".\"),\n\t\tserviceName,\n\t\tnamespace,\n\t\t[]string{},\n\t\t[]string{},\n\t)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create server key pair: %v\", err)\n\t}\n\n\t// create an opaque secret resource with certificate(s) created above\n\tsecret := &v1.Secret{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"Secret\",\n\t\t\tAPIVersion: \"v1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: secretName,\n\t\t\tNamespace: namespace,\n\t\t\tOwnerReferences: []metav1.OwnerReference{ownerReference},\n\t\t},\n\t\tType: v1.SecretTypeOpaque,\n\t\tData: map[string][]byte{\n\t\t\tappCrt: cert.EncodeCertPEM(apiServerKeyPair.Cert),\n\t\t\tappKey: cert.EncodePrivateKeyPEM(apiServerKeyPair.Key),\n\t\t\trootCrt: cert.EncodeCertPEM(caKeyPair.Cert),\n\t\t},\n\t}\n\n\tresult := shared.Create(context.TODO(), secret)\n\n\treturn secret, result\n}", "func initCertificate() {\n\tvar derBytes []byte\n\tvar err error\n\tif config.IsRootNode() {\n\t\tlog.Print(\"This is a root node, generating self-signed certificate\")\n\t\tderBytes, err = certificateForPublicKey(\"\", &privateKey.PublicKey)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Unable to generate self-signed certificate: %s\", err)\n\t\t}\n\t} else {\n\t\tlog.Print(\"We have a parent, requesting a certificate from parent\")\n\t\tpublicKeyBytes, err := x509.MarshalPKIXPublicKey(&privateKey.PublicKey)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Unable to get DER encoded bytes for public key: %s\", err)\n\t\t}\n\t\t_, err = requestCertFromParent(publicKeyBytes)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Unable to request certificate from parent: %s\", err)\n\t\t}\n\t}\n\n\tsaveCertificate(derBytes)\n\n\t// Notify anyone waiting for a cert\n\tfor _, waitingForCert := range waitingForCerts {\n\t\twaitingForCert <- certificate\n\t}\n}", "func (k *K8sutil) CreateCertsSecret(namespace, clusterName, certsDir string) error {\n\t// Read certs from disk\n\tnodeKeyStore, err := ioutil.ReadFile(fmt.Sprintf(\"%s/node-keystore.jks\", certsDir))\n\tif err != nil {\n\t\tlogrus.Error(\"Could not read certs:\", err)\n\t\treturn err\n\t}\n\n\tsgadminKeyStore, err := ioutil.ReadFile(fmt.Sprintf(\"%s/sgadmin-keystore.jks\", certsDir))\n\tif err != nil {\n\t\tlogrus.Error(\"Could not read certs:\", err)\n\t\treturn err\n\t}\n\n\t//TODO return err\n\ttrustStore, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/truststore.jks\", certsDir))\n\tca, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/ca.pem\", certsDir))\n\tcaKey, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/ca-key.pem\", certsDir))\n\tnode, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/node.pem\", certsDir))\n\tnodeKey, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/node-key.pem\", certsDir))\n\tnodeKeyPkcs8, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/node-key.pkcs8.pem\", certsDir))\n\tsgadmin, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/sgadmin.pem\", certsDir))\n\tsgadminKey, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/sgadmin-key.pem\", certsDir))\n\tkibanaKey, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/kibana-key.pem\", certsDir))\n\tkibana, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/kibana.pem\", certsDir))\n\tcerebroKey, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/cerebro-key.pem\", certsDir))\n\tcerebro, _ := ioutil.ReadFile(fmt.Sprintf(\"%s/cerebro.pem\", certsDir))\n\tsecret := &v1.Secret{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: fmt.Sprintf(\"%s-%s\", secretName, clusterName),\n\t\t},\n\t\tData: map[string][]byte{\n\t\t\t\"node-keystore.jks\": nodeKeyStore,\n\t\t\t\"sgadmin-keystore.jks\": sgadminKeyStore,\n\t\t\t\"truststore.jks\": trustStore,\n\t\t\t\"ca.pem\": ca,\n\t\t\t\"ca-key.pem\": caKey,\n\t\t\t\"node.pem\": node,\n\t\t\t\"node-key.pem\": nodeKey,\n\t\t\t\"node-key.pkcs8.pem\": nodeKeyPkcs8,\n\t\t\t\"sgadmin.pem\": sgadmin,\n\t\t\t\"sgadmin-key.pem\": sgadminKey,\n\t\t\t\"kibana-key.pem\": kibanaKey,\n\t\t\t\"kibana.pem\": kibana,\n\t\t\t\"cerebro-key.pem\": cerebroKey,\n\t\t\t\"cerebro.pem\": cerebro,\n\t\t},\n\t}\n\n\tif _, err = k.Kclient.CoreV1().Secrets(namespace).Create(secret); err != nil {\n\t\tlogrus.Error(\"Could not create elastic certs secret: \", err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func GenerateSecretForCerts(name string, namespace string) (*v1.Secret, error) {\n\tsecretTemplate, err := template.New(\"\").Funcs(sprig.TxtFuncMap()).Parse(certsSecretTemplate)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuffer := bytes.NewBuffer(nil)\n\n\terr = secretTemplate.Execute(buffer, map[string]string{\"cn\": name, \"externalDNS\": name + \".\" + namespace})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar secret v1.Secret\n\n\terr = yaml.Unmarshal(buffer.Bytes(), &secret)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsecret.Name = name + \"-tls\"\n\tsecret.Namespace = namespace\n\n\treturn &secret, nil\n}", "func (sc *SecretCache) GenerateSecret(ctx context.Context, proxyID, resourceName, token string) (*model.SecretItem, error) {\n\tvar ns *model.SecretItem\n\tkey := ConnKey{\n\t\tProxyID: proxyID,\n\t\tResourceName: resourceName,\n\t}\n\n\tif resourceName != RootCertReqResourceName {\n\t\t// Request for normal key/cert pair.\n\t\tns, err := sc.generateSecret(ctx, token, resourceName, time.Now())\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Failed to generate secret for proxy %q: %v\", proxyID, err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsc.secrets.Store(key, *ns)\n\t\treturn ns, nil\n\t}\n\n\t// If request is for root certificate,\n\t// retry since rootCert may be empty until there is CSR response returned from CA.\n\tif sc.rootCert == nil {\n\t\twait := retryWaitDuration\n\t\tretryNum := 0\n\t\tfor ; retryNum < maxRetryNum; retryNum++ {\n\t\t\ttime.Sleep(retryWaitDuration)\n\t\t\tif sc.rootCert != nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\twait *= 2\n\t\t}\n\t}\n\n\tif sc.rootCert == nil {\n\t\tlog.Errorf(\"Failed to get root cert for proxy %q\", proxyID)\n\t\treturn nil, errors.New(\"faied to get root cert\")\n\n\t}\n\n\tt := time.Now()\n\tns = &model.SecretItem{\n\t\tResourceName: resourceName,\n\t\tRootCert: sc.rootCert,\n\t\tToken: token,\n\t\tCreatedTime: t,\n\t\tVersion: t.String(),\n\t}\n\tsc.secrets.Store(key, *ns)\n\treturn ns, nil\n}", "func (l ListenConfig) getCertificate() tlsutils.TlsCert {\n\tpub, _ := ioutil.ReadFile(l.certFile)\n\n\tpriv, _ := ioutil.ReadFile(l.certKey)\n\n\treturn tlsutils.TlsCert{\n\t\tPublicKey: string(pub),\n\t\tPrivateKey: string(priv),\n\t}\n}", "func (kv *AzureKeyVault) GetCertificate(ctx context.Context, certName string) (*tls.Certificate, error) {\n\tif !kv.authenticated {\n\t\treturn nil, errors.New(\"Not Authorized - invoke AuthorizeFromEnvironment() first\")\n\t}\n\n\t// make sure a cert name is provided, otherwise we risk returning the wrong certificate\n\tif strings.Trim(certName, \" \") == \"\" {\n\t\treturn nil, errors.New(\"Certificate name not provided\")\n\t}\n\n\t// get version id for current version of certificate\n\tcertVersion, err := kv.getLatestCertVersion(ctx, certName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Fetch key from secret in Azure Key Vault.\n\tsecBundle, err := kv.client.GetSecret(ctx, kv.vaultBaseURL, certName, certVersion)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error fetching secret: %v\", err)\n\t}\n\n\t// Decode string to byte slice\n\tpfxBytes, err := base64.StdEncoding.DecodeString(*secBundle.Value)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Unable to decode keyvault.SecretBundle.Value: %v\", err)\n\t}\n\n\t// Using ToPEM, because some of our PFX files contain multiple certs (cert chain).\n\t// Decode throws an error if there are multiple certs.\n\tpemBlocks, err := pkcs12.ToPEM(pfxBytes, \"\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error converting PFX contents to PEM blocks: %v\", err)\n\t}\n\n\t// A PFX can contain more than one cert and we need to account for that here.\n\tcerts := &azureKeyVaultCert{}\n\tfor i, v := range pemBlocks {\n\t\tif strings.Contains(v.Type, \"KEY\") == true {\n\t\t\tvar keyPEM bytes.Buffer\n\t\t\terr = pem.Encode(&keyPEM, pemBlocks[i])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Error encoding key pem block: %v\", err)\n\t\t\t}\n\t\t\tcerts.key = keyPEM.Bytes()\n\t\t}\n\n\t\tif strings.Contains(v.Type, \"CERTIFICATE\") == true {\n\t\t\tvar certPEM bytes.Buffer\n\t\t\terr = pem.Encode(&certPEM, pemBlocks[1])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Error encoding certificate pem block: %v\", err)\n\t\t\t}\n\n\t\t\tif certs.cert == nil {\n\t\t\t\tcerts.cert = certPEM.Bytes()\n\t\t\t} else {\n\t\t\t\tcerts.cert = append(certs.cert, certPEM.Bytes()...)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Convert to x509 certificate\n\tcert, err := tls.X509KeyPair(certs.cert, certs.key)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error creating X509 Key Pair: %v\", err)\n\t}\n\n\treturn &cert, nil\n}", "func (c *client) storeCertInSecret(cert certificate.Certificater, secret corev1.SecretReference) error {\n\tsecretData := map[string][]byte{\n\t\t\"ca.crt\": cert.GetIssuingCA(),\n\t\t\"tls.crt\": cert.GetCertificateChain(),\n\t\t\"tls.key\": cert.GetPrivateKey(),\n\t}\n\n\tsec := &corev1.Secret{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: secret.Name,\n\t\t\tNamespace: secret.Namespace,\n\t\t},\n\t\tType: corev1.SecretTypeTLS,\n\t\tData: secretData,\n\t}\n\n\t_, err := c.kubeClient.CoreV1().Secrets(secret.Namespace).Create(context.Background(), sec, metav1.CreateOptions{})\n\tif apierrors.IsAlreadyExists(err) {\n\t\t_, err = c.kubeClient.CoreV1().Secrets(secret.Namespace).Update(context.Background(), sec, metav1.UpdateOptions{})\n\t}\n\treturn err\n}", "func LoadCertificate(certBytes []byte) (*tls.Certificate, error) {\n\tvar certificate tls.Certificate\n\n\tfor {\n\t\tblock, rest := pem.Decode(certBytes)\n\t\tif block == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif block.Type != \"CERTIFICATE\" {\n\t\t\treturn nil, errors.New(\"block is not a certificate, unable to load certificates\")\n\t\t}\n\n\t\tcertificate.Certificate = append(certificate.Certificate, block.Bytes)\n\t\tcertBytes = rest\n\t}\n\n\tif len(certificate.Certificate) == 0 {\n\t\treturn nil, errors.New(\"no certificate found, unable to load certificates\")\n\t}\n\n\treturn &certificate, nil\n}", "func GenerateCert(ethpriv *ecdsa.PrivateKey, validPeriod time.Duration) (cert []byte, key []byte, err error) {\n\tvar issuerCommonName = new(bytes.Buffer)\n\t// x509 Certificate signed with an randomly generated RSA key\n\t// Certificate contains signature of ecdsa publick with ethprivate key\n\tpriv, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tethPubKey := btcec.PublicKey(ethpriv.PublicKey)\n\tbase32SerializedPubETHKey := base32.StdEncoding.EncodeToString(ethPubKey.SerializeCompressed())\n\tissuerCommonName.WriteString(base32SerializedPubETHKey)\n\tissuerCommonName.WriteByte('@')\n\n\tserializedPubKey, err := x509.MarshalPKIXPublicKey(priv.Public())\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\t// Issuer must be signed with ethkey\n\tvar prv = btcec.PrivateKey(*ethpriv)\n\tsignature, err := prv.Sign(chainhash.DoubleHashB(serializedPubKey))\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to sign public key: %v\", err)\n\t}\n\tissuerCommonName.WriteString(base32.StdEncoding.EncodeToString(signature.Serialize()))\n\n\tdnsName := PubKeyToAddr(ethpriv.PublicKey)\n\ttemplate := &x509.Certificate{\n\t\tSerialNumber: big.NewInt(100),\n\t\tSubject: pkix.Name{\n\t\t\tCommonName: issuerCommonName.String(),\n\t\t},\n\t\tNotBefore: time.Now().Add(-time.Hour * 1),\n\t\tNotAfter: time.Now().Add(validPeriod),\n\t\tDNSNames: []string{dnsName.Hex()},\n\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},\n\t}\n\tcertDER, err := x509.CreateCertificate(rand.Reader, template, template, priv.Public(), priv)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\t// PEM encoded cert and key to load via tls.X509KeyPair\n\tcert = pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\tkey = pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(priv)})\n\treturn cert, key, err\n}", "func GetTLSSecret(secret map[string][]byte) (*TLSConfig, error) {\n\tif len(secret) == 0 {\n\t\treturn nil, fmt.Errorf(\"missing configuration\")\n\t}\n\n\t//Convert byte to a string\n\tconfig := &TLSConfig{\n\t\tTLSCertificate: string(secret[tlsConfigKey]),\n\t}\n\n\tif config.TLSCertificate == \"\" {\n\t\treturn nil, fmt.Errorf(\"tls certificate missing from secret\")\n\t}\n\n\treturn config, nil\n}", "func (am *admissionManager) generateCerts(create bool) (\n\tserverCertificate, serverPrivateKey, caCertificate []byte,\n\terr error) {\n\tvar caPrivateKey []byte\n\tcaPrivateKey, err = utils.SetUpCaKey()\n\tif err != nil {\n\t\tklog.Errorf(\"set up ca key failed %v\", err)\n\t\treturn nil, nil, nil, err\n\t}\n\tcaCertificate, err = utils.SetUpCaCert(webhookconstants.ComponentName, caPrivateKey)\n\tif err != nil {\n\t\tklog.Errorf(\"set up ca cert failed %v\", err)\n\t\treturn nil, nil, nil, err\n\t}\n\tnamespace := utils.GetCurrentNamespace()\n\tdomains, ips := subjectAltNames(namespace, am.externalService)\n\tserverCertificate, serverPrivateKey, err = utils.SetUpSignedCertAndKey(domains, ips,\n\t\twebhookconstants.ComponentName,\n\t\tcaPrivateKey, caCertificate, []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth})\n\tif err != nil {\n\t\tklog.Errorf(\"set up server cert error %v\", err)\n\t\treturn nil, nil, nil, err\n\t}\n\tif create {\n\t\t// try to create a new secret to save certificate and privateKey and ca certificate.\n\t\t_, err = am.kubeClient.CoreV1().Secrets(namespace).Create(context.Background(),\n\t\t\t&corev1.Secret{\n\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\tName: certsSecretName,\n\t\t\t\t\tNamespace: namespace,\n\t\t\t\t},\n\t\t\t\tData: map[string][]byte{\n\t\t\t\t\tserverCert: serverCertificate,\n\t\t\t\t\tserverKey: serverPrivateKey,\n\t\t\t\t\tcaCert: caCertificate,\n\t\t\t\t},\n\t\t\t}, metav1.CreateOptions{})\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"create new certificate secret error %v\", err)\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t} else {\n\t\t// try to update an old secret to save certificate and privateKey and ca certificate.\n\t\tif err = utils.UpdateSecret(am.kubeClient, namespace, certsSecretName,\n\t\t\tfunc(secret *corev1.Secret) {\n\t\t\t\tsecret.Data = map[string][]byte{\n\t\t\t\t\tserverCert: serverCertificate,\n\t\t\t\t\tserverKey: serverPrivateKey,\n\t\t\t\t\tcaCert: caCertificate,\n\t\t\t\t}\n\t\t\t}); err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t}\n\treturn caCertificate, serverCertificate, serverPrivateKey, nil\n}", "func loadParentCert() {\n\tif certificateData, err := ioutil.ReadFile(parentCertFile); err != nil {\n\t\tlog.Fatal(\"Unable to read parent certificate file from disk\")\n\t} else {\n\t\tif TrustedParents.AppendCertsFromPEM(certificateData) {\n\t\t\tlog.Print(\"Added trusted parent cert\")\n\t\t} else {\n\t\t\tlog.Fatal(\"Unable to add trusted parent cert\")\n\t\t}\n\t}\n}", "func (acm *AcmeFS) GetCertificate(email string) tlsfs.CertificateFunc {\n\treturn func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {\n\t\thname := hello.ServerName\n\t\tif hname == \"\" {\n\t\t\treturn nil, errors.New(\"acme/acmefs: missing server name\")\n\t\t}\n\n\t\t// if the requests is for a acme temporary certificate then we just need\n\t\t// to check the cache and return that one instead.\n\t\tif strings.HasSuffix(hname, \".acme.invalid\") {\n\t\t\tif cert, err := acm.config.TLSCertCache.Get(hname); err == nil {\n\t\t\t\treturn &cert, nil\n\t\t\t}\n\n\t\t\tif cert, err := acm.config.TLSCertCache.Get(strings.TrimSuffix(hname, \".acme.invalid\")); err == nil {\n\t\t\t\treturn &cert, nil\n\t\t\t}\n\n\t\t\treturn nil, fmt.Errorf(\"acme/acmefs: no cert for %q\", hname)\n\t\t}\n\n\t\tvar wanted tls.CurveID\n\t\tvar found bool\n\t\tfor _, curves := range []tls.CurveID{tls.CurveP384, tls.CurveP256} {\n\t\t\tfor _, wanted = range hello.SupportedCurves {\n\t\t\t\tif wanted == curves {\n\t\t\t\t\tfound = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif found {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tcurve := tlsfs.ECKey384\n\t\tswitch wanted {\n\t\tcase tls.CurveP256:\n\t\t\tcurve = tlsfs.ECKey256\n\t\tcase tls.CurveP384:\n\t\t\tcurve = tlsfs.ECKey384\n\t\tcase tls.CurveP521:\n\t\t\tcurve = tlsfs.ECKey512\n\t\t}\n\n\t\tvar acct tlsfs.NewDomain\n\t\tacct.Domain = hname\n\t\tacct.Email = email\n\t\tacct.KeyType = curve\n\t\tacct.CommonName = hname\n\n\t\tcert, _, err := acm.Create(acct, tlsfs.AgreeToTOS)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tuser, err := acm.GetUser(cert.User)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tcertbundle, err := certificates.EncodeCertificate(cert.Certificate)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tkeybundle, err := certificates.EncodePrivateKey(user.GetPrivateKey())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tobtained, err := tls.X509KeyPair(certbundle, keybundle)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn &obtained, nil\n\t}\n\n}", "func newTLSSecret(vr *api.VaultService, caKey *rsa.PrivateKey, caCrt *x509.Certificate, commonName, secretName string,\n\taddrs []string, fieldMap map[string]string) (*v1.Secret, error) {\n\ttc := tls.CertConfig{\n\t\tCommonName: commonName,\n\t\tOrganization: orgForTLSCert,\n\t\tAltNames: tls.NewAltNames(addrs),\n\t}\n\tkey, crt, err := newKeyAndCert(caCrt, caKey, tc)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"new TLS secret failed: %v\", err)\n\t}\n\tsecret := &v1.Secret{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"Secret\",\n\t\t\tAPIVersion: \"v1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: secretName,\n\t\t\tNamespace: vr.Namespace,\n\t\t\tLabels: labelsForVault(vr.Name),\n\t\t},\n\t\tData: map[string][]byte{\n\t\t\tfieldMap[\"key\"]: tls.EncodePrivateKeyPEM(key),\n\t\t\tfieldMap[\"cert\"]: tls.EncodeCertificatePEM(crt),\n\t\t\tfieldMap[\"ca\"]: tls.EncodeCertificatePEM(caCrt),\n\t\t},\n\t}\n\treturn secret, nil\n}", "func GenCertSelfSigned(template x509.Certificate) ([]byte, []byte, error) {\n\tpriv, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tderBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// Generate cert\n\tcertBuf := bytes.Buffer{}\n\terr = pem.Encode(&certBuf, &pem.Block{Type: \"CERTIFICATE\", Bytes: derBytes})\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// Generate key\n\tkeyBuf := bytes.Buffer{}\n\tpem.Encode(&keyBuf, &pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(priv)})\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn certBuf.Bytes(), keyBuf.Bytes(), nil\n}", "func LoadKeyAndCertificate(keyBytes []byte, certBytes []byte) (*tls.Certificate, error) {\n\tcertificate, err := LoadCertificate(certBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkey, err := LoadKey(keyBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcertificate.PrivateKey = key\n\treturn certificate, nil\n}", "func generateCertificate(d *schema.ResourceData, m interface{}, appID string) (*okta.JsonWebKey, error) {\n\trequestExecutor := getRequestExecutor(m)\n\tyears := d.Get(\"key_years_valid\").(int)\n\turl := fmt.Sprintf(\"/api/v1/apps/%s/credentials/keys/generate?validityYears=%d\", appID, years)\n\treq, err := requestExecutor.NewRequest(\"POST\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar key *okta.JsonWebKey\n\n\t_, err = requestExecutor.Do(req, &key)\n\n\treturn key, err\n}", "func ExampleELB_SetLoadBalancerListenerSSLCertificate_shared00() {\n\tsvc := elb.New(session.New())\n\tinput := &elb.SetLoadBalancerListenerSSLCertificateInput{\n\t\tLoadBalancerName: aws.String(\"my-load-balancer\"),\n\t\tLoadBalancerPort: aws.Int64(443),\n\t\tSSLCertificateId: aws.String(\"arn:aws:iam::123456789012:server-certificate/new-server-cert\"),\n\t}\n\n\tresult, err := svc.SetLoadBalancerListenerSSLCertificate(input)\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tcase elb.ErrCodeCertificateNotFoundException:\n\t\t\t\tfmt.Println(elb.ErrCodeCertificateNotFoundException, aerr.Error())\n\t\t\tcase elb.ErrCodeAccessPointNotFoundException:\n\t\t\t\tfmt.Println(elb.ErrCodeAccessPointNotFoundException, aerr.Error())\n\t\t\tcase elb.ErrCodeListenerNotFoundException:\n\t\t\t\tfmt.Println(elb.ErrCodeListenerNotFoundException, aerr.Error())\n\t\t\tcase elb.ErrCodeInvalidConfigurationRequestException:\n\t\t\t\tfmt.Println(elb.ErrCodeInvalidConfigurationRequestException, aerr.Error())\n\t\t\tcase elb.ErrCodeUnsupportedProtocolException:\n\t\t\t\tfmt.Println(elb.ErrCodeUnsupportedProtocolException, aerr.Error())\n\t\t\tdefault:\n\t\t\t\tfmt.Println(aerr.Error())\n\t\t\t}\n\t\t} else {\n\t\t\t// Print the error, cast err to awserr.Error to get the Code and\n\t\t\t// Message from an error.\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(result)\n}", "func LoadPrivateCertPEM(bytesCert []byte, keyBytes []byte) (*FullCert, error) {\n\tcertDERBlock, _ := pem.Decode(bytesCert)\n\tif certDERBlock == nil {\n\t\treturn nil, errors.New(\"No certificate data read from PEM\")\n\t}\n\tcert, err := x509.ParseCertificate(certDERBlock.Bytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tkeyBlock, _ := pem.Decode(keyBytes)\n\tif keyBlock == nil {\n\t\treturn nil, errors.New(\"No key data read from PEM\")\n\t}\n\tpriv, err := x509.ParsePKCS1PrivateKey(keyBlock.Bytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &FullCert{\n\t\tCert: cert,\n\t\tKey: priv,\n\t\tDerBytes: certDERBlock.Bytes,\n\t}, nil\n}", "func (c *AdminKubeConfigSignerCertKey) Load(f asset.FileFetcher) (bool, error) {\n\treturn c.loadCertKey(f, \"admin-kubeconfig-signer\")\n}", "func GenerateTrustCertificate(cert *CertInfo, name string) (*api.Certificate, error) {\n\tblock, _ := pem.Decode(cert.PublicKey())\n\tif block == nil {\n\t\treturn nil, fmt.Errorf(\"Failed to decode certificate\")\n\t}\n\n\tfingerprint, err := CertFingerprintStr(string(cert.PublicKey()))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to calculate fingerprint: %w\", err)\n\t}\n\n\tcertificate := base64.StdEncoding.EncodeToString(block.Bytes)\n\tapiCert := api.Certificate{\n\t\tCertificatePut: api.CertificatePut{\n\t\t\tCertificate: certificate,\n\t\t\tName: name,\n\t\t\tType: api.CertificateTypeServer, // Server type for intra-member communication.\n\t\t},\n\t\tFingerprint: fingerprint,\n\t}\n\n\treturn &apiCert, nil\n}", "func (cs *CertStore) LoadCerts() error {\n\tvar err error\n\tif cs.ClientCert1, err = tls.LoadX509KeyPair(testdata.Path(\"client_cert_1.pem\"), testdata.Path(\"client_key_1.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ClientCert2, err = tls.LoadX509KeyPair(testdata.Path(\"client_cert_2.pem\"), testdata.Path(\"client_key_2.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ServerCert1, err = tls.LoadX509KeyPair(testdata.Path(\"server_cert_1.pem\"), testdata.Path(\"server_key_1.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ServerCert2, err = tls.LoadX509KeyPair(testdata.Path(\"server_cert_2.pem\"), testdata.Path(\"server_key_2.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ServerPeer3, err = tls.LoadX509KeyPair(testdata.Path(\"server_cert_3.pem\"), testdata.Path(\"server_key_3.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ServerPeerLocalhost1, err = tls.LoadX509KeyPair(testdata.Path(\"server_cert_localhost_1.pem\"), testdata.Path(\"server_key_localhost_1.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ClientTrust1, err = readTrustCert(testdata.Path(\"client_trust_cert_1.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ClientTrust2, err = readTrustCert(testdata.Path(\"client_trust_cert_2.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ServerTrust1, err = readTrustCert(testdata.Path(\"server_trust_cert_1.pem\")); err != nil {\n\t\treturn err\n\t}\n\tif cs.ServerTrust2, err = readTrustCert(testdata.Path(\"server_trust_cert_2.pem\")); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *Server) getCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {\n\treturn s.certValue.Load().(*tls.Certificate), nil\n}", "func (c *controller) ensureSecretData(ctx context.Context, log logr.Logger, crt *cmapi.Certificate) error {\n\t// Retrieve the Secret which is associated with this Certificate.\n\tsecret, err := c.secretLister.Secrets(crt.Namespace).Get(crt.Spec.SecretName)\n\n\t// Secret doesn't exist so we can't do anything. The Certificate will be\n\t// marked for a re-issuance and the resulting Secret will be evaluated again.\n\tif apierrors.IsNotFound(err) {\n\t\tlog.V(logf.DebugLevel).Info(\"secret not found\", \"error\", err.Error())\n\t\treturn nil\n\t}\n\n\t// This error is transient, return error to be retried on the rate limiting\n\t// queue.\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog = log.WithValues(\"secret\", secret.Name)\n\n\t// If there is no certificate or private key data available at the target\n\t// Secret then exit early. The absense of these keys should cause an issuance\n\t// of the Certificate, so there is no need to run post issuance checks.\n\tif secret.Data == nil ||\n\t\tlen(secret.Data[corev1.TLSCertKey]) == 0 ||\n\t\tlen(secret.Data[corev1.TLSPrivateKeyKey]) == 0 {\n\t\tlog.V(logf.DebugLevel).Info(\"secret doesn't contain both certificate and private key data\",\n\t\t\t\"cert_data_len\", len(secret.Data[corev1.TLSCertKey]), \"key_data_len\", len(secret.Data[corev1.TLSPrivateKeyKey]))\n\t\treturn nil\n\t}\n\n\tdata := internal.SecretData{\n\t\tPrivateKey: secret.Data[corev1.TLSPrivateKeyKey],\n\t\tCertificate: secret.Data[corev1.TLSCertKey],\n\t\tCA: secret.Data[cmmeta.TLSCAKey],\n\t\tCertificateName: secret.Annotations[cmapi.CertificateNameKey],\n\t\tIssuerName: secret.Annotations[cmapi.IssuerNameAnnotationKey],\n\t\tIssuerKind: secret.Annotations[cmapi.IssuerKindAnnotationKey],\n\t\tIssuerGroup: secret.Annotations[cmapi.IssuerGroupAnnotationKey],\n\t}\n\n\t// Check whether the Certificate's Secret has correct output format and\n\t// metadata.\n\treason, message, isViolation := c.postIssuancePolicyChain.Evaluate(policies.Input{\n\t\tCertificate: crt,\n\t\tSecret: secret,\n\t})\n\n\tif isViolation {\n\t\tswitch reason {\n\t\tcase policies.InvalidCertificate, policies.ManagedFieldsParseError:\n\t\t\t//An error here indicates that the managed fields are malformed and the\n\t\t\t//decoder doesn't understand the managed fields on the Secret, or the\n\t\t\t//signed certificate data could not be decoded. There is nothing more the\n\t\t\t//controller can do here, so we exit nil so this controller doesn't end in\n\t\t\t//an infinite loop.\n\t\t\tlog.Error(errors.New(message), \"failed to determine whether the SecretTemplate matches Secret\")\n\t\t\treturn nil\n\t\tdefault:\n\n\t\t\t// Here the Certificate need to be re-reconciled.\n\t\t\tlog.Info(\"applying Secret data\", \"message\", message)\n\t\t\treturn c.secretsUpdateData(ctx, crt, data)\n\t\t}\n\t}\n\n\t// No Secret violations, nothing to do.\n\n\treturn nil\n}", "func selfSignPool(host, port string) (*x509.CertPool, error) {\n\tcertProvided := fileUploaded()\n\tif certProvided {\n\t\tcertPool, err := poolFromFile(host, port)\n\t\treturn certPool, err\n\t}\n\tcertPool, err := poolFromHost(host, port)\n\n\treturn certPool, err\n}", "func GenerateSelfSignedCertificate(host string) (SelfSignedCertificate, error) {\n\n\tprivateKey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn SelfSignedCertificate{}, errors.Wrap(err, \"unable to generate rsa key\")\n\t}\n\ttemplate := x509.Certificate{\n\t\tSerialNumber: big.NewInt(time.Now().Unix()),\n\t\tSubject: pkix.Name{\n\t\t\tCommonName: \"Odo self-signed certificate\",\n\t\t\tOrganization: []string{\"Odo\"},\n\t\t},\n\t\tNotBefore: time.Now(),\n\t\tNotAfter: time.Now().Add(time.Hour * 24 * 365 * 10),\n\t\tKeyUsage: x509.KeyUsageCertSign | x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,\n\t\tBasicConstraintsValid: true,\n\t\tDNSNames: []string{\"*.\" + host},\n\t}\n\n\tcertificateDerEncoding, err := x509.CreateCertificate(rand.Reader, &template, &template, &privateKey.PublicKey, privateKey)\n\tif err != nil {\n\t\treturn SelfSignedCertificate{}, errors.Wrap(err, \"unable to create certificate\")\n\t}\n\tout := &bytes.Buffer{}\n\terr = pem.Encode(out, &pem.Block{Type: \"CERTIFICATE\", Bytes: certificateDerEncoding})\n\tif err != nil {\n\t\treturn SelfSignedCertificate{}, errors.Wrap(err, \"unable to encode certificate\")\n\t}\n\tcertPemEncode := out.String()\n\tcertPemByteArr := []byte(certPemEncode)\n\n\ttlsPrivKeyEncoding := x509.MarshalPKCS1PrivateKey(privateKey)\n\terr = pem.Encode(out, &pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: tlsPrivKeyEncoding})\n\tif err != nil {\n\t\treturn SelfSignedCertificate{}, errors.Wrap(err, \"unable to encode rsa private key\")\n\t}\n\tkeyPemEncode := out.String()\n\tkeyPemByteArr := []byte(keyPemEncode)\n\n\treturn SelfSignedCertificate{CertPem: certPemByteArr, KeyPem: keyPemByteArr}, nil\n}", "func LoadPrivateCertFromFilePEM(certPath, keyPath string) (*FullCert, error) {\n\tcertBytes, err := ioutil.ReadFile(certPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkeyBytes, err := ioutil.ReadFile(keyPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn LoadPrivateCertPEM(certBytes, keyBytes)\n}", "func makeTLSConfig(reloadPeriod time.Duration) (*tls.Config, error) {\n\tcertFile := env(\"ROUTER_METRICS_TLS_CERT_FILE\", \"\")\n\tif len(certFile) == 0 {\n\t\treturn nil, nil\n\t}\n\tkeyFile := env(\"ROUTER_METRICS_TLS_KEY_FILE\", \"\")\n\n\t// Load the initial certificate contents.\n\tcertBytes, err := ioutil.ReadFile(certFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkeyBytes, err := ioutil.ReadFile(keyFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcertificate, err := tls.X509KeyPair(certBytes, keyBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Safely reload the certificate on a fixed period for simplicity.\n\tticker := time.NewTicker(reloadPeriod)\n\tvar lock sync.Mutex\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tlatestCertBytes, err := ioutil.ReadFile(certFile)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error(err, \"failed to read certificate file\", \"cert\", certFile, \"key\", keyFile)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tlatestKeyBytes, err := ioutil.ReadFile(keyFile)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error(err, \"failed to read key file\", \"cert\", certFile, \"key\", keyFile)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif bytes.Equal(latestCertBytes, certBytes) && bytes.Equal(latestKeyBytes, keyBytes) {\n\t\t\t\t\t// Nothing changed, try later.\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\t// Something changed, reload the certificate.\n\t\t\t\tlatest, err := tls.X509KeyPair(latestCertBytes, latestKeyBytes)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error(err, \"failed to reload certificate\", \"cert\", certFile, \"key\", keyFile)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcertBytes = latestCertBytes\n\t\t\t\tkeyBytes = latestKeyBytes\n\n\t\t\t\tlock.Lock()\n\t\t\t\tcertificate = latest\n\t\t\t\tlock.Unlock()\n\n\t\t\t\tlog.V(0).Info(\"reloaded metrics certificate\", \"cert\", certFile, \"key\", keyFile)\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn crypto.SecureTLSConfig(&tls.Config{\n\t\tGetCertificate: func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {\n\t\t\tlock.Lock()\n\t\t\tdefer lock.Unlock()\n\t\t\treturn &certificate, nil\n\t\t},\n\t\tClientAuth: tls.RequestClientCert,\n\t}), nil\n}", "func GenerateSelfSignedCert(host, certPath, keyPath string, alternateIPs []net.IP, alternateDNS []string) error {\n\tpriv, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttemplate := x509.Certificate{\n\t\tSerialNumber: big.NewInt(1),\n\t\tSubject: pkix.Name{\n\t\t\tCommonName: fmt.Sprintf(\"%s@%d\", host, time.Now().Unix()),\n\t\t},\n\t\tNotBefore: time.Now(),\n\t\tNotAfter: time.Now().Add(time.Hour * 24 * 365),\n\n\t\tKeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},\n\t\tBasicConstraintsValid: true,\n\t\tIsCA: true,\n\t}\n\n\tif ip := net.ParseIP(host); ip != nil {\n\t\ttemplate.IPAddresses = append(template.IPAddresses, ip)\n\t} else {\n\t\ttemplate.DNSNames = append(template.DNSNames, host)\n\t}\n\n\ttemplate.IPAddresses = append(template.IPAddresses, alternateIPs...)\n\ttemplate.DNSNames = append(template.DNSNames, alternateDNS...)\n\n\tderBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Generate cert\n\tcertBuffer := bytes.Buffer{}\n\tif err := pem.Encode(&certBuffer, &pem.Block{Type: \"CERTIFICATE\", Bytes: derBytes}); err != nil {\n\t\treturn err\n\t}\n\n\t// Generate key\n\tkeyBuffer := bytes.Buffer{}\n\tif err := pem.Encode(&keyBuffer, &pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(priv)}); err != nil {\n\t\treturn err\n\t}\n\n\t// Write cert\n\tif err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil {\n\t\treturn err\n\t}\n\tif err := ioutil.WriteFile(certPath, certBuffer.Bytes(), os.FileMode(0644)); err != nil {\n\t\treturn err\n\t}\n\n\t// Write key\n\tif err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil {\n\t\treturn err\n\t}\n\tif err := ioutil.WriteFile(keyPath, keyBuffer.Bytes(), os.FileMode(0600)); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func GenerateAndSignCertificate(root *KeyPair, publicKeyFile, privateKeyFile string) error {\n\tcert := &x509.Certificate{\n\t\tSerialNumber: big.NewInt(1658),\n\t\tSubject: pkix.Name{\n\t\t\tOrganization: []string{\"ayada\"},\n\t\t\tCountry: []string{\"US\"},\n\t\t\tProvince: []string{\"California\"},\n\t\t\tLocality: []string{\"San Francisco\"},\n\t\t\tCommonName: \"localhost\",\n\t\t},\n\t\tDNSNames: []string{\"localhost\", \"ayada.dev\"},\n\t\tIPAddresses: []net.IP{net.IPv4(127, 0, 0, 1), net.IPv6loopback},\n\t\tNotBefore: time.Now(),\n\t\tNotAfter: time.Now().AddDate(10, 0, 0),\n\t\tSubjectKeyId: []byte{1, 2, 3, 4, 6},\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},\n\t\tKeyUsage: x509.KeyUsageDigitalSignature,\n\t}\n\n\tcertPrivKey, err := rsa.GenerateKey(rand.Reader, 4096)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcertBytes, err := x509.CreateCertificate(rand.Reader, cert, root.PublicKey, &certPrivKey.PublicKey, root.PrivateKey)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcertPEM := new(bytes.Buffer)\n\tpem.Encode(certPEM, &pem.Block{\n\t\tType: \"CERTIFICATE\",\n\t\tBytes: certBytes,\n\t})\n\n\tcertPrivKeyPEM := new(bytes.Buffer)\n\tpem.Encode(certPrivKeyPEM, &pem.Block{\n\t\tType: \"RSA PRIVATE KEY\",\n\t\tBytes: x509.MarshalPKCS1PrivateKey(certPrivKey),\n\t})\n\n\tif err := ioutil.WriteFile(publicKeyFile, certPEM.Bytes(), 0644); err != nil {\n\t\treturn fmt.Errorf(\"failed to write to public key file: %w\", err)\n\t}\n\n\tif err := ioutil.WriteFile(privateKeyFile, certPrivKeyPEM.Bytes(), 0644); err != nil {\n\t\treturn fmt.Errorf(\"failed to write to private key file: %w\", err)\n\t}\n\n\treturn nil\n}", "func (d Driver) Get(request secrets.Request) secrets.Response {\n\t// Handle them panics.\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tzap.S().Errorf(\"pki: error issuing certificate: %s\", r)\n\t\t}\n\t}()\n\n\tzap.S().Debugf(\"pki: got request for certificate: %#v\", request)\n\n\t// For now the secrets.Request.SecretLabels value does not get populated.\n\t// To work around this, the secret's labels are inspected on the daemon.\n\tmeta, _, err := d.client.SecretInspectWithRaw(context.Background(), request.SecretName)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"pki: error inspecting secret: %s\", err.Error())\n\n\t\t// The error is explicitly logged because Docker doesn't log the error returned.\n\t\tzap.S().Error(msg)\n\n\t\treturn secrets.Response{\n\t\t\tErr: msg,\n\t\t}\n\t}\n\n\tcertRequest := CertRequest{}\n\tif err := certRequest.FromSecretLabels(meta.Spec.Labels); err != nil {\n\t\tmsg := fmt.Sprintf(\"pki: error parsing secret's labels: %s\", err.Error())\n\n\t\t// The error is explicitly logged because Docker doesn't log the error returned.\n\t\tzap.S().Error(msg)\n\n\t\treturn secrets.Response{\n\t\t\tErr: msg,\n\t\t}\n\t}\n\n\tbundle, err := d.IssueCertificate(certRequest)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"pki: error issuing certificate: %s\", err.Error())\n\n\t\t// The error is explicitly logged because Docker doesn't log the error returned.\n\t\tzap.S().Error(msg)\n\n\t\treturn secrets.Response{\n\t\t\tErr: msg,\n\t\t}\n\t}\n\n\treturn secrets.Response{\n\t\tValue: bundle,\n\t\tDoNotReuse: true,\n\t}\n}", "func AppendCertificate(config *tls.Config, crt, key string) error {\n\tfmt.Println(\"TLS: Loading certificates (crt, key):\", crt, key)\n\tcer, err := tls.LoadX509KeyPair(crt, key)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\tconfig.Certificates = append(config.Certificates, cer)\n\treturn nil\n}", "func getCertPart(data []byte, key string) ([]byte, error) {\n\tif key == corev1.TLSPrivateKeyKey {\n\t\treturn getPrivateKey(data)\n\t}\n\tif key == corev1.TLSCertKey {\n\t\treturn getCert(data)\n\t}\n\treturn nil, fmt.Errorf(\"tls key is not supported. Only tls.key and tls.crt are supported\")\n}", "func TestGenerateCertificate(t *testing.T) {\n\tid, _ := GenerateIdentity()\n\tif !bytes.Equal(id.certificate().Certificate[0], id.certificate().Certificate[0]) {\n\t\tt.Fatalf(\"Secret certificate not deterministic\")\n\t}\n}", "func secretToPem(secPath, outName string) error {\n\t// The secret, when present, is mounted on /etc/pki/tls/private\n\t// The secret has two components crt.tls and key.tls\n\t// When the default cert is provided by the admin it is a pem\n\t// tls.crt is the supplied pem and tls.key is the key\n\t// extracted from the pem\n\t// When the admin does not provide a default cert, the secret\n\t// is created via the service annotation. In this case\n\t// tls.crt is the cert and tls.key is the key\n\t// The crt and key are concatenated to form the needed pem\n\n\tvar fileCrtName = filepath.Join(secPath, \"tls.crt\")\n\tvar fileKeyName = filepath.Join(secPath, \"tls.key\")\n\tpemBlock, err := ioutil.ReadFile(fileCrtName)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pemBlock) > 0 && pemBlock[len(pemBlock)-1] != byte('\\n') {\n\t\tpemBlock = append(pemBlock, byte('\\n'))\n\t}\n\tkeys, err := privateKeysFromPEM(pemBlock)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(keys) == 0 {\n\t\t// Try to get the key from the tls.key file\n\t\tkeyBlock, err := ioutil.ReadFile(fileKeyName)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(keyBlock) > 0 && keyBlock[len(keyBlock)-1] != byte('\\n') {\n\t\t\tkeyBlock = append(keyBlock, byte('\\n'))\n\t\t}\n\t\tpemBlock = append(pemBlock, keyBlock...)\n\t}\n\treturn ioutil.WriteFile(outName, pemBlock, 0444)\n}", "func LoadPrivateCertFromFile(certPath, keyPath string) (*FullCert, error) {\n\tcertBytes, err := ioutil.ReadFile(certPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkeyBytes, err := ioutil.ReadFile(keyPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn LoadPrivateCert(certBytes, keyBytes)\n}", "func createCertificate(data *dataBundle) (*certutil.ParsedCertBundle, error) {\n\tvar err error\n\tresult := &certutil.ParsedCertBundle{}\n\n\tserialNumber, err := certutil.GenerateSerialNumber()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := certutil.GeneratePrivateKey(data.params.KeyType,\n\t\tdata.params.KeyBits,\n\t\tresult); err != nil {\n\t\treturn nil, err\n\t}\n\n\tsubjKeyID, err := certutil.GetSubjKeyID(result.PrivateKey)\n\tif err != nil {\n\t\treturn nil, errutil.InternalError{Err: fmt.Sprintf(\"error getting subject key ID: %s\", err)}\n\t}\n\n\tcertTemplate := &x509.Certificate{\n\t\tSerialNumber: serialNumber,\n\t\tNotBefore: time.Now().Add(-30 * time.Second),\n\t\tNotAfter: data.params.NotAfter,\n\t\tIsCA: false,\n\t\tSubjectKeyId: subjKeyID,\n\t\tSubject: data.params.Subject,\n\t\tDNSNames: data.params.DNSNames,\n\t\tEmailAddresses: data.params.EmailAddresses,\n\t\tIPAddresses: data.params.IPAddresses,\n\t\tURIs: data.params.URIs,\n\t}\n\tif data.params.NotBeforeDuration > 0 {\n\t\tcertTemplate.NotBefore = time.Now().Add(-1 * data.params.NotBeforeDuration)\n\t}\n\n\tif err := handleOtherSANs(certTemplate, data.params.OtherSANs); err != nil {\n\t\treturn nil, errutil.InternalError{Err: errwrap.Wrapf(\"error marshaling other SANs: {{err}}\", err).Error()}\n\t}\n\n\t// Add this before calling addKeyUsages\n\tif data.signingBundle == nil {\n\t\tcertTemplate.IsCA = true\n\t} else if data.params.BasicConstraintsValidForNonCA {\n\t\tcertTemplate.BasicConstraintsValid = true\n\t\tcertTemplate.IsCA = false\n\t}\n\n\t// This will only be filled in from the generation paths\n\tif len(data.params.PermittedDNSDomains) > 0 {\n\t\tcertTemplate.PermittedDNSDomains = data.params.PermittedDNSDomains\n\t\tcertTemplate.PermittedDNSDomainsCritical = true\n\t}\n\n\taddPolicyIdentifiers(data, certTemplate)\n\n\taddKeyUsages(data, certTemplate)\n\n\taddExtKeyUsageOids(data, certTemplate)\n\n\tcertTemplate.IssuingCertificateURL = data.params.URLs.IssuingCertificates\n\tcertTemplate.CRLDistributionPoints = data.params.URLs.CRLDistributionPoints\n\tcertTemplate.OCSPServer = data.params.URLs.OCSPServers\n\n\tvar certBytes []byte\n\tif data.signingBundle != nil {\n\t\tswitch data.signingBundle.PrivateKeyType {\n\t\tcase certutil.RSAPrivateKey:\n\t\t\tcertTemplate.SignatureAlgorithm = x509.SHA256WithRSA\n\t\tcase certutil.ECPrivateKey:\n\t\t\tcertTemplate.SignatureAlgorithm = x509.ECDSAWithSHA256\n\t\t}\n\n\t\tcaCert := data.signingBundle.Certificate\n\t\tcertTemplate.AuthorityKeyId = caCert.SubjectKeyId\n\n\t\tcertBytes, err = x509.CreateCertificate(rand.Reader, certTemplate, caCert, result.PrivateKey.Public(), data.signingBundle.PrivateKey)\n\t} else {\n\t\t// Creating a self-signed root\n\t\tif data.params.MaxPathLength == 0 {\n\t\t\tcertTemplate.MaxPathLen = 0\n\t\t\tcertTemplate.MaxPathLenZero = true\n\t\t} else {\n\t\t\tcertTemplate.MaxPathLen = data.params.MaxPathLength\n\t\t}\n\n\t\tswitch data.params.KeyType {\n\t\tcase \"rsa\":\n\t\t\tcertTemplate.SignatureAlgorithm = x509.SHA256WithRSA\n\t\tcase \"ec\":\n\t\t\tcertTemplate.SignatureAlgorithm = x509.ECDSAWithSHA256\n\t\t}\n\n\t\tcertTemplate.AuthorityKeyId = subjKeyID\n\t\tcertTemplate.BasicConstraintsValid = true\n\t\tcertBytes, err = x509.CreateCertificate(rand.Reader, certTemplate, certTemplate, result.PrivateKey.Public(), result.PrivateKey)\n\t}\n\n\tif err != nil {\n\t\treturn nil, errutil.InternalError{Err: fmt.Sprintf(\"unable to create certificate: %s\", err)}\n\t}\n\n\tresult.CertificateBytes = certBytes\n\tresult.Certificate, err = x509.ParseCertificate(certBytes)\n\tif err != nil {\n\t\treturn nil, errutil.InternalError{Err: fmt.Sprintf(\"unable to parse created certificate: %s\", err)}\n\t}\n\n\tif data.signingBundle != nil {\n\t\tif len(data.signingBundle.Certificate.AuthorityKeyId) > 0 &&\n\t\t\t!bytes.Equal(data.signingBundle.Certificate.AuthorityKeyId, data.signingBundle.Certificate.SubjectKeyId) {\n\n\t\t\tresult.CAChain = []*certutil.CertBlock{\n\t\t\t\t&certutil.CertBlock{\n\t\t\t\t\tCertificate: data.signingBundle.Certificate,\n\t\t\t\t\tBytes: data.signingBundle.CertificateBytes,\n\t\t\t\t},\n\t\t\t}\n\t\t\tresult.CAChain = append(result.CAChain, data.signingBundle.CAChain...)\n\t\t}\n\t}\n\n\treturn result, nil\n}", "func prepareDefaultVaultTLSSecrets(vr *api.VaultService) (err error) {\n\tdefer func() {\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"prepare default vault TLS secrets failed: %v\", err)\n\t\t}\n\t}()\n\n\t// if TLS spec doesn't exist or secrets doesn't exist, then we can go create secrets.\n\tif api.IsTLSConfigured(vr.Spec.TLS) {\n\t\tse := &v1.Secret{\n\t\t\tTypeMeta: metav1.TypeMeta{\n\t\t\t\tKind: \"Secret\",\n\t\t\t\tAPIVersion: \"v1\",\n\t\t\t},\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: vr.Spec.TLS.Static.ServerSecret,\n\t\t\t\tNamespace: vr.Namespace,\n\t\t\t},\n\t\t}\n\t\terr = query.Get(se)\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\t\tif !apierrors.IsNotFound(err) {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tcaKey, caCrt, err := newCACert()\n\tif err != nil {\n\t\treturn err\n\t}\n\tse, err := newVaultServerTLSSecret(vr, caKey, caCrt)\n\tif err != nil {\n\t\treturn err\n\t}\n\taddOwnerRefToObject(se, asOwner(vr))\n\terr = action.Create(se)\n\tif err != nil && !apierrors.IsAlreadyExists(err) {\n\t\treturn err\n\t}\n\n\tse = newVaultClientTLSSecret(vr, caCrt)\n\taddOwnerRefToObject(se, asOwner(vr))\n\terr = action.Create(se)\n\tif err != nil && !apierrors.IsAlreadyExists(err) {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Secret(s *dag.Secret) *envoy_tls_v3.Secret {\n\treturn &envoy_tls_v3.Secret{\n\t\tName: envoy.Secretname(s),\n\t\tType: &envoy_tls_v3.Secret_TlsCertificate{\n\t\t\tTlsCertificate: &envoy_tls_v3.TlsCertificate{\n\t\t\t\tPrivateKey: &envoy_core_v3.DataSource{\n\t\t\t\t\tSpecifier: &envoy_core_v3.DataSource_InlineBytes{\n\t\t\t\t\t\tInlineBytes: s.PrivateKey(),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tCertificateChain: &envoy_core_v3.DataSource{\n\t\t\t\t\tSpecifier: &envoy_core_v3.DataSource_InlineBytes{\n\t\t\t\t\t\tInlineBytes: s.Cert(),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}", "func SignCertificate(invocationDetail *FunctionInvocation, keyvaultClient *keyvault.BaseClient, keyvaultName string, keyName string, pubKey ssh.PublicKey) (*ssh.Certificate, error) {\n\t// Generate a nonce\n\tbytes := make([]byte, 32)\n\tnonce := make([]byte, len(bytes)*2)\n\tif _, err := rand.Read(bytes); err != nil {\n\t\treturn nil, err\n\t}\n\thex.Encode(nonce, bytes)\n\n\t// Generate a random serial number\n\tserial, err := rand.Int(rand.Reader, big.NewInt(math.MaxInt64))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Set the certificate principal to the signed in user\n\tusername := strings.Split(invocationDetail.ClientPrincipalName, \"@\")[0]\n\n\t// Get the current time and generate the validFrom and ValidTo\n\tnow := time.Now()\n\tvalidFrom := now.Add(time.Second * -15)\n\tvalidTo := now.Add(time.Minute * 2)\n\n\t// Convert the extensions slice to a map\n\textensions := make(map[string]string, len(supportedExtensions))\n\tfor _, ext := range supportedExtensions {\n\t\textensions[ext] = \"\"\n\t}\n\n\tcriticalOptions := make(map[string]string)\n\t// criticalOptions[\"force-command\"] = \"echo Hello, SSHizzle!\"\n\t// criticalOptions[\"source-address\"] = \"192.168.0.0/24\"\n\n\t// Key ID to [loosely] follow Netflix BLESS format: https://github.com/Netflix/bless\n\tkeyID := fmt.Sprintf(\"request[%s] for[%s] from[%s] command[%s] ssh_key[%s] ca[%s] valid_to[%s]\",\n\t\tinvocationDetail.InvocationID,\n\t\tusername,\n\t\tinvocationDetail.ClientIP,\n\t\t\"\", // Force command\n\t\tssh.FingerprintSHA256(pubKey),\n\t\tos.Getenv(\"WEBSITE_DEPLOYMENT_ID\"),\n\t\tvalidTo.Format(\"2006/01/02 15:04:05\"),\n\t)\n\t// Create a certificate with all of our details\n\tcertificate := ssh.Certificate{\n\t\tNonce: nonce,\n\t\tKey: pubKey,\n\t\tSerial: serial.Uint64(),\n\t\tCertType: ssh.UserCert,\n\t\tKeyId: keyID,\n\t\tValidPrincipals: []string{\n\t\t\tusername,\n\t\t},\n\t\tPermissions: ssh.Permissions{\n\t\t\tCriticalOptions: criticalOptions,\n\t\t\tExtensions: extensions,\n\t\t},\n\t\tValidAfter: uint64(validFrom.Unix()),\n\t\tValidBefore: uint64(validTo.Unix()),\n\t}\n\n\t// Create a \"KeyVaultSigner\" which returns a crypto.Signer that interfaces with Azure Key Vault\n\tkeyvaultSigner := azure.NewKeyVaultSigner(keyvaultClient, keyvaultName, keyName)\n\n\t// Create an SSHAlgorithmSigner with an RSA, SHA256 algorithm\n\tsshAlgorithmSigner, err := NewAlgorithmSignerFromSigner(keyvaultSigner, ssh.SigAlgoRSASHA2256)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Sign the certificate!\n\tif err := certificate.SignCert(rand.Reader, sshAlgorithmSigner); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Extract the public key (certificate) to return to the user\n\tpubkey, err := ssh.ParsePublicKey(certificate.Marshal())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Convert the cert to the correct format and return it\n\tcert, _, _, _, err := ssh.ParseAuthorizedKey(ssh.MarshalAuthorizedKey(pubkey))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn cert.(*ssh.Certificate), nil\n}", "func getServiceCertSecret(cert certificate.Certificater, name string) (*xds_auth.Secret, error) {\n\tsecret := &xds_auth.Secret{\n\t\t// The Name field must match the tls_context.common_tls_context.tls_certificate_sds_secret_configs.name in the Envoy yaml config\n\t\tName: name,\n\t\tType: &xds_auth.Secret_TlsCertificate{\n\t\t\tTlsCertificate: &xds_auth.TlsCertificate{\n\t\t\t\tCertificateChain: &xds_core.DataSource{\n\t\t\t\t\tSpecifier: &xds_core.DataSource_InlineBytes{\n\t\t\t\t\t\tInlineBytes: cert.GetCertificateChain(),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tPrivateKey: &xds_core.DataSource{\n\t\t\t\t\tSpecifier: &xds_core.DataSource_InlineBytes{\n\t\t\t\t\t\tInlineBytes: cert.GetPrivateKey(),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\treturn secret, nil\n}", "func getCert(ctx context.Context, conf *config.Config, awsClient *cziAWS.Client, username string, region config.Region) error {\n\tkmsauthContext := &kmsauth.AuthContextV2{\n\t\tFrom: username,\n\t\tTo: conf.LambdaConfig.FunctionName,\n\t\tUserType: \"user\",\n\t}\n\tkmsAuthCachePath, err := conf.GetKMSAuthCachePath(region.AWSRegion)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttg := kmsauth.NewTokenGenerator(\n\t\tregion.KMSAuthKeyID,\n\t\tkmsauth.TokenVersion2,\n\t\tconf.ClientConfig.CertLifetime.AsDuration(),\n\t\taws.String(kmsAuthCachePath),\n\t\tkmsauthContext,\n\t\tawsClient,\n\t)\n\tclient := bless.NewKMSAuthClient(conf).WithAwsClient(awsClient).WithTokenGenerator(tg).WithUsername(username)\n\terr = client.RequestCert(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (server *SingleInstance) TLSCertificate() *x509.Certificate {\n\tbytes, err := ioutil.ReadFile(path.Join(server.path, \"neo4jhome\", \"certificates\", \"neo4j.cert\"))\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tder, _ := pem.Decode(bytes)\n\tif der == nil {\n\t\treturn nil\n\t}\n\n\tcert, err := x509.ParseCertificate(der.Bytes)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\treturn cert\n}", "func (c *TLSConfig) LoadCerts() error {\n\tif !c.IsEnabled() {\n\t\treturn nil\n\t}\n\n\tdockerCertPath := os.Getenv(\"DOCKER_CERT_PATH\")\n\tif dockerCertPath == \"\" {\n\t\tdockerCertPath = filepath.Join(homedir.Get(), \".docker\")\n\t}\n\n\tif c.CACert == \"\" {\n\t\tc.CACert = filepath.Join(dockerCertPath, defaultCaFile)\n\t}\n\tif c.Cert == \"\" {\n\t\tc.Cert = filepath.Join(dockerCertPath, defaultCertFile)\n\t}\n\tif c.Key == \"\" {\n\t\tc.Key = filepath.Join(dockerCertPath, defaultKeyFile)\n\t}\n\n\ttlsConfig := &tls.Config{\n\t\tNextProtos: []string{\"http/1.1\"},\n\t\t// Avoid fallback on insecure SSL protocols\n\t\tMinVersion: tls.VersionTLS10,\n\t}\n\n\tif c.Verify {\n\t\tcertPool := x509.NewCertPool()\n\t\tfile, err := ioutil.ReadFile(c.CACert)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Couldn't read CA certificate: %v\", err)\n\t\t}\n\t\tcertPool.AppendCertsFromPEM(file)\n\t\ttlsConfig.ClientAuth = tls.RequireAndVerifyClientCert\n\t\ttlsConfig.ClientCAs = certPool\n\t}\n\n\t_, errCert := os.Stat(c.Cert)\n\t_, errKey := os.Stat(c.Key)\n\tif errCert == nil && errKey == nil {\n\t\tcert, err := tls.LoadX509KeyPair(c.Cert, c.Key)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Couldn't load X509 key pair: %q. Make sure the key is encrypted\", err)\n\t\t}\n\t\ttlsConfig.Certificates = []tls.Certificate{cert}\n\t}\n\n\tc.Config = tlsConfig\n\treturn nil\n}", "func (cm *CertificateManager) generateWebhookCertSecretData(ctx context.Context, notAfter time.Time) (map[string][]byte, error) {\n\tserverKey, serverCert, caCert, err := resources.CreateCerts(ctx, cm.opts.ServiceName, cm.opts.ServiceNamespace, notAfter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create certs: %w\", err)\n\t}\n\tdata := map[string][]byte{\n\t\tCACertName: caCert,\n\t\tServerCertName: serverCert,\n\t\tServerKeyName: serverKey,\n\t}\n\treturn data, nil\n}", "func MakeRootCertificate(config *Config, outPath string, outKeyPath string) (uint16, error) {\n\tsigner, err := getSigner(config.rand(), config.SignatureAlgorithm, config.EndEntity || config.ForDC)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tpriv, pub, err := signer.GenerateKey()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tspkiASN1, err := x509.MarshalPKIXPublicKey(pub)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tvar spki struct {\n\t\tAlgorithm pkix.AlgorithmIdentifier\n\t\tSubjectPublicKey asn1.BitString\n\t}\n\t_, err = asn1.Unmarshal(spkiASN1, &spki)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tskid := sha1.Sum(spki.SubjectPublicKey.Bytes)\n\n\tserialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)\n\tserialNumber, err := rand.Int(config.rand(), serialNumberLimit)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\ttpl := &x509.Certificate{\n\t\tSerialNumber: serialNumber,\n\t\tSubject: pkix.Name{\n\t\t\tOrganization: []string{\"tls-interop-runner development CA\"},\n\t\t\tOrganizationalUnit: []string{\"tls-interop-runner\"},\n\n\t\t\t// The CommonName is required by iOS to show the certificate in the\n\t\t\t// \"Certificate Trust Settings\" menu.\n\t\t\t// https://github.com/FiloSottile/mkcert/issues/47\n\t\t\tCommonName: \"tls-interop-runner\",\n\t\t},\n\t\tSubjectKeyId: skid[:],\n\n\t\tNotBefore: config.ValidFrom,\n\t\tNotAfter: config.ValidFrom.Add(config.ValidFor),\n\n\t\tKeyUsage: x509.KeyUsageCertSign,\n\n\t\tBasicConstraintsValid: true,\n\t\tIsCA: true,\n\t\tMaxPathLenZero: true,\n\t}\n\n\tcert, err := x509.CreateCertificate(config.rand(), tpl, tpl, pub, priv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tprivDER, err := x509.MarshalPKCS8PrivateKey(priv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\terr = ioutil.WriteFile(outKeyPath, pem.EncodeToMemory(\n\t\t&pem.Block{Type: \"PRIVATE KEY\", Bytes: privDER}), 0600)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\terr = ioutil.WriteFile(outPath, pem.EncodeToMemory(\n\t\t&pem.Block{Type: \"CERTIFICATE\", Bytes: cert}), 0644)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn signer.algorithmID, nil\n}", "func (pair TLSKeyCertPair) GetCertificate() (tls.Certificate, error) {\n\treturn tls.LoadX509KeyPair(pair.Cert, pair.Key)\n}", "func GetFakeSSLCert(o []string, cn string, dns []string) (cert, key []byte) {\n\n\tvar priv interface{}\n\tvar err error\n\n\tpriv, err = rsa.GenerateKey(rand.Reader, 2048)\n\n\tif err != nil {\n\t\tklog.Exitf(\"failed to generate fake private key: %s\", err)\n\t}\n\n\tnotBefore := time.Now()\n\t// This certificate is valid for 365 days\n\tnotAfter := notBefore.Add(365 * 24 * time.Hour)\n\n\tserialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)\n\tserialNumber, err := rand.Int(rand.Reader, serialNumberLimit)\n\n\tif err != nil {\n\t\tklog.Exitf(\"failed to generate fake serial number: %s\", err)\n\t}\n\n\ttemplate := x509.Certificate{\n\t\tSerialNumber: serialNumber,\n\t\tSubject: pkix.Name{\n\t\t\tOrganization: o,\n\t\t\tCommonName: cn,\n\t\t},\n\t\tNotBefore: notBefore,\n\t\tNotAfter: notAfter,\n\n\t\tKeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},\n\t\tBasicConstraintsValid: true,\n\t\tDNSNames: dns,\n\t}\n\tderBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.(*rsa.PrivateKey).PublicKey, priv)\n\tif err != nil {\n\t\tklog.Exitf(\"Failed to create fake certificate: %s\", err)\n\t}\n\n\tcert = pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: derBytes})\n\tkey = pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(priv.(*rsa.PrivateKey))})\n\treturn cert, key\n}", "func TestServer_Reload_TLS_Shared_Keyloader(t *testing.T) {\n\tt.Parallel()\n\tassert := assert.New(t)\n\n\t// We will start out with a bad cert and then reload with a good one.\n\tconst (\n\t\tcafile = \"../../helper/tlsutil/testdata/ca.pem\"\n\t\tfoocert = \"../../helper/tlsutil/testdata/nomad-bad.pem\"\n\t\tfookey = \"../../helper/tlsutil/testdata/nomad-bad-key.pem\"\n\t\tfoocert2 = \"../../helper/tlsutil/testdata/nomad-foo.pem\"\n\t\tfookey2 = \"../../helper/tlsutil/testdata/nomad-foo-key.pem\"\n\t)\n\n\tagent := NewTestAgent(t, t.Name(), func(c *Config) {\n\t\tc.TLSConfig = &sconfig.TLSConfig{\n\t\t\tEnableHTTP: true,\n\t\t\tEnableRPC: true,\n\t\t\tVerifyServerHostname: true,\n\t\t\tCAFile: cafile,\n\t\t\tCertFile: foocert,\n\t\t\tKeyFile: fookey,\n\t\t}\n\t})\n\tdefer agent.Shutdown()\n\n\toriginalKeyloader := agent.Config.TLSConfig.GetKeyLoader()\n\toriginalCert, err := originalKeyloader.GetOutgoingCertificate(nil)\n\tassert.NotNil(originalKeyloader)\n\tif assert.Nil(err) {\n\t\tassert.NotNil(originalCert)\n\t}\n\n\t// Switch to the correct certificates and reload\n\tnewConfig := &Config{\n\t\tTLSConfig: &sconfig.TLSConfig{\n\t\t\tEnableHTTP: true,\n\t\t\tEnableRPC: true,\n\t\t\tVerifyServerHostname: true,\n\t\t\tCAFile: cafile,\n\t\t\tCertFile: foocert2,\n\t\t\tKeyFile: fookey2,\n\t\t},\n\t}\n\n\tassert.Nil(agent.Reload(newConfig))\n\tassert.Equal(agent.Config.TLSConfig.CertFile, newConfig.TLSConfig.CertFile)\n\tassert.Equal(agent.Config.TLSConfig.KeyFile, newConfig.TLSConfig.KeyFile)\n\tassert.Equal(agent.Config.TLSConfig.GetKeyLoader(), originalKeyloader)\n\n\t// Assert is passed through on the server correctly\n\tif assert.NotNil(agent.server.GetConfig().TLSConfig) {\n\t\tserverKeyloader := agent.server.GetConfig().TLSConfig.GetKeyLoader()\n\t\tassert.Equal(serverKeyloader, originalKeyloader)\n\t\tnewCert, err := serverKeyloader.GetOutgoingCertificate(nil)\n\t\tassert.Nil(err)\n\t\tassert.NotEqual(originalCert, newCert)\n\t}\n\n\t// Assert is passed through on the client correctly\n\tif assert.NotNil(agent.client.GetConfig().TLSConfig) {\n\t\tclientKeyloader := agent.client.GetConfig().TLSConfig.GetKeyLoader()\n\t\tassert.Equal(clientKeyloader, originalKeyloader)\n\t\tnewCert, err := clientKeyloader.GetOutgoingCertificate(nil)\n\t\tassert.Nil(err)\n\t\tassert.NotEqual(originalCert, newCert)\n\t}\n}", "func (r CreateLoadBalancerTlsCertificateRequest) Send(ctx context.Context) (*CreateLoadBalancerTlsCertificateResponse, error) {\n\tr.Request.SetContext(ctx)\n\terr := r.Request.Send()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp := &CreateLoadBalancerTlsCertificateResponse{\n\t\tCreateLoadBalancerTlsCertificateOutput: r.Request.Data.(*CreateLoadBalancerTlsCertificateOutput),\n\t\tresponse: &aws.Response{Request: r.Request},\n\t}\n\n\treturn resp, nil\n}", "func (c *Certificate) ensure(ctx context.Context, kv clientv3.KV) (cert, key []byte, err error) {\n\tif c.name == \"\" {\n\t\t// Volatile certificate - generate.\n\t\t// TODO(q3k): cache internally?\n\t\tcert, key, err = c.Issuer.Issue(ctx, c, kv)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"failed to issue: %w\", err)\n\t\t\treturn\n\t\t}\n\t\treturn\n\t}\n\n\tcertPath, keyPath := c.etcdPaths()\n\n\t// Try loading certificate and key from etcd.\n\tcertRes, err := kv.Get(ctx, certPath)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to get certificate from etcd: %w\", err)\n\t\treturn\n\t}\n\tkeyRes, err := kv.Get(ctx, keyPath)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to get key from etcd: %w\", err)\n\t\treturn\n\t}\n\n\tif len(certRes.Kvs) == 1 && len(keyRes.Kvs) == 1 {\n\t\t// Certificate and key exists in etcd, return that.\n\t\tcert = certRes.Kvs[0].Value\n\t\tkey = keyRes.Kvs[0].Value\n\n\t\terr = nil\n\t\t// TODO(q3k): check for expiration\n\t\treturn\n\t}\n\n\t// No certificate found - issue one.\n\tcert, key, err = c.Issuer.Issue(ctx, c, kv)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to issue: %w\", err)\n\t\treturn\n\t}\n\n\t// Save to etcd in transaction. This ensures that no partial writes happen,\n\t// and that we haven't been raced to the save.\n\tres, err := kv.Txn(ctx).\n\t\tIf(\n\t\t\tclientv3.Compare(clientv3.CreateRevision(certPath), \"=\", 0),\n\t\t\tclientv3.Compare(clientv3.CreateRevision(keyPath), \"=\", 0),\n\t\t).\n\t\tThen(\n\t\t\tclientv3.OpPut(certPath, string(cert)),\n\t\t\tclientv3.OpPut(keyPath, string(key)),\n\t\t).Commit()\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to write newly issued certificate: %w\", err)\n\t} else if !res.Succeeded {\n\t\terr = fmt.Errorf(\"certificate issuance transaction failed: concurrent write\")\n\t}\n\n\treturn\n}", "func imitateCertificate(serverCert *x509.Certificate, selfSigned bool, sni string) (cert tls.Certificate, err error) {\n\tconf := getConfig()\n\t// Use a hash of the real certificate (plus some other things) as the serial number.\n\th := md5.New()\n\th.Write(serverCert.Raw)\n\tfor _, c := range conf.TLSCert.Certificate {\n\t\th.Write(c)\n\t}\n\tif sni != \"\" {\n\t\tio.WriteString(h, sni)\n\t}\n\n\ttemplate := &x509.Certificate{\n\t\tSerialNumber: big.NewInt(0).SetBytes(h.Sum(nil)),\n\t\tSubject: serverCert.Subject,\n\t\tNotBefore: serverCert.NotBefore,\n\t\tNotAfter: serverCert.NotAfter,\n\t\tKeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,\n\t\tExtKeyUsage: serverCert.ExtKeyUsage,\n\t\tUnknownExtKeyUsage: serverCert.UnknownExtKeyUsage,\n\t\tBasicConstraintsValid: false,\n\t\tSubjectKeyId: nil,\n\t\tDNSNames: serverCert.DNSNames,\n\t\tPermittedDNSDomainsCritical: serverCert.PermittedDNSDomainsCritical,\n\t\tPermittedDNSDomains: serverCert.PermittedDNSDomains,\n\t\tSignatureAlgorithm: x509.UnknownSignatureAlgorithm,\n\t}\n\n\t// If sni is not blank, make a certificate that covers only that domain,\n\t// instead of all the domains covered by the original certificate.\n\tif sni != \"\" {\n\t\ttemplate.DNSNames = []string{sni}\n\t\ttemplate.Subject.CommonName = sni\n\t}\n\n\tvar newCertBytes []byte\n\tif selfSigned {\n\t\tnewCertBytes, err = x509.CreateCertificate(rand.Reader, template, template, conf.ParsedTLSCert.PublicKey, conf.TLSCert.PrivateKey)\n\t} else {\n\t\tnewCertBytes, err = x509.CreateCertificate(rand.Reader, template, conf.ParsedTLSCert, conf.ParsedTLSCert.PublicKey, conf.TLSCert.PrivateKey)\n\t}\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\n\tnewCert := tls.Certificate{\n\t\tCertificate: [][]byte{newCertBytes},\n\t\tPrivateKey: conf.TLSCert.PrivateKey,\n\t}\n\n\tif !selfSigned {\n\t\tnewCert.Certificate = append(newCert.Certificate, conf.TLSCert.Certificate...)\n\t}\n\treturn newCert, nil\n}", "func loadCertificate() []webrtc.Certificate {\n\tcertFile, err := ioutil.ReadFile(\"cert.pem\")\n\tpanicIfErr(err)\n\n\tkeyFile, err := ioutil.ReadFile(\"key.pem\")\n\tpanicIfErr(err)\n\n\tcertPem, _ := pem.Decode(certFile)\n\tkeyPem, _ := pem.Decode(keyFile)\n\n\tcert, err := x509.ParseCertificate(certPem.Bytes)\n\tpanicIfErr(err)\n\n\tprivateKey, err := x509.ParsePKCS8PrivateKey(keyPem.Bytes)\n\tpanicIfErr(err)\n\n\treturn []webrtc.Certificate{webrtc.CertificateFromX509(privateKey, cert)}\n}", "func Load(homeDir, secKey string) (*[64]byte, *[64]byte, []byte, error) {\n\tif secKey == \"\" {\n\t\tsecretDir := filepath.Join(homeDir, def.SecretsSubDir)\n\t\tfiles, err := ioutil.ReadDir(secretDir)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t\tif len(files) > 1 {\n\t\t\treturn nil, nil, nil,\n\t\t\t\tfmt.Errorf(\"directory '%s' contains more than one secret file, use option -s\",\n\t\t\t\t\tsecretDir)\n\t\t}\n\t\tsecKey = filepath.Join(secretDir, files[0].Name())\n\t}\n\treturn seckey.Read(secKey)\n}", "func (c *Session) loadKey(pubKey, privKey []byte, parentKeyPassword, keyPassword string) (*SigningKey, error) {\n\tpub, err := tpm2.DecodePublic(pubKey)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"tpm2.DecodePublic failed: %w\", err)\n\t}\n\n\tcanSign := pub.Attributes&tpm2.FlagSign != 0\n\tif !canSign {\n\t\treturn nil, errors.New(\"not a signing key\")\n\t}\n\n\tvar sigHashAlg tpm2.Algorithm\n\tvar srkTemplate tpm2.Public\n\tswitch pub.Type {\n\tcase tpm2.AlgRSA:\n\t\tsrkTemplate = SRKTemplateHighRSA()\n\t\trsaParams := pub.RSAParameters\n\t\tif rsaParams != nil {\n\t\t\tsigHashAlg = rsaParams.Sign.Hash\n\t\t}\n\n\tcase tpm2.AlgECC:\n\t\tsrkTemplate = SRKTemplateHighECC()\n\t\teccParams := pub.ECCParameters\n\t\tif eccParams != nil {\n\t\t\tsigHashAlg = eccParams.Sign.Hash\n\t\t}\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"bad key type: 0x%04x\", pub.Type)\n\t}\n\n\tif sigHashAlg.IsNull() {\n\t\treturn nil, errors.New(\"signature hash algorithm is NULL\")\n\t}\n\n\tsrkHandle, _, _, _, _, _, err :=\n\t\ttpm2.CreatePrimaryEx(c.rwc, tpm2.HandleOwner,\n\t\t\ttpm2.PCRSelection{},\n\t\t\tc.ownerHierarchyPassword,\n\t\t\tparentKeyPassword,\n\t\t\tsrkTemplate)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"tpm2.CreatePrimaryEx failed: %w\", err)\n\t}\n\tdefer c.flushContext(srkHandle)\n\n\tkeyHandle, _, err := tpm2.Load(c.rwc, srkHandle, parentKeyPassword, pubKey, privKey)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"tpm2.Load failed: %w\", err)\n\t}\n\n\treturn &SigningKey{\n\t\tHandle: keyHandle,\n\t\tsigHashAlg: sigHashAlg,\n\t\trw: c.rwc,\n\t\tlog: c.log,\n\t\tpassword: keyPassword,\n\t}, nil\n}", "func (app *App) TLS(certFile, keyFile string) *App {\n\tcert, err := tls.LoadX509KeyPair(certFile, keyFile)\n\tif err != nil {\n\t\tpanic(\"hime: load key pair error; \" + err.Error())\n\t}\n\n\tif app.TLSConfig == nil {\n\t\tapp.TLSConfig = &tls.Config{}\n\t}\n\tapp.TLSConfig.Certificates = append(app.TLSConfig.Certificates, cert)\n\treturn app\n}", "func (state *RuntimeState) GenerateCert(domain string) ([]byte, error) {\n\n\t//generate new cert logic comes here and put in cache store\n\t//sleep for 10 secs to emulate external service call\n\ttime.Sleep(time.Second * 10)\n\tnewcert := \"foo-$\" + domain\n\n\tctx := context.Background()\n\n\tstate.CertMutex.Lock()\n\n\tdefer state.CertMutex.Unlock()\n\n\tdomainDir := filepath.Join(state.Config.CertStoreName, domain)\n\n\tcertstoreDir := autocert.DirCache(domainDir)\n\t//for every new domain name we create a new directory in \"certs\"(Cachestore) and store the cert.\n\n\terr := certstoreDir.Put(ctx, domain, []byte(newcert))\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\trenewinfo := RenewalInfo{time.Now().Unix(), time.Now().Add(time.Minute * state.Config.CertRenewAfterMin).Unix()}\n\tout, err := yaml.Marshal(renewinfo)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\terr = certstoreDir.Put(ctx, RenewalfileName, out)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tstate.RenewalInfoMutex.Lock()\n\tstate.Renewalinfo[domain] = renewinfo\n\tstate.RenewalInfoMutex.Unlock()\n\treturn []byte(newcert), nil\n}", "func LoadPrivateKey(keystorePath string) (bccsp.Key, crypto.Signer, error) {\n\tvar err error\n\tvar priv bccsp.Key\n\tvar s crypto.Signer\n\n\topts := &factory.FactoryOpts{\n\t\tProviderName: \"GMSW\",\n\t\tSwOpts: &factory.SwOpts{\n\t\t\tHashFamily: \"SM3\",\n\t\t\tSecLevel: 256,\n\n\t\t\tFileKeystore: &factory.FileKeystoreOpts{\n\t\t\t\tKeyStorePath: keystorePath,\n\t\t\t},\n\t\t},\n\t}\n\n\tcsp, err := factory.GetBCCSPFromOpts(opts)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\n\twalkFunc := func(path string, info os.FileInfo, err error) error {\n\t\tif strings.HasSuffix(path, \"_sk\") {\n\n\t\t\trawKey, err := ioutil.ReadFile(path)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\t//fmt.Println(\"rawKey\",rawKey)\n\n\t\t\tblock, _ := pem.Decode(rawKey)\n\t\t\tif block == nil {\n\t\t\t\treturn errors.Errorf(\"%s: wrong PEM encoding\", path)\n\t\t\t}\n\n\t\t\t//fmt.Println(\"block\",block.Bytes)\n\t\t\tpriv, err = csp.KeyImport(block.Bytes, &bccsp.SM2PrivateKeyImportOpts{Temporary: true})\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\t//fmt.Println(\"priv123\",priv)\n\t\t\ts, err = gmsigner.New(csp, priv)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn nil\n\t\t}\n\t\treturn nil\n\t}\n\n\terr = filepath.Walk(keystorePath, walkFunc)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn priv, s, err\n}", "func (f5 *f5LTM) AddCert(routename, hostname, cert, privkey,\n\tdestCACert string) error {\n\tif f5.privkey == \"\" {\n\t\treturn fmt.Errorf(\"Cannot configure TLS for route %s\"+\n\t\t\t\" because router was not provided an SSH private key\",\n\t\t\troutename)\n\t}\n\n\tvar deleteServerSslProfile,\n\t\tdeleteClientSslProfileFromVserver, deleteClientSslProfile,\n\t\tdeletePrivateKey, deleteCert, deleteCACert bool\n\n\tsuccess := false\n\n\tdefer func() {\n\t\tif success != true {\n\t\t\tf5.deleteCertParts(routename, false, deleteServerSslProfile,\n\t\t\t\tdeleteClientSslProfileFromVserver, deleteClientSslProfile,\n\t\t\t\tdeletePrivateKey, deleteCert, deleteCACert)\n\t\t}\n\t}()\n\n\tvar err error\n\n\tcertname := fmt.Sprintf(\"%s-https-cert\", routename)\n\terr = f5.uploadCert(cert, certname)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdeleteCert = true\n\n\tkeyname := fmt.Sprintf(\"%s-https-key\", routename)\n\terr = f5.uploadKey(privkey, keyname)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdeletePrivateKey = true\n\n\tclientSslProfileName := fmt.Sprintf(\"%s-client-ssl-profile\", routename)\n\terr = f5.createClientSslProfile(clientSslProfileName,\n\t\thostname, certname, keyname)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdeleteClientSslProfile = true\n\n\terr = f5.associateClientSslProfileWithVserver(clientSslProfileName,\n\t\tf5.httpsVserver)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdeleteClientSslProfileFromVserver = true\n\n\tif destCACert != \"\" {\n\t\tcacertname := fmt.Sprintf(\"%s-https-chain\", routename)\n\t\terr = f5.uploadCert(destCACert, cacertname)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdeleteCACert = true\n\n\t\tserverSslProfileName := fmt.Sprintf(\"%s-server-ssl-profile\", routename)\n\t\terr = f5.createServerSslProfile(serverSslProfileName,\n\t\t\thostname, cacertname)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdeleteServerSslProfile = true\n\n\t\terr = f5.associateServerSslProfileWithVserver(serverSslProfileName,\n\t\t\tf5.httpsVserver)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tsuccess = true\n\n\treturn nil\n}", "func NewCertReloader(certPath, keyPath string, logFile *os.File, cleanup func()) (*CertReloader, error) {\n\n\t// init reloader\n\treloader := &CertReloader{\n\t\tcertPath: certPath,\n\t\tkeyPath: keyPath,\n\t}\n\n\t// Load keypair\n\tcert, err := tls.LoadX509KeyPair(certPath, keyPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treloader.cert = &cert\n\n\t// kickoff routine for handling singals\n\tgo func() {\n\t\tsigChan := make(chan os.Signal, 1)\n\t\tsignal.Notify(sigChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGABRT)\n\t\tfor sig := range sigChan {\n\t\t\tif sig == syscall.SIGHUP {\n\t\t\t\tlog.Printf(\"Received SIGHUP, reloading TLS certificate and key from %q and %q\", certPath, keyPath)\n\t\t\t\treloader.reload()\n\t\t\t} else {\n\t\t\t\t// cleanup\n\t\t\t\terr := logFile.Close()\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(\"[FATAL] simplecert: failed to close logfile handle: \", err)\n\t\t\t\t}\n\t\t\t\tlog.Println(\"[INFO] simplecert: closed logfile handle\")\n\n\t\t\t\t// run custom cleanup func if available\n\t\t\t\tif cleanup != nil {\n\n\t\t\t\t\t// execute the cleanup function supplied by the user\n\t\t\t\t\t// if you want to keep the program running at this point, supply a cleanup function that does nothing.\n\t\t\t\t\tcleanup()\n\t\t\t\t} else {\n\t\t\t\t\t// if no cleanup function has been specified: exit cleanly\n\t\t\t\t\tos.Exit(0)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn reloader, nil\n}", "func (kv *FakeKeyVaultClient) ImportCertificate(arg0 context.Context, arg1, arg2 string, arg3 azkeyvault.CertificateImportParameters) (azkeyvault.CertificateBundle, error) {\n\treturn azkeyvault.CertificateBundle{}, fmt.Errorf(\"fake not implemented\")\n}", "func GenerateCert() (path string, err error) {\n\tpath, err = ioutil.TempDir(\"\", \"\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// generate a key\n\tprivKey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// create a certificate template\n\ttmpl := &x509.Certificate{\n\t\tSerialNumber: big.NewInt(1),\n\t\tSubject: pkix.Name{\n\t\t\tCommonName: \"jsonnet-controller\",\n\t\t\tOrganization: []string{\"pelotech\"},\n\t\t},\n\t\tDNSNames: []string{\n\t\t\t\"jsonnet-controller\",\n\t\t},\n\t\tNotBefore: time.Now(),\n\t\tNotAfter: time.Now().Add(time.Hour * 24 * 365),\n\t\tKeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,\n\t\tExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},\n\t\tBasicConstraintsValid: true,\n\t}\n\n\t// self-sign the certificate\n\tderBytes, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &privKey.PublicKey, privKey)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Write files to disk\n\tcertPath := filepath.Join(path, \"tls.crt\")\n\tkeyPath := filepath.Join(path, \"tls.key\")\n\n\tcf, err := os.Create(certPath)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer cf.Close()\n\tif err = pem.Encode(cf, &pem.Block{Type: \"CERTIFICATE\", Bytes: derBytes}); err != nil {\n\t\treturn\n\t}\n\n\tkf, err := os.Create(keyPath)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer kf.Close()\n\tif err = pem.Encode(kf, &pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(privKey)}); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func GenerateTLSCertificate(conf CertConf) error {\n\n\tserial := generateSerilaNumber(conf)\n\tkey, err := rsa.GenerateKey(conf.Random, conf.RASBits)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not generate RSA key, %v\", err)\n\t}\n\n\tcert := generateCert(conf, key, serial)\n\twriteKey := writeKeyPem(conf, key)\n\twriteCert := writeCertPem(conf, cert)\n\n\terrKey := <-writeKey\n\terrCert := <-writeCert\n\tif errKey != nil {\n\t\treturn errKey\n\t}\n\tif errCert != nil {\n\t\treturn errCert\n\t}\n\n\treturn nil\n}", "func (c CertificateKey) TLSCertificate() tls.Certificate {\n\treturn c.tlsCert\n}", "func LoadCertificateFromPEMBytes(pemBytes []byte) (*Certificate, error) {\n\tblock, _ := pem.Decode(pemBytes)\n\tif block == nil {\n\t\treturn nil, fmt.Errorf(\"Unable to decode PEM encoded certificate\")\n\t}\n\treturn bytesToCert(block.Bytes)\n}", "func readCert(t *testing.T) []byte {\n\tcert, err := ioutil.ReadFile(\"testdata/root.pem\")\n\tif err != nil {\n\t\tt.Fatalf(\"Error reading cert: %s\", err.Error())\n\t}\n\treturn cert\n}", "func readCert(t *testing.T) []byte {\n\tcert, err := ioutil.ReadFile(\"testdata/root.pem\")\n\tif err != nil {\n\t\tt.Fatalf(\"Error reading cert: %s\", err.Error())\n\t}\n\treturn cert\n}", "func GenerateAndSignLeafCert(commonName string,\n serialNumber int64,\n countryCode string,\n organizationalUnit string,\n algo string,\n ecCurve string,\n rootCADER []byte,\n rootPrivateKeyDER []byte) (leafCertDER []byte, leafCertPrivateKeyDER []byte, err error) {\n\n notBefore := time.Now().UTC()\n notAfter := notBefore.AddDate(LeafValidity, 0, 0) // (years, months, days)\n\n // Check inputs before doing things (zomg timing attacks, someone call the cryptographers /s)\n\n // https://golang.org/pkg/crypto/x509/#ParseCertificate\n rootCA, err := x509.ParseCertificate(rootCADER)\n if err != nil {\n return nil, nil, err\n }\n\n // Now we need to parse the private key\n // First we need to discover the private key algorithm (RSA vs ECDSA)\n // The algorithm is the same as rootCA.PublicKeyAlgorithm\n // https://golang.org/pkg/crypto/x509/#PublicKeyAlgorithm\n\n // We also need to match the signature hashing algorithm with private key of rootCA\n // Both should either be RSA or ECDSA\n // We will start with RSA and change it to ECDSA if we need to\n hashingAlgorithm := x509.SHA256WithRSA\n\n var rootCAPrivateKey interface{}\n\n rootCAPrivateKey, rootCAKeyAlgorithm, err := ParsePrivateKey(rootPrivateKeyDER)\n if err != nil {\n return nil, nil, errors.New(\"Could not parse CA private key\")\n }\n\n switch rootCAKeyAlgorithm {\n case \"EC\":\n hashingAlgorithm = x509.ECDSAWithSHA256\n // Not really needed\n case \"RSA\":\n hashingAlgorithm = x509.SHA256WithRSA\n default:\n return nil, nil, errors.New(\"Root CA private key algorithm is neither RSA nor ECDSA\")\n }\n\n leafCertTemplate := x509.Certificate{\n\n Subject: pkix.Name{\n CommonName: commonName,\n Country: []string{countryCode},\n Organization: []string{organizationalUnit},\n },\n\n NotBefore: notBefore,\n NotAfter: notAfter,\n SerialNumber: big.NewInt(serialNumber),\n KeyUsage: RootCAKeyUsage,\n\n // For CAs we at least want []x509.ExtKeyUsage{x509.ExtKeyUsageAny | x509.KeyUsageCertSign}\n // More info: https://golang.org/pkg/crypto/x509/#ExtKeyUsage\n ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageAny}, // this should work\n BasicConstraintsValid: false, // not a root CA\n\n SignatureAlgorithm: hashingAlgorithm, // other options are at https://golang.org/pkg/crypto/x509/#SignatureAlgorithm\n }\n\n privKey, pubKey, err := generateKeyPair(algo, ecCurve)\n if err != nil {\n return nil, nil, err\n }\n\n // https://golang.org/pkg/crypto/x509/#CreateCertificate\n // First template is the cert being signed and the second is signer\n // Public key belongs to singee and private key belongs to signer\n leafCertDER, err = x509.CreateCertificate(rand.Reader, &leafCertTemplate, rootCA, pubKey, rootCAPrivateKey)\n if err != nil {\n return nil, nil, err\n }\n\n leafCertPrivateKeyDER, err = MarshalPrivateKey(privKey)\n\n return leafCertDER, leafCertPrivateKeyDER, err\n}", "func (t *token) createSecret(printf shared.FormatFn) error {\n\tvar verbosef = shared.NoPrintf\n\tif t.Verbose {\n\t\tverbosef = printf\n\t}\n\n\tjwkSet := &jwk.Set{}\n\tverbosef(\"retrieving existing certificates...\")\n\n\tvar err error\n\tif t.truncate > 1 { // if 1, just skip old stuff\n\t\t// old jwks\n\t\tjwksURL := fmt.Sprintf(certsURLFormat, t.RemoteServiceProxyURL)\n\t\tjwkSet, err = jwk.FetchHTTP(jwksURL)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"fetching jwks\")\n\t\t}\n\t\tjwksBytes, err := json.Marshal(jwkSet)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"marshalling JSON\")\n\t\t}\n\t\tverbosef(\"old jkws...\\n%s\", string(jwksBytes))\n\t}\n\n\tt.keyID = time.Now().Format(time.RFC3339)\n\tprivateKey, err := rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"generating key\")\n\t}\n\n\t// jwks\n\tkey, err := jwk.New(&privateKey.PublicKey)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"generating jwks\")\n\t}\n\tkey.Set(jwk.KeyIDKey, t.keyID)\n\tkey.Set(jwk.AlgorithmKey, jwa.RS256.String())\n\n\tjwkSet.Keys = append(jwkSet.Keys, key)\n\n\t// sort increasing and truncate\n\tsort.Sort(sort.Reverse(byKID(jwkSet.Keys)))\n\tif t.truncate > 0 {\n\t\tjwkSet.Keys = jwkSet.Keys[:t.truncate]\n\t}\n\n\tjwksBytes, err := json.Marshal(jwkSet)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"marshalling JSON\")\n\t}\n\tverbosef(\"new jkws...\\n%s\", string(jwksBytes))\n\n\t// private key\n\tkeyBytes := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\",\n\t\tBytes: x509.MarshalPKCS1PrivateKey(privateKey)})\n\n\t// kid\n\tkidProp := fmt.Sprintf(kidSecretPropFormat, t.keyID)\n\n\t// Secret CRD\n\tdata := map[string]string{\n\t\tjwksSecretKey: base64.StdEncoding.EncodeToString(jwksBytes),\n\t\tkeySecretKey: base64.StdEncoding.EncodeToString(keyBytes),\n\t\tkidSecretKey: base64.StdEncoding.EncodeToString([]byte(kidProp)),\n\t}\n\n\tcrd := shared.KubernetesCRD{\n\t\tAPIVersion: \"v1\",\n\t\tKind: \"Secret\",\n\t\tType: \"Opaque\",\n\t\tMetadata: shared.Metadata{\n\t\t\tName: fmt.Sprintf(policySecretNameFormat, t.Org, t.Env),\n\t\t\tNamespace: t.namespace,\n\t\t},\n\t\tData: data,\n\t}\n\n\t// encode as YAML\n\tvar yamlBuffer bytes.Buffer\n\tyamlEncoder := yaml.NewEncoder(&yamlBuffer)\n\tyamlEncoder.SetIndent(2)\n\terr = yamlEncoder.Encode(crd)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"encoding YAML\")\n\t}\n\n\tprintf(\"# Secret for apigee-remote-service-envoy\")\n\tprintf(\"# generated by apigee-remote-service-cli provision on %s\", time.Now().Format(\"2006-01-02 15:04:05\"))\n\tprintf(yamlBuffer.String())\n\treturn nil\n}", "func LoadCertificates(publicCertificate, privateCertificate string) error {\n\tvar err error\n\tcertificateLoader.Do(func() {\n\t\terr = loadCertificates(publicCertificate, privateCertificate)\n\t})\n\n\treturn err\n}", "func newVaultClientTLSSecret(vr *api.VaultService, caCrt *x509.Certificate) *v1.Secret {\n\treturn &v1.Secret{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"Secret\",\n\t\t\tAPIVersion: \"v1\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: api.DefaultVaultClientTLSSecretName(vr.Name),\n\t\t\tNamespace: vr.Namespace,\n\t\t\tLabels: labelsForVault(vr.Name),\n\t\t},\n\t\tData: map[string][]byte{\n\t\t\tapi.CATLSCertName: tls.EncodeCertificatePEM(caCrt),\n\t\t},\n\t}\n}", "func LoadPemEncodedCertificate(name string) (certificate *x509.Certificate, err error) {\n\tvar content []byte\n\n\tif content, err = Load(name); err != nil {\n\t\tlog.Fatalf(\"%s\\n\", err)\n\t} else {\n\t\tcertificate, err = tlsutil.ParsePEMEncodedCACert(content)\n\t\tif err != nil {\n\t\t\tlog.Println(\"LoadPemEncodedCertificate\", name)\n\t\t\tpanic(err)\n\t\t}\n\t\tif app.Debug {\n\t\t\tfmt.Println(Jsonify(certificate))\n\t\t}\n\t}\n\treturn certificate, err\n}", "func LoadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) {\n\tcertPEMBlock, err := ioutil.ReadFile(certFile)\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\tkeyPEMBlock, err := ioutil.ReadFile(keyFile)\n\tif err != nil {\n\t\treturn tls.Certificate{}, err\n\t}\n\treturn X509KeyPair(certPEMBlock, keyPEMBlock)\n}", "func AddOrUpdateCertAndKey(name string, cert, key, ca []byte) (*ingress.SSLCert, error) {\n\tpemName := fmt.Sprintf(\"%v.pem\", name)\n\tpemFileName := fmt.Sprintf(\"%v/%v\", ingress.DefaultCrtDirectory, pemName)\n\n\ttempPemFile, err := ioutil.TempFile(ingress.DefaultCrtDirectory, pemName)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not create temp pem file %v: %v\", pemFileName, err)\n\t}\n\tklog.V(3).Infof(\"Creating temp file %v for Keypair: %v\", tempPemFile.Name(), pemName)\n\n\t// Controller v0.14 and older should be running as root, so trying to change\n\t// tmpfile owner to haproxy PID, in that case it has a chance to read if running\n\t// as a sidecar. No problem if err, should be permission due to controller not\n\t// be running as root. HAProxy sidecar should be running as 99 or 0, so no\n\t// problem as well. Other HAProxy distros might be using another PID, which\n\t// this change won't be neither helping nor impacting.\n\t_ = os.Chown(tempPemFile.Name(), 99, 99)\n\n\t_, err = tempPemFile.Write(cert)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not write to pem file %v: %v\", tempPemFile.Name(), err)\n\t}\n\t_, err = tempPemFile.Write([]byte(\"\\n\"))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not write to pem file %v: %v\", tempPemFile.Name(), err)\n\t}\n\t_, err = tempPemFile.Write(key)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not write to pem file %v: %v\", tempPemFile.Name(), err)\n\t}\n\n\terr = tempPemFile.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not close temp pem file %v: %v\", tempPemFile.Name(), err)\n\t}\n\n\tpemCerts, err := ioutil.ReadFile(tempPemFile.Name())\n\tif err != nil {\n\t\t_ = os.Remove(tempPemFile.Name())\n\t\treturn nil, err\n\t}\n\n\tpemBlock, _ := pem.Decode(pemCerts)\n\tif pemBlock == nil {\n\t\t_ = os.Remove(tempPemFile.Name())\n\t\treturn nil, fmt.Errorf(\"no valid PEM formatted block found\")\n\t}\n\n\t// If the file does not start with 'BEGIN CERTIFICATE' it's invalid and must not be used.\n\tif pemBlock.Type != \"CERTIFICATE\" {\n\t\t_ = os.Remove(tempPemFile.Name())\n\t\treturn nil, fmt.Errorf(\"certificate %v contains invalid data, and must be created with 'kubectl create secret tls'\", name)\n\t}\n\n\tpemCert, err := x509.ParseCertificate(pemBlock.Bytes)\n\tif err != nil {\n\t\t_ = os.Remove(tempPemFile.Name())\n\t\treturn nil, err\n\t}\n\n\t//Ensure that certificate and private key have a matching public key\n\tif _, err := tls.X509KeyPair(cert, key); err != nil {\n\t\t_ = os.Remove(tempPemFile.Name())\n\t\treturn nil, err\n\t}\n\n\tcn := sets.NewString(pemCert.Subject.CommonName)\n\tfor _, dns := range pemCert.DNSNames {\n\t\tif !cn.Has(dns) {\n\t\t\tcn.Insert(dns)\n\t\t}\n\t}\n\n\tif len(pemCert.Extensions) > 0 {\n\t\tklog.V(3).Info(\"parsing ssl certificate extensions\")\n\t\tfor _, ext := range getExtension(pemCert, oidExtensionSubjectAltName) {\n\t\t\tdns, _, _, err := parseSANExtension(ext.Value)\n\t\t\tif err != nil {\n\t\t\t\tklog.Warningf(\"unexpected error parsing certificate extensions: %v\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor _, dns := range dns {\n\t\t\t\tif !cn.Has(dns) {\n\t\t\t\t\tcn.Insert(dns)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\terr = os.Rename(tempPemFile.Name(), pemFileName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not move temp pem file %v to destination %v: %v\", tempPemFile.Name(), pemFileName, err)\n\t}\n\n\tif len(ca) > 0 {\n\t\tbundle := x509.NewCertPool()\n\t\tbundle.AppendCertsFromPEM(ca)\n\n\t\tintBundle := x509.NewCertPool()\n\t\tintBundle.AppendCertsFromPEM(cert)\n\n\t\topts := x509.VerifyOptions{\n\t\t\tRoots: bundle,\n\t\t\tIntermediates: intBundle,\n\t\t}\n\n\t\t_, err := pemCert.Verify(opts)\n\t\tif err != nil {\n\t\t\toe := fmt.Sprintf(\"failed to verify certificate chain: \\n\\t%s\\n\", err)\n\t\t\treturn nil, errors.New(oe)\n\t\t}\n\n\t\tcaFile, err := os.OpenFile(pemFileName, os.O_RDWR|os.O_APPEND, 0600)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not open file %v for writing additional CA chains: %v\", pemFileName, err)\n\t\t}\n\n\t\tdefer caFile.Close()\n\t\t_, err = caFile.Write([]byte(\"\\n\"))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not append CA to cert file %v: %v\", pemFileName, err)\n\t\t}\n\t\tcaFile.Write(ca)\n\t\tcaFile.Write([]byte(\"\\n\"))\n\n\t\treturn &ingress.SSLCert{\n\t\t\tCertificate: pemCert,\n\t\t\tCAFileName: pemFileName,\n\t\t\tPemFileName: pemFileName,\n\t\t\tPemSHA: file.SHA1(pemFileName),\n\t\t\tCN: cn.List(),\n\t\t\tExpireTime: pemCert.NotAfter,\n\t\t}, nil\n\t}\n\n\treturn &ingress.SSLCert{\n\t\tCertificate: pemCert,\n\t\tPemFileName: pemFileName,\n\t\tPemSHA: file.SHA1(pemFileName),\n\t\tCN: cn.List(),\n\t\tExpireTime: pemCert.NotAfter,\n\t}, nil\n}", "func (s *secretRenewer) sign(token string) (*tls.Certificate, *http.Transport, error) {\n\treq, pk, err := ca.CreateSignRequest(token)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tsign, err := s.client.Sign(req)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn s.createCertAndTransport(sign, pk)\n}", "func LoadCertificate(path string) (*x509.Certificate, error) {\n\trawData, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, errors.WithStackTrace(err)\n\t}\n\tcertificatePemBlock, _ := pem.Decode(rawData)\n\tcertificate, err := x509.ParseCertificate(certificatePemBlock.Bytes)\n\tif err != nil {\n\t\treturn nil, errors.WithStackTrace(err)\n\t}\n\treturn certificate, nil\n}", "func TLSServingCertificateReconciler(data tlsServingCertReconcilerData) reconciling.NamedSecretReconcilerFactory {\n\treturn func() (string, reconciling.SecretReconciler) {\n\t\treturn resources.OperatingSystemManagerWebhookServingCertSecretName, func(se *corev1.Secret) (*corev1.Secret, error) {\n\t\t\tif se.Data == nil {\n\t\t\t\tse.Data = map[string][]byte{}\n\t\t\t}\n\n\t\t\tca, err := data.GetRootCA()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to get root ca: %w\", err)\n\t\t\t}\n\n\t\t\tcommonName := fmt.Sprintf(\"%s.%s.svc.cluster.local.\", resources.OperatingSystemManagerWebhookServiceName, data.Cluster().Status.NamespaceName)\n\t\t\taltNames := certutil.AltNames{\n\t\t\t\tDNSNames: []string{\n\t\t\t\t\tresources.OperatingSystemManagerWebhookServiceName,\n\t\t\t\t\tfmt.Sprintf(\"%s.%s\", resources.OperatingSystemManagerWebhookServiceName, data.Cluster().Status.NamespaceName),\n\t\t\t\t\tcommonName,\n\t\t\t\t\tfmt.Sprintf(\"%s.%s.svc\", resources.OperatingSystemManagerWebhookServiceName, data.Cluster().Status.NamespaceName),\n\t\t\t\t\tfmt.Sprintf(\"%s.%s.svc.\", resources.OperatingSystemManagerWebhookServiceName, data.Cluster().Status.NamespaceName),\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tif b, exists := se.Data[resources.OperatingSystemManagerWebhookServingCertCertKeyName]; exists {\n\t\t\t\tcerts, err := certutil.ParseCertsPEM(b)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to parse certificate (key=%s) from existing secret: %w\", resources.OperatingSystemManagerWebhookServingCertCertKeyName, err)\n\t\t\t\t}\n\t\t\t\tif resources.IsServerCertificateValidForAllOf(certs[0], commonName, altNames, ca.Cert) {\n\t\t\t\t\treturn se, nil\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnewKP, err := triple.NewServerKeyPair(ca,\n\t\t\t\tcommonName,\n\t\t\t\tresources.OperatingSystemManagerWebhookServiceName,\n\t\t\t\tdata.Cluster().Status.NamespaceName,\n\t\t\t\t\"\",\n\t\t\t\tnil,\n\t\t\t\t// For some reason the name the APIServer validates against must be in the SANs, having it as CN is not enough\n\t\t\t\t[]string{commonName})\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to generate serving cert: %w\", err)\n\t\t\t}\n\n\t\t\tse.Data[resources.OperatingSystemManagerWebhookServingCertCertKeyName] = triple.EncodeCertPEM(newKP.Cert)\n\t\t\tse.Data[resources.OperatingSystemManagerWebhookServingCertKeyKeyName] = triple.EncodePrivateKeyPEM(newKP.Key)\n\t\t\t// Include the CA for simplicity\n\t\t\tse.Data[resources.CACertSecretKey] = triple.EncodeCertPEM(ca.Cert)\n\n\t\t\treturn se, nil\n\t\t}\n\t}\n}" ]
[ "0.67040336", "0.6692501", "0.64090234", "0.619866", "0.61599535", "0.614306", "0.60478413", "0.60309976", "0.6009421", "0.5974995", "0.5934542", "0.5929582", "0.58173513", "0.5784342", "0.5741942", "0.56803405", "0.56732273", "0.56301534", "0.5622985", "0.56219256", "0.55680686", "0.5564073", "0.5505776", "0.5479459", "0.5469945", "0.545755", "0.5456615", "0.5428351", "0.5421133", "0.54012126", "0.53946674", "0.5394573", "0.5388714", "0.5376524", "0.5355509", "0.5354119", "0.5347753", "0.5342229", "0.5331119", "0.5320723", "0.5302813", "0.52718866", "0.52665955", "0.52573436", "0.5251344", "0.5250075", "0.5247108", "0.52457047", "0.52357346", "0.52230066", "0.5218283", "0.5216258", "0.5208971", "0.52048445", "0.5180193", "0.5159575", "0.5142308", "0.51363635", "0.5125207", "0.51150405", "0.5113474", "0.51053524", "0.50978446", "0.50940716", "0.5092242", "0.5089748", "0.50888187", "0.5086201", "0.5085613", "0.5083509", "0.5070258", "0.50691164", "0.5064625", "0.5057463", "0.50552356", "0.50464743", "0.5029492", "0.5021605", "0.5014444", "0.5008251", "0.5002009", "0.4994533", "0.4987463", "0.49773112", "0.49753234", "0.4967237", "0.49650344", "0.49641424", "0.4961817", "0.4961817", "0.49598455", "0.4955678", "0.49523652", "0.49513474", "0.49420664", "0.49414343", "0.49388546", "0.49340072", "0.49316123", "0.4928086" ]
0.805537
0
createTLSConfig creates a TLS config based on given config
func createTLSConfig(cert, key string) (*tls.Config, error) { var result *tls.Config c, err := tls.X509KeyPair([]byte(cert), []byte(key)) if err != nil { return nil, errors.WithStack(err) } result = &tls.Config{ Certificates: []tls.Certificate{c}, } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func createTLSConfig(certFile, keyFile string) (*tls.Config, error) {\n\tvar err error\n\tconfig := &tls.Config{}\n\tconfig.Certificates = make([]tls.Certificate, 1)\n\tconfig.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn config, nil\n}", "func createTlsConfiguration(certFile string, keyFile string, caFile string, verifySsl bool) (t *tls.Config) {\n\tif certFile != \"\" && keyFile != \"\" && caFile != \"\" {\n\t\tcert, err := tls.LoadX509KeyPair(certFile, keyFile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tcaCert, err := ioutil.ReadFile(caFile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tcaCertPool := x509.NewCertPool()\n\t\tcaCertPool.AppendCertsFromPEM(caCert)\n\n\t\tt = &tls.Config{\n\t\t\tCertificates: []tls.Certificate{cert},\n\t\t\tRootCAs: caCertPool,\n\t\t\tInsecureSkipVerify: verifySsl,\n\t\t}\n\t}\n\treturn t\n}", "func createTlsConfig() {\n\n}", "func GenerateTLSConfig() *tls.Config {\n\tkey, err := rsa.GenerateKey(crand.Reader, 1024)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttemplate := x509.Certificate{SerialNumber: big.NewInt(1)}\n\tcertDER, err := x509.CreateCertificate(crand.Reader, &template, &template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tkeyPEM := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(key)})\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\n\ttlsCert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{tlsCert},\n\t\tNextProtos: []string{\"exemplo\"},\n\t}\n}", "func generateTLSConfig() *tls.Config {\n\tkey, err := rsa.GenerateKey(rand.Reader, 1024)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttemplate := x509.Certificate{SerialNumber: big.NewInt(1)}\n\tcertDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tkeyPEM := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(key)})\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\n\ttlsCert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &tls.Config{Certificates: []tls.Certificate{tlsCert}}\n}", "func generateTLSConfig() *tls.Config {\n\tkey, err := rsa.GenerateKey(rand.Reader, 1024)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttemplate := x509.Certificate{SerialNumber: big.NewInt(1)}\n\tcertDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tkeyPEM := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(key)})\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\n\ttlsCert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &tls.Config{Certificates: []tls.Certificate{tlsCert}}\n}", "func generateTLSConfig() *tls.Config {\n\tkey, err := rsa.GenerateKey(rand.Reader, 1024)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttemplate := x509.Certificate{SerialNumber: big.NewInt(1)}\n\tcertDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tkeyPEM := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(key)})\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\n\ttlsCert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &tls.Config{Certificates: []tls.Certificate{tlsCert}}\n}", "func generateTLSConfig() *tls.Config {\n\tkey, err := rsa.GenerateKey(rand.Reader, 1024)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttemplate := x509.Certificate{SerialNumber: big.NewInt(1)}\n\tcertDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tkeyPEM := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(key)})\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\n\ttlsCert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &tls.Config{Certificates: []tls.Certificate{tlsCert}}\n}", "func generateTLSConfig(k string) *tls.Config {\n\n\tkey, err := rsa.GenerateKey(rand.Reader, 1024)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttemplate := x509.Certificate{SerialNumber: big.NewInt(1)}\n\tcertDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tkeyPEM := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(key)})\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\n\ttlsCert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{tlsCert},\n\t\tNextProtos: []string{k},\n\t}\n}", "func GenerateTLSConfig(config TLSHelperConfig) (tlsCfg *tls.Config, reloadConfig func(), err error) {\n\twrapper := new(wrapperTLSConfig)\n\ttlsCfg = new(tls.Config)\n\twrapper.config = tlsCfg\n\n\tcert, err := parseCertificate(config.CertRequired, config.Cert, config.Key)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tif cert != nil {\n\t\ttlsCfg.Certificates = []tls.Certificate{*cert}\n\t\tpool, err := generateCertPool(config.RootCACert, config.UseSystemCACerts)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tswitch config.ConfigType {\n\t\tcase TLSClientConfig:\n\t\t\ttlsCfg.RootCAs = pool\n\n\t\tcase TLSServerConfig:\n\t\t\twrapper.cert = &wrapperCert{cert: cert}\n\t\t\ttlsCfg.GetCertificate = wrapper.getCertificate\n\t\t\ttlsCfg.VerifyPeerCertificate = wrapper.verifyPeerCertificate\n\t\t\ttlsCfg.ClientCAs = pool\n\t\t\twrapper.clientCAPool = &wrapperCAPool{pool: pool}\n\t\t}\n\t}\n\n\tauth, err := setupClientAuth(config.ClientAuth)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// If the client cert is required to be checked with the CAs\n\tif auth >= tls.VerifyClientCertIfGiven {\n\t\t// A custom cert validation is set because the current implementation is\n\t\t// not thread safe, it's needed bypass that validation and manually\n\t\t// manage the different cases, for that reason, the wrapper is\n\t\t// configured with the real auth level and the tlsCfg is only set with a\n\t\t// auth level who are a simile but without the use of any CA\n\t\tif auth == tls.VerifyClientCertIfGiven {\n\t\t\ttlsCfg.ClientAuth = tls.RequestClientCert\n\t\t} else {\n\t\t\ttlsCfg.ClientAuth = tls.RequireAnyClientCert\n\t\t}\n\t\twrapper.clientAuth = auth\n\t} else {\n\t\t// it's not necessary a external validation with the CAs, so the wrapper\n\t\t// is not used\n\t\ttlsCfg.ClientAuth = auth\n\t}\n\n\ttlsCfg.MinVersion = tls.VersionTLS11\n\ttlsCfg.MaxVersion = tls.VersionTLS12\n\ttlsCfg.ServerName = config.ServerName\n\n\tif config.ConfigType == TLSClientConfig {\n\t\treturn tlsCfg, nil, nil\n\t}\n\n\twrapper.helperConfig = &config\n\treturn tlsCfg, wrapper.reloadConfig, nil\n}", "func generateTLSConfig() *tls.Config {\n\tkey, err := rsa.GenerateKey(rand.Reader, 1024)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttemplate := x509.Certificate{SerialNumber: big.NewInt(1)}\n\tcertDER, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tkeyPEM := pem.EncodeToMemory(&pem.Block{Type: \"RSA PRIVATE KEY\", Bytes: x509.MarshalPKCS1PrivateKey(key)})\n\tcertPEM := pem.EncodeToMemory(&pem.Block{Type: \"CERTIFICATE\", Bytes: certDER})\n\n\ttlsCert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{tlsCert},\n\t\tNextProtos: []string{\"quic-echo-example\"},\n\t}\n}", "func configureTLS(\n\tsaramaConf *sarama.Config, tlsConf *config.TLS,\n) (*sarama.Config, error) {\n\ttlsConfig, err := vtls.BuildTLSConfig(\n\t\ttlsConf.CertFile,\n\t\ttlsConf.KeyFile,\n\t\ttlsConf.TruststoreFile,\n\t)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif tlsConfig != nil {\n\t\tsaramaConf.Net.TLS.Config = tlsConfig\n\t\tsaramaConf.Net.TLS.Enable = true\n\t}\n\n\treturn saramaConf, nil\n}", "func newTLSConfig(clientCert, clientKey, caCert string) (*tls.Config, error) {\n\tvalid := false\n\n\tconfig := &tls.Config{}\n\n\tif clientCert != \"\" && clientKey != \"\" {\n\t\tcert, err := tls.X509KeyPair([]byte(clientCert), []byte(clientKey))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tconfig.Certificates = []tls.Certificate{cert}\n\t\tconfig.BuildNameToCertificate()\n\t\tvalid = true\n\t}\n\n\tif caCert != \"\" {\n\t\tcaCertPool := x509.NewCertPool()\n\t\tcaCertPool.AppendCertsFromPEM([]byte(caCert))\n\t\tconfig.RootCAs = caCertPool\n\t\t// The CN of Heroku Kafka certs do not match the hostname of the\n\t\t// broker, but Go's default TLS behavior requires that they do.\n\t\tconfig.VerifyPeerCertificate = verifyCertSkipHostname(caCertPool)\n\t\tconfig.InsecureSkipVerify = true\n\t\tvalid = true\n\t}\n\n\tif !valid {\n\t\tconfig = nil\n\t}\n\n\treturn config, nil\n}", "func newTLSConfig(clientCert, clientKey, caCert string) (*tls.Config, error) {\n\tvalid := false\n\n\tconfig := &tls.Config{}\n\n\tif clientCert != \"\" && clientKey != \"\" {\n\t\tcert, err := tls.X509KeyPair([]byte(clientCert), []byte(clientKey))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tconfig.Certificates = []tls.Certificate{cert}\n\t\tconfig.BuildNameToCertificate()\n\t\tvalid = true\n\t}\n\n\tif caCert != \"\" {\n\t\tcaCertPool := x509.NewCertPool()\n\t\tcaCertPool.AppendCertsFromPEM([]byte(caCert))\n\t\tconfig.RootCAs = caCertPool\n\t\t// The CN of Heroku Kafka certs do not match the hostname of the\n\t\t// broker, but Go's default TLS behavior requires that they do.\n\t\tconfig.VerifyPeerCertificate = verifyCertSkipHostname(caCertPool)\n\t\tconfig.InsecureSkipVerify = true\n\t\tvalid = true\n\t}\n\n\tif !valid {\n\t\tconfig = nil\n\t}\n\n\treturn config, nil\n}", "func TLSConfig(enabled bool, caPool *x509.CertPool) (opt urls.Option, config *tls.Config) {\n\topt = urls.Scheme(\"http\")\n\tif enabled {\n\t\topt = urls.Scheme(\"https\")\n\t\tif caPool != nil {\n\t\t\tconfig = &tls.Config{\n\t\t\t\tRootCAs: caPool,\n\t\t\t}\n\t\t} else {\n\t\t\t// do HTTPS without verifying the Mesos master certificate\n\t\t\tconfig = &tls.Config{\n\t\t\t\tInsecureSkipVerify: true,\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func TLSConfig(enabled bool, caPool *x509.CertPool, cert tls.Certificate) (opt urls.Option, config *tls.Config) {\n\topt = urls.Scheme(\"http\")\n\tif enabled {\n\t\topt = urls.Scheme(\"https\")\n\t\tconfig = &tls.Config{\n\t\t\tCertificates: \t\t[]tls.Certificate{cert},\n\t\t\tRootCAs: caPool,\n\t\t\tInsecureSkipVerify: caPool == nil,\n\t\t}\n\t}\n\treturn\n}", "func (k *KafkaWriterConfig) GenerateTLSConfig(cfg *KafkaWriterConfig) error {\n\tif strings.ToLower(cfg.TLSEnabled) != \"true\" {\n\t\treturn nil\n\t}\n\n\tif cfg.TLSCertFile == \"\" || cfg.TLSKeyFile == \"\" {\n\t\treturn errors.New(\"TLS Cert File/Key missing\")\n\t}\n\n\tcert, err := tls.LoadX509KeyPair(cfg.TLSCertFile, cfg.TLSKeyFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar caCertPool *x509.CertPool\n\n\tif cfg.CAFile != \"\" {\n\t\tcaCert, err := ioutil.ReadFile(cfg.CAFile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"kafka TLS CA file error: \", err)\n\t\t}\n\t\tcaCertPool = x509.NewCertPool()\n\t\tcaCertPool.AppendCertsFromPEM(caCert)\n\t}\n\n\tk.TLSConfig = &tls.Config{\n\t\tCertificates: []tls.Certificate{cert},\n\t\tRootCAs: caCertPool,\n\t\tInsecureSkipVerify: strings.ToLower(cfg.TLSSkipVerify) == \"true\",\n\t}\n\n\treturn nil\n}", "func NewTlsConfig(t *Tls, extra ...PeerVerifier) (*tls.Config, error) {\n\tif t == nil {\n\t\treturn nil, nil\n\t}\n\n\tif len(t.CertificateFile) == 0 || len(t.KeyFile) == 0 {\n\t\treturn nil, ErrTlsCertificateRequired\n\t}\n\n\tvar nextProtos []string\n\tif len(t.NextProtos) > 0 {\n\t\tnextProtos = append(nextProtos, t.NextProtos...)\n\t} else {\n\t\t// assume http/1.1 by default\n\t\tnextProtos = append(nextProtos, \"http/1.1\")\n\t}\n\n\ttc := &tls.Config{ // nolint: gosec\n\t\tMinVersion: t.MinVersion,\n\t\tMaxVersion: t.MaxVersion,\n\t\tServerName: t.ServerName,\n\t\tNextProtos: nextProtos,\n\n\t\t// disable vulnerable ciphers\n\t\tCipherSuites: []uint16{\n\t\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,\n\t\t\ttls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,\n\t\t},\n\t}\n\n\t// if no MinVersion was set, default to TLS 1.2\n\tif tc.MinVersion == 0 {\n\t\ttc.MinVersion = tls.VersionTLS12\n\t}\n\n\tif pvs := NewPeerVerifiers(t.PeerVerify, extra...); len(pvs) > 0 {\n\t\ttc.VerifyPeerCertificate = pvs.VerifyPeerCertificate\n\t}\n\n\tif cert, err := tls.LoadX509KeyPair(t.CertificateFile, t.KeyFile); err != nil {\n\t\treturn nil, err\n\t} else {\n\t\ttc.Certificates = []tls.Certificate{cert}\n\t}\n\n\tif len(t.ClientCACertificateFile) > 0 {\n\t\tcaCert, err := os.ReadFile(t.ClientCACertificateFile)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tcaCertPool := x509.NewCertPool()\n\t\tif !caCertPool.AppendCertsFromPEM(caCert) {\n\t\t\treturn nil, ErrUnableToAddClientCACertificate\n\t\t}\n\n\t\ttc.ClientCAs = caCertPool\n\t\ttc.ClientAuth = tls.RequireAndVerifyClientCert\n\t}\n\n\ttc.BuildNameToCertificate() // nolint: staticcheck\n\treturn tc, nil\n}", "func TLSConfig(crtName string, skipInsecureVerify bool) (*tls.Config, error) {\n\tappConfig, err := GetAppConfig()\n\tif err != nil {\n\t\tlog.Error(\"Get app config error.\", nil)\n\t\treturn nil, err\n\t}\n\tcertNameConfig := appConfig[crtName]\n\tif len(certNameConfig) == 0 {\n\t\tlog.Errorf(nil, \"Certificate(%s) path doesn't available in the app config.\", crtName)\n\t\treturn nil, errors.New(\"cert name configuration is not set\")\n\t}\n\n\tcrt, err := ioutil.ReadFile(certNameConfig)\n\tif err != nil {\n\t\tlog.Error(\"Unable to read certificate.\", nil)\n\t\treturn nil, err\n\t}\n\n\trootCAs := x509.NewCertPool()\n\tok := rootCAs.AppendCertsFromPEM(crt)\n\tif !ok {\n\t\tlog.Error(\"Failed to decode the certificate file.\", nil)\n\t\treturn nil, errors.New(\"failed to decode cert file\")\n\t}\n\n\tserverName := appConfig[\"server_name\"]\n\tserverNameIsValid, validateServerNameErr := validateServerName(serverName)\n\tif validateServerNameErr != nil || !serverNameIsValid {\n\t\tlog.Error(\"Validate server name error.\", nil)\n\t\treturn nil, validateServerNameErr\n\t}\n\tsslCiphers := appConfig[\"ssl_ciphers\"]\n\tif len(sslCiphers) == 0 {\n\t\treturn nil, errors.New(\"TLS cipher configuration is not recommended or invalid\")\n\t}\n\tcipherSuites := getCipherSuites(sslCiphers)\n\tif cipherSuites == nil {\n\t\treturn nil, errors.New(\"TLS cipher configuration is not recommended or invalid\")\n\t}\n\treturn &tls.Config{\n\t\tRootCAs: rootCAs,\n\t\tServerName: serverName,\n\t\tMinVersion: tls.VersionTLS12,\n\t\tCipherSuites: cipherSuites,\n\t\tInsecureSkipVerify: skipInsecureVerify,\n\t}, nil\n}", "func (s *Server) generateTLSConfig(opts *TLSOptions) (*tls.Config, error) {\n\treturn generateTLSConfig(opts)\n}", "func newTLSConfig(target string, registry *prometheus.Registry, cfg *config.TLSConfig) (*tls.Config, error) {\n\ttlsConfig, err := config.NewTLSConfig(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif tlsConfig.ServerName == \"\" && target != \"\" {\n\t\ttargetAddress, _, err := net.SplitHostPort(target)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttlsConfig.ServerName = targetAddress\n\t}\n\n\ttlsConfig.VerifyConnection = func(state tls.ConnectionState) error {\n\t\treturn collectConnectionStateMetrics(state, registry)\n\t}\n\n\treturn tlsConfig, nil\n}", "func getTLSConfig(cfg *Config) (*tls.Config, *credentials.TransportCredentials,\n\terror) {\n\n\t// Let's load our certificate first or create then load if it doesn't\n\t// yet exist.\n\tcertData, parsedCert, err := loadCertWithCreate(cfg)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// If the certificate expired or it was outdated, delete it and the TLS\n\t// key and generate a new pair.\n\tif time.Now().After(parsedCert.NotAfter) {\n\t\tlog.Info(\"TLS certificate is expired or outdated, \" +\n\t\t\t\"removing old file then generating a new one\")\n\n\t\terr := os.Remove(cfg.TLSCertPath)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\n\t\terr = os.Remove(cfg.TLSKeyPath)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\n\t\tcertData, _, err = loadCertWithCreate(cfg)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\n\ttlsCfg := cert.TLSConfFromCert(certData)\n\ttlsCfg.NextProtos = []string{\"h2\"}\n\trestCreds, err := credentials.NewClientTLSFromFile(\n\t\tcfg.TLSCertPath, \"\",\n\t)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn tlsCfg, &restCreds, nil\n}", "func buildTLSConfig() *tls.Config {\n\trawTLSSetting := OptionalCLIConfigValue(\"core.ssl_verify\")\n\tif strings.EqualFold(rawTLSSetting, \"false\") {\n\t\t// 'false' (case insensitive): disable cert validation\n\t\treturn &tls.Config{InsecureSkipVerify: true}\n\t} else if strings.EqualFold(rawTLSSetting, \"true\") {\n\t\t// 'true' (case insensitive): require validation against default CAs\n\t\treturn &tls.Config{InsecureSkipVerify: false}\n\t} else if len(rawTLSSetting) != 0 {\n\t\t// '<other string>': path to local/custom cert file\n\t\tcert, err := ioutil.ReadFile(rawTLSSetting)\n\t\tif err != nil {\n\t\t\tPrintMessageAndExit(\"Unable to read from CA certificate file %s: %s\", rawTLSSetting, err)\n\t\t}\n\t\tcertPool := x509.NewCertPool()\n\t\tcertPool.AppendCertsFromPEM(cert)\n\t\treturn &tls.Config{\n\t\t\tInsecureSkipVerify: false,\n\t\t\tRootCAs: certPool,\n\t\t}\n\t} else { // len(rawTLSSetting) == 0\n\t\t// This shouldn't happen: 'dcos auth login' requires a non-empty setting.\n\t\t// Play it safe and leave cert verification enabled by default (equivalent to 'true' case)\n\t\treturn &tls.Config{InsecureSkipVerify: false}\n\t}\n}", "func MQTTNewTLSConfig(crtPath, keyPath string, skipVerify bool) (*tls.Config, error) {\n\t// Import trusted certificates from CAfile.pem.\n\t// Alternatively, manually add CA certificates to\n\t// default openssl CA bundle.\n\tcertpool := x509.NewCertPool()\n\tpemCerts, err := ioutil.ReadFile(\"samplecerts/CAfile.pem\")\n\tif err == nil {\n\t\tcertpool.AppendCertsFromPEM(pemCerts)\n\t}\n\n\t// Import client certificate/key pair\n\tcert, err := tls.LoadX509KeyPair(crtPath, keyPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create tls.Config with desired tls properties\n\treturn &tls.Config{\n\t\t// RootCAs = certs used to verify server cert.\n\t\tRootCAs: certpool,\n\t\t// ClientAuth = whether to request cert from server.\n\t\t// Since the server is set up for SSL, this happens\n\t\t// anyways.\n\t\tClientAuth: tls.NoClientCert,\n\t\t// ClientCAs = certs used to validate client cert.\n\t\tClientCAs: nil,\n\t\t// InsecureSkipVerify = verify that cert contents\n\t\t// match server. IP matches what is in cert etc.\n\t\tInsecureSkipVerify: skipVerify,\n\t\t// Certificates = list of certs client sends to server.\n\t\tCertificates: []tls.Certificate{cert},\n\t}, nil\n}", "func generateTLSConfig(caCertFile string, clientCertFile string, clientKeyFile string, customVerifyFunc customVerifyFunc) (*tls.Config, error) {\n\tclientKeyPair, err := tls.LoadX509KeyPair(clientCertFile, clientKeyFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcaCertFileBytes, err := ioutil.ReadFile(caCertFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\troots := x509.NewCertPool()\n\troots.AppendCertsFromPEM(caCertFileBytes)\n\n\ttlsConfig := &tls.Config{\n\t\tCertificates: []tls.Certificate{clientKeyPair},\n\t\tRootCAs: roots,\n\t\tMinVersion: tls.VersionTLS12,\n\t\tInsecureSkipVerify: true,\n\t\t// Legacy TLS Verification using the new VerifyConnection callback\n\t\t// important for go version 1.15+ as some certificates in environments\n\t\t// that cause the new standard lib verification to fail.\n\t\t// This isn't really needed if your SSL certificates don't have the Common Name issue.\n\t\t// For more information: https://github.com/golang/go/issues/39568\n\t\tVerifyConnection: func(cs tls.ConnectionState) error {\n\t\t\tcommonName := cs.PeerCertificates[0].Subject.CommonName\n\t\t\tif commonName != cs.ServerName {\n\t\t\t\treturn fmt.Errorf(\"invalid certificate name %q, expected %q\", commonName, cs.ServerName)\n\t\t\t}\n\t\t\topts := x509.VerifyOptions{\n\t\t\t\tRoots: roots,\n\t\t\t\tIntermediates: x509.NewCertPool(),\n\t\t\t}\n\t\t\tfor _, cert := range cs.PeerCertificates[1:] {\n\t\t\t\topts.Intermediates.AddCert(cert)\n\t\t\t}\n\t\t\t_, err := cs.PeerCertificates[0].Verify(opts)\n\t\t\treturn err\n\t\t},\n\t}\n\tif customVerifyFunc != nil {\n\t\ttlsConfig.VerifyPeerCertificate = customVerifyFunc\n\t\ttlsConfig.VerifyConnection = nil\n\t}\n\ttlsConfig.BuildNameToCertificate()\n\n\treturn tlsConfig, nil\n}", "func ConfigTLS(config *appConf.Config, restConfig *restclient.Config) *tls.Config {\n\tif len(config.CertFile) != 0 && len(config.KeyFile) != 0 {\n\t\tsCert, err := tls.LoadX509KeyPair(config.CertFile, config.KeyFile)\n\t\tif err != nil {\n\t\t\tglog.Fatal(err)\n\t\t}\n\n\t\treturn &tls.Config{\n\t\t\tCertificates: []tls.Certificate{sCert},\n\t\t}\n\t}\n\n\tif len(restConfig.CertData) != 0 && len(restConfig.KeyData) != 0 {\n\t\tsCert, err := tls.X509KeyPair(restConfig.CertData, restConfig.KeyData)\n\t\tif err != nil {\n\t\t\tglog.Fatal(err)\n\t\t}\n\n\t\treturn &tls.Config{\n\t\t\tCertificates: []tls.Certificate{sCert},\n\t\t}\n\t}\n\n\tglog.Fatal(\"tls: failed to find any tls config data\")\n\treturn &tls.Config{}\n}", "func TestNewConfigTLS(t *testing.T) {\n\tconfig, err := NewConfig(\"configs/tls.yaml\")\n\trequire.NoError(t, err)\n\t// Liftbridge TLS\n\trequire.Equal(t, \"./configs/certs/server/server-key.pem\", config.TLSKey)\n\trequire.Equal(t, \"./configs/certs/server/server-cert.pem\", config.TLSCert)\n}", "func tlsConfig(caCertPath, clientCertPath, clientKeyPath string) (tconfKey string, err error) {\n\tpem, err := ioutil.ReadFile(caCertPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\trootCertPool := x509.NewCertPool()\n\tif ok := rootCertPool.AppendCertsFromPEM(pem); !ok {\n\t\treturn \"\", errCertPEM\n\t}\n\tcert, err := tls.LoadX509KeyPair(clientCertPath, clientKeyPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdbTLSConfig := &tls.Config{\n\t\tRootCAs: rootCertPool,\n\t\tCertificates: []tls.Certificate{cert},\n\t}\n\ttconfKey = \"custom\"\n\tif err := mysql.RegisterTLSConfig(tconfKey, dbTLSConfig); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn tconfKey, nil\n}", "func (i *TiFlashInstance) setTLSConfig(ctx context.Context, enableTLS bool, configs map[string]any, paths meta.DirPaths) (map[string]any, error) {\n\tif enableTLS {\n\t\tif configs == nil {\n\t\t\tconfigs = make(map[string]any)\n\t\t}\n\t\tconfigs[\"security.ca_path\"] = fmt.Sprintf(\n\t\t\t\"%s/tls/%s\",\n\t\t\tpaths.Deploy,\n\t\t\tTLSCACert,\n\t\t)\n\t\tconfigs[\"security.cert_path\"] = fmt.Sprintf(\n\t\t\t\"%s/tls/%s.crt\",\n\t\t\tpaths.Deploy,\n\t\t\ti.Role())\n\t\tconfigs[\"security.key_path\"] = fmt.Sprintf(\n\t\t\t\"%s/tls/%s.pem\",\n\t\t\tpaths.Deploy,\n\t\t\ti.Role())\n\t} else {\n\t\t// drainer tls config list\n\t\ttlsConfigs := []string{\n\t\t\t\"security.ca_path\",\n\t\t\t\"security.cert_path\",\n\t\t\t\"security.key_path\",\n\t\t}\n\t\t// delete TLS configs\n\t\tif configs != nil {\n\t\t\tfor _, config := range tlsConfigs {\n\t\t\t\tdelete(configs, config)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn configs, nil\n}", "func NewTLSConfig() *tls.Config {\n\treturn &tls.Config{\n\t\tInsecureSkipVerify: false,\n\t\tMinVersion: tls.VersionTLS12,\n\t}\n}", "func getTLSConfig(c *Config) (*tls.Config, error) {\n\tcfg := &tls.Config{\n\t\tCurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},\n\t\tPreferServerCipherSuites: true,\n\t\tMinVersion: tls.VersionTLS12,\n\t\tClientAuth: tls.NoClientCert,\n\t}\n\n\t// @step: load the server certificates\n\tif c.TLSCert != \"\" && c.TLSKey != \"\" {\n\t\tcert, err := tls.LoadX509KeyPair(c.TLSCert, c.TLSKey)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcfg.Certificates = []tls.Certificate{cert}\n\t}\n\n\treturn cfg, nil\n}", "func prepareTlS(cfg config.Https) *tls.Config {\n\tcrt, err := ioutil.ReadFile(cfg.Cert)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tkey, err := ioutil.ReadFile(cfg.CertKey)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tcert, err := tls.X509KeyPair(crt, key)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{cert},\n\t\tServerName: cfg.ServerName,\n\t}\n}", "func TLSConfig(tc *tls.Config) ConfigOpt {\n\treturn func(c *Config) {\n\t\tc.transport.TLSClientConfig = tc\n\t}\n}", "func (i *MonitorInstance) setTLSConfig(ctx context.Context, enableTLS bool, configs map[string]any, paths meta.DirPaths) (map[string]any, error) {\n\treturn nil, nil\n}", "func (c Config) TLSConfig() (*tls.Config, error) {\n\t// Setup root cert\n\troots := x509.NewCertPool()\n\tok := roots.AppendCertsFromPEM([]byte(c.TrustedCert))\n\tif !ok {\n\t\treturn nil, errors.New(\"unable to parse trusted certs\")\n\t}\n\n\t// Setup client certs\n\tcert, err := tls.X509KeyPair([]byte(c.ClientCert), []byte(c.ClientCertKey))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"setting up client cert\")\n\t}\n\n\ttc := tls.Config{\n\t\tCertificates: []tls.Certificate{cert},\n\t\tInsecureSkipVerify: true,\n\t\tRootCAs: roots,\n\t}\n\ttc.BuildNameToCertificate()\n\n\treturn &tc, nil\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func configureTLS(tlsConfig *tls.Config) {\n\t// Make all necessary changes to the TLS configuration here.\n}", "func TLSConfig(t *tls.Config) Option {\n\treturn func(o *Options) {\n\t\to.TLSConfig = t\n\t}\n}", "func TLSConfig(t *tls.Config) Option {\n\treturn func(o *Options) {\n\t\to.TLSConfig = t\n\t}\n}", "func (a *Announcement) TLSConfig() (*tls.Config, error) {\n\tif a.NetAddress == \"\" {\n\t\treturn nil, errors.New(\"No address known for this component\")\n\t}\n\tnetAddress := strings.Split(a.NetAddress, \",\")[0]\n\tnetHost, _, _ := net.SplitHostPort(netAddress)\n\tif a.Certificate == \"\" {\n\t\treturn nil, nil\n\t}\n\trootCAs := x509.NewCertPool()\n\tok := rootCAs.AppendCertsFromPEM([]byte(a.Certificate))\n\tif !ok {\n\t\treturn nil, errors.New(\"Could not read component certificate\")\n\t}\n\treturn &tls.Config{ServerName: netHost, RootCAs: rootCAs}, nil\n}", "func NewWithConfig(ssconfig SelfSignedConfig) (*tls.Config, error) {\n\tcert, err := newSelfSignedCertificate(ssconfig)\n\treturn &tls.Config{Certificates: []tls.Certificate{cert}}, err\n}", "func TlsConfig() (*tls.Config, error) {\n\trootCAs := x509.NewCertPool()\n\tdomainName := os.Getenv(\"MEPSERVER_CERT_DOMAIN_NAME\")\n\tif ValidateDomainName(domainName) != nil {\n\t\treturn nil, errors.New(\"domain name validation failed\")\n\t}\n\treturn &tls.Config{\n\t\tRootCAs: rootCAs,\n\t\tServerName: domainName,\n\t\tMinVersion: tls.VersionTLS12,\n\t\tInsecureSkipVerify: true,\n\t}, nil\n}", "func ConfigTLS(c Config) *tls.Config {\n\tsCert, err := tls.LoadX509KeyPair(c.CertFile, c.KeyFile)\n\tif err != nil {\n\t\tglog.Fatal(err)\n\t}\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{sCert},\n\t\t// TODO: uses mutual tls after we agree on what cert the apiserver should use.\n\t\t// ClientAuth: tls.RequireAndVerifyClientCert,\n\t}\n}", "func (e *Exporter) buildTLSConfig() (*tls.Config, error) {\n\ttlsConfig := &tls.Config{}\n\tif e.config.TLSConfig == nil {\n\t\treturn tlsConfig, nil\n\t}\n\n\t// Set the server name if it exists.\n\tif e.config.TLSConfig[\"server_name\"] != \"\" {\n\t\ttlsConfig.ServerName = e.config.TLSConfig[\"server_name\"]\n\t}\n\n\t// Set InsecureSkipVerify. Viper reads the bool as a string since it is in a map.\n\tif isv, ok := e.config.TLSConfig[\"insecure_skip_verify\"]; ok {\n\t\tvar err error\n\t\tif tlsConfig.InsecureSkipVerify, err = strconv.ParseBool(isv); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Load certificates from CA file if it exists.\n\tcaFile := e.config.TLSConfig[\"ca_file\"]\n\tif caFile != \"\" {\n\t\tcaFileData, err := ioutil.ReadFile(caFile)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcertPool := x509.NewCertPool()\n\t\tcertPool.AppendCertsFromPEM(caFileData)\n\t\ttlsConfig.RootCAs = certPool\n\t}\n\n\t// Load the client certificate if it exists.\n\tcertFile := e.config.TLSConfig[\"cert_file\"]\n\tkeyFile := e.config.TLSConfig[\"key_file\"]\n\tif certFile != \"\" && keyFile != \"\" {\n\t\tcert, err := tls.LoadX509KeyPair(certFile, keyFile)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttlsConfig.Certificates = []tls.Certificate{cert}\n\t}\n\n\treturn tlsConfig, nil\n}", "func TLSConfig() *tls.Config {\n\tif len(hostname) == 0 || len(cacertFile) == 0 ||\n\t\tlen(certFile) == 0 || len(keyFile) == 0 {\n\t\tflag.Usage()\n\t\tos.Exit(1)\n\t}\n\ttls, err := LoadTLSConfig(keyFile, certFile, cacertFile)\n\tif err != nil {\n\t\tflag.Usage()\n\t\tos.Exit(1)\n\t}\n\ttls.ServerName = hostname\n\treturn tls\n}", "func (s TLSConfig) ToTLSConfig() (*tls.Config, error) {\n\tif len(s.SSLCABytes) != 0 || len(s.SSLCertBytes) != 0 || len(s.SSLKEYBytes) != 0 {\n\t\tcert, err := tls.X509KeyPair(s.SSLCertBytes, s.SSLKEYBytes)\n\t\tif err != nil {\n\t\t\treturn nil, errs.ErrCryptoX509KeyPair.GenWithStackByCause()\n\t\t}\n\t\tcertificates := []tls.Certificate{cert}\n\t\t// Create a certificate pool from CA\n\t\tcertPool := x509.NewCertPool()\n\t\t// Append the certificates from the CA\n\t\tif !certPool.AppendCertsFromPEM(s.SSLCABytes) {\n\t\t\treturn nil, errs.ErrCryptoAppendCertsFromPEM.GenWithStackByCause()\n\t\t}\n\t\treturn &tls.Config{\n\t\t\tCertificates: certificates,\n\t\t\tRootCAs: certPool,\n\t\t\tNextProtos: []string{\"h2\", \"http/1.1\"}, // specify `h2` to let Go use HTTP/2.\n\t\t}, nil\n\t}\n\n\tif len(s.CertPath) == 0 && len(s.KeyPath) == 0 {\n\t\treturn nil, nil\n\t}\n\tallowedCN, err := s.GetOneAllowedCN()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttlsInfo := transport.TLSInfo{\n\t\tCertFile: s.CertPath,\n\t\tKeyFile: s.KeyPath,\n\t\tTrustedCAFile: s.CAPath,\n\t\tAllowedCN: allowedCN,\n\t}\n\n\ttlsConfig, err := tlsInfo.ClientConfig()\n\tif err != nil {\n\t\treturn nil, errs.ErrEtcdTLSConfig.Wrap(err).GenWithStackByCause()\n\t}\n\treturn tlsConfig, nil\n}", "func LoadTLSConfig(config *TLSConfig) (*tls.Config, error) {\n\tif config == nil {\n\t\treturn nil, nil\n\t}\n\n\tcertificate := config.Certificate\n\tkey := config.CertificateKey\n\trootCAs := config.CAs\n\thasCertificate := certificate != \"\"\n\thasKey := key != \"\"\n\n\tvar certs []tls.Certificate\n\tswitch {\n\tcase hasCertificate && !hasKey:\n\t\treturn nil, ErrCertificateNoKey\n\tcase !hasCertificate && hasKey:\n\t\treturn nil, ErrKeyNoCertificate\n\tcase hasCertificate && hasKey:\n\t\tcert, err := tls.LoadX509KeyPair(certificate, key)\n\t\tif err != nil {\n\t\t\tlogp.Critical(\"Failed loading client certificate\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tcerts = []tls.Certificate{cert}\n\t}\n\n\tvar roots *x509.CertPool\n\tif len(rootCAs) > 0 {\n\t\troots = x509.NewCertPool()\n\t\tfor _, caFile := range rootCAs {\n\t\t\tpemData, err := ioutil.ReadFile(caFile)\n\t\t\tif err != nil {\n\t\t\t\tlogp.Critical(\"Failed reading CA certificate: %s\", err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tif ok := roots.AppendCertsFromPEM(pemData); !ok {\n\t\t\t\treturn nil, ErrNotACertificate\n\t\t\t}\n\t\t}\n\t}\n\n\tminVersion, err := parseTLSVersion(config.MinVersion)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif minVersion == 0 {\n\t\t// require minimum TLS-1.0 if not configured\n\t\tminVersion = tls.VersionTLS10\n\t}\n\n\tmaxVersion, err := parseTLSVersion(config.MaxVersion)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcipherSuites, err := parseTLSCipherSuites(config.CipherSuites)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcurveIDs, err := parseCurveTypes(config.CurveTypes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttlsConfig := tls.Config{\n\t\tMinVersion: minVersion,\n\t\tMaxVersion: maxVersion,\n\t\tCertificates: certs,\n\t\tRootCAs: roots,\n\t\tInsecureSkipVerify: config.Insecure,\n\t\tCipherSuites: cipherSuites,\n\t\tCurvePreferences: curveIDs,\n\t}\n\treturn &tlsConfig, nil\n}", "func generateTLSConfig(certfile string) (tls.Config, error) {\n\ttlsConfig := tls.Config{}\n\ttlsConfig.InsecureSkipVerify = true\n\tcertficate, err := ioutil.ReadFile(certfile)\n\tif err != nil {\n\t\treturn tlsConfig, err\n\t}\n\trootCAs := x509.NewCertPool()\n\tif !rootCAs.AppendCertsFromPEM([]byte(certficate)) {\n\t\treturn tlsConfig, errors.New(\"ERROR: Fehler beim parsen des Serverzertifikats.\\n\")\n\t}\n\treturn tlsConfig, nil\n}", "func (rootCA RootCA) CreateSecurityConfig(ctx context.Context, krw *KeyReadWriter, config CertificateRequestConfig) (*SecurityConfig, func() error, error) {\n\tctx = log.WithModule(ctx, \"tls\")\n\n\t// Create a new random ID for this certificate\n\tcn := identity.NewID()\n\torg := config.Organization\n\tif config.Organization == \"\" {\n\t\torg = identity.NewID()\n\t}\n\n\tproposedRole := ManagerRole\n\ttlsKeyPair, issuerInfo, err := rootCA.IssueAndSaveNewCertificates(krw, cn, proposedRole, org)\n\tswitch errors.Cause(err) {\n\tcase ErrNoValidSigner:\n\t\tconfig.RetryInterval = GetCertRetryInterval\n\t\t// Request certificate issuance from a remote CA.\n\t\t// Last argument is nil because at this point we don't have any valid TLS creds\n\t\ttlsKeyPair, issuerInfo, err = rootCA.RequestAndSaveNewCertificates(ctx, krw, config)\n\t\tif err != nil {\n\t\t\tlog.G(ctx).WithError(err).Error(\"failed to request and save new certificate\")\n\t\t\treturn nil, nil, err\n\t\t}\n\tcase nil:\n\t\tlog.G(ctx).WithFields(log.Fields{\n\t\t\t\"node.id\": cn,\n\t\t\t\"node.role\": proposedRole,\n\t\t}).Debug(\"issued new TLS certificate\")\n\tdefault:\n\t\tlog.G(ctx).WithFields(log.Fields{\n\t\t\t\"node.id\": cn,\n\t\t\t\"node.role\": proposedRole,\n\t\t}).WithError(err).Errorf(\"failed to issue and save new certificate\")\n\t\treturn nil, nil, err\n\t}\n\n\tsecConfig, cleanup, err := NewSecurityConfig(&rootCA, krw, tlsKeyPair, issuerInfo)\n\tif err == nil {\n\t\tlog.G(ctx).WithFields(log.Fields{\n\t\t\t\"node.id\": secConfig.ClientTLSCreds.NodeID(),\n\t\t\t\"node.role\": secConfig.ClientTLSCreds.Role(),\n\t\t}).Debugf(\"new node credentials generated: %s\", krw.Target())\n\t}\n\treturn secConfig, cleanup, err\n}", "func newBaseTLSConfig(certPEM, keyPEM, caPEM []byte) (*tls.Config, error) {\n\tcert, err := tls.X509KeyPair(certPEM, keyPEM)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcertPool := x509.NewCertPool()\n\n\tif !certPool.AppendCertsFromPEM(caPEM) {\n\t\treturn nil, errors.Errorf(\"failed to parse PEM data to pool\")\n\t}\n\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{cert},\n\t\tRootCAs: certPool,\n\n\t\t// This is Go's default list of cipher suites (as of go 1.8.3),\n\t\t// with the following differences:\n\t\t// - 3DES-based cipher suites have been removed. This cipher is\n\t\t// vulnerable to the Sweet32 attack and is sometimes reported by\n\t\t// security scanners. (This is arguably a false positive since\n\t\t// it will never be selected: Any TLS1.2 implementation MUST\n\t\t// include at least one cipher higher in the priority list, but\n\t\t// there's also no reason to keep it around)\n\t\t// - AES is always prioritized over ChaCha20. Go makes this decision\n\t\t// by default based on the presence or absence of hardware AES\n\t\t// acceleration.\n\t\t// TODO(bdarnell): do the same detection here. See\n\t\t// https://github.com/golang/go/issues/21167\n\t\t//\n\t\t// Note that some TLS cipher suite guidance (such as Mozilla's[1])\n\t\t// recommend replacing the CBC_SHA suites below with CBC_SHA384 or\n\t\t// CBC_SHA256 variants. We do not do this because Go does not\n\t\t// currerntly implement the CBC_SHA384 suites, and its CBC_SHA256\n\t\t// implementation is vulnerable to the Lucky13 attack and is disabled\n\t\t// by default.[2]\n\t\t//\n\t\t// [1]: https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility\n\t\t// [2]: https://github.com/golang/go/commit/48d8edb5b21db190f717e035b4d9ab61a077f9d7\n\t\tCipherSuites: []uint16{\n\t\t\ttls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,\n\t\t\ttls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,\n\t\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,\n\t\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,\n\t\t\ttls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,\n\t\t\ttls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,\n\t\t\ttls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,\n\t\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,\n\t\t\ttls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,\n\t\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,\n\t\t\ttls.TLS_RSA_WITH_AES_128_GCM_SHA256,\n\t\t\ttls.TLS_RSA_WITH_AES_256_GCM_SHA384,\n\t\t\ttls.TLS_RSA_WITH_AES_128_CBC_SHA,\n\t\t\ttls.TLS_RSA_WITH_AES_256_CBC_SHA,\n\t\t},\n\n\t\tMinVersion: tls.VersionTLS12,\n\t}, nil\n}", "func MakeBackendTLSConfig(backendsTls *config.BackendsTls) (*tls.Config, error) {\n\n\tif backendsTls == nil {\n\t\treturn nil, nil\n\t}\n\n\tvar err error\n\n\tresult := &tls.Config{\n\t\tInsecureSkipVerify: backendsTls.IgnoreVerify,\n\t\tCipherSuites: MapCiphers(backendsTls.Ciphers),\n\t\tPreferServerCipherSuites: backendsTls.PreferServerCiphers,\n\t\tMinVersion: MapVersion(backendsTls.MinVersion),\n\t\tMaxVersion: MapVersion(backendsTls.MaxVersion),\n\t\tSessionTicketsDisabled: !backendsTls.SessionTickets,\n\t}\n\n\tif backendsTls.CertPath != nil && backendsTls.KeyPath != nil {\n\n\t\tvar crt tls.Certificate\n\n\t\tif crt, err = tls.LoadX509KeyPair(*backendsTls.CertPath, *backendsTls.KeyPath); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tresult.Certificates = []tls.Certificate{crt}\n\t}\n\n\tif backendsTls.RootCaCertPath != nil {\n\n\t\tvar caCertPem []byte\n\n\t\tif caCertPem, err = ioutil.ReadFile(*backendsTls.RootCaCertPath); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tcaCertPool := x509.NewCertPool()\n\t\tif ok := caCertPool.AppendCertsFromPEM(caCertPem); !ok {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tresult.RootCAs = caCertPool\n\n\t}\n\n\treturn result, nil\n\n}", "func (a *autocertProvider) TLSConfig(hosts ...string) (*tls.Config, error) {\n\t// create a new manager\n\tm := &autocert.Manager{\n\t\tPrompt: autocert.AcceptTOS,\n\t}\n\tif len(hosts) > 0 {\n\t\tm.HostPolicy = autocert.HostWhitelist(hosts...)\n\t}\n\tdir := cacheDir()\n\tif err := os.MkdirAll(dir, 0700); err != nil {\n\t\tif logger.V(logger.InfoLevel, logger.DefaultLogger) {\n\t\t\tlogger.Infof(\"warning: autocert not using a cache: %v\", err)\n\t\t}\n\t} else {\n\t\tm.Cache = autocert.DirCache(dir)\n\t}\n\treturn m.TLSConfig(), nil\n}", "func NewTLSConfig(certPath string, passphrase string, clientCA string) (*tls.Config, error) {\n\tcer, err := readPKCS12Cert(certPath, passphrase)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar caCertPool *x509.CertPool\n\tif clientCA != \"\" {\n\t\tcaCert, err := ioutil.ReadFile(clientCA)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcaCertPool = x509.NewCertPool()\n\t\tcaCertPool.AppendCertsFromPEM(caCert)\n\t}\n\n\ttlsConfig := &tls.Config{\n\t\tCertificates: []tls.Certificate{*cer},\n\t\tRootCAs: caCertPool,\n\t}\n\treturn tlsConfig, nil\n}", "func (m *Manager) TLSConfig() *tls.Config {\n\ttlsConf := tlsconfig.NewServerTLSConfig(tlsconfig.TLSModeServerStrict)\n\ttlsConf.NextProtos = []string{\n\t\t\"h2\", \"http/1.1\", // enable HTTP/2\n\t\tacme.ALPNProto, // enable tls-alpn ACME challenges\n\t}\n\ttlsConf.GetCertificate = m.GetCertificateFunc\n\treturn tlsConf\n}", "func (as *ArgocdServer) initTLSConfig() error {\n\tif len(as.opt.ServerCert) != 0 && len(as.opt.ServerKey) != 0 && len(as.opt.ServerCa) != 0 {\n\t\ttlsConfig, err := ssl.ServerTslConfVerityClient(as.opt.ServerCa, as.opt.ServerCert,\n\t\t\tas.opt.ServerKey, static.ServerCertPwd)\n\t\tif err != nil {\n\t\t\tblog.Errorf(\"load bcs argocd server tls config failed, err %s\", err.Error())\n\t\t\treturn err\n\t\t}\n\t\tas.tlsConfig = tlsConfig\n\t\tblog.Infof(\"load bcs argocd server tls config successfully\")\n\t}\n\n\tif len(as.opt.ClientCert) != 0 && len(as.opt.ClientKey) != 0 && len(as.opt.ClientCa) != 0 {\n\t\ttlsConfig, err := ssl.ClientTslConfVerity(as.opt.ClientCa, as.opt.ClientCert,\n\t\t\tas.opt.ClientKey, static.ClientCertPwd)\n\t\tif err != nil {\n\t\t\tblog.Errorf(\"load bcs argocd server client tls config failed, err %s\", err.Error())\n\t\t\treturn err\n\t\t}\n\t\tas.clientTLSConfig = tlsConfig\n\t\tblog.Infof(\"load bcs argocd server client tls config successfully\")\n\t}\n\treturn nil\n}", "func copyTLSConfig(cfg *tls.Config) *tls.Config {\n\treturn &tls.Config{\n\t\tCertificates: cfg.Certificates,\n\t\tCipherSuites: cfg.CipherSuites,\n\t\tClientAuth: cfg.ClientAuth,\n\t\tClientCAs: cfg.ClientCAs,\n\t\tClientSessionCache: cfg.ClientSessionCache,\n\t\tCurvePreferences: cfg.CurvePreferences,\n\t\tInsecureSkipVerify: cfg.InsecureSkipVerify,\n\t\tMaxVersion: cfg.MaxVersion,\n\t\tMinVersion: cfg.MinVersion,\n\t\tNextProtos: cfg.NextProtos,\n\t\tPreferServerCipherSuites: cfg.PreferServerCipherSuites,\n\t\tRand: cfg.Rand,\n\t\tRootCAs: cfg.RootCAs,\n\t\tServerName: cfg.ServerName,\n\t\tSessionTicketsDisabled: cfg.SessionTicketsDisabled,\n\t}\n}", "func TLSConfig(c *tls.Config) ServerOption {\n\treturn func(o *Server) {\n\t\to.tlsConf = c\n\t}\n}", "func TLSConfig() *tls.Config {\n\treturn &tls.Config{\n\t\tMinVersion: tls.VersionTLS12,\n\t\tCipherSuites: teleutils.DefaultCipherSuites(),\n\t\tPreferServerCipherSuites: true,\n\t}\n}", "func configureTLS(tlsConfig *tls.Config) {\n\ttlsConfig.RootCAs = GlobalRootCAs\n\ttlsConfig.GetCertificate = GlobalTLSCertsManager.GetCertificate\n}", "func TLSConfigFor(config *Config) (*tls.Config, error) {\n\tcfg, err := config.TransportConfig()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn transport.TLSConfigFor(cfg)\n}", "func (i *TiFlashInstance) setTLSConfigWithTiFlashLearner(ctx context.Context, enableTLS bool, configs map[string]any, paths meta.DirPaths) (map[string]any, error) {\n\tif enableTLS {\n\t\tif configs == nil {\n\t\t\tconfigs = make(map[string]any)\n\t\t}\n\t\tconfigs[\"security.ca-path\"] = fmt.Sprintf(\n\t\t\t\"%s/tls/%s\",\n\t\t\tpaths.Deploy,\n\t\t\tTLSCACert,\n\t\t)\n\t\tconfigs[\"security.cert-path\"] = fmt.Sprintf(\n\t\t\t\"%s/tls/%s.crt\",\n\t\t\tpaths.Deploy,\n\t\t\ti.Role())\n\t\tconfigs[\"security.key-path\"] = fmt.Sprintf(\n\t\t\t\"%s/tls/%s.pem\",\n\t\t\tpaths.Deploy,\n\t\t\ti.Role())\n\t} else {\n\t\t// drainer tls config list\n\t\ttlsConfigs := []string{\n\t\t\t\"security.ca-path\",\n\t\t\t\"security.cert-path\",\n\t\t\t\"security.key-path\",\n\t\t}\n\t\t// delete TLS configs\n\t\tif configs != nil {\n\t\t\tfor _, config := range tlsConfigs {\n\t\t\t\tdelete(configs, config)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn configs, nil\n}", "func newClientTLSConfig(certPEM, keyPEM, caPEM []byte) (*tls.Config, error) {\n\treturn newBaseTLSConfig(certPEM, keyPEM, caPEM)\n}", "func UpdateTLSConfig(tlsConfig *tls.Config, c *configpb.TLSConfig, addClientCACerts bool) error {\n\tif c.GetDisableCertValidation() {\n\t\ttlsConfig.InsecureSkipVerify = true\n\t}\n\n\tif c.GetCaCertFile() != \"\" {\n\t\tcaCert, err := file.ReadFile(c.GetCaCertFile())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcaCertPool := x509.NewCertPool()\n\t\tif !caCertPool.AppendCertsFromPEM(caCert) {\n\t\t\treturn fmt.Errorf(\"error while adding CA certs from: %s\", c.GetCaCertFile())\n\t\t}\n\n\t\ttlsConfig.RootCAs = caCertPool\n\t\t// Client CA certs are used by servers to authenticate clients.\n\t\tif addClientCACerts {\n\t\t\ttlsConfig.ClientCAs = caCertPool\n\t\t}\n\t}\n\n\tif c.GetTlsCertFile() != \"\" {\n\t\tcertPEMBlock, err := file.ReadFile(c.GetTlsCertFile())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tkeyPEMBlock, err := file.ReadFile(c.GetTlsKeyFile())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcert, err := tls.X509KeyPair(certPEMBlock, keyPEMBlock)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttlsConfig.Certificates = append(tlsConfig.Certificates, cert)\n\t}\n\n\tif c.GetServerName() != \"\" {\n\t\ttlsConfig.ServerName = c.GetServerName()\n\t}\n\n\treturn nil\n}", "func (c *ClientConfig) TLSConfig() (*tls.Config, error) {\n\t// Support deprecated variable names\n\tif c.TLSCA == \"\" && c.SSLCA != \"\" {\n\t\tc.TLSCA = c.SSLCA\n\t}\n\tif c.TLSCert == \"\" && c.SSLCert != \"\" {\n\t\tc.TLSCert = c.SSLCert\n\t}\n\tif c.TLSKey == \"\" && c.SSLKey != \"\" {\n\t\tc.TLSKey = c.SSLKey\n\t}\n\n\tif c.TLSCA == \"\" && c.TLSKey == \"\" && c.TLSCert == \"\" && !c.InsecureSkipVerify {\n\t\treturn nil, nil\n\t}\n\n\ttlsConfig := &tls.Config{\n\t\tInsecureSkipVerify: c.InsecureSkipVerify,\n\t\tRenegotiation: tls.RenegotiateNever,\n\t}\n\n\tif c.TLSCA != \"\" {\n\t\tpool, err := makeCertPool([]string{c.TLSCA})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttlsConfig.RootCAs = pool\n\t}\n\n\tif c.TLSCert != \"\" && c.TLSKey != \"\" {\n\t\terr := loadCertificate(tlsConfig, c.TLSCert, c.TLSKey)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn tlsConfig, nil\n}", "func ConfigureTLSConfig(tlsConf *tls.Config) *tls.Config {\n\t// The tls.Config used to setup the quic.Listener needs to have the GetConfigForClient callback set.\n\t// That way, we can get the QUIC version and set the correct ALPN value.\n\treturn &tls.Config{\n\t\tGetConfigForClient: func(ch *tls.ClientHelloInfo) (*tls.Config, error) {\n\t\t\t// determine the ALPN from the QUIC version used\n\t\t\tproto := NextProtoH3\n\t\t\tval := ch.Context().Value(quic.QUICVersionContextKey)\n\t\t\tif v, ok := val.(quic.VersionNumber); ok {\n\t\t\t\tproto = versionToALPN(v)\n\t\t\t}\n\t\t\tconfig := tlsConf\n\t\t\tif tlsConf.GetConfigForClient != nil {\n\t\t\t\tgetConfigForClient := tlsConf.GetConfigForClient\n\t\t\t\tvar err error\n\t\t\t\tconf, err := getConfigForClient(ch)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif conf != nil {\n\t\t\t\t\tconfig = conf\n\t\t\t\t}\n\t\t\t}\n\t\t\tif config == nil {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\tconfig = config.Clone()\n\t\t\tconfig.NextProtos = []string{proto}\n\t\t\treturn config, nil\n\t\t},\n\t}\n}", "func newServerTLSConfig(certPEM, keyPEM, caPEM []byte) (*tls.Config, error) {\n\tcfg, err := newBaseTLSConfig(certPEM, keyPEM, caPEM)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcfg.ClientAuth = tls.VerifyClientCertIfGiven\n\tcfg.ClientCAs = cfg.RootCAs\n\t// Use the default cipher suite from golang (RC4 is going away in 1.5).\n\t// Prefer the server-specified suite.\n\tcfg.PreferServerCipherSuites = true\n\t// Should we disable session resumption? This may break forward secrecy.\n\t// cfg.SessionTicketsDisabled = true\n\treturn cfg, nil\n}", "func (cfg *Config) loadTLSConfig() error {\n\tif cfg.TLS.Enable {\n\t\tif cfg.TLS.CA == \"\" {\n\t\t\treturn errors.New(\"The CA can not be empty\")\n\t\t}\n\t\tif cfg.TLS.RawCert == \"\" {\n\t\t\treturn errors.New(\"The cert can not be empty\")\n\t\t}\n\t\tif cfg.TLS.Key == \"\" {\n\t\t\treturn errors.New(\"The key can not be empty\")\n\t\t}\n\t\t// load pool\n\t\tpool := x509.NewCertPool()\n\t\tca, err := ioutil.ReadFile(cfg.TLS.CA)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tok := pool.AppendCertsFromPEM(ca)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Failed to load ca file: %s\", cfg.TLS.CA)\n\t\t}\n\t\t// load cert\n\t\tcert, err := tls.LoadX509KeyPair(cfg.TLS.RawCert, cfg.TLS.Key)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcfg.TLS.Pool = pool\n\t\tcfg.TLS.Cert = &cert\n\t}\n\treturn nil\n}", "func (e *endpoints) getTLSConfig(ctx context.Context) func(*tls.ClientHelloInfo) (*tls.Config, error) {\n\treturn func(hello *tls.ClientHelloInfo) (*tls.Config, error) {\n\t\tcerts, roots, err := e.getCerts(ctx)\n\t\tif err != nil {\n\t\t\te.c.Log.Errorf(\"Could not generate TLS config for gRPC client %v: %v\", hello.Conn.RemoteAddr(), err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tc := &tls.Config{\n\t\t\t// When bootstrapping, the agent does not yet have\n\t\t\t// an SVID. In order to include the bootstrap endpoint\n\t\t\t// in the same server as the rest of the Node API,\n\t\t\t// request but don't require a client certificate\n\t\t\tClientAuth: tls.VerifyClientCertIfGiven,\n\n\t\t\tCertificates: certs,\n\t\t\tClientCAs: roots,\n\t\t}\n\t\treturn c, nil\n\t}\n}", "func TLSConfig(c *tls.Config) func(*Attacker) {\n\treturn func(a *Attacker) {\n\t\ttr := a.client.Transport.(*http.Transport)\n\t\ttr.TLSClientConfig = c\n\t}\n}", "func WithTLSConfig(config *tls.Config) TransportOption {\n\treturn func(tr *Transport) {\n\t\ttr.tls = config\n\t}\n}", "func CreateCryptoConfig(recipients []string, keys []string) (encconfig.CryptoConfig, error) {\n\tvar decryptCc *encconfig.CryptoConfig\n\tccs := []encconfig.CryptoConfig{}\n\tif len(keys) > 0 {\n\t\tdcc, err := CreateDecryptCryptoConfig(keys, []string{})\n\t\tif err != nil {\n\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t}\n\t\tdecryptCc = &dcc\n\t\tccs = append(ccs, dcc)\n\t}\n\n\tif len(recipients) > 0 {\n\t\tgpgRecipients, pubKeys, x509s, pkcs11Pubkeys, pkcs11Yamls, keyProvider, err := processRecipientKeys(recipients)\n\t\tif err != nil {\n\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t}\n\t\tencryptCcs := []encconfig.CryptoConfig{}\n\n\t\t// Create GPG client with guessed GPG version and default homedir\n\t\tgpgClient, err := ocicrypt.NewGPGClient(\"\", \"\")\n\t\tgpgInstalled := err == nil\n\t\tif len(gpgRecipients) > 0 && gpgInstalled {\n\t\t\tgpgPubRingFile, err := gpgClient.ReadGPGPubRingFile()\n\t\t\tif err != nil {\n\t\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t\t}\n\n\t\t\tgpgCc, err := encconfig.EncryptWithGpg(gpgRecipients, gpgPubRingFile)\n\t\t\tif err != nil {\n\t\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t\t}\n\t\t\tencryptCcs = append(encryptCcs, gpgCc)\n\t\t}\n\n\t\t// Create Encryption Crypto Config\n\t\tif len(x509s) > 0 {\n\t\t\tpkcs7Cc, err := encconfig.EncryptWithPkcs7(x509s)\n\t\t\tif err != nil {\n\t\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t\t}\n\t\t\tencryptCcs = append(encryptCcs, pkcs7Cc)\n\t\t}\n\t\tif len(pubKeys) > 0 {\n\t\t\tjweCc, err := encconfig.EncryptWithJwe(pubKeys)\n\t\t\tif err != nil {\n\t\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t\t}\n\t\t\tencryptCcs = append(encryptCcs, jweCc)\n\t\t}\n\t\tvar p11conf *pkcs11.Pkcs11Config\n\t\tif len(pkcs11Yamls) > 0 || len(pkcs11Pubkeys) > 0 {\n\t\t\tp11conf, err = pkcs11config.GetUserPkcs11Config()\n\t\t\tif err != nil {\n\t\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t\t}\n\t\t\tpkcs11Cc, err := encconfig.EncryptWithPkcs11(p11conf, pkcs11Pubkeys, pkcs11Yamls)\n\t\t\tif err != nil {\n\t\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t\t}\n\t\t\tencryptCcs = append(encryptCcs, pkcs11Cc)\n\t\t}\n\n\t\tif len(keyProvider) > 0 {\n\t\t\tkeyProviderCc, err := encconfig.EncryptWithKeyProvider(keyProvider)\n\t\t\tif err != nil {\n\t\t\t\treturn encconfig.CryptoConfig{}, err\n\t\t\t}\n\t\t\tencryptCcs = append(encryptCcs, keyProviderCc)\n\t\t}\n\t\tecc := encconfig.CombineCryptoConfigs(encryptCcs)\n\t\tif decryptCc != nil {\n\t\t\tecc.EncryptConfig.AttachDecryptConfig(decryptCc.DecryptConfig)\n\t\t}\n\t\tccs = append(ccs, ecc)\n\t}\n\n\tif len(ccs) > 0 {\n\t\treturn encconfig.CombineCryptoConfigs(ccs), nil\n\t}\n\treturn encconfig.CryptoConfig{}, nil\n}", "func ShallowCopyTLSConfig(cfg *tls.Config) *tls.Config {\n\tncfg := tls.Config{\n\t\tTime: cfg.Time,\n\t\tCertificates: cfg.Certificates,\n\t\tNameToCertificate: cfg.NameToCertificate,\n\t\tGetCertificate: cfg.GetCertificate,\n\t\tRootCAs: cfg.RootCAs,\n\t\tNextProtos: cfg.NextProtos,\n\t\tServerName: cfg.ServerName,\n\t\tClientAuth: cfg.ClientAuth,\n\t\tClientCAs: cfg.ClientCAs,\n\t\tInsecureSkipVerify: cfg.InsecureSkipVerify,\n\t\tCipherSuites: cfg.CipherSuites,\n\t\tPreferServerCipherSuites: cfg.PreferServerCipherSuites,\n\t\tSessionTicketKey: cfg.SessionTicketKey,\n\t\tClientSessionCache: cfg.ClientSessionCache,\n\t\tMinVersion: cfg.MinVersion,\n\t\tMaxVersion: cfg.MaxVersion,\n\t\tDynamicRecordSizingDisabled: cfg.DynamicRecordSizingDisabled,\n\t\tRenegotiation: cfg.Renegotiation,\n\t\tCurvePreferences: cfg.CurvePreferences,\n\t}\n\treturn &ncfg\n}", "func NewTLSTransport(config TLSConfig, inner Transport) (*TLSTransport, error) {\n\ttransport := &TLSTransport{inner: inner}\n\ttc := &transport.tlsConfig\n\n\tcert, err := tls.LoadX509KeyPair(config.Cert, config.Key)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to load key pair\")\n\t}\n\ttc.Certificates = append(tc.Certificates, cert)\n\n\tif len(config.CAs) == 0 {\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\tif len(config.ExtraCAs) > 0 {\n\t\t\t\treturn nil, errors.New(\n\t\t\t\t\t\"currently adding extra CA(s) to \" +\n\t\t\t\t\t\t\"system default CA pool is not supported on Windows\")\n\t\t\t}\n\t\t} else {\n\t\t\tif tc.RootCAs, err = x509.SystemCertPool(); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"failed to load system CA pool\")\n\t\t\t}\n\t\t}\n\t} else {\n\t\ttc.RootCAs = x509.NewCertPool()\n\t}\n\tcaToAdd := append(config.CAs, config.ExtraCAs...)\n\tfor i := range caToAdd {\n\t\tif err := addCA(tc.RootCAs, caToAdd[i]); err != nil {\n\t\t\treturn nil, errors.Wrapf(\n\t\t\t\terr, \"failed to add %s to the root ca list\", caToAdd[i])\n\t\t}\n\t}\n\n\tif config.VerifyClient {\n\t\ttc.ClientAuth = tls.RequireAndVerifyClientCert\n\t}\n\n\tif len(config.ClientCAs) > 0 {\n\t\ttc.ClientCAs = x509.NewCertPool()\n\t\tfor i := range config.ClientCAs {\n\t\t\tif err := addCA(tc.ClientCAs, config.ClientCAs[i]); err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err,\n\t\t\t\t\t\"failed to add %s to the client ca list\",\n\t\t\t\t\tconfig.ClientCAs[i])\n\t\t\t}\n\t\t}\n\t}\n\n\ttc.MinVersion = tls.VersionTLS11\n\n\ttc.CipherSuites = []uint16{\n\t\ttls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,\n\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,\n\t\ttls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,\n\t\ttls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,\n\t\ttls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,\n\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,\n\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,\n\t\ttls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,\n\t}\n\n\ttc.ClientSessionCache = tls.NewLRUClientSessionCache(\n\t\tconfig.SessionCacheSize)\n\n\tif config.HandshakeTimeout != \"\" {\n\t\tt, err := time.ParseDuration(config.HandshakeTimeout)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"invalid handshake_timeout\")\n\t\t}\n\t\tif t <= 0 {\n\t\t\treturn nil, errors.New(\"handshake_timeout should be > 0\")\n\t\t}\n\t\ttransport.handshakeTimeout = t\n\t} else {\n\t\ttransport.handshakeTimeout = defaultTLSHandshakeTimeout\n\t}\n\n\treturn transport, nil\n}", "func LoadTLSConfig(conn ssh.Connection) (*tls.Config, error) {\n\tsshfs := sshiofs.New(conn)\n\t// Download CA\n\tcaCertPem, err := fs.ReadFile(sshfs, \"/etc/kubernetes/pki/etcd/ca.crt\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Download cert\n\tcertPem, err := fs.ReadFile(sshfs, \"/etc/kubernetes/pki/etcd/server.crt\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Download key\n\tkeyPem, err := fs.ReadFile(sshfs, \"/etc/kubernetes/pki/etcd/server.key\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add certificate and key to the TLS config\n\tcert, err := tls.X509KeyPair(certPem, keyPem)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add CA certificate to the TLS config\n\tcaCertPool := x509.NewCertPool()\n\tcaCertPool.AppendCertsFromPEM(caCertPem)\n\n\treturn &tls.Config{\n\t\tMinVersion: tls.VersionTLS12,\n\t\tRootCAs: caCertPool,\n\t\tCertificates: []tls.Certificate{cert},\n\t}, nil\n}", "func (s *Server) tlsConfig() (*tls.Config, error) {\n\tc, err := tls2.GetX509KeyPair(s.config.Ssl.CertFile, s.config.Ssl.KeyFile, s.config.Ssl.KeyPassword)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error with certificate file %s: %w\", s.config.Ssl.CertFile, err)\n\t}\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{c},\n\t\tPreferServerCipherSuites: true,\n\t\tMinVersion: tls.VersionTLS12,\n\t}, nil\n}", "func (ca *CA) getTLSConfig(auth *authority.Authority) (*tls.Config, *tls.Config, error) {\n\t// Create initial TLS certificate\n\ttlsCrt, err := auth.GetTLSCertificate()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// Start tls renewer with the new certificate.\n\t// If a renewer was started, attempt to stop it before.\n\tif ca.renewer != nil {\n\t\tca.renewer.Stop()\n\t}\n\n\tca.renewer, err = NewTLSRenewer(tlsCrt, auth.GetTLSCertificate)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tca.renewer.Run()\n\n\tvar serverTLSConfig *tls.Config\n\tif ca.config.TLS != nil {\n\t\tserverTLSConfig = ca.config.TLS.TLSConfig()\n\t} else {\n\t\tserverTLSConfig = &tls.Config{\n\t\t\tMinVersion: tls.VersionTLS12,\n\t\t}\n\t}\n\n\t// GetCertificate will only be called if the client supplies SNI\n\t// information or if tlsConfig.Certificates is empty.\n\t// When client requests are made using an IP address (as opposed to a domain\n\t// name) the server does not receive any SNI and may fallback to using the\n\t// first entry in the Certificates attribute; by setting the attribute to\n\t// empty we are implicitly forcing GetCertificate to be the only mechanism\n\t// by which the server can find it's own leaf Certificate.\n\tserverTLSConfig.Certificates = []tls.Certificate{}\n\n\tclientTLSConfig := serverTLSConfig.Clone()\n\n\tserverTLSConfig.GetCertificate = ca.renewer.GetCertificateForCA\n\tclientTLSConfig.GetClientCertificate = ca.renewer.GetClientCertificate\n\n\t// initialize a certificate pool with root CA certificates to trust when doing mTLS.\n\tcertPool := x509.NewCertPool()\n\t// initialize a certificate pool with root CA certificates to trust when connecting\n\t// to webhook servers\n\trootCAsPool, err := x509.SystemCertPool()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tfor _, crt := range auth.GetRootCertificates() {\n\t\tcertPool.AddCert(crt)\n\t\trootCAsPool.AddCert(crt)\n\t}\n\n\t// adding the intermediate CA certificates to the pool will allow clients that\n\t// do mTLS but don't send an intermediate to successfully connect. The intermediates\n\t// added here are used when building a certificate chain.\n\tintermediates := tlsCrt.Certificate[1:]\n\tfor _, certBytes := range intermediates {\n\t\tcert, err := x509.ParseCertificate(certBytes)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tcertPool.AddCert(cert)\n\t\trootCAsPool.AddCert(cert)\n\t}\n\n\t// Add support for mutual tls to renew certificates\n\tserverTLSConfig.ClientAuth = tls.VerifyClientCertIfGiven\n\tserverTLSConfig.ClientCAs = certPool\n\n\tclientTLSConfig.RootCAs = rootCAsPool\n\n\treturn serverTLSConfig, clientTLSConfig, nil\n}", "func RecordTLSConfig(root tls.Certificate, w *WritableArchive) (*tls.Config, error) {\n\troot_cert, err := getRootCert(root)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"bad local cert: %v\", err)\n\t}\n\ttp := &tlsProxy{&root, root_cert, nil, w}\n\treturn &tls.Config{\n\t\tGetConfigForClient: tp.getRecordConfigForClient,\n\t}, nil\n}", "func (instance *TLSProvider) CreateListener(network string, address string) (listener net.Listener, err error) {\n\tconfig := &tls.Config{\n\t\tClientAuth: tls.NoClientCert,\n\t\t//MinVersion: tls.VersionTLS10,\n\t\tNextProtos: []string{\"h2\", \"http/1.1\"},\n\t\tGetCertificate: instance.GetCertificate,\n\t\tPreferServerCipherSuites: true,\n\t\t// If CipherSuites is nil, a default list of secure cipher suites is used, with a preference order based on hardware performance.\n\t\t/*\n\t\t\tCipherSuites: []uint16{\n\t\t\t\t// https://pkg.go.dev/crypto/tls#pkg-constants\n\n\t\t\t\t// TLS 1.0 - 1.2 (for RSA server certifacte)\n\t\t\t\t//tls.TLS_RSA_WITH_RC4_128_SHA, // 142.03 req/s\n\t\t\t\t//tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, // 27.58 req/s\n\t\t\t\t//tls.TLS_RSA_WITH_AES_128_CBC_SHA, // 168.58 req/s\n\t\t\t\t//tls.TLS_RSA_WITH_AES_256_CBC_SHA, // 164.96 req/s\n\t\t\t\t//tls.TLS_RSA_WITH_AES_128_CBC_SHA256, // 128.54 req/s\n\t\t\t\t//tls.TLS_RSA_WITH_AES_128_GCM_SHA256, // 221.98 req/s\n\t\t\t\t//tls.TLS_RSA_WITH_AES_256_GCM_SHA384, // 214.77 req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, // 189.06 req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, // 183.72 req/s\n\t\t\t\t//tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, // 130.55 req/s\n\t\t\t\t// TLS 1.0 - 1.2 (for ECC server certificate)\n\t\t\t\t//tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, // ? req/s\n\t\t\t\t//tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, // ? req/s\n\t\t\t\t// TLS 1.3\n\t\t\t\t//tls.TLS_AES_128_GCM_SHA256, // ? req/s\n\t\t\t\t//tls.TLS_AES_256_GCM_SHA384, // ? req/s\n\t\t\t\t//tls.TLS_CHACHA20_POLY1305_SHA256, // ? req/s\n\t\t\t},\n\t\t*/\n\t}\n\tlistener, err = net.Listen(network, address)\n\tif err != nil {\n\t\treturn\n\t}\n\tlistener = tls.NewListener(listener, config)\n\treturn\n}", "func (i *IdentityFile) TLSConfig() (*tls.Config, error) {\n\tcert, err := keys.X509KeyPair(i.Certs.TLS, i.PrivateKey)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\tpool := x509.NewCertPool()\n\tfor _, caCerts := range i.CACerts.TLS {\n\t\tif !pool.AppendCertsFromPEM(caCerts) {\n\t\t\treturn nil, trace.BadParameter(\"invalid CA cert PEM\")\n\t\t}\n\t}\n\n\treturn &tls.Config{\n\t\tCertificates: []tls.Certificate{cert},\n\t\tRootCAs: pool,\n\t}, nil\n}", "func (ep *Endpoint) tlsConfig() (*tls.Config, error) {\n\tif ep.TLSData == nil && !ep.SkipTLSVerify {\n\t\t// there is no specific tls config\n\t\treturn nil, nil\n\t}\n\tvar tlsOpts []func(*tls.Config)\n\tif ep.TLSData != nil && ep.TLSData.CA != nil {\n\t\tcertPool := x509.NewCertPool()\n\t\tif !certPool.AppendCertsFromPEM(ep.TLSData.CA) {\n\t\t\treturn nil, errors.New(\"failed to retrieve context tls info: ca.pem seems invalid\")\n\t\t}\n\t\ttlsOpts = append(tlsOpts, func(cfg *tls.Config) {\n\t\t\tcfg.RootCAs = certPool\n\t\t})\n\t}\n\tif ep.TLSData != nil && ep.TLSData.Key != nil && ep.TLSData.Cert != nil {\n\t\tkeyBytes := ep.TLSData.Key\n\t\tpemBlock, _ := pem.Decode(keyBytes)\n\t\tif pemBlock == nil {\n\t\t\treturn nil, errors.New(\"no valid private key found\")\n\t\t}\n\t\tif x509.IsEncryptedPEMBlock(pemBlock) { //nolint:staticcheck // SA1019: x509.IsEncryptedPEMBlock is deprecated, and insecure by design\n\t\t\treturn nil, errors.New(\"private key is encrypted - support for encrypted private keys has been removed, see https://docs.docker.com/go/deprecated/\")\n\t\t}\n\n\t\tx509cert, err := tls.X509KeyPair(ep.TLSData.Cert, keyBytes)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to retrieve context tls info\")\n\t\t}\n\t\ttlsOpts = append(tlsOpts, func(cfg *tls.Config) {\n\t\t\tcfg.Certificates = []tls.Certificate{x509cert}\n\t\t})\n\t}\n\tif ep.SkipTLSVerify {\n\t\ttlsOpts = append(tlsOpts, func(cfg *tls.Config) {\n\t\t\tcfg.InsecureSkipVerify = true\n\t\t})\n\t}\n\treturn tlsconfig.ClientDefault(tlsOpts...), nil\n}", "func ValidateTLSConfig(config *schema.TLS, configDefault *schema.TLS) (err error) {\n\tif configDefault == nil {\n\t\treturn errors.New(\"must provide configDefault\")\n\t}\n\n\tif config == nil {\n\t\treturn\n\t}\n\n\tif config.ServerName == \"\" {\n\t\tconfig.ServerName = configDefault.ServerName\n\t}\n\n\tif config.MinimumVersion.Value == 0 {\n\t\tconfig.MinimumVersion.Value = configDefault.MinimumVersion.Value\n\t}\n\n\tif config.MaximumVersion.Value == 0 {\n\t\tconfig.MaximumVersion.Value = configDefault.MaximumVersion.Value\n\t}\n\n\tif config.MinimumVersion.MinVersion() < tls.VersionTLS10 {\n\t\treturn errors.New(\"option 'minimum_version' is invalid: minimum version is TLS1.0 but SSL3.0 was configured\")\n\t}\n\n\tif config.MinimumVersion.MinVersion() > config.MaximumVersion.MaxVersion() {\n\t\treturn fmt.Errorf(\"option combination of 'minimum_version' and 'maximum_version' is invalid: minimum version %s is greater than the maximum version %s\", config.MinimumVersion.String(), config.MaximumVersion.String())\n\t}\n\n\tif (config.CertificateChain.HasCertificates() || config.PrivateKey != nil) && !config.CertificateChain.EqualKey(config.PrivateKey) {\n\t\treturn errors.New(\"option 'certificates' is invalid: provided certificate does not contain the public key for the private key provided\")\n\t}\n\n\treturn nil\n}" ]
[ "0.79326254", "0.73788613", "0.7294283", "0.72898865", "0.71747434", "0.71747434", "0.71747434", "0.71747434", "0.7162306", "0.71118134", "0.6947135", "0.6874644", "0.6862285", "0.6862285", "0.673357", "0.67174786", "0.67114896", "0.6697693", "0.66969925", "0.66713005", "0.6668117", "0.66388613", "0.6628726", "0.6625738", "0.6622439", "0.66170937", "0.65634155", "0.6551943", "0.6514775", "0.6509724", "0.6502401", "0.64933753", "0.6459192", "0.64461285", "0.6432107", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6418362", "0.6402101", "0.6402101", "0.6377326", "0.6348638", "0.63470054", "0.6338183", "0.63132435", "0.62991697", "0.62944835", "0.62870926", "0.627902", "0.6269259", "0.6232701", "0.6223338", "0.62221056", "0.62194014", "0.62160796", "0.62131554", "0.61998427", "0.61764324", "0.6150376", "0.6073594", "0.6065611", "0.6048644", "0.60484064", "0.6047089", "0.60273707", "0.6026271", "0.60170126", "0.6013475", "0.6012893", "0.5996866", "0.5984009", "0.5974319", "0.5952142", "0.59220934", "0.590085", "0.5889418", "0.5880425", "0.58316064", "0.5825276", "0.58055556", "0.5776965", "0.5773106" ]
0.7967637
0
Constructor will Initialize your data structure here.
func Constructor() RandomizedSet { return RandomizedSet{ Value: map[int]bool{}, Keys: []int{}, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewData() *Data {\n d := &Data{}\n d.hashMap = make(map[int]string)\n return d\n}", "func Constructor() MyHashMap {\n\treturn MyHashMap{[10005][]Node{}}\n}", "func Constructor() WordDictionary {\n\treturn WordDictionary{root:newNode2(),size:0}\n}", "func initialize() {\n\n\thead.data = \"San Francisco\"\n\thead.next = nil\n\n\tvar Oakland *Node = &Node{data: \"Oakland\", next: nil}\n\thead.next = Oakland\n\n\tvar Berkely *Node = &Node{data: \"Berkely\", next: nil}\n\tOakland.next = Berkely\n\n\tvar Fremont *Node = &Node{data: \"Fremont\", next: nil}\n\tBerkely.next = Fremont\n\n\t// remember this pattern for linked list\n\t// make the last insertion, tail = last value\n\ttail = Fremont\n\ttail.next = nil\n\tBerkely.next = tail\n}", "func Constructor() MyHashMap {\n\treturn MyHashMap{make([]*Node, 10000), 10000}\n}", "func Constructor() WordDictionary {\n \n}", "func init(){\n\n\tcustomers = loadAllCustomers()\n\tBuildRank()\n\tBuildTable()\n\n}", "func init() {\n\tSliceOfString = make([]string, 0, 10)\n\tMapOfString = make(map[string]string)\n\tMapOfBool = make(map[string]bool)\n}", "func (l *list) init() {\n\tl.nodes = 0\n\tl.begin = &node{\"\", nil, nil}\n}", "func Constructor() MyHashMap {\n\tsize := 100\n\thm := MyHashMap{\n\t\tArrays: make([]*Node, size),\n\t\tSize: 100,\n\t\tHashFunc: func(key int) int {\n\t\t\treturn key % size\n\t\t},\n\t}\n\n\treturn hm\n}", "func Constructor() WordDictionary {\n\troot := TrieNode{}\n\troot.next = make([]*TrieNode, 26)\n\tw := WordDictionary{&root}\n\treturn w\n}", "func Constructor() WordDictionary {\n\treturn WordDictionary{\n\t\troot: getNode(),\n\t}\n}", "func Constructor() Trie {\n\treturn Trie{data: [26]*Trie{}}\n}", "func initData() {\n\tallMap = make(map[string]int64, 0)\n\terrMap = make(map[string]int64, 0)\n}", "func (m *MixtapeIndex) init() {\n\tm.Users = make(map[string]*User)\n\tm.Playlists = make(map[string]*Playlist)\n\tm.Songs = make(map[string]*Song)\n\tm.PlaylistIdUpperBound = -1\n}", "func InitializeData() {\n\t// First we do the black cards\n\tBlackCards = make(map[int]BlackCard)\n\tImportBlackCards()\n\t// Print the amount of Black Cards loaded into memory.\n\tfmt.Printf(\"%d Black Cards loaded!\\n\", len(BlackCards))\n\n\t// Then we do the white cards.\n\tWhiteCards = make(map[int]WhiteCard)\n\tImportWhiteCards()\n\t// Print the amount of White Cards loaded into memory.\n\tfmt.Printf(\"%d White Cards loaded!\\n\", len(WhiteCards))\n\n\t// Moving on, we now want to make the players map.\n\tPlayers = make(map[string]Player)\n\n\t// We want to clear the following variables..\n\tPlayerCount = 0\n\tHighScore = 0\n\tZar = 0\n\tRound = 0\n\tRounds = 10\n\tRoundText = \"\"\n\tRoundResults = nil\n\tCreatorID = \"\"\n\tZars = nil\n\tJudging = false\n}", "func Constructor() MagicDictionary {\n\twords := make(map[int][]string)\n\treturn MagicDictionary{words: words}\n}", "func init() {\n\tcdb = &classDB{classMap: make(map[int]Class)}\n\tif err := loadData(cdb); err != nil {\n\t\tlog.Print(\"Panic in loading data\")\n\t}\n\tlog.Print(\"Class Data from file is loaded!!\")\n\n}", "func Constructor() MyHashMap {\n\treturn MyHashMap{0, InitContainer, make([]*Node, InitContainer)}\n}", "func (d *DB) Init() {\n\td.NumCell = 1024 // set num cell first!\n\td.root = d.NewNode()\n\t//log.Printf(\"+d.root: %v\\n\", d.root)\n}", "func Constructor() RandomizedCollection {\n\treturn RandomizedCollection{\n\t\tm: make(map[int][]int),\n\t\ta: []int{},\n\t}\n}", "func init() {\n\t//allocate memory to maps\n\tusermap = make(map[string]UserData)\n\tstopwords = make(map[string]struct{})\n\tSubCommentMap = make(map[string]SubsCommentData)\n\tusagecmmts = make(map[string](map[string]SubsWordData))\n\tusagesubmstitle = make(map[string](map[string]SubsWordData))\n\tusagesubmsbody = make(map[string](map[string]SubsWordData))\n\n\t//load secret file\n\tconfigdata, err := os.Open(\"C:\\\\Users\\\\Myke\\\\Dropbox\\\\School\\\\CSCI164\\\\Project\\\\config.secret\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t//close file when program is done\n\tdefer configdata.Close()\n\n\t//load config file from json to config struct\n\tscanner := bufio.NewScanner(configdata)\n\tfor scanner.Scan() {\n\t\terr = json.Unmarshal(scanner.Bytes(), &config)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t}\n\n\t//load stopwords\n\tstopdata, err := os.Open(\"C:\\\\Users\\\\Myke\\\\Dropbox\\\\School\\\\CSCI164\\\\Project\\\\stopwords\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t//place stop words into a map\n\tscanner = bufio.NewScanner(stopdata)\n\tfor scanner.Scan() {\n\t\tvar z struct{}\n\t\tstopwords[scanner.Text()] = z\n\t}\n\n\t//close file when program is done\n\tdefer stopdata.Close()\n\n}", "func (s *Struct) Init() {\n\ts.Comments = make([]string, 0)\n\ts.Attributes = make([]*Attribute, 0)\n\ts.Fields = make([]*Field, 0)\n}", "func init() {\n\t// Initialization goes here\n}", "func Constructor() Trie {\n\twords := make(map[int][]string)\n\treturn Trie{words: words}\n}", "func Constructor() MyHashMap {\n\treturn MyHashMap{\n\t\t[1111]*Node{},\n\t}\n}", "func Constructor() TwoSum {\n\treturn TwoSum{data: map[int]int{}}\n}", "func Constructor() AllOne {\n return AllOne{m: make(map[string]*dll), g: make(map[int][]*dll)}\n}", "func (this *Vector)init(){\n\tif this.v==nil{\n\t\tthis.v=make([]interface{},0,1)\n\t}\n}", "func Constructor() WordDictionary {\n\treturn WordDictionary{head: &trieNode{}}\n}", "func init() {\n\tSample = map[string]Personas{\n\t\t\"1\": Personas{Id: \"1\", Nombre: \"Luis\", Apellido: \"Perez\"},\n\t\t\"2\": Personas{Id: \"2\", Nombre: \"Maria\", Apellido: \"Romano\"},\n\t\t\"3\": Personas{Id: \"3\", Nombre: \"Nestor\", Apellido: \"Sanchez\"},\n\t}\n}", "func Constructor() WordDictionary {\n\treturn WordDictionary{\n\t\tTree: new(Trie),\n\t}\n}", "func init() {\n\t//todo...\n}", "func Constructor() RandomizedCollection {\n \n}", "func Constructor() RandomizedSet {\n\tvar randomizedSet RandomizedSet\n\trandomizedSet.indices = make(map[int]int)\n\trandomizedSet.list = make([]int, 0, 10)\n\treturn randomizedSet\n}", "func Constructor() MyHashMap {\n\thm := new(MyHashMap)\n\tcapacity := 10000\n\thm.HMap = make([]*HMListNode, capacity)\n\treturn *hm\n}", "func Constructor(length int) SnapshotArray {\n\ts := make([]map[int]int, 0, 128)\n\tc := make(map[int]int, 32)\n\treturn SnapshotArray{\n\t\tsnaps: s,\n\t\tcurrent: c,\n\t\tid: 0,\n\t}\n}", "func Constructor() RandomizedSet {\n\tp := make(map[int]struct{})\n\treturn RandomizedSet{p}\n}", "func Constructor() WordDictionary {\n\treturn WordDictionary{\n\t\tNexts: make([]*WordDictionary, 26),\n\t}\n}", "func Constructor() MyHashMap {\n\treturn MyHashMap{b: 1 << 10, bucket: make([][]kv, 1<<10)}\n}", "func Constructor() WordDictionary {\n\treturn WordDictionary{}\n}", "func Constructor() MyHashSet {\n\ths := MyHashSet{}\n\ths.bucket = 1337\n\ths.Table = make([]*List, hs.bucket)\n\tfor i := uint32(0); i < hs.bucket; i++ {\n\t\ths.Table[i] = &List{}\n\t}\n\treturn hs\n}", "func (m *metricRedisMemoryLua) init() {\n\tm.data.SetName(\"redis.memory.lua\")\n\tm.data.SetDescription(\"Number of bytes used by the Lua engine\")\n\tm.data.SetUnit(\"By\")\n\tm.data.SetEmptyGauge()\n}", "func init() {\n\tif err := mb.Registry.AddMetricSet(\"consulkv\", \"kv\", New); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (l *Labels) init() {\n\tif l.lmap == nil {\n\t\tl.lmap = make(map[string]int64)\n\t\tl.offLabels = make(map[int64][]string)\n\t}\n}", "func (c *Collector) Init() error { return nil }", "func Constructor() Trie {\n\ttrie := Trie{root: &TrieNode{children: make([]*TrieNode, 26)}, res: make([]string, 0)}\n\treturn trie\n}", "func Constructor() MyHashSet {\n\tvar myHashSet MyHashSet\n\tmyHashSet.value = make(map[int][]int)\n\treturn myHashSet\n}", "func New() *Data {\n\treturn &Data{Values: make(map[Key][]byte)}\n}", "func (l *lru_cache) Init(capacity int) {\n\tl.dataMap = make(map[Key]*list.Element)\n\n\tl.capacity = capacity\n\tl.linkList.Init()\n}", "func Constructor() MyQueue {\n\treturn Myqueue{list: listNew()}\n}", "func Constructor() MapSum {\n\tobj := MapSum{}\n\tobj.Nodes = map[byte]*MapSum{}\n\treturn obj\n}", "func (c *Carta) Init(id, tipo, era, puntos, edificioGratis, cartaRequerida int, nombre string, produce, requiere [CANTIDAD_RECURSOS]int){\n c.Id = id\n c.Tipo = tipo\n c.era = era\n c.puntos = puntos\n c.edificioGratis = edificioGratis\n c.Nombre = nombre\n c.Produce = produce\n c.requiere = requiere\n c.cartaRequerida = cartaRequerida\n}", "func InitBook(ticker string) *Book {\n return &Book{\n BuyTree: binarytree.NewTree(),\n SellTree: binarytree.NewTree(),\n LowestSell: nil,\n HighestBuy: nil,\n OrderMap: make(map[int]*Order),\n BuyLimitMap: make(map[LimitPrice]*InfoAtLimit),\n SellLimitMap: make(map[LimitPrice]*InfoAtLimit),\n TickerOFBook: ticker}\n}", "func Constructor() RandomizedSet {\n\treturn RandomizedSet{\n\t\tvalsSet: make(map[int]valEl),\n\t}\n\n}", "func (l *log) init() {\n\tl.entries = make([]*Entry, 0)\n}", "func Constructor() RandomizedSet {\n\treturn RandomizedSet{\n\t\tm: make(map[int]int),\n\t\tdata: make([]int, 0),\n\t}\n}", "func Constructor() Trie {\n\tt := Trie{}\n\tt.links = make(map[string]*Trie)\n\tt.isEnd = false\n\treturn t\n}", "func (m *clistModel) Init(t *rapid.T) {\n\tm.clist = clist.New()\n\tm.model = []*clist.CElement{}\n}", "func Constructor() Twitter {\n\treturn Twitter{\n\t\tsequence: 0,\n\t\tfollows: make(map[int]map[int]struct{}),\n\t\tsendTwitters: make(map[int][]Node),\n\t}\n}", "func Constructor() Trie {\n\treturn Trie{100, false, [26]*Trie{}}\n}", "func New() *Data {\n\treturn &Data{\n\t\tValues: make(map[string]DataType),\n\t\tData: make(map[string]interface{}),\n\t\tunexportedData: make(map[string]interface{}),\n\t\tcache: make(map[string]interface{}),\n\t}\n}", "func Constructor() HitCounter {\n\treturn HitCounter{&Node{0,0,nil,nil}}\n}", "func (d *Data) Init() {\n\t// (X) d = NewData()\n\t// This only updates its pointer\n\t// , not the Data itself\n\t//\n\t*d = *NewData()\n}", "func Constructor() Trie {\n\treturn Trie{\n\t\tnext: [26]*Trie{},\n\t}\n}", "func Constructor() Trie {\n\t// return new trie instance\n\treturn Trie{root: &TrieNode{map[rune]*TrieNode{}, false}}\n}", "func (s StatsGraph) construct() StatsGraphClass { return &s }", "func Constructor() MyHashMap {\n\tvar hmap MyHashMap\n\thmap.v = make([]int, 1000001)\n\tfor i := 0; i < 1000001; i++ {\n\t\thmap.v[i] = -1\n\t}\n\treturn hmap\n}", "func (kb *Kbucket) Init(nodeID ID) {\n\tkb.ContactList = make([]Contact, 0, k)\n\tkb.NodeID = nodeID\n}", "func (m *metricMysqlBufferPoolDataPages) init() {\n\tm.data.SetName(\"mysql.buffer_pool.data_pages\")\n\tm.data.SetDescription(\"The number of data pages in the InnoDB buffer pool.\")\n\tm.data.SetUnit(\"1\")\n\tm.data.SetEmptySum()\n\tm.data.Sum().SetIsMonotonic(false)\n\tm.data.Sum().SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative)\n\tm.data.Sum().DataPoints().EnsureCapacity(m.capacity)\n}", "func (m *metricRedisMaxmemory) init() {\n\tm.data.SetName(\"redis.maxmemory\")\n\tm.data.SetDescription(\"The value of the maxmemory configuration directive\")\n\tm.data.SetUnit(\"By\")\n\tm.data.SetEmptyGauge()\n}", "func Constructor() Twitter {\n\treturn Twitter{Users: make(map[int]*User)}\n}", "func (db *Database) init(g []Group, e []Entry, opts *Options) {\n\t// Clear inputted key material.\n\tif db.cparams.ComputedKey == nil {\n\t\tpanic(\"key should have been precomputed\")\n\t}\n\tdb.cparams.Key.Password, db.cparams.Key.KeyFileHash = nil, nil\n\n\tdb.staticIV = opts.staticIV()\n\tdb.groups = make(map[uint32]*Group, len(g))\n\tdb.entries = make([]*Entry, 0, len(e))\n\tdb.rand = opts.getRand()\n\tdb.root = &Group{Name: \"Root\", db: db}\n\tfor i := range g {\n\t\tgg := &g[i]\n\t\tdb.groups[gg.ID] = gg\n\t}\n\tfor i := range e {\n\t\tee := &e[i]\n\t\tif ee.isMetaStream() {\n\t\t\tdb.meta = append(db.meta, ee)\n\t\t} else {\n\t\t\tdb.entries = append(db.entries, ee)\n\t\t}\n\t}\n}", "func InitGraph() {\n\tgraph.Rooms = make(map[string]Room)\n\t// graph.steps = make(map[int]string)\n\n}", "func NewData() *Data {\n\tnmap := make(map[interface{}]int)\n\treturn &Data{\n\t\tm: nmap,\n\t}\n\t// return make(Data)\n}", "func Constructor() MyHashSet {\n\treturn MyHashSet{make([]list.List, base)}\n\n}", "func (svc Service) Initialize() {\n\tlog.Info(\"initialize the database...\")\n\tlines := strings.Split(geodata, \"\\n\")\n\n\tlog.Info(\"processing %d data rows...\\n\", len(lines))\n\tfor i := 0; i < len(lines); i++ {\n\t\tfields := strings.Split(lines[i], \",\")\n\t\tzipcode := Ziptype(fields[0])\n\n\t\tlat, _ := strconv.ParseFloat(fields[1], 64)\n\t\tlng, _ := strconv.ParseFloat(fields[2], 64)\n\n\t\tkey := svc.CreateKey(lat, lng)\n\n\t\tcoord := Coord{lat, lng}\n\t\tzipMap[zipcode] = &coord\n\n\t\tzcoord := ZipcodeCoord{zipcode, coord}\n\t\tkeyMap[key] = append(keyMap[key], &zcoord)\n\t}\n\n\tlog.Info(\"processed %d rows...\\n\", len(lines))\n}", "func (m *metricAerospikeNamespaceMemoryUsage) init() {\n\tm.data.SetName(\"aerospike.namespace.memory.usage\")\n\tm.data.SetDescription(\"Memory currently used by each component of the namespace\")\n\tm.data.SetUnit(\"By\")\n\tm.data.SetEmptySum()\n\tm.data.Sum().SetIsMonotonic(false)\n\tm.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)\n\tm.data.Sum().DataPoints().EnsureCapacity(m.capacity)\n}", "func (m *metricActiveDirectoryDsReplicationObjectRate) init() {\n\tm.data.SetName(\"active_directory.ds.replication.object.rate\")\n\tm.data.SetDescription(\"The number of objects transmitted by the Directory Replication Agent per second.\")\n\tm.data.SetUnit(\"{objects}/s\")\n\tm.data.SetEmptySum()\n\tm.data.Sum().SetIsMonotonic(false)\n\tm.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)\n\tm.data.Sum().DataPoints().EnsureCapacity(m.capacity)\n}", "func (s *SinglyLinkedList) Init() *SinglyLinkedList {\n s.length = 0\n return s\n}", "func init() {\n\n\t//Welcome Message\n\tfmt.Println(\"------------------------------------------------------------------\")\n\tfmt.Println(\"Starting Natyla...\")\n\tfmt.Println(\"Version: 1.02\")\n\n\t//Set the thread quantity based on the number of CPU's\n\tcoreNum := runtime.NumCPU()\n\n\tfmt.Println(\"Number of cores: \", coreNum)\n\n\t//read the config file\n\treadConfig()\n\n\t//create the data directory\n\tcreateDataDir()\n\n\t//set max memory form config\n\tmaxMemBytes, _ = config[\"memory\"].(json.Number).Int64()\n\tfmt.Println(\"Max memory defined as: \", maxMemBytes/1024/1024, \" Mbytes\")\n\n\truntime.GOMAXPROCS(coreNum)\n\n\t//Create a new doble-linked list to act as LRU\n\tlruList = list.New()\n\n\t//Create the channels\n\tlisChan = make(chan int, 1)\n\tLRUChan = make(chan int, 1)\n\tcollectionChan = make(chan int, 1)\n\n\tcollections = make(map[string]collectionChannel)\n\n\t//Read collections from disk\n\tnRead := readAllFromDisk()\n\tfmt.Println(\"Read\", nRead, \"entries from disk\")\n\n\tfmt.Println(\"Ready, API Listening on http://localhost:8080, Telnet on port 8081\")\n\tfmt.Println(\"------------------------------------------------------------------\")\n}", "func Constructor() Trie {\n\treturn Trie{root:&TrieNode{links:make(map[int32]*TrieNode)}}\n}", "func init() {\n\tMemory = &memoryStorage{\n\t\ttraces: make(map[string]tracer.Trace),\n\t\tservices: make(map[string]string),\n\t\tserviceDeps: make(map[string]*tracer.Dependencies),\n\t}\n}", "func (m *metricRedisDbKeys) init() {\n\tm.data.SetName(\"redis.db.keys\")\n\tm.data.SetDescription(\"Number of keyspace keys\")\n\tm.data.SetUnit(\"{key}\")\n\tm.data.SetEmptyGauge()\n\tm.data.Gauge().DataPoints().EnsureCapacity(m.capacity)\n}", "func Constructor() RandomizedSet {\n\treturn RandomizedSet{\n\t\ttable: map[int]int{},\n\t}\n}", "func Constructor() MapSum {\n\treturn MapSum{\n\t\troot: &TrieNode{},\n\t}\n}", "func (m *metricRedisMemoryUsed) init() {\n\tm.data.SetName(\"redis.memory.used\")\n\tm.data.SetDescription(\"Total number of bytes allocated by Redis using its allocator\")\n\tm.data.SetUnit(\"By\")\n\tm.data.SetEmptyGauge()\n}", "func (d *SliceDataStore) Init(parameters ...interface{}) error {\n\td.slice = make([]Record, parameters[0].(int))\n\treturn nil\n}", "func init() {\n\tstationsCache = make(map[string]Station)\n}", "func (m *metricRedisMemoryRss) init() {\n\tm.data.SetName(\"redis.memory.rss\")\n\tm.data.SetDescription(\"Number of bytes that Redis allocated as seen by the operating system\")\n\tm.data.SetUnit(\"By\")\n\tm.data.SetEmptyGauge()\n}", "func Constructor() RandomizedSet {\n\treturn RandomizedSet{arr: make([]int, 0), table: make(map[int]int)}\n}", "func (m *metricBigipPoolMemberCount) init() {\n\tm.data.SetName(\"bigip.pool.member.count\")\n\tm.data.SetDescription(\"Total number of pool members.\")\n\tm.data.SetUnit(\"{members}\")\n\tm.data.SetEmptySum()\n\tm.data.Sum().SetIsMonotonic(false)\n\tm.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)\n\tm.data.Sum().DataPoints().EnsureCapacity(m.capacity)\n}", "func Constructor() MyQueue {\n return MyQueue{q: []int{}}\n}", "func (s *Store) Init(sessionID []byte, defaultExpiration time.Duration) {\n\ts.sessionID = sessionID\n\ts.defaultExpiration = defaultExpiration\n\n\tif s.data == nil { // Ensure the store always has a valid pointer of Dict\n\t\ts.data = new(Dict)\n\t}\n}", "func (l *List) Init() {\r\n\tl.list = list.New()\r\n}", "func (g *Graph) init(numVertex int) {\n if g.vertex == nil {\n g.vertex = make([]*NodeG, numVertex)\n }\n}", "func (c *Context) init(ctx *fasthttp.RequestCtx) {\n\tc.RequestCtx = ctx\n\tc.data = newDataMap()\n\tc.index = -1\n\tc.Serialize = Serialize\n}", "func Constructor() MapSum {\n\treturn MapSum{\n\t\thash: make(map[string]int),\n\t\troot: &TrieNode{children: make(map[byte]*TrieNode)},\n\t}\n}", "func Constructor() RandomizedSet {\n\treturn RandomizedSet{\n\t\thash: make(map[int]int),\n\t\tarr: make([]int, 0),\n\t}\n}", "func Constructor() RandomizedSet {\n\treturn RandomizedSet{\n\t\tarr: make([]int, 0),\n\t\tv: make(map[int]int),\n\t}\n}", "func initializeGuildData(guildID string) {\n\t_, guildDataExists := guildData[guildID]\n\tif !guildDataExists {\n\t\tguildData[guildID] = &GuildData{}\n\t\tguildData[guildID].Queries = make(map[string]*Query)\n\t}\n}" ]
[ "0.60873514", "0.60087246", "0.5856668", "0.5840631", "0.5805296", "0.58047825", "0.5797549", "0.5733434", "0.57284784", "0.5727212", "0.57259125", "0.5710063", "0.570584", "0.5699865", "0.56768256", "0.56670105", "0.5664013", "0.56486166", "0.5637623", "0.5632756", "0.5629911", "0.5624332", "0.5623539", "0.5609566", "0.560591", "0.55951357", "0.5585481", "0.5582238", "0.5576917", "0.5574059", "0.5554059", "0.5526797", "0.5518094", "0.55165076", "0.5512621", "0.55099225", "0.5500688", "0.54966724", "0.5459204", "0.54472053", "0.5446736", "0.5430877", "0.54253566", "0.5424325", "0.5422522", "0.54206073", "0.54202116", "0.5415679", "0.5403755", "0.53981674", "0.53944516", "0.53845507", "0.53800607", "0.5367838", "0.5341757", "0.5334994", "0.5332093", "0.533207", "0.53274775", "0.53178984", "0.53155124", "0.5312529", "0.52911305", "0.52862483", "0.5277933", "0.52769125", "0.5273083", "0.52685404", "0.52675426", "0.5258884", "0.525837", "0.5252926", "0.5243252", "0.5238553", "0.5237722", "0.52287745", "0.52270675", "0.52266616", "0.5224181", "0.5220692", "0.5220574", "0.5217653", "0.5213475", "0.52095294", "0.52080685", "0.52043843", "0.52042294", "0.52010614", "0.520059", "0.52003044", "0.5199589", "0.5194999", "0.51824796", "0.51781064", "0.5178021", "0.51724356", "0.51694095", "0.5168493", "0.51677424", "0.5163275", "0.5160374" ]
0.0
-1
Insert will Inserts a value to the set. Returns true if the set did not already contain the specified element.
func (set *RandomizedSet) Insert(val int) bool { if v, ok := set.Value[val]; ok { if v { return false } } else { set.Keys = append(set.Keys, val) } set.Value[val] = true set.Count++ return true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.m[val]; ok{\n\t\treturn false\n\t}\n\tthis.m[val] = struct{}{}\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\t_, ok := this.m[val]\n\tif !ok {\n\t\tthis.m[val] = len(this.data)\n\t\tthis.data = append(this.data, val)\n\t}\n\n\treturn !ok\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\t_, ok := this.set[val]\n\tif ok {\n\t\treturn false\n\t}\n\tthis.set[val] = len(this.a)\n\tthis.a = append(this.a, val)\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.valsSet[val]; !ok {\n\t\tthis.valsSet[val] = valEl{val: val, ind: len(this.vals)}\n\t\tthis.vals = append(this.vals, val)\n\t\treturn true\n\t}\n\treturn false\n}", "func (rs *RandomizedSet) Insert(val int) bool {\n\tif _, ok := rs.set[val]; ok {\n\t\treturn false\n\t}\n\trs.set[val] = len(rs.keys)\n\trs.keys = append(rs.keys, val)\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.m[val]; ok {\n\t\treturn false\n\t}\n\tn := len(this.arr)\n\tthis.m[val] = n\n\tthis.arr = append(this.arr, val)\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.M[val]; ok {\n\t\treturn false\n\t}\n\tthis.M[val] = len(this.list)\n\tthis.list = append(this.list, val)\n\treturn true\n}", "func (s *RandomizedSet) Insert(val int) bool {\n\tif _, ok := s.table[val]; ok {\n\t\treturn false\n\t}\n\tn := len(s.arr)\n\ts.table[val] = n\n\ts.arr = append(s.arr, val)\n\n\treturn true\n}", "func (rs *RandomizedSet) Insert(val int) bool {\n\tif _, ok := rs.hash[val]; ok {\n\t\treturn false\n\t}\n\trs.hash[val] = len(rs.arr)\n\trs.arr = append(rs.arr, val)\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.table[val]; !ok {\n\t\tthis.arr = append(this.arr, val)\n\t\tthis.table[val] = len(this.arr) - 1\n\n\t\treturn true\n\t} else {\n\n\t\treturn false\n\t}\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.record[val]; ok {\n\t\treturn false\n\t}\n\tthis.nums = append(this.nums, val)\n\tthis.record[val] = len(this.nums) - 1\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.v[val]; ok {\n\t\treturn false\n\t}\n\tthis.arr = append(this.arr, val)\n\tthis.v[val] = len(this.arr) - 1\n\tthis.rand = 0\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.hashMap[val]; ok {\n\t\treturn false\n\t}\n\tvar idx int\n\tif len(this.arr) == this.length {\n\t\tthis.arr = append(this.arr, val)\n\t\tidx = len(this.arr) - 1\n\t} else {\n\t\tthis.arr[this.length] = val\n\t\tidx = this.length\n\t}\n\tthis.hashMap[val] = idx\n\tthis.length++\n\treturn true\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\tif _, ok := this.set[val]; !ok {\n\t\tthis.data = append(this.data, val) // 从尾部加入\n\t\tthis.set[val] = this.length\n\t\tthis.length++\n\t\treturn true\n\t}\n\treturn false\n}", "func (this *RandomizedSet) Insert(val int) bool {\r\n\tif _, ok := this.dict[val]; ok {return false}\r\n\tthis.dict[val] = len(this.location)\r\n\tthis.location = append(this.location, val)\r\n\treturn true\r\n}", "func (s *Set) Add(element interface{}) bool {\n\t_, exists := (*s)[element]\n\t(*s)[element] = struct{}{}\n\treturn !exists\n}", "func (this *RandomizedSet) Insert(val int) bool {\n\t_, ok := this.indices[val]\n\tif ok {\n\t\treturn false\n\t}\n\tthis.indices[val] = len(this.list)\n\tthis.list = append(this.list, val)\n\treturn true\n}", "func (set *LLSet) Insert(elem int) bool {\n\tif set.Contains(elem) {\n\t\treturn false\n\t}\n\n\tif set.head == nil {\n\t\tset.head = &Node{data: elem}\n\t\treturn true\n\t}\n\n\tcurrent := set.head\n\tfor current.next != nil {\n\t\tcurrent = current.next\n\t}\n\tcurrent.next = &Node{data: elem}\n\n\treturn true\n}", "func (this *RandomizedCollection) Insert(val int) bool {\n\tvar found bool\n\tif _, found = this.m[val]; !found {\n\t\tthis.m[val] = []int{}\n\t}\n\tthis.m[val] = append(this.m[val], len(this.a))\n\tthis.a = append(this.a, val)\n\treturn !found\n}", "func (set *Set) Add(element interface{}) {\n\tif !set.Contains(element) {\n\t\tset.mu.Lock()\n\t\tdefer set.mu.Unlock()\n\t\tset.elements[element] = true\n\n\t}\n}", "func (s Set) Insert(element string) {\n\ts[strings.ToLower(element)] = nothing{}\n}", "func (t *TST) Insert(s string, val interface{}) bool {\n\tif !t.Find(s) {\n\t\tt.Size++\n\t}\n\treturn t.root.rinsert(s, val) != nil\n}", "func (v *Set) Insert(b []byte) bool {\n\tiRepr := new(big.Int).SetBytes(b)\n\n\tl := len(*v)\n\tif l == 0 {\n\t\t*v = append(*v, iRepr)\n\t\treturn true\n\t}\n\n\tidx, found := v.indexOf(iRepr)\n\tif found {\n\t\treturn false\n\t}\n\n\t*v = append(*v, new(big.Int))\n\tcopy((*v)[idx+1:], (*v)[idx:])\n\n\t(*v)[idx] = iRepr\n\treturn true\n}", "func (t tagSet) Insert(p tagPair) tagSet {\n\ti := t.Search(p.key)\n\tif i < len(t) && t[i].key == p.key {\n\t\tt[i].value = p.value\n\t\treturn t // exists\n\t}\n\t// append t to the end of the slice\n\tif i == len(t) {\n\t\treturn append(t, p)\n\t}\n\t// insert p\n\tt = append(t, tagPair{})\n\tcopy(t[i+1:], t[i:])\n\tt[i] = p\n\treturn t\n}", "func (this *HashSet) Add(ele interface{}) bool {\n\treturn this.mmap.Put(ele, PRESENT)\n}", "func (s *Set) Insert(elements ...string) error {\n\tif len(elements) == 0 {\n\t\treturn nil\n\t}\n\n\tifaces := make([]interface{}, len(elements))\n\tfor i := range elements {\n\t\tifaces[i] = elements[i]\n\t}\n\n\tif _, err := s.store.Do(s.key, set.Insert, ifaces...); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *Set) Add(val int) bool {\n\tif s.Contains(val) {\n\t\treturn false\n\t}\n\ts.data = append(s.data, val)\n\treturn true\n}", "func (m *Map) Insert(key, value interface{}) (inserted bool) {\n\tm.root, inserted = m.insert(m.root, key, value)\n\tm.root.red = false\n\tif inserted {\n\t\tm.length++\n\t}\n\treturn inserted\n}", "func (s *SkipList) Insert(key Comparable) bool {\n\t_, created, _ := s.findOrCreate(key, true)\n\treturn created\n}", "func (s *HashSet) Add(data interface{}) error {\n\terr := s.checkT(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, ok := s.set[data]\n\tif ok {\n\t\treturn errors.New(\"ele exist\")\n\t}\n\ts.set[data] = nil\n\ts.size++\n\treturn nil\n}", "func Add(set Interface, x interface{}) bool {\n\treturn set.Add(x)\n}", "func (s *Set) Add(val interface{}) {\n\ts.set[val] = true\n}", "func (s RunIDSet) Insert(runID int64) {\n\ts[runID] = struct{}{}\n}", "func (s *Set) Add(val interface{}) {\n\ts.vals[val] = true\n}", "func (s *Set) Add(key string) {\n\tif s.Get(key) == nil {\n\t\ts.Insert(&Element{\n\t\t\tKey: key,\n\t\t})\n\t}\n}", "func (d *DB) Insert(keyVal *Pair) (bool, error) {\n\t// find insert position\n\tfound, cursor := recursiveSearch(keyVal.Key, d.root)\n\tif found && noDup { // found dup key\n\t\tkv := getKeyVal(cursor)\n\t\tlog.Printf(\"found dup key: %v -> %v\\n\", *keyVal, *kv)\n\t\tsetKeyVal(cursor, keyVal) // overwrite dup key\n\t\treturn true, nil\n\t}\n\tif cursor.Node == nil {\n\t\tlog.Panic(\"found invalid cursor!\")\n\t}\n\t// insert this kv pair first to make it really full;\n\tok, err := d.insertIntoNode(cursor, keyVal)\n\tif !ok {\n\t\tlog.Printf(\"failed insertIntoNode - cursor:%v, kv:%v\", cursor, keyVal)\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func (s HamtSet) Insert(e Entry) Set {\n\treturn HamtSet{\n\t\tset: s.set.Insert(e.(hamt.Entry)),\n\t}\n}", "func (c *Cuckoo) Insert(key Key, val Value) (ok bool) {\n\tok, _ = c.insert(key, val, c.StartLevel)\n\treturn\n}", "func (s int64set) add(value int64) bool {\n\n\t// 'ok' is true if value is within set\n\t_, ok := s[value]\n\tif ok {\n\t\treturn false // signifies nothing was inserted\n\t}\n\n\t// empty struct creation. The value in our set is mapped\n\t// to an empty struct because it takes of zero bytes.\n\t// but at least now the value is present in the set.\n\t// zero bytes thing is some black magic.\n\ts[value] = struct{}{}\n\treturn true\n}", "func (s *Set) Add(str string) bool {\n\tif s.Exist(str) {\n\t\treturn false\n\t}\n\ts.m[str] = struct{}{}\n\treturn false\n}", "func (c *OrderedMap) Insert(index int, key string, value interface{}) (interface{}, bool) {\n\toldValue, exists := c.Map[key]\n\tc.Map[key] = value\n\tif exists {\n\t\treturn oldValue, true\n\t}\n\tif index == len(c.Keys) {\n\t\tc.Keys = append(c.Keys, key)\n\t} else {\n\t\tc.Keys = append(c.Keys[:index+1], c.Keys[index:]...)\n\t\tc.Keys[index] = key\n\t}\n\treturn nil, false\n}", "func (set *StringSet) Add(val string) bool {\n\t_, found := set.m[val]\n\tset.m[val] = true\n\treturn !found\n}", "func (s Set) Insert(x interface{}) Set {\n\treturn Set{s.Tree.Insert(x)}\n}", "func (s *Set) Add(value string) error {\n\toriginalValue := value\n\tif !s.host.rawUTF8 {\n\t\tEncode(&value)\n\t}\n\t// Check that the value is not already there before adding\n\thas, err := s.Has(originalValue)\n\tif !has || noResult(err) {\n\t\t_, err = s.host.db.Exec(fmt.Sprintf(\"INSERT INTO %s (%s) VALUES ($1)\", s.table, setCol), value)\n\t}\n\treturn err\n}", "func (gs *GameSet) Add(item int64) bool {\n\tgs.mutex.Lock()\n\tgs.data[item] = true\n\tgs.mutex.Unlock()\n\treturn true\n}", "func (g *Group) Insert(e *GroupExpr) bool {\n\tif e == nil || g.Exists(e) {\n\t\treturn false\n\t}\n\n\toperand := GetOperand(e.ExprNode)\n\tvar newEquiv *list.Element\n\tmark, hasMark := g.FirstExpr[operand]\n\tif hasMark {\n\t\tnewEquiv = g.Equivalents.InsertAfter(e, mark)\n\t} else {\n\t\tnewEquiv = g.Equivalents.PushBack(e)\n\t\tg.FirstExpr[operand] = newEquiv\n\t}\n\tg.Fingerprints[e.FingerPrint()] = newEquiv\n\te.Group = g\n\treturn true\n}", "func (list *ArrayList[T]) Insert(index int, ele T) bool {\n\tif index < 0 || index > list.Size() {\n\t\treturn false\n\t}\n\tif index == list.Size() {\n\t\treturn list.Add(ele)\n\t}\n\ttemp := append(list.elems[:index], ele)\n\tlist.elems = append(temp, list.elems[index+1:]...)\n\treturn true\n}", "func (h Hash) Add(in string) bool {\n\tif _, ok := h[in]; ok {\n\t\t// already in the set\n\t\treturn false\n\t}\n\t// not in the set\n\th[in] = struct{}{}\n\treturn true\n}", "func (set *IntSet) Add(i int) bool {\n\t_, found := set.members[i]\n\tset.members[i] = true\n\treturn !found //False if it existed already\n}", "func (m MultiSet) Insert(val string){\n\tvar err error\n\tindex := rand.Intn(99999)\n\tfor m[strconv.Itoa(index)] != 0 {\n\t\tindex = rand.Intn(99999)\n\t}\n\tif m[strconv.Itoa(index)], err = strconv.Atoi(val); err != nil {\n\t\tfmt.Println(err)\n\t}\n}", "func (ts *TagSet) Add(tag string) (ok bool) {\n\tif ts.Has(tag) {\n\t\treturn false\n\t}\n\t*ts = append(*ts, tag)\n\treturn true\n}", "func (s StringSet) Add(element string) {\n\ts.Set[element] = true\n}", "func (c *lru) Insert(key string, value engines.Value) bool {\n\tif el, ok := c.cache[key]; ok {\n\t\tc.list.MoveToFront(el)\n\t\treturn false\n\t}\n\tentry := engines.NewEntry(key, value)\n\tel := c.list.PushFront(entry)\n\tc.cache[key] = el\n\tc.size += entry.Len()\n\tif c.capacity > 0 {\n\t\t// Limit configured\n\t\tfor c.size > c.capacity {\n\t\t\tc.evict()\n\t\t}\n\t}\n\treturn true\n}", "func (this *RandomizedCollection) Insert(val int) bool {\n \n}", "func (s OrderedSet) Insert(e Entry) Set {\n\tfor idx, entry := range s.slice {\n\t\tif e.Equal(entry) {\n\t\t\t// To preserve the order of items, the replacement\n\t\t\t// entry is positioned over the currently existing one.\n\t\t\t// Another approach would be to delete the current entry\n\t\t\t// and append the new one at the end.\n\t\t\t// Perhaps a switch could be added to OrderedSet to choose\n\t\t\t// the desired behaviour.\n\t\t\tsCopy := make([]Entry, len(s.slice))\n\t\t\tcopy(sCopy, s.slice)\n\t\t\tsCopy[idx] = e\n\t\t\treturn OrderedSet{\n\t\t\t\tslice: sCopy,\n\t\t\t}\n\t\t}\n\t}\n\treturn OrderedSet{\n\t\tslice: append(s.slice, e),\n\t}\n}", "func (s Set) Add(st string) {\n\tif _, ok := s[st]; !ok {\n\t\ts[st] = true\n\t}\n}", "func (shard *hashShard) shardInsert(key KeyType, hashValue IndexType, value ValueType) bool {\n\tshard.rehash()\n\tinitIdx := shard.searchExists(key, hashValue)\n\n\tif (*shard.data)[initIdx].isOccupied && (*shard.data)[initIdx].key == key {\n\t\treturn false\n\t}\n\n\tinsertIdx := shard.searchToInsert(key, hashValue)\n\tif !(*shard.data)[insertIdx].isOccupied {\n\t\tshard.occupied++\n\t}\n\n\t(*shard.data)[insertIdx] = hashElement{true, true, key, value}\n\tshard.size++\n\treturn true\n}", "func (s *Set) Contains(element interface{}) bool {\n\t_, exists := (*s)[element]\n\treturn exists\n}", "func (s *Set) Add(val string) {\n\ts.set[val] = true\n}", "func (qt *QuadTree) Insert(p *Stop) bool {\n\t// Ignore objects which do not belong in this quad tree.\n\tif !qt.boundary.ContainsPoint(p) {\n\t\treturn false\n\t}\n\n\t// If there is space in this quad tree, add the object here.\n\tif len(qt.points) < cap(qt.points) {\n\t\tqt.points = append(qt.points, p)\n\t\treturn true\n\t}\n\n\t// Otherwise, we need to subdivide then add the point to whichever node\n\t// will accept it.\n\tif qt.northWest == nil {\n\t\tqt.subDivide()\n\t}\n\n\tif qt.northWest.Insert(p) {\n\t\treturn true\n\t}\n\tif qt.northEast.Insert(p) {\n\t\treturn true\n\t}\n\tif qt.southWest.Insert(p) {\n\t\treturn true\n\t}\n\tif qt.southEast.Insert(p) {\n\t\treturn true\n\t}\n\n\t// Otherwise, the point cannot be inserted for some unknown reason.\n\t// (which should never happen)\n\treturn false\n}", "func (bf *BloomFilter) Insert(key []byte) error {\n\treturn bf.setKeyToBool(key, true)\n}", "func (qt *QuadTree) Insert(p *Point) bool {\n\tif !qt.boundary.ContainsPoint(p) {\n\t\treturn false\n\t}\n\n\tif qt.nodes[0] == nil {\n\t\tif len(qt.points) < Capacity {\n\t\t\tqt.points = append(qt.points, p)\n\t\t\treturn true\n\t\t}\n\n\t\tif qt.depth < MaxDepth {\n\t\t\tqt.divide()\n\t\t} else {\n\t\t\tqt.points = append(qt.points, p)\n\t\t\treturn true\n\t\t}\n\t}\n\n\tfor _, node := range qt.nodes {\n\t\tif node.Insert(p) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (set *Set) Contains(element interface{}) bool {\n\tval, ok := set.elements[element]\n\tif val && ok {\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *StrSet) Add(element string) {\n\ts.els[element] = true\n}", "func (table *ConcurrentHashMap) Insert(key KeyType, value ValueType) bool {\n\thashValue := table.mhash(key)\n\tshard := table.getShard(hashValue)\n\n\ttable.RWLocks[shard].Lock()\n\n\twasPairInserted := table.shards[shard].shardInsert(key, hashValue, value)\n\n\ttable.RWLocks[shard].Unlock()\n\n\treturn wasPairInserted\n}", "func (s *S43_SmallSetOfIntegers) Insert(n int, done chan bool) {\n\tdefer close(done)\n\n\ti := s.SEARCH(n)\n\tif i < s.size {\n\t\tdone <- false\n\t\treturn // nothing to do\n\t}\n\t// not found, insert to the array\n\tif i == s.size && s.size < 100 {\n\t\ts.content[s.size] = n\n\t\ts.size++\n\t\tdone <- true\n\t\treturn\n\t}\n\n\tdone <- false\n\treturn\n}", "func (s *Set) Add(item string) {\n\ts.safeMap()\n\ts.m[item] = true\n}", "func (self *QueuedSet) Add(item interface{}) (isNew bool) {\n\tself.lock.Lock()\n\tdefer self.lock.Unlock()\n\tcount := self.set[item]\n\tself.q.Enqueue(item)\n\tself.set[item] = count + 1\n\treturn count == 0\n}", "func (s S) SetInsert(key string, values ...string) error {\n\tvar vv SortedString\n\treturn s.ReadModify(key, &vv, func(_ interface{}) (r bool) {\n\t\tfor _, v := range values {\n\t\t\tr = r || vv.Insert(v)\n\t\t}\n\t\treturn\n\t})\n}", "func (t *Set) Add(key []byte) bool {\n\t// test for empty tree\n\tif t.Empty() {\n\t\tt.root.Key = key\n\t\tt.size++\n\t\treturn true\n\t}\n\t// walk for best member\n\tp := &t.root\n\tfor p.node != nil {\n\t\t// try next node\n\t\tp = &p.node.child[p.node.dir(key)]\n\t}\n\t// find critical bit\n\tvar off uint\n\tvar ch, bit byte\n\tvar klen = uint(len(key))\n\tvar plen = uint(len(p.Key))\n\t// find differing byte\n\tfor off = 0; off < klen; off++ {\n\t\tif ch = 0; off < plen {\n\t\t\tch = p.Key[off]\n\t\t}\n\t\tif keych := key[off]; ch != keych {\n\t\t\tbit = ch ^ keych\n\t\t\tgoto ByteFound\n\t\t}\n\t}\n\tif off < plen {\n\t\tch = p.Key[off]\n\t\tbit = ch\n\t\tgoto ByteFound\n\t}\n\t// key exists\n\treturn false\nByteFound:\n\t// find differing bit\n\tbit |= bit >> 1\n\tbit |= bit >> 2\n\tbit |= bit >> 4\n\tnum := popcount(bit >> 1) // 0001 1111 -> 4\n\tbit = bit &^ (bit >> 1) // 0001 1111 -> 0001 0000\n\tvar ndir byte\n\tif ch & bit != 0 {\n\t\tndir++\n\t}\n\t// insert new node\n\tnn := Node{bitoff: (off << 3) + uint(num)}\n\tnn.child[1-ndir].Key = key\n\n\t// walk for best insertion node\n\twp := &t.root\n\tfor wp.node != nil {\n\t\tn := wp.node\n\t\tbyteoff := n.bitoff >> 3\n\t\tbitnum := byte(n.bitoff) & 7 // 0001 1111 -> 0000 0111 (7)\n\t\tif byteoff > off || byteoff == off && bitnum < num {\n\t\t\tbreak\n\t\t}\n\t\t// try next node\n\t\twp = &n.child[n.dir(key)]\n\t}\n\tnn.child[ndir] = *wp\n\twp.node = &nn\n\twp.Key = nil\n\tt.size++\n\n\treturn true\n}", "func (m MultiValueMap) Insert(key, value string) MultiValueMap {\n\tsets.InsertOrNew(m, key, value)\n\treturn m\n}", "func (t *Todo) Insert(todo string) bool {\n\tt.todos[len(t.todos)+1] = todo\n\n\treturn true\n}", "func (s *Set) Insert(db XODB) error {\n\tvar err error\n\n\t// if already exist, bail\n\tif s._exists {\n\t\treturn errors.New(\"insert failed: already exists\")\n\t}\n\n\t// sql insert query, primary key provided by sequence\n\tconst sqlstr = `INSERT INTO sets (` +\n\t\t`baseSetSize, block, booster, code, isFoilOnly, isForeignOnly, isNonFoilOnly, isOnlineOnly, isPartialPreview, keyruneCode, mcmId, mcmIdExtras, mcmName, mtgoCode, name, parentCode, releaseDate, sealedProduct, tcgplayerGroupId, totalSetSize, type` +\n\t\t`) VALUES (` +\n\t\t`?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?` +\n\t\t`) RETURNING id`\n\n\t// run query\n\tXOLog(sqlstr, s.Basesetsize, s.Block, s.Booster, s.Code, s.Isfoilonly, s.Isforeignonly, s.Isnonfoilonly, s.Isonlineonly, s.Ispartialpreview, s.Keyrunecode, s.Mcmid, s.Mcmidextras, s.Mcmname, s.Mtgocode, s.Name, s.Parentcode, s.Releasedate, s.Sealedproduct, s.Tcgplayergroupid, s.Totalsetsize, s.Type)\n\terr = db.QueryRow(sqlstr, s.Basesetsize, s.Block, s.Booster, s.Code, s.Isfoilonly, s.Isforeignonly, s.Isnonfoilonly, s.Isonlineonly, s.Ispartialpreview, s.Keyrunecode, s.Mcmid, s.Mcmidextras, s.Mcmname, s.Mtgocode, s.Name, s.Parentcode, s.Releasedate, s.Sealedproduct, s.Tcgplayergroupid, s.Totalsetsize, s.Type).Scan(&s.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set existence\n\ts._exists = true\n\n\treturn nil\n}", "func (s Set) Add(key string) {\n\ts[key] = true\n}", "func (h *hashtable) Insert(item *CacheItem) (*CacheItem, bool) {\n\tbucketIndex := int(item.hash) % h.bucketcount\n\n\tfor node := h.buckets[bucketIndex]; node != nil; node = node.chain {\n\t\tif node.hash == item.hash {\n\t\t\tif node.data.Equals(item.data) {\n\t\t\t\t// found a duplicate\n\t\t\t\treturn node, false\n\t\t\t}\n\t\t}\n\t}\n\tif node := h.buckets[bucketIndex]; node != nil {\n\t\titem.chain = node\n\t\th.buckets[bucketIndex] = item\n\t} else {\n\t\th.buckets[bucketIndex] = item\n\t}\n\th.size++\n\treturn h.buckets[bucketIndex], true\n}", "func (s Set) Add(k string) {\n\tif s.Contains(k) {\n\t\treturn\n\t}\n\ts.add(k)\n}", "func (s *HashSet) Contain(data interface{}) (bool, error) {\n\terr := s.checkT(data)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\t_, ok := s.set[data]\n\tif ok {\n\t\treturn true, nil\n\t} else {\n\t\treturn false, nil\n\t}\n}", "func (s *Storage) Set(elem mvcc.Element) bool {\n\tsuccess := s.memtable.Set(elem)\n\tif success {\n\t\ts.wal.Append(elem)\n\t}\n\treturn success\n}", "func (d *DSU) Add(x interface{}) bool {\n\tif d.Contains(x) {\n\t\treturn false\n\t}\n\n\td.nodes[x] = &node{value: x, parent: nil, size: 1}\n\treturn true\n}", "func (h *sorter) Add(bts []byte, ord uint64) bool {\n\tif len(h.sets) == 0 {\n\t\th.allocateNewSet()\n\t}\n\tset := h.sets[len(h.sets)-1]\n\tif !set.Add(bts, ord) {\n\t\tif h.setSize*(len(h.sets)+1) > h.limit { // limit reached\n\t\t\treturn false\n\t\t}\n\t\tnewSet := h.allocateNewSet()\n\t\tnewSet.Add(bts, ord)\n\t}\n\treturn true\n}", "func (h *Heap) Insert(item int) bool {\n\tif h.count >= h.size {\n\t\treturn false\n\t}\n\n\th.count++\n\th.items[h.count] = item\n\ti := h.count\n\n\t// Adjust the location of nodes and their children.\n\t// Use large elements as parent nodes.\n\tfor (i/2 > 0) && (h.items[i] > h.items[i/2]) {\n\t\th.items[i], h.items[i/2] = h.items[i/2], h.items[i]\n\t\ti = i / 2\n\t}\n\n\treturn true\n}", "func (s BlobSet) Insert(h BlobHandle) {\n\ts[h] = struct{}{}\n}", "func (st *SetTranslation) Insert(db XODB) error {\n\tvar err error\n\n\t// if already exist, bail\n\tif st._exists {\n\t\treturn errors.New(\"insert failed: already exists\")\n\t}\n\n\t// sql insert query, primary key provided by sequence\n\tconst sqlstr = `INSERT INTO set_translations (` +\n\t\t`language, setCode, translation` +\n\t\t`) VALUES (` +\n\t\t`?, ?, ?` +\n\t\t`) RETURNING id`\n\n\t// run query\n\tXOLog(sqlstr, st.Language, st.Setcode, st.Translation)\n\terr = db.QueryRow(sqlstr, st.Language, st.Setcode, st.Translation).Scan(&st.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set existence\n\tst._exists = true\n\n\treturn nil\n}", "func (s *Set) Has(value string) (bool, error) {\n\tif !s.host.rawUTF8 {\n\t\tEncode(&value)\n\t}\n\trows, err := s.host.db.Query(fmt.Sprintf(\"SELECT %s FROM %s WHERE %s = $1\", setCol, s.table, setCol), value)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif rows == nil {\n\t\treturn false, errors.New(\"Set Has returned no rows for value \" + value)\n\t}\n\tdefer rows.Close()\n\tvar scanValue sql.NullString\n\t// Get the value. Should not loop more than once.\n\tcounter := 0\n\tfor rows.Next() {\n\t\terr = rows.Scan(&scanValue)\n\t\tif err != nil {\n\t\t\t// No rows\n\t\t\treturn false, err\n\t\t}\n\t\tcounter++\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn false, err\n\t}\n\t//if counter > 1 {\n\t// more than one element that has the same *value* is fine!\n\t//}\n\treturn counter > 0, nil\n}", "func (this *LinkedList) Insert(index int, ele interface{}) bool {\n\tif index < 0 || index > this.Size() {\n\t\tpanic(\"index out of bound\")\n\t}\n\tif index == this.Size() {\n\t\treturn this.Add(ele)\n\t}\n\ten := entry{ele, nil}\n\tpe := this.head\n\tvar ps *entry\n\tps = nil\n\tfor i := 0; i < index; i++ {\n\t\tps = pe\n\t\tpe = pe.next\n\t}\n\tif ps != nil {\n\t\tps.next = &en\n\t\ten.next = pe\n\t} else {\n\t\t// insert in the first place\n\t\tthis.head = &en\n\t\ten.next = pe\n\t}\n\tthis.size++\n\treturn true\n}", "func (cache *_TrxCache) Push(trx Trx) bool {\n\tcache.mtx.Lock()\n\tdefer cache.mtx.Unlock()\n\n\tif _, exists := cache.dict[string(trx)]; exists {\n\t\treturn false\n\t}\n\n\tif cache.list.Len() >= cache.size {\n\t\tpopped := cache.list.Front()\n\t\tpoppedTx := popped.Value.(Trx)\n\t\t// NOTE: the trx may have already been removed from the map\n\t\t// but deleting a non-existent element is fine\n\t\tdelete(cache.dict, string(poppedTx))\n\t\tcache.list.Remove(popped)\n\t}\n\tcache.dict[string(trx)] = struct{}{}\n\tcache.list.PushBack(trx)\n\treturn true\n}", "func (list *ArrayList[T]) Set(index int, ele T) bool {\n\tif index < 0 || index >= list.Size() {\n\t\treturn false\n\t}\n\tlist.elems[index] = ele\n\treturn true\n}", "func (s *Set) Contains(val interface{}) bool {\n\tif _, ok := s.vals[val]; ok {\n\t\treturn true\n\t}\n\treturn false\n}", "func insert(insertStruct *Insert) (bool, error) {\n\terr := insertStruct.Collection.Insert(&insertStruct.Data)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn false, err\n\t}\n\treturn true, err\n}", "func (s *Set) Remove(element interface{}) bool {\n\tif _, exists := (*s)[element]; exists {\n\t\tdelete(*s, element)\n\t\treturn true\n\t}\n\treturn false\n}", "func (self *Cache) Insert(key interface{}, value interface{}, sizeBytes uint64) (canonicalValue interface{}, in_cache bool) {\n\tself.insertLock.Lock()\n\tdefer self.insertLock.Unlock()\n\n\t_, canonicalValue, in_cache = self.insert(key, value, sizeBytes)\n\treturn\n}", "func (ll *SinglyLinkedList) Insert(value, index int) bool {\n\tif index > ll.length {\n\t\treturn false\n\t}\n\n\tif index == 0 {\n\t\tll.Prepend(value)\n\t\treturn true\n\t}\n\n\tif index == ll.length {\n\t\tll.Append(value)\n\t\treturn true\n\t}\n\n\tposition := 1\n\tpreviousNode := ll.head\n\tcurrentNode := ll.head.next\n\n\tfor currentNode != nil {\n\t\tif position == index {\n\t\t\tnewNode := createListNode(value)\n\t\t\tnewNode.next = currentNode\n\t\t\tpreviousNode.next = newNode\n\t\t\tll.length += 1\n\t\t\treturn true\n\t\t}\n\n\t\tposition += 1\n\t\tpreviousNode = previousNode.next\n\t\tcurrentNode = currentNode.next\n\t}\n\n\treturn false\n}", "func (s *Set) Add(val string) {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\ts.set[val] = struct{}{}\n}", "func (h *HashTable) put(key int, value int) bool {\n\tindex := hashFunction(key, len(h.table.buckets))\n\titerator := h.table.buckets[index]\n\tnode := Element{key, value, nil}\n\tif iterator == nil {\n\t\th.table.buckets[index] = &node\n\t} else {\n\t\tprev := &Element{0, 0, nil}\n\t\tfor iterator != nil {\n\t\t\tif iterator.key == key { // Key already exists\n\t\t\t\titerator.value = value\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tprev = iterator\n\t\t\titerator = iterator.next\n\t\t}\n\t\tprev.next = &node\n\t}\n\t*h.size += 1\n\treturn true\n}", "func (s *Set) Add(elem A) *Set {\n\ts.m[elem] = SetNothing{}\n\treturn s\n}", "func (this *HashSet) Contains(ele interface{}) bool {\n\treturn this.mmap.ContainsKey(ele)\n}", "func InsertElement(root *Segment, new *Segment) *Segment {\n\tfor _, s := range root.descendants {\n\t\tif s.Eq(new) {\n\t\t\treturn s\n\t\t}\n\t}\n\troot.descendants = append(root.descendants, new)\n\treturn new\n}", "func (t *openAddressing) Insert(key string, value interface{}) {\n\tif t.loadFactor() > 0.5 {\n\t\tt.tableDouble()\n\t}\n\tround := 0\n\tfor round != len(t.values) {\n\t\thash := t.hash(key, round)\n\t\tif t.values[hash] == nil || t.values[hash].deleted {\n\t\t\tt.values[hash] = &deletablePair{\n\t\t\t\tpair: pair{key, value},\n\t\t\t\tdeleted: false,\n\t\t\t}\n\t\t\tt.len++\n\t\t\treturn\n\t\t}\n\t\tround++\n\t}\n}", "func (cf *CFilter) Insert(item []byte) bool {\n\tf := fprint(item, cf.fpSize, cf.hashfn)\n\tj := hashfp(item) % cf.size\n\tk := (j ^ hashfp(f)) % cf.size\n\n\tif cf.buckets[j].insert(f) || cf.buckets[k].insert(f) {\n\t\tcf.count++\n\t\treturn true\n\t}\n\n\ti := [2]uint{j, k}[rand.Intn(2)]\n\tfor n := uint(0); n < cf.kicks; n++ {\n\t\tf = cf.buckets[i].swap(f)\n\t\ti = (i ^ hashfp(f)) % cf.size\n\n\t\tif cf.buckets[i].insert(f) {\n\t\t\tcf.count++\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (s Set) Contain(el string) bool {\n\t_, in := s[el]\n\treturn in\n}" ]
[ "0.78956634", "0.7808493", "0.7805946", "0.7777138", "0.7772888", "0.777273", "0.7771234", "0.77451116", "0.7713906", "0.76536494", "0.7653306", "0.7574232", "0.75585407", "0.7501971", "0.7489873", "0.747495", "0.74315095", "0.727646", "0.7046946", "0.6831391", "0.681875", "0.67097557", "0.66928726", "0.66224545", "0.6486962", "0.6420016", "0.64134705", "0.6372167", "0.6301864", "0.6301275", "0.6262224", "0.62287784", "0.62002146", "0.61649185", "0.6157592", "0.61456484", "0.61405224", "0.6112011", "0.6076039", "0.605009", "0.6032077", "0.60215706", "0.60133594", "0.60039", "0.5997193", "0.59765893", "0.5953674", "0.5947884", "0.5936068", "0.5927196", "0.5883045", "0.58611727", "0.5859109", "0.58470726", "0.5845254", "0.5844294", "0.5844095", "0.58236814", "0.5822698", "0.58153147", "0.57863134", "0.57828283", "0.578196", "0.5772333", "0.57702035", "0.57543063", "0.5749253", "0.57368314", "0.5717724", "0.57098174", "0.5708245", "0.5667814", "0.56574875", "0.5619598", "0.56149507", "0.5613373", "0.5608579", "0.560105", "0.5581729", "0.5570174", "0.5555011", "0.55451417", "0.5534685", "0.55236554", "0.5518877", "0.5518079", "0.55179983", "0.5487452", "0.5482913", "0.5481169", "0.546955", "0.5463812", "0.5461989", "0.5456486", "0.54546773", "0.5443173", "0.54312086", "0.5420802", "0.5413437", "0.54027313" ]
0.7923681
0
Remove will Removes a value from the set. Returns true if the set contained the specified element.
func (set *RandomizedSet) Remove(val int) bool { if !set.Value[val] { return false } set.Value[val] = false set.Count-- if len(set.Keys) > 5*set.Count { keys := []int{} for key := range set.Value { keys = append(keys, key) } set.Keys = keys } return true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Set) Remove(element interface{}) bool {\n\tif _, exists := (*s)[element]; exists {\n\t\tdelete(*s, element)\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *Set) Remove(elem A) bool {\n\t_, found := s.m[elem]\n\tif found {\n\t\tdelete(s.m, elem)\n\t}\n\treturn found\n}", "func (s *Set) Remove(val interface{}) bool {\n\tif _, ok := s.vals[val]; !ok {\n\t\treturn false\n\t}\n\n\tdelete(s.vals, val)\n\n\treturn true\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tif _, ok := this.m[val]; ok{\n\t\tdelete(this.m, val)\n\t\treturn true\n\t}\n\treturn false\n}", "func (this *HashSet) Remove(ele interface{}) bool {\n\treturn this.mmap.Remove(ele)\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tif _, ok := this.M[val]; !ok {\n\t\treturn false\n\t}\n\tindex := this.M[val]\n\tlastValue := this.list[len(this.list)-1]\n\tthis.M[lastValue] = index\n\tthis.list[index] = lastValue\n\tthis.list = this.list[:len(this.list)-1]\n\tdelete(this.M, val)\n\treturn true\n}", "func (rs *RandomizedSet) Remove(val int) bool {\n\tif _, ok := rs.set[val]; !ok {\n\t\treturn false\n\t}\n\tp := rs.set[val]\n\trs.keys[p] = rs.keys[len(rs.keys)-1]\n\trs.set[rs.keys[p]] = p\n\trs.keys = rs.keys[:len(rs.keys)-1]\n\tdelete(rs.set, val)\n\treturn true\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tindex, ok := this.set[val]\n\tif !ok {\n\t\treturn false\n\t}\n\tlast := len(this.a) - 1\n\tthis.set[this.a[last]] = index\n\tthis.a[index] = this.a[last]\n\tthis.a = this.a[:last]\n\tdelete(this.set, val)\n\treturn true\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tif setIt, ok := this.valsSet[val]; ok {\n\t\tlast := this.vals[len(this.vals)-1]\n\t\tthis.vals[setIt.ind] = last\n\t\tthis.vals = this.vals[:len(this.vals)-1]\n\t\tthis.valsSet[last] = valEl{last, setIt.ind}\n\t\tdelete(this.valsSet, val)\n\t\treturn true\n\t}\n\treturn false\n}", "func (set *LLSet) Remove(elem int) bool {\n\tif set.head == nil {\n\t\treturn false\n\t}\n\n\tif set.head.data == elem {\n\t\tset.head = nil\n\t\treturn true\n\t}\n\n\tcurrent := set.head\n\tfor current != nil && current.next != nil {\n\t\tif current.next.data == elem {\n\t\t\tcurrent.next = current.next.next\n\t\t\treturn true\n\t\t}\n\t\tcurrent = current.next\n\t}\n\treturn false\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tvar found bool\n\tif _, found = this.m[val]; !found {\n\t\treturn false\n\t}\n\tif len(this.a) == 1 {\n\t\tthis.a = []int{}\n\t\tthis.m = map[int]int{}\n\t} else {\n\t\tidx := this.m[val]\n\t\tval2 := this.a[len(this.a)-1]\n\t\tthis.a[idx] = val2\n\t\tthis.a = this.a[:len(this.a)-1]\n\t\tthis.m[val2] = idx\n\t\tdelete(this.m, val)\n\t}\n\treturn true\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tindex, ok := this.m[val]\n\tif ok {\n\t\tthis.m[this.data[len(this.data)-1]] = index\n\t\tthis.data[index], this.data[len(this.data)-1] = this.data[len(this.data)-1], this.data[index]\n\n\t\tthis.data = this.data[:len(this.data)-1]\n\t\tdelete(this.m, val)\n\t}\n\n\treturn ok\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tif i, ok := this.record[val]; !ok {\n\t\treturn false\n\t} else {\n\t\tswap := this.nums[len(this.nums)-1]\n\t\tthis.record[swap] = i\n\t\tthis.nums[i] = swap\n\t\tthis.nums = this.nums[0 : len(this.nums)-1]\n\n\t\tdelete(this.record, val)\n\t}\n\treturn true\n}", "func (s *ConcurrentSet) Remove(e interface{}) bool {\n\t_, exists := s.hash.Load(e)\n\ts.hash.Delete(e)\n\tif exists {\n\t\tatomic.AddUint32(&s.size, ^uint32(0))\n\t}\n\treturn exists\n}", "func (this *RandomizedSet) Remove(val int) bool {\r\n\tloc, ok := this.dict[val]\r\n\tif !ok {return false}\r\n\tif loc > 0 {\r\n\t\tfirst := this.location[0]\r\n\t\tthis.location[loc] = first\r\n\t\tthis.dict[first] = loc\r\n\t}\r\n\tthis.location = this.location[1:]\r\n\tdelete(this.dict, val)\r\n\treturn true\r\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tidx, ok := this.hashMap[val]\n\tif !ok {\n\t\treturn false\n\t}\n\tdelete(this.hashMap, val)\n\tthis.arr[idx] = this.arr[this.length-1]\n\tif idx != this.length-1 {\n\t\tthis.hashMap[this.arr[idx]] = idx\n\t}\n\tthis.length--\n\treturn true\n}", "func (rs *RandomizedSet) Remove(val int) bool {\n\tif index, ok := rs.hash[val]; ok {\n\t\tlast := len(rs.arr) - 1\n\t\trs.arr[index], rs.arr[last] = rs.arr[last], rs.arr[index]\n\t\trs.hash[rs.arr[index]] = index\n\t\tdelete(rs.hash, val)\n\t\trs.arr = rs.arr[:last]\n\t\treturn true\n\t}\n\treturn false\n}", "func (s int64set) remove(value int64) bool {\n\n\t// 'ok' is true if value is within set\n\t_, ok := s[value]\n\tif !ok {\n\t\treturn false // signifies nothing was removed\n\t}\n\n\t// otherwise it exists so you should remove it.\n\tdelete(s, value)\n\treturn true\n}", "func (s *RandomizedSet) Remove(val int) bool {\n\tif ind, ok := s.table[val]; ok {\n\t\tn := len(s.arr)\n\t\tlast := s.arr[n-1]\n\t\ts.table[last] = ind\n\t\ts.arr[ind] = last\n\t\ts.arr = s.arr[:n-1]\n\t\tdelete(s.table, val)\n\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tif _, ok := this.set[val]; ok {\n\t\tindex := this.set[val]\n\t\tlast_val := this.data[len(this.data)-1]\n\t\tthis.data[index], this.data[len(this.data)-1] = this.data[len(this.data)-1], this.data[index] // 将要删除的元素和最后一个元素交换,然后再删除,这样就是常数时间删除了,不需要移动数组\n\t\tthis.data = this.data[:len(this.data)-1]\n\t\tthis.set[last_val] = index\n\t\tdelete(this.set, val)\n\t\tthis.length--\n\t\treturn true\n\t}\n\treturn false\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\n\tif index, ok := this.m[val]; ok {\n\t\tn := len(this.arr)\n\t\tif n-1 != index {\n\t\t\tthis.arr[index], this.arr[n-1] = this.arr[n-1], this.arr[index]\n\t\t\tthis.m[this.arr[index]] = index\n\t\t}\n\t\tthis.arr = this.arr[:n-1]\n\t\tdelete(this.m, val)\n\t\treturn true\n\t}\n\treturn false\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\ti, ok := this.indices[val]\n\tif !ok {\n\t\treturn false\n\t}\n\tlastVal := this.list[len(this.list)-1]\n\tthis.indices[lastVal] = i\n\tdelete(this.indices, val)\n\tthis.list[i] = lastVal\n\tthis.list = this.list[:len(this.list)-1]\n\treturn true\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tif _, ok := this.v[val]; !ok {\n\t\treturn false\n\t}\n\tlastIndex := len(this.arr) - 1\n\tif this.v[val] == lastIndex {\n\t\tthis.arr = this.arr[0:lastIndex]\n\t} else {\n\t\tthis.v[this.arr[lastIndex]] = this.v[val]\n\t\tthis.arr[this.v[val]] = this.arr[lastIndex]\n\t\tthis.arr = this.arr[0:lastIndex]\n\t}\n\tdelete(this.v, val)\n\tthis.rand = 0\n\treturn true\n}", "func (this *RandomizedSet) Remove(val int) bool {\n\tif ind, ok := this.table[val]; ok {\n\t\tdelete(this.table, val)\n\t\tthis.arr[ind], this.arr[len(this.arr)-1] = this.arr[len(this.arr)-1], this.arr[ind]\n\t\tthis.arr = this.arr[:len(this.arr)-1]\n\t\tif ind < len(this.arr) {\n\t\t\tthis.table[this.arr[ind]] = ind\n\t\t}\n\n\t\treturn true\n\t} else {\n\n\t\treturn false\n\t}\n}", "func (s *Set) Remove(key interface{}) (ok bool) {\n\t_, ok = s.skiplist.Delete(key)\n\treturn ok\n}", "func (s StringSet) Remove(element string) {\n\tif s.Has(element) {\n\t\tdelete(s.Set, element)\n\t}\n}", "func (set *Set) Contains(element interface{}) bool {\n\tval, ok := set.elements[element]\n\tif val && ok {\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *Set) Add(element interface{}) bool {\n\t_, exists := (*s)[element]\n\t(*s)[element] = struct{}{}\n\treturn !exists\n}", "func (s *HashSet) Remove(data interface{}) error {\n\terr := s.checkT(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, ok := s.set[data]\n\tif ok {\n\t\tdelete(s.set, data)\n\t\ts.size--\n\t\treturn nil\n\t}\n\treturn errors.New(\"key not exist\")\n}", "func (s *Set) Contains(element interface{}) bool {\n\t_, exists := (*s)[element]\n\treturn exists\n}", "func (v *Set) Remove(pubKeyBLS []byte) bool {\n\ti, found := v.IndexOf(pubKeyBLS)\n\tif found {\n\t\t// TODO: this is inefficient\n\t\t*v = append((*v)[:i], (*v)[i+1:]...)\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (s *Set) Has(element string) (bool, error) {\n\tv, err := s.store.Do(s.key, set.Has, element)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tval, ok := v.(bool)\n\tif !ok {\n\t\treturn false, newTypeErr(val, v)\n\t}\n\n\treturn val, nil\n}", "func (list *ArrayList[T]) Remove(ele T) bool {\n\tfor i := 0; i < len(list.elems); i++ {\n\t\to := list.elems[i]\n\t\tif o == ele {\n\t\t\tlist.elems = append(list.elems[:i], list.elems[i+1:]...)\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (s Set) Remove(value interface{}) {\n\thash, err := hashstructure.Hash(value, nil)\n\tif err != nil {\n\t\tlog.Errorf(\"type could not be hashed: %+v\", value)\n\t}\n\tif _, exists := s[hash]; exists {\n\t\tdelete(s, hash)\n\t}\n}", "func (s Set) Remove(k string) {\n\tif !s.Contains(k) {\n\t\treturn\n\t}\n\tdelete(s.m, k)\n}", "func (s Set) Remove(element string) {\n\te := strings.ToLower(element)\n\n\tif _, ok := s[e]; ok {\n\t\tdelete(s, e)\n\t}\n}", "func (s *Set) Contains(val interface{}) bool {\n\t_, contains := s.set[val]\n\treturn contains\n}", "func (s *Set) Contains(elem A) bool {\n\t_, found := s.m[elem]\n\treturn found\n}", "func (p *PropertySet) Remove(s string) bool {\n\tp.mux.Lock()\n\tdefer p.mux.Unlock()\n\n\tif !p.Contains(s) {\n\t\treturn false\n\t}\n\n\tdelete(p.props, s)\n\treturn true\n}", "func (ts *TagSet) Remove(tag string) (ok bool) {\n\tfor i := 0; i < len(*ts); {\n\t\tif (*ts)[i] == tag {\n\t\t\t*ts = append((*ts)[:i], (*ts)[i+1:]...)\n\t\t\tok = true\n\t\t} else {\n\t\t\ti++\n\t\t}\n\t}\n\treturn\n}", "func (this *HashSet) Contains(ele interface{}) bool {\n\treturn this.mmap.ContainsKey(ele)\n}", "func (set *StringSet) Remove(val string) {\n\tdelete(set.m, val)\n}", "func (s *StrSet) Remove(element string) {\n\tdelete(s.els, element)\n}", "func (s *Set) Contains(val interface{}) bool {\n\tif _, ok := s.vals[val]; ok {\n\t\treturn true\n\t}\n\treturn false\n}", "func (s StringSet) Has(element string) bool {\n\t_, ok := s.Set[element]\n\treturn ok\n}", "func (q *Queue) Remove(v interface{}) bool {\r\n\tq.mu.Lock()\r\n\tdefer q.mu.Unlock()\r\n\r\n\tel, ok := q.m[v]\r\n\tif !ok {\r\n\t\treturn false\r\n\t}\r\n\r\n\tfirst := q.first\r\n\tdelete(q.m, v)\r\n\tq.remove(el)\r\n\r\n\t// If the element was first, we need to start a new timer\r\n\tif first == el && q.first != nil {\r\n\t\tgo q.timer(q.first, q.first.time)\r\n\t}\r\n\treturn true\r\n}", "func (ss *StringSet) Remove(element string) *StringSet {\n\tdelete(ss.set, element)\n\treturn ss\n}", "func (s Set) Contain(el string) bool {\n\t_, in := s[el]\n\treturn in\n}", "func (tree *BTree) Remove(val interface{}) bool {\n\treturn tree.remove(wrap(val))\n}", "func (s *Set) Remove(item string) {\n\tdelete(s.m, item)\n}", "func (s *StrSet) Contains(element string) bool {\n\tif _, ok := s.els[element]; !ok {\n\t\treturn false\n\t}\n\treturn true\n}", "func (s Set) Has(element string) bool {\n\t_, exists := s[strings.ToLower(element)]\n\treturn exists\n}", "func (s *Set[T]) Contains(elt T) bool {\n\t_, contains := (*s)[elt]\n\treturn contains\n}", "func (dict *Dictionary) Remove(key DictKey) bool {\n\tdict.lock.Lock()\n\tdefer dict.lock.Unlock()\n\tvar exists bool\n\t_, exists = dict.elements[key]\n\tif exists {\n\t\tdelete(dict.elements, key)\n\t}\n\treturn exists\n}", "func (s *Set) Has(val int) bool {\n\t_, ok := s.set[val]\n\treturn ok\n}", "func (t *Set) Del(key []byte) bool {\n\t// test for empty tree\n\tif t.Empty() {\n\t\treturn false\n\t}\n\t// walk for best member\n\tvar dir byte\n\tvar wp *Ref\n\tp := &t.root\n\tfor p.node != nil {\n\t\twp = p\n\t\t// try next node\n\t\tdir = p.node.dir(key)\n\t\tp = &p.node.child[dir]\n\t}\n\t// check for membership\n\tklen := len(key)\n\tif klen != len(p.Key) {\n\t\treturn false\n\t}\n\tfor i, b := range p.Key {\n\t\tif b != key[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\t// delete from the tree\n\tt.size--\n\tif wp == nil {\n\t\tt.root = Ref{}\n\t\treturn true\n\t}\n\t*wp = wp.node.child[1-dir]\n\treturn true\n}", "func (s *Set) Has(elements ...interface{}) (has bool) {\n\tif len(elements) == 0 {\n\t\treturn false\n\t}\n\n\ts.mutex.RLock()\n\tfor _, element := range elements {\n\t\tif _, has = s.m[element]; !has {\n\t\t\tbreak\n\t\t}\n\t}\n\ts.mutex.RUnlock()\n\n\treturn\n}", "func (s *Set) Has(value string) (bool, error) {\n\tif !s.host.rawUTF8 {\n\t\tEncode(&value)\n\t}\n\trows, err := s.host.db.Query(fmt.Sprintf(\"SELECT %s FROM %s WHERE %s = $1\", setCol, s.table, setCol), value)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif rows == nil {\n\t\treturn false, errors.New(\"Set Has returned no rows for value \" + value)\n\t}\n\tdefer rows.Close()\n\tvar scanValue sql.NullString\n\t// Get the value. Should not loop more than once.\n\tcounter := 0\n\tfor rows.Next() {\n\t\terr = rows.Scan(&scanValue)\n\t\tif err != nil {\n\t\t\t// No rows\n\t\t\treturn false, err\n\t\t}\n\t\tcounter++\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn false, err\n\t}\n\t//if counter > 1 {\n\t// more than one element that has the same *value* is fine!\n\t//}\n\treturn counter > 0, nil\n}", "func (vector *Vector) Contains(element interface{}) bool {\n\tvar index int = vector.Peek(element)\n\tif index == -1 {\n\t\treturn false\n\t}\n\treturn true\n}", "func (d *Data) Remove(key string) bool {\n\t_, ok := d.Values[key]\n\tif !ok {\n\t\treturn false\n\t}\n\tdelete(d.Values, key)\n\tdelete(d.Data, key)\n\treturn true\n}", "func (s Set) Contains(val int) bool {\n\tfor i := 0; i < len(s.data); i++ {\n\t\tif s.data[i] == val {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (s *mapStringSet) removeSingle(value string) (removed bool) {\n\tif _, ok := s.storage[value]; ok {\n\t\tdelete(s.storage, value)\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}", "func (s *Set) Remove(elements ...string) error {\n\tif len(elements) == 0 {\n\t\treturn nil\n\t}\n\n\tifaces := make([]interface{}, len(elements))\n\tfor i := range elements {\n\t\tifaces[i] = elements[i]\n\t}\n\n\tif _, err := s.store.Do(s.key, set.Remove, ifaces...); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *IntSet) Remove(e int) {\n\tdelete(s.elem, e)\n}", "func (l *List) Remove(element interface{}) bool {\n\titem, found := l.find(element)\n\tif !found {\n\t\treturn false\n\t}\n\tif l.Len() == 1 {\n\t\tl.firstElement = nil\n\t\tl.lastElement = nil\n\t}\n\tif item.Prev != nil {\n\t\titem.Prev.Next = item.Next\n\t} else {\n\t\tl.firstElement = item.Next\n\t\tl.firstElement.Prev = nil\n\t}\n\tif item.Next != nil {\n\t\titem.Next.Prev = item.Prev\n\t} else {\n\t\tl.lastElement = item.Prev\n\t\tl.lastElement.Next = nil\n\t}\n\tl.len = l.len - 1\n\treturn true\n}", "func (s Set) Remove(key string) {\n\tdelete(s, key)\n}", "func (s Set) Contains(value interface{}) bool {\n\thash, err := hashstructure.Hash(value, nil)\n\tif err != nil {\n\t\tlog.Errorf(\"type could not be hashed: %+v\", value)\n\t}\n\t_, found := s[hash]\n\treturn found\n}", "func (s *Set) Contains(item Value) bool {\n\t_, ok := s.backingMap.Load(item)\n\treturn ok\n}", "func (s *Set) Remove(elements ...interface{}) {\n\tif len(elements) == 0 {\n\t\treturn\n\t}\n\n\ts.mutex.Lock()\n\tfor _, element := range elements {\n\t\tdelete(s.m, element)\n\t}\n\ts.mutex.Unlock()\n}", "func (h Hash) Remove(in string) bool {\n\tif _, ok := h[in]; ok {\n\t\t// exists\n\t\tdelete(h, in)\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *Set) Remove(c cid.Cid) {\n\ts.lk.Lock()\n\tdefer s.lk.Unlock()\n\tdelete(s.set, c)\n}", "func (ss Set) Remove(k string) {\n\tdelete(ss, k)\n}", "func (s IntSet) Remove(e int) {\n\tdelete(s, e)\n}", "func (s Set) Remove(e graph.Node) {\n\tdelete(s, e.ID())\n}", "func (n *TNode) Remove(id TreeEntity, group int) bool {\n\tn.Count--\n\tll := len(n.Sets)\n\tvar nil TreeEntity // because this is a template\n\tfor i := range n.Sets {\n\t\ts := &n.Sets[i]\n\t\tif s.Group == group {\n\t\t\tl := len(s.IDs)\n\n\t\t\tif l == 1 {\n\t\t\t\tif s.IDs[0] != id {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\ts.IDs[0] = nil\n\t\t\t\tn.Sets[i], n.Sets[ll-1] = n.Sets[ll-1], *s\n\t\t\t\tn.Sets = n.Sets[:ll-1]\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tfor j := 0; j < l; j++ {\n\t\t\t\tif id == s.IDs[j] {\n\t\t\t\t\tl--\n\t\t\t\t\ts.IDs[j] = s.IDs[l]\n\t\t\t\t\ts.IDs[l] = nil\n\t\t\t\t\ts.IDs = s.IDs[:l]\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false\n}", "func (s Set) Remove(removeMem setMember) {\n\n\tdelete(s.mem, removeMem)\n\n}", "func (s *SetOfStr) Remove(x string) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\tdelete(s.set, x)\n}", "func (s *Set) Delete(val interface{}) {\n\tdelete(s.set, val)\n}", "func (s Set) hasValue(v uint8) bool {\n\tfor i := range s {\n\t\tif s[i].Value() == v {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (s *set) Contains(t *Term) bool {\n\treturn s.get(t) != nil\n}", "func (s *Set) SRem(key string, member []byte) bool {\n\tif !s.exist(key) {\n\t\treturn false\n\t}\n\n\tif ok := s.record[key][string(member)]; ok {\n\t\tdelete(s.record[key], string(member))\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (w *WindowedMap) Remove(uid UID) (interface{}, bool) {\n\tw.ExpireOldEntries()\n\titem, ok := w.uidMap[uid]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\theap.Remove(&w.uidList, item.index)\n\tdelete(w.uidMap, uid)\n\treturn item.value, true\n}", "func (set *IntSet) Contains(i int) bool {\n\t_, found := set.members[i]\n\treturn found //true if it existed already\n}", "func (s Set) Contains(k string) bool {\n\t_, ok := s.m[k]\n\treturn ok\n}", "func (il *IntList) Remove(val int) bool {\n last := il.Last()\n for it := il.First(); it != last; it = it.Next() {\n if it.Value() == val {\n it.prev.next = it.next\n it.next.prev = it.prev\n // TODO(david): are the next two lines needed (for the GC)?\n it.next = nil\n it.prev = nil\n\n il.length--\n return true\n }\n }\n return false\n}", "func (s *IntSet) Contains(e int) bool {\n\t_, flag := s.elem[e]\n\treturn flag\n}", "func (s *intSet) has(i int) bool {\n\tif s == nil {\n\t\treturn false\n\t}\n\treturn s.members[i] > 0\n}", "func (set *SetUI) Remove(uint uint) {\n\tset.lock.Lock()\n\tdelete(set.cache, uint)\n\tset.lock.Unlock()\n}", "func (s *HashSet) Contain(data interface{}) (bool, error) {\n\terr := s.checkT(data)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\t_, ok := s.set[data]\n\tif ok {\n\t\treturn true, nil\n\t} else {\n\t\treturn false, nil\n\t}\n}", "func (s *SetOfInt) Remove(x int) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\tdelete(s.set, x)\n}", "func (s IntSet) Has(e int) bool {\n\t_, ok := s[e]\n\treturn ok\n}", "func (m *OrderedMap[K,V]) Remove(k K) (v V, ok bool) {\n\tif !m.Has(k) {\n\t\treturn\n\t}\n\te := m.mp[k]\n\tm.list.Remove(e)\n\tdelete(m.mp, k)\n\tv, ok = e.Value.Value, true\n\treturn\n}", "func (s Set) Contains(t Set) bool {\n\tif len(t) > len(s) {\n\t\treturn false\n\t}\n\tfor n := range t {\n\t\tif _, ok := s[n]; !ok {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (s *Set) Pop(elem A) (A, bool) {\n\t_, found := s.m[elem]\n\tif found {\n\t\tdelete(s.m, elem)\n\t}\n\treturn elem, found\n}", "func (this *RandomizedCollection) Remove(val int) bool {\n \n}", "func Contains(set Interface, x interface{}) bool {\n\treturn set.Contains(x)\n}", "func (s Set) Contains(key string) bool {\n\t_, ok := s[key]\n\treturn ok\n}", "func (l *Int32) Remove(value int32) bool {\n\tfor i, v := range l.values {\n\t\tif v == value {\n\t\t\tl.values = append(l.values[:i], l.values[i+1:]...)\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (set *Set) Rem(element interface{}) {\n\tif set.Contains(element) {\n\t\tset.mu.Lock()\n\t\tdefer set.mu.Unlock()\n\t\tset.elements[element] = false\n\n\t}\n}", "func (set *SetUI) Has(uint uint) bool { return set.cache[uint] }" ]
[ "0.8324413", "0.801336", "0.78466815", "0.7746541", "0.7681242", "0.7564174", "0.7546115", "0.7481034", "0.7443292", "0.73528993", "0.7302366", "0.73018223", "0.7271032", "0.72703797", "0.72621644", "0.72470576", "0.7179773", "0.71460664", "0.71451026", "0.7127476", "0.7070838", "0.7067519", "0.7023564", "0.6849775", "0.6677276", "0.6646308", "0.6617576", "0.66088283", "0.656875", "0.6555078", "0.65132743", "0.6468044", "0.6414427", "0.6365966", "0.63570553", "0.6355946", "0.63491017", "0.63443977", "0.6340685", "0.63310736", "0.63093996", "0.62369484", "0.6198512", "0.6195883", "0.6191167", "0.6188532", "0.6178764", "0.61746037", "0.61195993", "0.60954976", "0.609276", "0.6078855", "0.6070291", "0.60684127", "0.606631", "0.60578936", "0.6057362", "0.6049267", "0.60401815", "0.60354996", "0.6020688", "0.6008513", "0.6001598", "0.5999792", "0.59873885", "0.59784186", "0.594927", "0.5948228", "0.59466195", "0.5939526", "0.5914667", "0.5900759", "0.58891624", "0.5875142", "0.5863803", "0.5859023", "0.5844485", "0.584413", "0.5837185", "0.5828191", "0.5826747", "0.5824416", "0.5823132", "0.5822602", "0.5803199", "0.579103", "0.5788405", "0.57865345", "0.57801425", "0.5779538", "0.57793033", "0.5773701", "0.576122", "0.5756053", "0.5751559", "0.5747079", "0.57458866", "0.57368577", "0.5735388", "0.572983" ]
0.7388723
9
GetRandom will Get a random element from the set.
func (set *RandomizedSet) GetRandom() int { if set.Count == 0 { return 0 } idx := rand.Int() % len(set.Keys) for !set.Value[set.Keys[idx]] { idx = rand.Int() % len(set.Keys) } return set.Keys[idx] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *RandomizedSet) GetRandom() int {\n\tindex := rand.Intn(len(this.a))\n\treturn this.a[index]\n}", "func (this *RandomizedSet) GetRandom() int {\n\treturn this.list[rand.Intn(len(this.list))]\n}", "func (this *RandomizedSet) GetRandom() int {\n\treturn this.a[rand.Intn(len(this.a))]\n}", "func (this *RandomizedSet) GetRandom() int {\n\tif len(this.list) == 0 {\n\t\treturn -1\n\t}\n\ti := rand.Intn(len(this.list))\n\treturn this.list[i]\n}", "func (rs *RandomizedSet) GetRandom() int {\n\treturn rs.keys[rand.Intn(len(rs.keys))]\n}", "func (this *RandomizedSet) GetRandom() int {\n\tindex := rand.Intn(len(this.arr))\n\treturn this.arr[index]\n}", "func (this *RandomizedSet) GetRandom() int {\n\treturn this.data[rand.Intn(len(this.data))]\n}", "func (rs *RandomizedSet) GetRandom() int {\n\treturn rs.arr[rand.Intn(len(rs.arr))]\n}", "func (this *RandomizedSet) GetRandom() int {\n\tind := rand.Intn(len(this.arr))\n\treturn this.arr[ind]\n}", "func (this *RandomizedSet) GetRandom() int {\n\treturn this.vals[rand.Intn(len(this.vals))]\n}", "func (s *RandomizedSet) GetRandom() int {\n\tind := rand.Intn(len(s.table))\n\n\treturn s.arr[ind]\n}", "func (this *RandomizedSet) GetRandom() int {\n\treturn this.arr[rand.Intn(this.length)]\n}", "func (this *RandomizedSet) GetRandom() int {\n\treturn this.nums[rand.Int()%len(this.record)]\n}", "func (this *RandomizedSet) GetRandom() int {\r\n\tloc := rand.Intn(len(this.location))\r\n\treturn this.location[loc]\r\n}", "func (this *RandomizedSet) GetRandom() int {\n\tfor key, _ := range this.m{\n\t\treturn key\n\t}\n\treturn 0\n}", "func (this *RandomizedSet) GetRandom() int {\n\treturn this.arr[rand.Intn(len(this.arr))]\n\t//if this.rand == 0 {\n\t//\tthis.rand = len(this.arr)\n\t//}\n\t//index := rand.Intn(this.rand)\n\t//r := this.arr[index]\n\t//\n\t//if index+1 != this.rand {\n\t//\tthis.v[this.arr[index]], this.v[this.arr[this.rand-1]] = this.v[this.arr[this.rand-1]], this.v[this.arr[index]]\n\t//\tthis.arr[index], this.arr[this.rand-1] = this.arr[this.rand-1], this.arr[index]\n\t//}\n\t//\n\t//this.rand--\n\t//if this.rand == 0 {\n\t//\tthis.rand = len(this.arr)\n\t//}\n\t//\n\t//return r\n}", "func (this *RandomizedSet) GetRandom() int {\n\tif this.length > 0 {\n\t\tkey := rand.Intn(this.length)\n\t\treturn this.data[key]\n\t}\n\treturn -1\n}", "func (omikujis *AllOmikujis) GetRandom(min, max int) Omikuji {\n\tif min < 0 || max > omikujis.GetMax() || min >= max {\n\t\tmsg := fmt.Sprintf(\"Invalid arguments: min=%d, max=%d\", min, max)\n\t\terrors.ThrowOmikujiException(msg, errors.OmikujiErrorCode)\n\t}\n\n\trandIndex := min + rand.Intn(max-min)\n\treturn (*omikujis)[randIndex]\n}", "func (this *Solution) GetRandom() int {\n\tr := rand.Intn(this.count + 1)\n\tthis.count++\n\tif r == this.count-1 && this.head != nil {\n\t\tt := this.head\n\t\tthis.head = this.head.Next\n\t\tthis.pool = append(this.pool, t.Val)\n\t\treturn t.Val\n\t} else {\n\t\treturn this.pool[r%len(this.pool)]\n\t}\n\n}", "func GetRandom(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *RandomState, opts ...pulumi.ResourceOption) (*Random, error) {\n\tvar resource Random\n\terr := ctx.ReadResource(\"xyz:index:Random\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (this *RandomizedCollection) GetRandom() int {\n \n}", "func (s *Set) Random() Proxy {\n\ts.m.Lock()\n\tdefer s.m.Unlock()\n\n\tfor k := range s.proxies {\n\t\treturn k\n\t}\n\n\treturn Proxy{}\n}", "func (this *Solution) GetRandom() int {\n\trand.Seed(time.Now().UnixNano())\n\tcount := rand.Intn(this.size)\n\tp := this.h\n\tfor count > 0 {\n\t\tp = p.Next\n\t\tcount--\n\t}\n\treturn p.Val\n}", "func GetRandom() string {\n\treturn Default.GetRandom()\n}", "func (r *RandomStruct) GetRandom() int {\n\treturn rand.Intn(100) // nolint:gosec\n}", "func (book *Book) GetRandom() []Book {\n\tdb := utils.OpenDB()\n\tdefer db.Close()\n\tvar books []Book\n\tdb.Order(gorm.Expr(\"random()\")).Limit(5).Find(&books)\n\treturn books\n}", "func (bi *bucketInternal) GetRandom(valuePtr interface{}) (string, Cas, error) {\n\treturn bi.b.getRandom(valuePtr)\n}", "func (ps *PeerStore) GetRandom() *Peer {\n\tps.lock.RLock()\n\tdefer ps.lock.RUnlock()\n\tfor _, p := range ps.peers {\n\t\treturn p\n\t}\n\treturn nil\n}", "func GetRandom(rw io.ReadWriter, size uint32) ([]byte, error) {\n\tvar b tpmutil.U32Bytes\n\tin := []interface{}{size}\n\tout := []interface{}{&b}\n\t// There's no need to check the ret value here, since the err value\n\t// contains all the necessary information.\n\tif _, err := submitTPMRequest(rw, tagRQUCommand, ordGetRandom, in, out); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b, nil\n}", "func (h *Hash) Random() interface{} {\n\tif n := len(h.compact.a); n > 0 {\n\t\tidx := rand.Intn(n)\n\t\treturn h.compact.a[idx]\n\t}\n\treturn nil\n}", "func (g *Groups) Random() *Group {\n\tif len(*g) == 0 {\n\t\tpanic(\"No groups to select from!\")\n\t}\n\ti := rand.Intn(len(*g))\n\treturn (*g)[i]\n}", "func (u *UARand) GetRandom() string {\n\treturn UserAgents[u.Intn(len(UserAgents))]\n}", "func (m *wasiSnapshotPreview1Impl) randomGet(pbuf pointer, pbufLen wasiSize) (err wasiErrno) {\n\t_, rerr := rand.Read(m.slice(pbuf, pbufLen))\n\tif rerr != nil {\n\t\treturn fileErrno(rerr)\n\t}\n\treturn wasiErrnoSuccess\n}", "func (r *random) GetRandom(maxNum int) int {\n\trand.Seed(time.Now().UnixNano())\n\treturn rand.Intn(maxNum)\n}", "func GetRandItem() Item {\n\tfor {\n\t\tidx := rand.Intn(len(items))\n\t\titem, ok := items[idx+1]\n\t\tif ok {\n\t\t\treturn item\n\t\t}\n\t}\n}", "func GetRandomOne(arr interface{}) interface{} {\n\trv := reflect.ValueOf(arr)\n\tif rv.Kind() != reflect.Slice && rv.Kind() != reflect.Array {\n\t\treturn arr\n\t}\n\n\ti := mathutil.RandomInt(0, rv.Len())\n\tr := rv.Index(i).Interface()\n\n\treturn r\n}", "func (hpc *HashPeersCache) GetRandom(hash types.Hash32, hint datastore.Hint, rng *rand.Rand) (p2p.Peer, bool) {\n\thpc.mu.Lock()\n\tdefer hpc.mu.Unlock()\n\n\thashPeersMap, exists := hpc.getWithStats(hash, hint)\n\tif !exists {\n\t\treturn p2p.NoPeer, false\n\t}\n\tn := rng.Intn(len(hashPeersMap)) + 1\n\ti := 0\n\tfor peer := range hashPeersMap {\n\t\ti++\n\t\tif i == n {\n\t\t\treturn peer, true\n\t\t}\n\t}\n\treturn p2p.NoPeer, false\n}", "func (list List) RandomChoice() interface{} {\n\trand.Seed(time.Now().Unix())\n\treturn list[rand.Intn(len(list))]\n}", "func Random() string {\n\treturn names[\"all\"][rand.Intn(len(names[\"all\"]))]\n}", "func (this *Solution) GetRandom() int {\n \n}", "func LoadRandom(itemtype Item, conn *redis.Client) (Item, bool, error) {\n\t//fetch 1 random element\n\treply, err := conn.Cmd(\"SRANDMEMBER\", itemtype.getMembersKey(), 1).List()\n\tif err != nil {\n\t\tOnPrimaryFailure()\n\t\treturn nil, false, err\n\t}\n\n\tif len(reply) == 0 {\n\t\t//no such item exists\n\t\treturn nil, false, nil\n\t}\n\n\tuuid := uuid.FromStringOrNil(reply[0])\n\tiLocal := itemtype.create(&uuid)\n\n\t//load the valid element\n\treturn Load(iLocal, conn)\n}", "func GetRandom() Request {\n\trequests := []Request{\n\t\tNewRequest(READ),\n\t\tNewRequest(WRITE),\n\t\tNewRequest(DELETE),\n\t}\n\tkeys := []string{\"Foo\", \"Coolboy\", \"My Heros\"}\n\trequest := requests[rand.Intn(len(requests))]\n\trequest.Key = keys[rand.Intn(len(keys))]\n\trequest.Payload = DataStore[request.Key]\n\treturn request\n}", "func (q *Quotes) Random() Quote {\n\tq.Lock()\n\tdefer q.Unlock()\n\tif len(q.quotes) == 0 {\n\t\treturn Quote{}\n\t}\n\tvar ids []string\n\tfor id := range q.quotes {\n\t\tids = append(ids, id)\n\t}\n\trandID := ids[rand.Intn(len(ids))]\n\treturn q.quotes[randID]\n}", "func (q QuoteSlice) Random() QuoteType {\n\treturn q[rand.Intn(len(q))]\n}", "func (deck Deck) PickRandom() Card {\n\n\tnumber := 1 + rand.Intn(13)\n\tsuite := Suite(rand.Intn(4))\n\tcard := Card{Number: number, Suite: suite}\n\tif deck.CardRemoved(card) {\n\t\treturn deck.PickRandom()\n\t} else {\n\t\tdeck.AddToRemovedCards(card)\n\t\treturn card\n\t}\n}", "func GetRandomNode(ll *list.SinglyLinkedList) *list.SinglyNode {\n\n\t// Let the result be the first node's Data\n\tresult := ll.Head\n\tcurrent := ll.Head\n\tn := 2\n\n\t// Iterate over all the nodes starting from the second and \n\t// give each node an equally likely probability of getting selected\n\t// Start from n=2 and keep moving till the last node\n\t// At each step \n\t// 1. generate a random number in between 0 and (n-1), say j\n\t// \t (First step 1 it would be between 0 and 1, for 2nd it would be 0 and 2 and so on)\n\t// 2. Select the current node as the result only if (j == 0)\n\t// See more explanation below\n\n\tfor n=2; current != nil; n++ {\n\t\t// change the result with probability of 1/n\n\t\tif randInt(0, n-1) == 0 {\n\t\t\tresult = current\n\t\t}\n\t\tcurrent = current.Next\n\t}\n\n\treturn result\n}", "func GetRandomWordSet() []string {\n\tkey := make([]byte, 1)\n\t_, err := rand.Read(key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn WordList[int(key[0])]\n}", "func GetRandomNumber() RandomNum {\n\t//INIT OMIT\n\tredisService := os.Getenv(\"REDIS_SERVICE\")\n\tredisHost := os.Getenv(redisService)\n\tc, err := redis.Dial(\"tcp\", redisHost+\":6379\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer c.Close()\n\n\trand.Seed(time.Now().UTC().UnixNano())\n\trNum := 1 + rand.Intn(13)\n\tfmt.Println(rNum)\n\n\t//get\n\tr, err := redis.String(c.Do(\"GET\", rNum))\n\tif err != nil {\n\t\tfmt.Println(\"key not found\")\n\t}\n\n\tfmt.Println(r)\n\ts := RandomNum{r}\n\treturn s\n\t//ENDINIT OMIT\n}", "func GetRandomFood() FoodType {\n\treturn FoodTypes[rand.Intn(len(FoodTypes))]\n}", "func (c *StoreCandidates) RandomPick() *core.StoreInfo {\n\tif len(c.Stores) == 0 {\n\t\treturn nil\n\t}\n\treturn c.Stores[rand.Intn(len(c.Stores))]\n}", "func (d *MessagesDhConfigNotModified) GetRandom() (value []byte) {\n\tif d == nil {\n\t\treturn\n\t}\n\treturn d.Random\n}", "func (pool *ComplexPool) Random() (Proxy, error) {\n\tlength := pool.SizeAll()\n\n\tif length == 0 {\n\t\tif !pool.Config.ReloadWhenEmpty {\n\t\t\treturn Proxy{}, fmt.Errorf(\"prox (%p): cannot select random proxy, no proxies in pool\", pool)\n\t\t}\n\n\t\terr := pool.Load()\n\t\tif err != nil {\n\t\t\treturn Proxy{}, fmt.Errorf(\"prox (%p): cannot select random proxy, error occurred while reloading empty pool: %v\", pool, err)\n\t\t}\n\n\t\tlength = pool.SizeAll()\n\t}\n\n\trawProxy := pool.All.Random()\n\tpool.Unused.Remove(rawProxy)\n\n\treturn *CastProxy(rawProxy), nil\n}", "func (m *Provider) Random() (string, error) {\n\t// Get random picture\n\trand.Seed(time.Now().Unix())\n\treturn getURL(m.siteurl, m.allpics[rand.Intn(len(m.allpics))], \"1920x1080\")\n}", "func (g *NormalGrid) Random() *Cell {\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\trow := r.Intn(g.rows)\n\tcol := r.Intn(g.cols)\n\treturn g.Get(row, col)\n}", "func (m *memory) Random() (Quote, error) {\n\t// two options on picking a random item from a map in Go\n\t// either iterate the map and break immediately (maps aren't guaranteed to be deterministic in ordering)\n\t// or get the keys into a slice and choose an entry at random\n\tvar k string\n\tvar q Quote\n\tfor k, q = range m.quotes {\n\t\tbreak\n\t}\n\tif k == \"\" {\n\t\treturn Quote{}, fmt.Errorf(\"no quotes in data store\")\n\t}\n\treturn q, nil\n}", "func (net *Network) GetRandomNeuron() *Neuron {\n\tallNeurons := net.All()\n\tchosenIndex := rand.Intn(len(allNeurons))\n\tif chosenIndex < 0 || chosenIndex >= len(allNeurons) {\n\t\tpanic(\"implementation error: the chosen Index is invalid\")\n\t}\n\tchosenNeuron := allNeurons[chosenIndex]\n\tif chosenNeuron == nil {\n\t\tpanic(\"implementation error: the chosen neuron is nil\")\n\t}\n\treturn chosenNeuron\n}", "func GetRandomStr(r *rand.Rand, arr []string) string {\n\treturn arr[r.Intn(len(arr))]\n}", "func GetRandomHead() rune {\n\treturn heads[rand.Intn(len(heads))]\n}", "func (set Set) RandomMember(ctx context.Context) (string, error) {\n\treq := newRequest(\"*2\\r\\n$11\\r\\nSRANDMEMBER\\r\\n$\")\n\treq.addString(set.name)\n\treturn set.c.cmdString(ctx, req)\n}", "func RandomSet(max int, possible []Profession) ([]Profession, error) {\n\tprofessions := []Profession{}\n\tprofession := Profession{}\n\n\tif len(possible) == 0 {\n\t\terr := fmt.Errorf(\"no possible professions given\")\n\t\treturn []Profession{}, err\n\t}\n\n\tif max > len(possible) {\n\t\tmax = len(possible)\n\t}\n\n\tfor i := 0; i < max; i++ {\n\t\tprofession = possible[rand.Intn(len(possible))]\n\t\tif !profession.InSlice(professions) {\n\t\t\tprofessions = append(professions, profession)\n\t\t}\n\t}\n\n\treturn professions, nil\n}", "func Random() (species.Species, error) {\n\traces, err := All()\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to find random race: %w\", err)\n\t\treturn species.Species{}, err\n\t}\n\n\tif len(races) == 0 {\n\t\terr := fmt.Errorf(\"tried to get random race from slice of zero races\")\n\t\treturn species.Species{}, err\n\t}\n\n\tif len(races) == 1 {\n\t\treturn races[0], nil\n\t}\n\n\trace := races[rand.Intn(len(races))]\n\n\treturn race, nil\n}", "func (d *MessagesDhConfig) GetRandom() (value []byte) {\n\tif d == nil {\n\t\treturn\n\t}\n\treturn d.Random\n}", "func Random() (Profession, error) {\n\tall, err := All()\n\tif err != nil {\n\t\terr = fmt.Errorf(\"could not fetch professions: %w\", err)\n\t\treturn Profession{}, err\n\t}\n\n\tprofessions, err := RandomSet(1, all)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"could not get random profession: %w\", err)\n\t\treturn Profession{}, err\n\t}\n\n\treturn professions[0], nil\n}", "func getValue(intSet64 *IntSet64, max int) int {\n\tfor {\n\t\tv := rand.Intn(max)\n\t\tif !intSet64.Has(v) {\n\t\t\treturn v\n\t\t}\n\t}\n}", "func (d *Discrete) Sample(r *rand.Rand) Value {\n\treturn d.DiscreteValues[r.Intn(len(d.DiscreteValues))]\n}", "func (b *DirCensus) Random() (Population, error) {\n\tls, err := deps.ReadDir(b.Dir)\n\tif err != nil {\n\t\treturn Population{}, err\n\t}\n\tif len(ls) == 0 {\n\t\treturn Population{}, ErrNoneFound\n\t}\n\tfi := ls[rand.Intn(len(ls))]\n\treturn b.decodeFromFilename(path.Join(b.Dir, fi.Name()))\n}", "func GetRandomAlbum() *Album {\n\trand.Seed(time.Now().UnixNano())\n\treturn GetAlbumAtPosition(rand.Intn(1000))\n}", "func (s *SampleStore) RandomTeam() (model.Team, error) {\n\treturn model.Team{}, nil\n}", "func GetRand() (*amcl.RAND) {\n\tseedLength := 32\n\tb := make([]byte, seedLength)\n\t_, err := rand.Read(b)\n\tif err != nil {\n\t\t fmt.Print(err ,\"error getting randomness for seed\")\n\t\t return nil\n\t}\n\trng := amcl.NewRAND()\n\trng.Clean()\n\trng.Seed(seedLength, b)\n\treturn rng\n}", "func GetRand() (*amcl.RAND) {\n\tseedLength := 32\n\tb := make([]byte, seedLength)\n\t_, err := rand.Read(b)\n\tif err != nil {\n\t\t fmt.Print(err ,\"error getting randomness for seed\")\n\t\t return nil\n\t}\n\trng := amcl.NewRAND()\n\trng.Clean()\n\trng.Seed(seedLength, b)\n\treturn rng\n}", "func GetRand() (*amcl.RAND) {\n\tseedLength := 32\n\tb := make([]byte, seedLength)\n\t_, err := rand.Read(b)\n\tif err != nil {\n\t\t fmt.Print(err ,\"error getting randomness for seed\")\n\t\t return nil\n\t}\n\trng := amcl.NewRAND()\n\trng.Clean()\n\trng.Seed(seedLength, b)\n\treturn rng\n}", "func (f *Framework) GetRandomNode() (*corev1.Node, error) {\n\tvar nodeList corev1.NodeList\n\terr := f.KubeClient.List(f, &nodeList)\n\tExpectNoError(err)\n\tif len(nodeList.Items) == 0 {\n\t\treturn nil, fmt.Errorf(\"Could not find an available node\")\n\t}\n\trandomNode := nodeList.Items[rand.Intn(len(nodeList.Items))]\n\n\treturn &randomNode, nil\n}", "func GetRandomMessage(messages []string) string {\n\tresult := rand.Intn(len(messages))\n\treturn messages[result]\n}", "func (a *App) GetRandomInt(n int) (res int, err error) {\n\t// As rand.Intn panics if n <= 0, but this would crash the host,\n\t// recover from it.\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tfmt.Println(\"Recovered in GetRandomInt\", e)\n\t\t\terr = errors.New(\"n <= 0 is not allowed\")\n\t\t}\n\t}()\n\n\tif !a.isSeeded {\n\t\trand.Seed(time.Now().UnixNano())\n\t\ta.isSeeded = true\n\t}\n\n\treturn rand.Intn(n), nil\n}", "func RandomNode(a AbstractGraph) *Node {\n\tnodes := a.GetNodes()\n\n\tstop := rand.Int() % len(*nodes)\n\n\tfor k := range *nodes {\n\t\tif stop == 0 {\n\t\t\treturn (*nodes)[k]\n\t\t}\n\t\tstop--\n\t}\n\n\treturn nil\n}", "func GetRandomUserAgent() string {\n\treturn uaPool[r.Intn(len(uaPool))]\n}", "func GetRandomInt(r *rand.Rand, arr []int) int {\n\treturn arr[r.Intn(len(arr))]\n}", "func (ds Depots) RandomSelect() (k int, v *Depot) {\n\tmapKeys := reflect.ValueOf(ds).MapKeys()\n\tselectedKey := mapKeys[rand.Intn(len(mapKeys))].Interface().(int)\n\treturn selectedKey, ds[selectedKey]\n}", "func randChoice(list []string) string {\n randIndex := rand.Intn(len(list))\n return list[randIndex]\n}", "func random(services []*registry.ServiceURL) Next {\n\treturn func(ID uint64) (*registry.ServiceURL, error) {\n\t\tif len(services) == 0 {\n\t\t\treturn nil, ErrNoneAvailable\n\t\t}\n\n\t\ti := ((uint64)(rand.Int()) + ID) % (uint64)(len(services))\n\t\treturn services[i], nil\n\t}\n}", "func (group *Group) Rand() Node {\n\trand.Seed(time.Now().Unix()) // initialize global pseudo random generator\n\n\treturn group.items[rand.Intn(group.Count())]\n}", "func (r Repository) Random() *Quote {\n\tstmt, err := r.db.Prepare(`SELECT id_quote, content, score, uuid\n FROM quotes\n ORDER BY RANDOM()\n LIMIT 1`)\n\n\tif err != nil {\n\t\tlog.Fatal(\"Malformed SQL :\" + err.Error())\n\t}\n\n\t// closes db connection\n\tdefer func() {\n\t\terr := stmt.Close()\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}()\n\n\tslice := buildSliceFromData(stmt)\n\tif len(slice) == 0 {\n\t\treturn nil\n\t}\n\n\treturn &slice[0]\n}", "func (inst Instance) GetRandomSpawnPortal() (Portal, error) {\n\tportals := []Portal{}\n\n\tfor _, p := range inst.portals {\n\t\tif p.name == \"sp\" {\n\t\t\tportals = append(portals, p)\n\t\t}\n\t}\n\n\tif len(portals) == 0 {\n\t\treturn Portal{}, fmt.Errorf(\"No spawn portals in map\")\n\t}\n\n\treturn portals[rand.Intn(len(portals))], nil\n}", "func Random() string {\n\trand.Seed(time.Now().UnixNano())\n\tmin := 0\n\tmax := len(superheroes) - 1\n\treturn superheroes[rand.Intn(max-min+1)+min]\n}", "func (indis Individuals) sample(n int, generator *rand.Rand) Individuals {\n\tvar sample = indis.shuffle(generator)[:n]\n\treturn sample\n}", "func (t table) Sample() string {\n\tr := rand.Intn(t.total)\n\treturn t.Pick(r)\n}", "func (db *FileDB) GetRandomFile() (File, error) {\n\tUUIDs := db.GetUUIDs()\n\n\tif len(UUIDs) == 0 {\n\t\treturn File{}, ErrFileDBEmpty\n\t}\n\n\t// pick random from slice\n\trandomUUID := UUIDs[RandomInt(0, len(UUIDs))]\n\tfile, ok := db.Published.Get(randomUUID)\n\tif !ok {\n\t\treturn File{}, errors.New(\"file does not exist\")\n\t}\n\n\treturn file, nil\n}", "func randset(arr []T, n int) {\n\n}", "func RandomColorset() {\n\treturn Colorset{}\n}", "func (p PropertyGenerator) Random() templateUtils.Property {\n\tproperties := []templateUtils.Property{\n\t\t\"height\",\n\t\t\"width\",\n\t\t\"length\",\n\t\t\"opacity\",\n\t\t\"volume\",\n\t\t\"field\",\n\t\t\"area\",\n\t}\n\n\trand.Seed(time.Now().UnixNano())\n\tmin := 0\n\tmax := len(properties) - 1\n\trandIndex := rand.Intn(max-min+1) + min\n\n\treturn properties[randIndex]\n}", "func get_random_name() (name string) {\n rand.Seed(time.Now().UnixNano())\n names := []string{\n \"Bob\", \"Jane\", \"John\", \"Rob\",\n }\n name = names[rand.Intn(len(names))]\n return\n}", "func Random() float64 {\n\treturn randGen.Float64()\n}", "func (s *SampleStore) RandomPost() (model.Post, error) {\n\treturn model.Post{}, nil\n}", "func (ev *ImgEnv) PickRndImage() {\n\tnimg := len(ev.Images)\n\tev.ImageIdx.Set(rand.Intn(nimg))\n}", "func (ht *HostTrees) SelectRandom(tree string, n int, ignore []types.SiaPublicKey) []modules.HostDBEntry {\n\tht.mu.Lock()\n\tdefer ht.mu.Unlock()\n\treturn ht.trees[tree].SelectRandom(n, ignore)\n}", "func (b *Bucket) GetRandomDoc() (*gomemcached.MCResponse, error) {\n\t// get a connection from the pool\n\tconn, pool, err := b.getRandomConnection()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// We may need to select the bucket before GetRandomDoc()\n\t// will work. This is sometimes done at startup (see defaultMkConn())\n\t// but not always, depending on the auth type.\n\t_, err = conn.SelectBucket(b.Name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// get a randomm document from the connection\n\tdoc, err := conn.GetRandomDoc()\n\t// need to return the connection to the pool\n\tpool.Return(conn)\n\treturn doc, err\n}", "func (c combinatorics) RandomTime(values []time.Time) time.Time {\n\tif len(values) == 0 {\n\t\treturn time.Time{}\n\t}\n\tif len(values) == 1 {\n\t\treturn values[0]\n\t}\n\treturn values[RandomProvider().Intn(len(values))]\n}", "func (am *ArtifactMap) GetRandomApp(sessionState *State) (ArtifactEntry, error) {\n\tam.mu.Lock()\n\tdefer am.mu.Unlock()\n\n\tn := len(am.AppList)\n\tif n < 1 {\n\t\treturn ArtifactEntry{}, errors.New(\"cannot select random app: ArtifactMap is empty\")\n\t}\n\trandomIndex := sessionState.Randomizer().Rand(n)\n\tselectedKVP := am.AppList[randomIndex]\n\treturn *selectedKVP, nil\n}", "func (g *AllergyGenerator) randomReaction() string {\n\treturn g.reactions[rand.Intn(len(g.reactions))]\n}", "func (s *SampleStore) RandomTeamMember(teamId string) (model.TeamMember, error) {\n\treturn model.TeamMember{}, nil\n}" ]
[ "0.8133475", "0.80877596", "0.8075978", "0.805595", "0.7991664", "0.79250515", "0.791871", "0.7899077", "0.7874426", "0.7870769", "0.78109825", "0.77761334", "0.77267087", "0.76966566", "0.7687145", "0.7679171", "0.76757604", "0.7478473", "0.7123785", "0.71016484", "0.70449287", "0.70328337", "0.6880275", "0.68328154", "0.674608", "0.6684065", "0.66820997", "0.65494627", "0.6541704", "0.6512484", "0.6501805", "0.6378511", "0.63090307", "0.62803423", "0.6247386", "0.61901075", "0.6183975", "0.61460745", "0.6133719", "0.61173284", "0.6085902", "0.6081121", "0.60763633", "0.60337067", "0.6014401", "0.5988566", "0.59762543", "0.58937067", "0.5873773", "0.58367234", "0.5818612", "0.5815903", "0.5804626", "0.5790839", "0.57856816", "0.5777808", "0.5755685", "0.5754816", "0.5751102", "0.57359123", "0.5735808", "0.5717059", "0.57098174", "0.5707659", "0.5706578", "0.5692124", "0.568886", "0.56548446", "0.5643846", "0.5643846", "0.5643846", "0.563993", "0.5639815", "0.56395745", "0.56356704", "0.56313604", "0.5622675", "0.5618416", "0.56128", "0.56092757", "0.5548742", "0.55378675", "0.5536207", "0.55239445", "0.5518005", "0.551573", "0.548689", "0.54686254", "0.543877", "0.54363006", "0.542519", "0.54100925", "0.5379521", "0.5374952", "0.53644174", "0.53583664", "0.5350679", "0.5330946", "0.5329758", "0.53201616" ]
0.7441737
18
TODO move this to sizing.go TODO when doing so, account for margins
func (w *widgetbase) allocate(x int, y int, width int, height int, d *sizing) []*allocation { return []*allocation{&allocation{ x: x, y: y, width: width, height: height, this: w, }} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Screen) Size() Point { return Point{X: s.width, Y: len(s.current) / s.width} }", "func (b *Element) Resize(sz fyne.Size) {\n\tif b.size == sz {\n\t\treturn\n\t}\n\n\tb.parseDims(sz)\n\n\tif b.Name == \"inputElement\" || b.Name == \"inputView\" {\n\t\tfmt.Println(\"--Resize:\", b.Name, sz, b.parsedDims.minW)\n\t}\n\n\tb.size = sz\n\tb.claimed = b.minSize\n\tst := b.Style\n\tdims := &b.parsedDims\n\tif st.Position == PositionAbsolute {\n\t\tb.claimed = sz\n\t} else if st.Display == DisplayBlock {\n\t\t// block Element is greedy in x.\n\t\tb.claimed.Width = sz.Width\n\t\tif dims.width != 0 {\n\t\t\tb.claimed.Width = dims.width\n\t\t} else if b.claimed.Width < dims.minW {\n\t\t\tb.claimed.Width = dims.minW\n\t\t} else if dims.maxW != 0 && b.claimed.Width > dims.maxW {\n\t\t\tb.claimed.Width = dims.maxW\n\t\t}\n\t}\n\tif st.ExpandVertically {\n\t\tb.claimed.Height = sz.Height\n\t}\n\n\tif b.Name == \"inputElement\" {\n\t\tfmt.Println(\"--claimed:\", b.claimed)\n\t}\n\n\tif b.Name == \"inputElement\" || b.Name == \"inputView\" {\n\t\tfmt.Println(\"--claimed:\", b.Name, b.claimed)\n\t}\n\n\t// // Give the kids a chance to be greedy too.\n\tfor _, o := range b.kids {\n\t\tif isNativeInline(o) || isAbsolutelyPositioned(o) {\n\t\t\tcontinue\n\t\t}\n\t\tif b.Name == \"homeBox\" || b.Name == \"appRow\" {\n\t\t\tfmt.Printf(\"-- %s resizing child %T \\n\", b.Name, o)\n\t\t}\n\t\to.Resize(b.claimed)\n\t}\n\t// Recalculate our own MinSize.\n\tb.Refresh()\n\tif b.cachedRenderer != nil {\n\t\tb.cachedRenderer.Layout(b.claimed)\n\t}\n}", "func (r *renderer) Spacing() int { return 0 }", "func (tbd *TermboxDriver) Size() (width int, height int) {\n\treturn tbd.width, tbd.height\n}", "func (b BC5) Size() int32 {\n\n\treturn int32(b.Rect.Size().X) * int32(b.Rect.Size().Y)\n}", "func (s *WidgetBase) Resize(pos image.Point, size image.Point) {\n\tnewRect := image.Rect(pos.X, pos.Y, pos.X+size.X, pos.Y+size.Y)\n\trect := s.Block.GetRect()\n\t//s.size = size\n\tif rect != newRect {\n\t\ts.Block.SetRect(newRect.Min.X, newRect.Min.Y, newRect.Min.X+size.X, newRect.Min.Y+size.Y)\n\t\ts.layoutChildren(newRect.Min, newRect.Size())\n\t}\n}", "func (s *sizes) setSizes(width int, height int) {\n\ts.width = width\n\ts.height = height\n\ts.curStreamsPerStreamDisplay = 1 + height/10\n}", "func calcSize(items []string) (w, h int) {\n\th = len(items) + (padding * 2)\n\n\tw = minWidth\n\tfor _, s := range items {\n\t\tif len(s) > w {\n\t\t\tw = len(s)\n\t\t}\n\t}\n\tw += (padding * 2)\n\n\treturn w, h\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {\n\treturn 320, 240\n}", "func (self *Graphics) BoundsPadding() int{\n return self.Object.Get(\"boundsPadding\").Int()\n}", "func (e *Emulator) Bounds() image.Rectangle { return image.Rect(0, 0, e.Width, e.Height) }", "func (m *MdiaBox) Size() uint64 {\n\treturn containerSize(m.Children)\n}", "func (t *Terminal) updateSize() {\n\n\tt.width, t.height = termbox.Size()\n\tnumTabs := len(t.activeTabs)\n\n\tif numTabs > 0 {\n\n\t\t//divides width of terminal excluding spacers\n\t\tavgTabWidth := (t.width - (numTabs - 1)) / numTabs\n\t\tleftOverSpace := (t.width - (numTabs - 1)) % numTabs\n\n\t\tstartX := 0\n\t\tendX := -1\n\t\tfor i, tab := range t.activeTabs {\n\t\t\tstartX = endX + 1\n\t\t\tendX = startX + avgTabWidth\n\n\t\t\t//Distribute the left over space\n\t\t\tif i < leftOverSpace {\n\t\t\t\tendX++\n\t\t\t}\n\n\t\t\ttab.startX = startX\n\t\t\ttab.endX = endX\n\n\t\t}\n\n\t}\n\n}", "func minSizeEffective(item LayoutItem) Size {\n\tgeometry := item.Geometry()\n\n\tvar s Size\n\tif msh, ok := item.(MinSizer); ok {\n\t\ts = msh.MinSize()\n\t} else if is, ok := item.(IdealSizer); ok {\n\t\ts = is.IdealSize()\n\t}\n\n\tsize := maxSize(geometry.MinSize, s)\n\n\tmax := geometry.MaxSize\n\tif max.Width > 0 && size.Width > max.Width {\n\t\tsize.Width = max.Width\n\t}\n\tif max.Height > 0 && size.Height > max.Height {\n\t\tsize.Height = max.Height\n\t}\n\n\treturn size\n}", "func (sm3 *SM3) Size() int { return 32 }", "func Size() (w int, h int) {\n\tw = goterm.Width()\n\th = goterm.Height()\n\treturn\n}", "func Size() (w int, h int) {\n\tw = goterm.Width()\n\th = goterm.Height()\n\treturn\n}", "func (li *gridLayoutItem) sectionSizesForSpace(orientation Orientation, space int, widths []int) []int {\n\tvar stretchFactors []int\n\tif orientation == Horizontal {\n\t\tstretchFactors = li.columnStretchFactors\n\t} else {\n\t\tstretchFactors = li.rowStretchFactors\n\t}\n\n\tvar sectionCountWithGreedyNonSpacer int\n\tvar sectionCountWithGreedySpacer int\n\tvar stretchFactorsTotal [3]int\n\tvar minSizesRemaining int\n\tminSizes := make([]int, len(stretchFactors))\n\tmaxSizes := make([]int, len(stretchFactors))\n\tsizes := make([]int, len(stretchFactors))\n\tsortedSections := gridLayoutSectionInfoList(make([]gridLayoutSectionInfo, len(stretchFactors)))\n\n\tfor i := 0; i < len(stretchFactors); i++ {\n\t\tvar otherAxisCount int\n\t\tif orientation == Horizontal {\n\t\t\totherAxisCount = len(li.rowStretchFactors)\n\t\t} else {\n\t\t\totherAxisCount = len(li.columnStretchFactors)\n\t\t}\n\n\t\tfor j := 0; j < otherAxisCount; j++ {\n\t\t\tvar item LayoutItem\n\t\t\tif orientation == Horizontal {\n\t\t\t\titem = li.cells[j][i].item\n\t\t\t} else {\n\t\t\t\titem = li.cells[i][j].item\n\t\t\t}\n\n\t\t\tif item == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !shouldLayoutItem(item) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tinfo := li.item2Info[item]\n\t\t\tflags := item.LayoutFlags()\n\n\t\t\tmax := item.Geometry().MaxSize\n\n\t\t\tvar pref Size\n\t\t\tif hfw, ok := item.(HeightForWidther); !ok || !hfw.HasHeightForWidth() {\n\t\t\t\tif is, ok := item.(IdealSizer); ok {\n\t\t\t\t\tpref = is.IdealSize()\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif orientation == Horizontal {\n\t\t\t\tif info.spanHorz == 1 {\n\t\t\t\t\tminSizes[i] = maxi(minSizes[i], li.MinSizeEffectiveForChild(item).Width)\n\t\t\t\t}\n\n\t\t\t\tif max.Width > 0 {\n\t\t\t\t\tmaxSizes[i] = maxi(maxSizes[i], max.Width)\n\t\t\t\t} else if pref.Width > 0 && flags&GrowableHorz == 0 {\n\t\t\t\t\tmaxSizes[i] = maxi(maxSizes[i], pref.Width)\n\t\t\t\t} else {\n\t\t\t\t\tmaxSizes[i] = 32768\n\t\t\t\t}\n\n\t\t\t\tif info.spanHorz == 1 && flags&GreedyHorz > 0 {\n\t\t\t\t\tif _, isSpacer := item.(*spacerLayoutItem); isSpacer {\n\t\t\t\t\t\tsortedSections[i].hasGreedySpacer = true\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsortedSections[i].hasGreedyNonSpacer = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif info.spanVert == 1 {\n\t\t\t\t\tif hfw, ok := item.(HeightForWidther); ok && hfw.HasHeightForWidth() {\n\t\t\t\t\t\tminSizes[i] = maxi(minSizes[i], hfw.HeightForWidth(li.spannedWidth(info, widths)))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tminSizes[i] = maxi(minSizes[i], li.MinSizeEffectiveForChild(item).Height)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif max.Height > 0 {\n\t\t\t\t\tmaxSizes[i] = maxi(maxSizes[i], max.Height)\n\t\t\t\t} else if hfw, ok := item.(HeightForWidther); ok && flags&GrowableVert == 0 && hfw.HasHeightForWidth() {\n\t\t\t\t\tmaxSizes[i] = minSizes[i]\n\t\t\t\t} else if pref.Height > 0 && flags&GrowableVert == 0 {\n\t\t\t\t\tmaxSizes[i] = maxi(maxSizes[i], pref.Height)\n\t\t\t\t} else {\n\t\t\t\t\tmaxSizes[i] = 32768\n\t\t\t\t}\n\n\t\t\t\tif info.spanVert == 1 && flags&GreedyVert > 0 {\n\t\t\t\t\tif _, isSpacer := item.(*spacerLayoutItem); isSpacer {\n\t\t\t\t\t\tsortedSections[i].hasGreedySpacer = true\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsortedSections[i].hasGreedyNonSpacer = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsortedSections[i].index = i\n\t\tsortedSections[i].minSize = minSizes[i]\n\t\tsortedSections[i].maxSize = maxSizes[i]\n\t\tsortedSections[i].stretch = maxi(1, stretchFactors[i])\n\n\t\tminSizesRemaining += minSizes[i]\n\n\t\tif sortedSections[i].hasGreedyNonSpacer {\n\t\t\tsectionCountWithGreedyNonSpacer++\n\t\t\tstretchFactorsTotal[0] += stretchFactors[i]\n\t\t} else if sortedSections[i].hasGreedySpacer {\n\t\t\tsectionCountWithGreedySpacer++\n\t\t\tstretchFactorsTotal[1] += stretchFactors[i]\n\t\t} else {\n\t\t\tstretchFactorsTotal[2] += stretchFactors[i]\n\t\t}\n\t}\n\n\tsort.Stable(sortedSections)\n\n\tmargins := MarginsFrom96DPI(li.margins96dpi, li.ctx.dpi)\n\tspacing := IntFrom96DPI(li.spacing96dpi, li.ctx.dpi)\n\n\tif orientation == Horizontal {\n\t\tspace -= margins.HNear + margins.HFar\n\t} else {\n\t\tspace -= margins.VNear + margins.VFar\n\t}\n\n\tvar spacingRemaining int\n\tfor _, max := range maxSizes {\n\t\tif max > 0 {\n\t\t\tspacingRemaining += spacing\n\t\t}\n\t}\n\tif spacingRemaining > 0 {\n\t\tspacingRemaining -= spacing\n\t}\n\n\toffsets := [3]int{0, sectionCountWithGreedyNonSpacer, sectionCountWithGreedyNonSpacer + sectionCountWithGreedySpacer}\n\tcounts := [3]int{sectionCountWithGreedyNonSpacer, sectionCountWithGreedySpacer, len(stretchFactors) - sectionCountWithGreedyNonSpacer - sectionCountWithGreedySpacer}\n\n\tfor i := 0; i < 3; i++ {\n\t\tstretchFactorsRemaining := stretchFactorsTotal[i]\n\n\t\tfor j := 0; j < counts[i]; j++ {\n\t\t\tinfo := sortedSections[offsets[i]+j]\n\t\t\tk := info.index\n\n\t\t\tstretch := stretchFactors[k]\n\t\t\tmin := info.minSize\n\t\t\tmax := info.maxSize\n\t\t\tsize := min\n\n\t\t\tif min < max {\n\t\t\t\texcessSpace := float64(space - minSizesRemaining - spacingRemaining)\n\n\t\t\t\tsize += int(excessSpace * float64(stretch) / float64(stretchFactorsRemaining))\n\t\t\t\tif size < min {\n\t\t\t\t\tsize = min\n\t\t\t\t} else if size > max {\n\t\t\t\t\tsize = max\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tsizes[k] = size\n\n\t\t\tminSizesRemaining -= min\n\t\t\tstretchFactorsRemaining -= stretch\n\n\t\t\tspace -= (size + spacing)\n\t\t\tspacingRemaining -= spacing\n\t\t}\n\t}\n\n\treturn sizes\n}", "func (w *LDRWrapper) Size() int {\n\treturn w.Bounds().Dx() * w.Bounds().Dy()\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {\n\treturn 600, 700\n}", "func (v *View) Resize(w, h int) {\n\t// Always include 1 line for the command line at the bottom\n\th--\n\tv.width = int(float32(w) * float32(v.widthPercent) / 100)\n\t// We subtract 1 for the statusline\n\tv.height = int(float32(h)*float32(v.heightPercent)/100) - 1\n}", "func (w *WidgetImplement) Size() (int, int) {\n\treturn w.w, w.h\n}", "func (game *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {\n return 640, 480\n}", "func (b *borderLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {\n\tminSize := fyne.NewSize(0, 0)\n\tfor _, child := range objects {\n\t\tif !child.Visible() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif child != b.top && child != b.bottom && child != b.left && child != b.right {\n\t\t\tminSize = minSize.Union(child.MinSize())\n\t\t}\n\t}\n\n\tif b.left != nil && b.left.Visible() {\n\t\tminHeight := fyne.Max(minSize.Height, b.left.MinSize().Height)\n\t\tminSize = fyne.NewSize(minSize.Width+b.left.MinSize().Width+theme.Padding(), minHeight)\n\t}\n\tif b.right != nil && b.right.Visible() {\n\t\tminHeight := fyne.Max(minSize.Height, b.right.MinSize().Height)\n\t\tminSize = fyne.NewSize(minSize.Width+b.right.MinSize().Width+theme.Padding(), minHeight)\n\t}\n\n\tif b.top != nil && b.top.Visible() {\n\t\tminWidth := fyne.Max(minSize.Width, b.top.MinSize().Width)\n\t\tminSize = fyne.NewSize(minWidth, minSize.Height+b.top.MinSize().Height+theme.Padding())\n\t}\n\tif b.bottom != nil && b.bottom.Visible() {\n\t\tminWidth := fyne.Max(minSize.Width, b.bottom.MinSize().Width)\n\t\tminSize = fyne.NewSize(minWidth, minSize.Height+b.bottom.MinSize().Height+theme.Padding())\n\t}\n\n\treturn minSize\n}", "func getThumbnailSize(w, h int, size string) (newWidth, newHeight int) {\n\tvar thumbWidth int\n\tvar thumbHeight int\n\n\tswitch {\n\tcase size == \"op\":\n\t\tthumbWidth = config.Config.ThumbWidth\n\t\tthumbHeight = config.Config.ThumbHeight\n\tcase size == \"reply\":\n\t\tthumbWidth = config.Config.ThumbWidthReply\n\t\tthumbHeight = config.Config.ThumbHeightReply\n\tcase size == \"catalog\":\n\t\tthumbWidth = config.Config.ThumbWidthCatalog\n\t\tthumbHeight = config.Config.ThumbHeightCatalog\n\t}\n\tif w == h {\n\t\tnewWidth = thumbWidth\n\t\tnewHeight = thumbHeight\n\t} else {\n\t\tvar percent float32\n\t\tif w > h {\n\t\t\tpercent = float32(thumbWidth) / float32(w)\n\t\t} else {\n\t\t\tpercent = float32(thumbHeight) / float32(h)\n\t\t}\n\t\tnewWidth = int(float32(w) * percent)\n\t\tnewHeight = int(float32(h) * percent)\n\t}\n\treturn\n}", "func (r *blockRenderer) Layout(sz fyne.Size) {\n\tst := r.el.Style\n\tpt, pr, pb, pl := st.Padding[0], st.Padding[1], st.Padding[2], st.Padding[3]\n\tmt, mr, mb, ml := st.Margins[0], st.Margins[1], st.Margins[2], st.Margins[3]\n\tbw, br, brdc, bgc := st.BorderWidth, st.BorderRadius, st.BorderColor, st.BgColor\n\txSpace := 2*bw + ml + pl + mr + pr\n\tySpace := 2*bw + mt + pt + mb + pb\n\tlSpace := bw + ml + pl\n\ttSpace := bw + mt + pt\n\n\t// The elementLayout takes care of the sizing within the kids' space. We need\n\t// to offset the within our own margins, padding, and borders.\n\tkidBoxSize := r.el.claimed.Subtract(fyne.NewSize(xSpace, ySpace))\n\tflowingKids, positionedKids := layoutItems(r.el.kids)\n\tr.el.Layout(flowingKids, kidBoxSize)\n\tr.el.positionAbsolutely(positionedKids)\n\n\tkidOffset := fyne.NewPos(lSpace, tSpace)\n\n\tif r.el.Name == \"hr\" {\n\t\tfmt.Println(\"--blockRenderer.Layout \", r.el.claimed, kidBoxSize)\n\t}\n\n\tapplyOffset(flowingKids, kidOffset)\n\n\tx, y := ml, mt\n\tworkingSize := r.el.claimed.Subtract(fyne.NewSize(ml+mr, mt+mb))\n\tobs := make([]fyne.CanvasObject, 0)\n\tif st.BorderWidth > 0 {\n\t\tif br > 0 {\n\t\t\tobs = append(obs, roundedRectangle(workingSize.Width, workingSize.Height,\n\t\t\t\tx, y, br, float32(br*2), brdc)...)\n\t\t} else {\n\t\t\trect := canvas.NewRectangle(brdc)\n\t\t\trect.Resize(workingSize)\n\t\t\tobs = append(obs, rect)\n\t\t\trect.Move(fyne.NewPos(x, y))\n\t\t}\n\t\tx += bw\n\t\ty += bw\n\t\tworkingSize = workingSize.Subtract(fyne.NewSize(bw*2, bw*2))\n\t}\n\n\tif bgc != Transparent {\n\t\tif br > 0 {\n\t\t\tobs = append(obs, roundedRectangle(workingSize.Width, workingSize.Height,\n\t\t\t\tx, y, br, float32(br*2), bgc)...)\n\t\t} else {\n\t\t\trect := canvas.NewRectangle(bgc)\n\t\t\trect.Resize(workingSize)\n\t\t\trect.Move(fyne.NewPos(x, y))\n\t\t\tobs = append(obs, rect)\n\t\t}\n\t}\n\tr.el.obs = obs\n}", "func adjustSize(dst types.Path, img image.Image, w, h int, crop bool, logger *log.Entry) (int, int, error) {\n\tvar out image.Image\n\tvar err error\n\tif crop {\n\t\tinAR := float64(img.Bounds().Dx()) / float64(img.Bounds().Dy())\n\t\toutAR := float64(w) / float64(h)\n\n\t\tvar scaleW, scaleH uint\n\t\tif inAR > outAR {\n\t\t\t// input has shorter AR than requested output so use requested height and calculate width to match input AR\n\t\t\tscaleW = uint(float64(h) * inAR)\n\t\t\tscaleH = uint(h)\n\t\t} else {\n\t\t\t// input has taller AR than requested output so use requested width and calculate height to match input AR\n\t\t\tscaleW = uint(w)\n\t\t\tscaleH = uint(float64(w) / inAR)\n\t\t}\n\n\t\tscaled := resize.Resize(scaleW, scaleH, img, resize.Lanczos3)\n\n\t\txoff := (scaled.Bounds().Dx() - w) / 2\n\t\tyoff := (scaled.Bounds().Dy() - h) / 2\n\n\t\ttr := image.Rect(0, 0, w, h)\n\t\ttarget := image.NewRGBA(tr)\n\t\tdraw.Draw(target, tr, scaled, image.Pt(xoff, yoff), draw.Src)\n\t\tout = target\n\t} else {\n\t\tout = resize.Thumbnail(uint(w), uint(h), img, resize.Lanczos3)\n\t}\n\n\tif err = writeFile(out, string(dst)); err != nil {\n\t\tlogger.WithError(err).Error(\"Failed to encode and write image\")\n\t\treturn -1, -1, err\n\t}\n\n\treturn out.Bounds().Max.X, out.Bounds().Max.Y, nil\n}", "func (v *mandelbrotViewer) Layout(outsideWidth, outsideHeight int) (int, int) {\n\treturn *widthFlag, *heightFlag\n}", "func mustSize(s *scope, name string) *core.Size {\n\tsize, present := s.state.Config.Size[name]\n\ts.Assert(present, \"Unknown size %s\", name)\n\treturn size\n}", "func (e *Element) MarginRealSize() mat.Vec {\n\treturn sumAABB(e.Margin)\n}", "func (w *WidgetImplement) FixedSize() (int, int) {\n\treturn w.fixedW, w.fixedH\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {\n\treturn outsideWidth, outsideHeight\n}", "func (dim *Dimensions) Init() {\n\tdim.height = dim.TopRight.X - dim.BottomLeft.X + 1\n\tdim.width = dim.TopRight.Y - dim.BottomLeft.Y + 1\n\tdim.Size = dim.height * dim.width\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {\n\treturn outsideWidth, outsideHeight\n}", "func (s Spacer) Fn(gtx Ctx) Dims {\n\treturn Dims{\n\t\tSize: image.Point{\n\t\t\tX: gtx.Px(s.Width),\n\t\t\tY: gtx.Px(s.Height),\n\t\t},\n\t}\n}", "func (e *Editor) Layout(gtx layout.Context, sh text.Shaper, font text.Font, size unit.Value) layout.Dimensions {\n\ttextSize := fixed.I(gtx.Px(size))\n\tif e.font != font || e.textSize != textSize {\n\t\te.invalidate()\n\t\te.font = font\n\t\te.textSize = textSize\n\t}\n\tmaxWidth := gtx.Constraints.Max.X\n\tif e.singleLine {\n\t\tmaxWidth = Inf\n\t}\n\tif maxWidth != e.maxWidth {\n\t\te.maxWidth = maxWidth\n\t\te.invalidate()\n\t}\n\tif sh != e.shaper {\n\t\te.shaper = sh\n\t\te.invalidate()\n\t}\n\tif e.mask != e.lastMask {\n\t\te.lastMask = e.mask\n\t\te.invalidate()\n\t}\n\te.makeValid()\n\te.processEvents(gtx)\n\te.makeValid()\n\tif viewSize := gtx.Constraints.Constrain(e.dims.Size); viewSize != e.viewSize {\n\t\te.viewSize = viewSize\n\t\te.invalidate()\n\t}\n\te.makeValid()\n\treturn e.layout(gtx)\n}", "func (o *Grid) Size() int {\n\treturn o.npts[0] * o.npts[1] * o.npts[2]\n}", "func execmStdSizesSizeof(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := args[0].(*types.StdSizes).Sizeof(args[1].(types.Type))\n\tp.Ret(2, ret)\n}", "func (w *sliderElement) Layout(bc base.Constraints) base.Size {\n\tif !bc.HasBoundedWidth() && !bc.HasBoundedHeight() {\n\t\t// No need to worry about breaking the constraints. We can take as\n\t\t// much space as desired.\n\t\twidth := w.MinIntrinsicWidth(base.Inf)\n\t\t_, height := w.handle.GetPreferredHeight()\n\t\t// Dimensions may need to be increased to meet minimums.\n\t\treturn bc.Constrain(base.Size{width, base.FromPixelsY(height)})\n\t}\n\tif !bc.HasBoundedHeight() {\n\t\t// No need to worry about height. Find the width that best meets the\n\t\t// widgets preferred width.\n\t\twidth := bc.ConstrainWidth(w.MinIntrinsicWidth(base.Inf))\n\t\t// Get the best height for this width.\n\t\t_, height := syscall.WidgetGetPreferredHeightForWidth(w.handle, width.PixelsX())\n\t\t// Height may need to be increased to meet minimum.\n\t\treturn base.Size{width, bc.ConstrainHeight(base.FromPixelsY(height))}\n\t}\n\n\t// Not clear the following is the best general approach given GTK layout\n\t// model.\n\t_, height2 := w.handle.GetPreferredHeight()\n\tif height := base.FromPixelsY(height2); height < bc.Max.Height {\n\t\twidth := w.MinIntrinsicWidth(height)\n\t\treturn bc.Constrain(base.Size{width, height})\n\t}\n\n\theight := base.FromPixelsY(height2)\n\twidth := w.MinIntrinsicWidth(height)\n\treturn bc.Constrain(base.Size{width, height})\n}", "func (d *Diagram) AdaptSize() (int, int) {\n\tfor _, s := range d.Content {\n\t\ts, ok := s.(shape.Shape)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tx, y := s.Position()\n\t\tswitch s := s.(type) {\n\t\tcase *shape.Line:\n\t\t\tx = min(s.Start.X, s.End.X)\n\t\t\ty = min(s.Start.Y, s.End.Y)\n\t\tcase *shape.Arrow:\n\t\t\tx = min(s.Start.X, s.End.X)\n\t\t\ty = min(s.Start.Y, s.End.Y)\n\t\t}\n\t\tw := x + s.Width()\n\t\tif w > d.Width() {\n\t\t\td.SetWidth(w)\n\t\t}\n\t\th := y + s.Height()\n\t\tif h > d.Height() {\n\t\t\td.SetHeight(h)\n\t\t}\n\t}\n\td.SetWidth(d.Width() + 1) // Fixes right most pixels not visible\n\td.SetHeight(d.Height() + 1) // Fixes bottom pixels not visible\n\treturn d.Width(), d.Height()\n}", "func (w *WidgetBase) SizePolicy() (SizePolicy, SizePolicy) {\n\treturn w.sizePolicyX, w.sizePolicyY\n}", "func SizeBox(child iup.Ihandle) iup.Ihandle {\n\t//Ihandle* IupGLSizeBox(Ihandle* child);\n\treturn mkih(C.IupGLSizeBox(pih(child)))\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {\n\treturn ScreenWidth, ScreenHeight\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {\n\treturn ScreenWidth, ScreenHeight\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {\n\treturn screenWidth, screenHeight\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {\n\treturn screenWidth, screenHeight\n}", "func (canvas *Canvas) Size() (width, height Unit) {\n\tmbox := canvas.page.MediaBox\n\treturn mbox.Dx(), mbox.Dy()\n}", "func (*Plasma) Layout(_, _ int) (int, int) {\r\n\treturn Width, Height\r\n}", "func (bl *barLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {\n\ttotal := 0\n\toffset := 0\n\tbarWidth := 0\n\ticonCount := len(objects)\n\tif !bl.bar.disableTaskbar {\n\t\ticonCount--\n\t\tbarWidth = (iconCount * (bl.bar.iconSize + theme.Padding())) + separatorWidth\n\t} else {\n\t\tbarWidth = iconCount * (bl.bar.iconSize + theme.Padding())\n\t}\n\tbarLeft := (size.Width - barWidth) / 2\n\ticonLeft := barLeft\n\n\tmouseX := bl.mousePosition.X\n\tzoom := bl.mouseInside && mouseX >= barLeft && mouseX <= barLeft+barWidth\n\n\tfor _, child := range objects {\n\t\tif zoom && !appBar.disableZoom {\n\t\t\ticonCenter := iconLeft + bl.bar.iconSize/2\n\t\t\toffsetX := float64(mouseX - iconCenter)\n\n\t\t\tscale := float64(bl.bar.iconScale) - (math.Abs(offsetX) / float64(bl.bar.iconSize*4))\n\t\t\tnewSize := int(math.Floor(float64(bl.bar.iconSize) * scale))\n\t\t\tif newSize < bl.bar.iconSize {\n\t\t\t\tnewSize = bl.bar.iconSize\n\t\t\t}\n\t\t\tif _, ok := child.(*canvas.Rectangle); ok {\n\t\t\t\tchild.Resize(fyne.NewSize(separatorWidth, newSize))\n\t\t\t\ttotal += separatorWidth\n\t\t\t} else {\n\t\t\t\tchild.Resize(fyne.NewSize(newSize, newSize))\n\t\t\t\ttotal += newSize\n\n\t\t\t\tif iconLeft+bl.bar.iconSize+theme.Padding() < mouseX {\n\t\t\t\t\toffset += (newSize - bl.bar.iconSize)\n\t\t\t\t} else if iconLeft < mouseX {\n\t\t\t\t\tratio := float64(mouseX-iconLeft) / float64(bl.bar.iconSize+theme.Padding())\n\t\t\t\t\toffset += int(float64(newSize-bl.bar.iconSize)*(ratio)) + theme.Padding()\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif _, ok := child.(*canvas.Rectangle); ok {\n\t\t\t\tchild.Resize(fyne.NewSize(separatorWidth, bl.bar.iconSize))\n\t\t\t\ttotal += separatorWidth\n\t\t\t} else {\n\t\t\t\tchild.Resize(fyne.NewSize(bl.bar.iconSize, bl.bar.iconSize))\n\t\t\t\ttotal += bl.bar.iconSize\n\t\t\t}\n\t\t}\n\t\ttotal += theme.Padding()\n\t\tif _, ok := child.(*canvas.Rectangle); ok {\n\t\t\ticonLeft += separatorWidth\n\t\t} else {\n\t\t\ticonLeft += bl.bar.iconSize\n\t\t}\n\t\ticonLeft += theme.Padding()\n\t}\n\n\tx := 0\n\tx += barLeft - offset\n\n\tfor _, child := range objects {\n\t\twidth := child.Size().Width\n\t\theight := child.Size().Height\n\n\t\tif bl.mouseInside {\n\t\t\tchild.Move(fyne.NewPos(x, int(float32(bl.bar.iconSize)*bl.bar.iconScale)-height))\n\t\t} else {\n\t\t\tchild.Move(fyne.NewPos(x, 0))\n\t\t}\n\t\tx += width + theme.Padding()\n\t}\n}", "func (c *cardRenderer) MinSize() fyne.Size {\n\thasHeader := c.card.Title != \"\"\n\thasSubHeader := c.card.Subtitle != \"\"\n\thasImage := c.card.Image != nil\n\thasContent := c.card.Content != nil\n\n\tif !hasHeader && !hasSubHeader && !hasContent { // just image, or nothing\n\t\tif c.card.Image == nil {\n\t\t\treturn fyne.NewSize(theme.Padding(), theme.Padding()) // empty, just space for border\n\t\t}\n\t\treturn fyne.NewSize(c.card.Image.MinSize().Width+theme.Padding(), cardMediaHeight+theme.Padding())\n\t}\n\n\tcontentPad := theme.Padding()\n\tmin := fyne.NewSize(theme.Padding(), theme.Padding())\n\tif hasImage {\n\t\tmin = fyne.NewSize(min.Width, min.Height+cardMediaHeight)\n\t}\n\n\tif hasHeader || hasSubHeader {\n\t\ttitlePad := theme.Padding() * 2\n\t\tmin = min.Add(fyne.NewSize(0, titlePad*2))\n\t\tif hasHeader {\n\t\t\theaderMin := c.header.MinSize()\n\t\t\tmin = fyne.NewSize(fyne.Max(min.Width, headerMin.Width+titlePad*2+theme.Padding()),\n\t\t\t\tmin.Height+headerMin.Height)\n\t\t\tif hasSubHeader {\n\t\t\t\tmin.Height += theme.Padding()\n\t\t\t}\n\t\t}\n\t\tif hasSubHeader {\n\t\t\tsubHeaderMin := c.subHeader.MinSize()\n\t\t\tmin = fyne.NewSize(fyne.Max(min.Width, subHeaderMin.Width+titlePad*2+theme.Padding()),\n\t\t\t\tmin.Height+subHeaderMin.Height)\n\t\t}\n\t}\n\n\tif hasContent {\n\t\tcontentMin := c.card.Content.MinSize()\n\t\tmin = fyne.NewSize(fyne.Max(min.Width, contentMin.Width+contentPad*2+theme.Padding()),\n\t\t\tmin.Height+contentMin.Height+contentPad*2)\n\t}\n\n\treturn min\n}", "func printSizeAlign(s string, sz uintptr, al uintptr) {\n\tfmt.Println(\"Type\", s, \"size\", sz, \"alignment\", al)\n}", "func (m *MvexBox) Size() uint64 {\n\treturn containerSize(m.Children)\n}", "func (mw *MagickWand) Size() (columns, rows uint, err error) {\n\treturn mw.Width(), mw.Height(), nil\n}", "func (b *SmhdBox) Size() uint64 {\n\treturn boxHeaderSize + 8\n}", "func GetItemInnerSpacing() (w, h float32) {\n\tvec2 := imgui.CurrentStyle().ItemInnerSpacing()\n\treturn vec2.X, vec2.Y\n}", "func (f *Flex) Layout(children ...FlexChild) Dimens {\n\tmainc := axisMainConstraint(f.Axis, f.cs)\n\tcrossSize := axisCrossConstraint(f.Axis, f.cs).Constrain(f.maxCross)\n\tvar space int\n\tif mainc.Min > f.size {\n\t\tspace = mainc.Min - f.size\n\t}\n\tvar mainSize int\n\tvar baseline int\n\tswitch f.Spacing {\n\tcase SpaceSides:\n\t\tmainSize += space / 2\n\tcase SpaceStart:\n\t\tmainSize += space\n\tcase SpaceEvenly:\n\t\tmainSize += space / (1 + len(children))\n\tcase SpaceAround:\n\t\tmainSize += space / (len(children) * 2)\n\t}\n\tfor i, child := range children {\n\t\tdims := child.dims\n\t\tb := dims.Baseline\n\t\tvar cross int\n\t\tswitch f.Alignment {\n\t\tcase End:\n\t\t\tcross = crossSize - axisCross(f.Axis, dims.Size)\n\t\tcase Middle:\n\t\t\tcross = (crossSize - axisCross(f.Axis, dims.Size)) / 2\n\t\tcase Baseline:\n\t\t\tif f.Axis == Horizontal {\n\t\t\t\tcross = f.maxBaseline - b\n\t\t\t}\n\t\t}\n\t\tvar stack ui.StackOp\n\t\tstack.Push(f.ops)\n\t\tui.TransformOp{}.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))).Add(f.ops)\n\t\tchild.macro.Add(f.ops)\n\t\tstack.Pop()\n\t\tmainSize += axisMain(f.Axis, dims.Size)\n\t\tif i < len(children)-1 {\n\t\t\tswitch f.Spacing {\n\t\t\tcase SpaceEvenly:\n\t\t\t\tmainSize += space / (1 + len(children))\n\t\t\tcase SpaceAround:\n\t\t\t\tmainSize += space / len(children)\n\t\t\tcase SpaceBetween:\n\t\t\t\tmainSize += space / (len(children) - 1)\n\t\t\t}\n\t\t}\n\t\tif b != dims.Size.Y {\n\t\t\tbaseline = b\n\t\t}\n\t}\n\tswitch f.Spacing {\n\tcase SpaceSides:\n\t\tmainSize += space / 2\n\tcase SpaceEnd:\n\t\tmainSize += space\n\tcase SpaceEvenly:\n\t\tmainSize += space / (1 + len(children))\n\tcase SpaceAround:\n\t\tmainSize += space / (len(children) * 2)\n\t}\n\tsz := axisPoint(f.Axis, mainSize, crossSize)\n\tif baseline == 0 {\n\t\tbaseline = sz.Y\n\t}\n\treturn Dimens{Size: sz, Baseline: baseline}\n}", "func (b *borderLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {\n\tvar topSize, bottomSize, leftSize, rightSize fyne.Size\n\tif b.top != nil && b.top.Visible() {\n\t\tb.top.Resize(fyne.NewSize(size.Width, b.top.MinSize().Height))\n\t\tb.top.Move(fyne.NewPos(0, 0))\n\t\ttopSize = fyne.NewSize(size.Width, b.top.MinSize().Height+theme.Padding())\n\t}\n\tif b.bottom != nil && b.bottom.Visible() {\n\t\tb.bottom.Resize(fyne.NewSize(size.Width, b.bottom.MinSize().Height))\n\t\tb.bottom.Move(fyne.NewPos(0, size.Height-b.bottom.MinSize().Height))\n\t\tbottomSize = fyne.NewSize(size.Width, b.bottom.MinSize().Height+theme.Padding())\n\t}\n\tif b.left != nil && b.left.Visible() {\n\t\tb.left.Resize(fyne.NewSize(b.left.MinSize().Width, size.Height-topSize.Height-bottomSize.Height))\n\t\tb.left.Move(fyne.NewPos(0, topSize.Height))\n\t\tleftSize = fyne.NewSize(b.left.MinSize().Width+theme.Padding(), size.Height-topSize.Height-bottomSize.Height)\n\t}\n\tif b.right != nil && b.right.Visible() {\n\t\tb.right.Resize(fyne.NewSize(b.right.MinSize().Width, size.Height-topSize.Height-bottomSize.Height))\n\t\tb.right.Move(fyne.NewPos(size.Width-b.right.MinSize().Width, topSize.Height))\n\t\trightSize = fyne.NewSize(b.right.MinSize().Width+theme.Padding(), size.Height-topSize.Height-bottomSize.Height)\n\t}\n\n\tmiddleSize := fyne.NewSize(size.Width-leftSize.Width-rightSize.Width, size.Height-topSize.Height-bottomSize.Height)\n\tmiddlePos := fyne.NewPos(leftSize.Width, topSize.Height)\n\tfor _, child := range objects {\n\t\tif !child.Visible() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif child != b.top && child != b.bottom && child != b.left && child != b.right {\n\t\t\tchild.Resize(middleSize)\n\t\t\tchild.Move(middlePos)\n\t\t}\n\t}\n}", "func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {\n\treturn g.w, g.h\n}", "func (g *NormalGrid) Size() int {\n\treturn g.rows * g.cols\n}", "func (t *Text) Size() image.Point { return t.size }", "func (tv *TextView) RenderSize() mat32.Vec2 {\n\tspc := tv.Sty.BoxSpace()\n\tif tv.Par == nil {\n\t\treturn mat32.Vec2Zero\n\t}\n\tparw := tv.ParentLayout()\n\tif parw == nil {\n\t\tlog.Printf(\"giv.TextView Programmer Error: A TextView MUST be located within a parent Layout object -- instead parent is %v at: %v\\n\", tv.Par.Type(), tv.PathUnique())\n\t\treturn mat32.Vec2Zero\n\t}\n\tparw.SetReRenderAnchor()\n\tpaloc := parw.LayData.AllocSizeOrig\n\tif !paloc.IsNil() {\n\t\t// fmt.Printf(\"paloc: %v, pvp: %v lineonoff: %v\\n\", paloc, parw.VpBBox, tv.LineNoOff)\n\t\ttv.RenderSz = paloc.Sub(parw.ExtraSize).SubScalar(spc * 2)\n\t\ttv.RenderSz.X -= spc // extra space\n\t\t// fmt.Printf(\"alloc rendersz: %v\\n\", tv.RenderSz)\n\t} else {\n\t\tsz := tv.LayData.AllocSizeOrig\n\t\tif sz.IsNil() {\n\t\t\tsz = tv.LayData.SizePrefOrMax()\n\t\t}\n\t\tif !sz.IsNil() {\n\t\t\tsz.SetSubScalar(2 * spc)\n\t\t}\n\t\ttv.RenderSz = sz\n\t\t// fmt.Printf(\"fallback rendersz: %v\\n\", tv.RenderSz)\n\t}\n\ttv.RenderSz.X -= tv.LineNoOff\n\t// fmt.Printf(\"rendersz: %v\\n\", tv.RenderSz)\n\treturn tv.RenderSz\n}", "func (tv *TextView) VisSizes() {\n\tif tv.Sty.Font.Size.Val == 0 { // not yet styled\n\t\ttv.StyleTextView()\n\t}\n\tsty := &tv.Sty\n\tspc := sty.BoxSpace()\n\tsty.Font.OpenFont(&sty.UnContext)\n\ttv.FontHeight = sty.Font.Face.Metrics.Height\n\ttv.LineHeight = tv.FontHeight * sty.Text.EffLineHeight()\n\tsz := tv.VpBBox.Size()\n\tif sz == image.ZP {\n\t\ttv.VisSize.Y = 40\n\t\ttv.VisSize.X = 80\n\t} else {\n\t\ttv.VisSize.Y = int(mat32.Floor(float32(sz.Y) / tv.LineHeight))\n\t\ttv.VisSize.X = int(mat32.Floor(float32(sz.X) / sty.Font.Face.Metrics.Ch))\n\t}\n\ttv.LineNoDigs = ints.MaxInt(1+int(mat32.Log10(float32(tv.NLines))), 3)\n\tif tv.Buf != nil && tv.Buf.Opts.LineNos {\n\t\ttv.SetFlag(int(TextViewHasLineNos))\n\t\ttv.LineNoOff = float32(tv.LineNoDigs+3)*sty.Font.Face.Metrics.Ch + spc // space for icon\n\t} else {\n\t\ttv.ClearFlag(int(TextViewHasLineNos))\n\t\ttv.LineNoOff = 0\n\t}\n\ttv.RenderSize()\n}", "func (mw *MapWidget) Size() fyne.Size {\n\treturn mw.size\n}", "func (b *barRenderer) MinSize() fyne.Size {\n\treturn b.layout.MinSize(b.objects)\n}", "func (w *WindowWidget) Size(width, height float32) *WindowWidget {\n\tw.width, w.height = width, height\n\treturn w\n}", "func (t *Terminal) Resize(s fyne.Size) {\n\tif s.Width == t.Size().Width && s.Height == t.Size().Height {\n\t\treturn\n\t}\n\tif s.Width < 20 { // not sure why we get tiny sizes\n\t\treturn\n\t}\n\tt.BaseWidget.Resize(s)\n\tt.content.Resize(s)\n\n\tcellSize := t.guessCellSize()\n\toldRows := int(t.config.Rows)\n\n\tt.config.Columns = uint(math.Floor(float64(s.Width) / float64(cellSize.Width)))\n\tt.config.Rows = uint(math.Floor(float64(s.Height) / float64(cellSize.Height)))\n\tif t.scrollBottom == 0 || t.scrollBottom == oldRows-1 {\n\t\tt.scrollBottom = int(t.config.Rows) - 1\n\t}\n\tt.onConfigure()\n\n\tgo t.updatePTYSize()\n}", "func (r Rect) Size() Vec {\n\treturn V(r.W(), r.H())\n}", "func checkSize(img image.Image) image.Image {\n\tif img.Bounds().Dx() > IMAGE_MAX_SIZE {\n\t\timg = resize.Resize(IMAGE_MAX_SIZE, 0, img, resize.Bilinear)\n\t}\n\n\tif img.Bounds().Dy() > IMAGE_MAX_SIZE {\n\t\timg = resize.Resize(0, IMAGE_MAX_SIZE, img, resize.Bilinear)\n\t}\n\n\treturn img\n}", "func (mtr *Dppdpp1intspareMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Spare_0.Size()\n\n\tsz += mtr.Spare_1.Size()\n\n\tsz += mtr.Spare_2.Size()\n\n\tsz += mtr.Spare_3.Size()\n\n\tsz += mtr.Spare_4.Size()\n\n\tsz += mtr.Spare_5.Size()\n\n\tsz += mtr.Spare_6.Size()\n\n\tsz += mtr.Spare_7.Size()\n\n\tsz += mtr.Spare_8.Size()\n\n\tsz += mtr.Spare_9.Size()\n\n\tsz += mtr.Spare_10.Size()\n\n\tsz += mtr.Spare_11.Size()\n\n\tsz += mtr.Spare_12.Size()\n\n\tsz += mtr.Spare_13.Size()\n\n\tsz += mtr.Spare_14.Size()\n\n\tsz += mtr.Spare_15.Size()\n\n\tsz += mtr.Spare_16.Size()\n\n\tsz += mtr.Spare_17.Size()\n\n\tsz += mtr.Spare_18.Size()\n\n\tsz += mtr.Spare_19.Size()\n\n\tsz += mtr.Spare_20.Size()\n\n\tsz += mtr.Spare_21.Size()\n\n\tsz += mtr.Spare_22.Size()\n\n\tsz += mtr.Spare_23.Size()\n\n\tsz += mtr.Spare_24.Size()\n\n\tsz += mtr.Spare_25.Size()\n\n\tsz += mtr.Spare_26.Size()\n\n\tsz += mtr.Spare_27.Size()\n\n\tsz += mtr.Spare_28.Size()\n\n\tsz += mtr.Spare_29.Size()\n\n\tsz += mtr.Spare_30.Size()\n\n\tsz += mtr.Spare_31.Size()\n\n\treturn sz\n}", "func (c *Container) Size() (float64, float64) {\n\treturn c.w, c.h\n}", "func (r *Rectangle) Size() Size {\n\treturn Size{W: r.Max.X - r.Min.X, H: r.Max.Y - r.Min.Y}\n}", "func (p *Area) ExtraMarginPixels() (float64, float64, float64, float64) {\n\treturn p.Weight, p.Weight, p.Weight, p.Weight\n}", "func (v *StackPanel) Measure(availableWidth, availableHeight int) (width int, height int) {\n\twidth, height = 0, 0\n\tv.heights = make(map[Element]int)\n\tv.widths = make(map[Element]int)\n\tfor _, child := range v.childs {\n\t\tif v.orientation == Vertical {\n\t\t\tcw, ch := MeasureChild(child, availableWidth, availableHeight-height)\n\t\t\tif cw > width {\n\t\t\t\twidth = cw\n\t\t\t}\n\t\t\theight += ch\n\t\t\tv.heights[child] = ch\n\t\t\tv.widths[child] = cw\n\t\t} else {\n\t\t\tcw, ch := MeasureChild(child, availableWidth-width, availableHeight)\n\t\t\tif ch > height {\n\t\t\t\theight = ch\n\t\t\t}\n\t\t\twidth += cw\n\t\t\tv.heights[child] = ch\n\t\t\tv.widths[child] = cw\n\t\t}\n\t}\n\treturn\n}", "func (b *ElngBox) Size() uint64 {\n\treturn uint64(boxHeaderSize + len(b.Language) + 1)\n}", "func (s *WidgetBase) SizeHint() image.Point {\n\tvar sizeHint image.Point\n\n\tfor _, child := range s.children {\n\t\tsize := child.SizeHint()\n\t\tif s.LayoutMode() == Horizontal {\n\t\t\tsizeHint.X += size.X\n\t\t\tif size.Y > sizeHint.Y {\n\t\t\t\tsizeHint.Y = size.Y\n\t\t\t}\n\t\t} else {\n\t\t\tsizeHint.Y += size.Y\n\t\t\tif size.X > sizeHint.X {\n\t\t\t\tsizeHint.X = size.X\n\t\t\t}\n\t\t}\n\t}\n\n\tif s.Border {\n\t\tsizeHint = sizeHint.Add(image.Point{2, 2})\n\t}\n\n\treturn sizeHint\n}", "func (s Size) ScaleDown(x, y int) Size {\n\ts.W /= x\n\ts.H /= y\n\treturn s\n}", "func (self *scroll) Size() float64 {\n\treturn self.size\n}", "func (b BoundingBox) SizeX() int32 {\n\treturn b.MaxX - b.MinX\n}", "func (cb *CarvedBlock) Sizes() *Meta {\n\tm := &Meta{\n\t\tMapData: len(cb.MapData),\n\t\tCentralDir: len(cb.CentralDir),\n\t\tMapInfo: len(cb.MapInfo),\n\t\tSpecialActions: len(cb.SpecialActions),\n\t\tNPCTable: len(cb.NPCTable),\n\t\tMonsterNames: len(cb.MonsterNames),\n\t\tMonsterData: len(cb.MonsterData),\n\t\tStringsArea: len(cb.StringsArea),\n\t}\n\n\tfor _, at := range cb.ActionTables {\n\t\tm.ActionTables = append(m.ActionTables, len(at))\n\t}\n\n\treturn m\n}", "func (self *Rectangle) Resize(width int, height int) *Rectangle{\n return &Rectangle{self.Object.Call(\"resize\", width, height)}\n}", "func (s *Menu) Layout(outsideWidth, outsideHeight int) (int, int) {\n\n\txCenter := outsideWidth / 2\n\tyPlaces := []int{} // golang gotcha: can't use len(s.widgets) to make an array\n\tslots := len(s.widgets) + 1\n\tfor i := 0; i < slots; i++ {\n\t\tyPlaces = append(yPlaces, (outsideHeight/slots)*i)\n\t}\n\n\tfor i, w := range s.widgets {\n\t\tw.SetPosition(xCenter, yPlaces[i+1])\n\t}\n\n\treturn outsideWidth, outsideHeight\n}", "func (self *Graphics) Width() int{\n return self.Object.Get(\"width\").Int()\n}", "func Dimen(c canvas, xp, yp, sp float64) (x, y, s float64) {\n\tx = (xp / 100) * float64(c.Width)\n\ty = (yp / 100) * float64(c.Height)\n\ts = (sp / 100) * float64(c.Width)\n\treturn\n}", "func (bl *barLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {\n\tbarWidth := 0\n\ticonCount := len(objects)\n\tif !bl.bar.disableTaskbar {\n\t\ticonCount--\n\t\tbarWidth = (iconCount * (bl.bar.iconSize + theme.Padding())) + separatorWidth\n\t} else {\n\t\tbarWidth = iconCount * (bl.bar.iconSize + theme.Padding())\n\t}\n\tif bl.mouseInside {\n\n\t\treturn fyne.NewSize(barWidth, int(float32(bl.bar.iconSize)*bl.bar.iconScale))\n\t}\n\n\treturn fyne.NewSize(barWidth, bl.bar.iconSize)\n}", "func GetItemSpacing() (w, h float32) {\n\tvec2 := imgui.CurrentStyle().ItemSpacing()\n\treturn vec2.X, vec2.Y\n}", "func (it *ImageTxt) SizeX() int {\n\treturn it.sizeX\n}", "func Size(n int) int {\n\treturn int(align(_headerSize + int32(n) + _footerSize))\n}", "func RectSized(pos Vec2, size Size) Rectangle {\n\treturn Rectangle{Min: pos, Max: Vec2{X: pos.X + size.W, Y: pos.Y + size.H}}\n}", "func (d *Device) Size() (w, h int16) {\n\tif d.rotation == drivers.Rotation0 || d.rotation == drivers.Rotation180 {\n\t\treturn d.width, d.height\n\t}\n\treturn d.height, d.width\n}", "func (l *Legofy) getNewSize(baseImage image.Image, brickImg image.Image, size int) (int, int) {\n\tnewImageSize := baseImage.Bounds()\n\tbrickSize := brickImg.Bounds()\n\tscaleX, scaleY := 0, 0\n\tif size != 0 {\n\t\tscaleX, scaleY = size, size\n\t} else {\n\t\tscaleX, scaleY = brickSize.Max.X, brickSize.Max.Y\n\t}\n\n\tif newImageSize.Max.X > scaleX || newImageSize.Max.Y > scaleY {\n\t\tscale := 0.00\n\t\tif newImageSize.Max.X < newImageSize.Max.Y {\n\t\t\tscale = float64(newImageSize.Max.Y) / float64(scaleY)\n\t\t} else {\n\t\t\tscale = float64(newImageSize.Max.X) / float64(scaleX)\n\t\t}\n\n\t\treturn int(math.Floor(float64(newImageSize.Max.X) / float64(scale))), int(math.Floor(float64(newImageSize.Max.Y) / float64(scale)))\n\t}\n\treturn newImageSize.Max.X, newImageSize.Max.Y\n}", "func main() {\n\n\tpdf := lib.NewPDF()\n\tleftMargin := 12.0\n\ttopMargin := 12.0\n\n\tboundWidth := letterWidth - (2 * leftMargin) - 15\n\tboundHeight := letterHeight - (2 * topMargin)\n\n\t// draw outside box\n\tsquare := 24.0 // dimensions of the square\n\tinner := square / 3 // for inner lines\n\n\tnumCol := int(boundWidth / square)\n\tnumRow := int(boundHeight / square)\n\n\t// set a box's left/top margin so they are nicely spaced and don't touch\n\tlMargin := (boundWidth - (square * float64(numCol))) / float64(numCol)\n\ttMargin := (boundHeight - (square * float64(numRow))) / float64(numRow)\n\n\tfmt.Println(\"Each sheet has :\", numRow*numCol, \"squares\")\n\n\tfor page := 0; page < 2; page++ {\n\t\tpdf.AddPage()\n\t\tpdf.SetLeftMargin(leftMargin)\n\t\tpdf.SetTopMargin(topMargin)\n\n\t\tfor row := 0; row < numRow; row++ {\n\t\t\tfor col := 0; col < numCol; col++ {\n\n\t\t\t\tfrow := float64(row)\n\t\t\t\tfcol := float64(col)\n\n\t\t\t\ttop := topMargin + frow*square + tMargin*frow\n\t\t\t\tleft := leftMargin + fcol*square + lMargin*fcol\n\n\t\t\t\tpdf.SetLineWidth(0.1)\n\t\t\t\tpdf.SetDrawColor(150, 150, 150)\n\t\t\t\tpdf.Line(left+inner, top, left+inner, top+square)\n\t\t\t\tpdf.Line(left+(2*inner), top, left+(2*inner), top+square)\n\n\t\t\t\tpdf.Line(left, top+inner, left+square, top+inner)\n\t\t\t\tpdf.Line(left, top+2*inner, left+square, top+2*inner)\n\n\t\t\t\tpdf.SetLineWidth(0.3)\n\t\t\t\tpdf.SetDrawColor(0, 0, 0)\n\n\t\t\t\tpdf.Rect(left, top, square, square, \"\")\n\n\t\t\t\t//\n\t\t\t}\n\t\t}\n\n\t\t// draw top/bottom lines on side of page for kids to write their name\n\t\tpdf.SetDrawColor(0, 0, 0)\n\t\tpdf.Line(letterWidth-leftMargin+4, topMargin, letterWidth-leftMargin+4, letterHeight-topMargin)\n\t\tpdf.Line(letterWidth-leftMargin-10, topMargin, letterWidth-leftMargin-10, letterHeight-topMargin)\n\n\t\t// middle dashed line\n\t\tpdf.SetDrawColor(150, 150, 150)\n\t\tdashLength := 2\n\t\tnumDashes := int(letterHeight-topMargin) / dashLength\n\t\tfmt.Println(numDashes)\n\t\tfor num := 0; num < numDashes; num++ {\n\t\t\tif num%2 != 0 {\n\t\t\t\tcontinue // white space\n\t\t\t}\n\n\t\t\tstart := topMargin + float64(num*dashLength)\n\t\t\tend := start + float64(dashLength)\n\n\t\t\t// guard against drawing too long of a dashed line\n\t\t\tif end > letterHeight-topMargin {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tpdf.Line(letterWidth-leftMargin-3, start, letterWidth-leftMargin-3, end)\n\t\t}\n\t}\n\n\tif err := pdf.OutputFileAndClose(\"chinese-template.pdf\"); err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\n}", "func (p PhotoStrippedSize) construct() PhotoSizeClass { return &p }", "func (r Rect) Resized(anchor, size Vec) Rect {\n\tif r.W()*r.H() == 0 {\n\t\tpanic(fmt.Errorf(\"(%T).Resize: zero area\", r))\n\t}\n\tfraction := Vec{size.X / r.W(), size.Y / r.H()}\n\treturn Rect{\n\t\tMin: anchor.Add(r.Min.Sub(anchor).ScaledXY(fraction)),\n\t\tMax: anchor.Add(r.Max.Sub(anchor).ScaledXY(fraction)),\n\t}\n}", "func termsize(L *lua.LState) int {\n\tw, h, err := term.GetSize(int(os.Stdin.Fd()))\n\tif err != nil {\n\t\tL.RaiseError(err.Error())\n\t\treturn 0\n\t}\n\tdimensions := L.NewTable()\n\tL.SetField(dimensions, \"width\", lua.LNumber(w))\n\tL.SetField(dimensions, \"height\", lua.LNumber(h))\n\n\tL.Push(dimensions)\n\treturn 1\n}", "func TestResizeWH(t *testing.T) {\n\tjp2 := jp2i()\n\tjp2.SetResizeWH(50, 50)\n\ti, err := jp2.DecodeImage()\n\tassert.Equal(err, nil, \"No error decoding jp2\", t)\n\tassert.Equal(0, i.Bounds().Min.X, \"Min.X should be 0\", t)\n\tassert.Equal(0, i.Bounds().Min.Y, \"Min.Y should be 0\", t)\n\tassert.Equal(50, i.Bounds().Max.X, \"Max.X should be 50\", t)\n\tassert.Equal(50, i.Bounds().Max.Y, \"Max.Y should be 50\", t)\n}", "func (mtr *Dppdpp0intspareMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Spare_0.Size()\n\n\tsz += mtr.Spare_1.Size()\n\n\tsz += mtr.Spare_2.Size()\n\n\tsz += mtr.Spare_3.Size()\n\n\tsz += mtr.Spare_4.Size()\n\n\tsz += mtr.Spare_5.Size()\n\n\tsz += mtr.Spare_6.Size()\n\n\tsz += mtr.Spare_7.Size()\n\n\tsz += mtr.Spare_8.Size()\n\n\tsz += mtr.Spare_9.Size()\n\n\tsz += mtr.Spare_10.Size()\n\n\tsz += mtr.Spare_11.Size()\n\n\tsz += mtr.Spare_12.Size()\n\n\tsz += mtr.Spare_13.Size()\n\n\tsz += mtr.Spare_14.Size()\n\n\tsz += mtr.Spare_15.Size()\n\n\tsz += mtr.Spare_16.Size()\n\n\tsz += mtr.Spare_17.Size()\n\n\tsz += mtr.Spare_18.Size()\n\n\tsz += mtr.Spare_19.Size()\n\n\tsz += mtr.Spare_20.Size()\n\n\tsz += mtr.Spare_21.Size()\n\n\tsz += mtr.Spare_22.Size()\n\n\tsz += mtr.Spare_23.Size()\n\n\tsz += mtr.Spare_24.Size()\n\n\tsz += mtr.Spare_25.Size()\n\n\tsz += mtr.Spare_26.Size()\n\n\tsz += mtr.Spare_27.Size()\n\n\tsz += mtr.Spare_28.Size()\n\n\tsz += mtr.Spare_29.Size()\n\n\tsz += mtr.Spare_30.Size()\n\n\tsz += mtr.Spare_31.Size()\n\n\treturn sz\n}", "func (c *Camera) santizeBounds() {\n\t// x and y\n\tif c.x < 0 {\n\t\tc.x = 0\n\t}\n\tif c.y < 0 {\n\t\tc.y = 0\n\t}\n\tif c.x+c.width > c.worldWidth {\n\t\tc.x = c.worldWidth - c.width\n\t}\n\tif c.y+c.height > c.worldHeight {\n\t\tc.y = c.worldHeight - c.height\n\t}\n\n\t// width and height\n\tif c.width < 100 {\n\t\tc.width = 100\n\t}\n\tif c.height < 100 {\n\t\tc.height = 100\n\t}\n\tif c.width > c.worldWidth {\n\t\tc.width = c.worldWidth\n\t}\n\tif c.height > c.worldHeight {\n\t\tc.height = c.worldHeight\n\t}\n}", "func (mtr *Dprdpr1intspareMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.Spare_0.Size()\n\n\tsz += mtr.Spare_1.Size()\n\n\tsz += mtr.Spare_2.Size()\n\n\tsz += mtr.Spare_3.Size()\n\n\tsz += mtr.Spare_4.Size()\n\n\tsz += mtr.Spare_5.Size()\n\n\tsz += mtr.Spare_6.Size()\n\n\tsz += mtr.Spare_7.Size()\n\n\tsz += mtr.Spare_8.Size()\n\n\tsz += mtr.Spare_9.Size()\n\n\tsz += mtr.Spare_10.Size()\n\n\tsz += mtr.Spare_11.Size()\n\n\tsz += mtr.Spare_12.Size()\n\n\tsz += mtr.Spare_13.Size()\n\n\tsz += mtr.Spare_14.Size()\n\n\tsz += mtr.Spare_15.Size()\n\n\tsz += mtr.Spare_16.Size()\n\n\tsz += mtr.Spare_17.Size()\n\n\tsz += mtr.Spare_18.Size()\n\n\tsz += mtr.Spare_19.Size()\n\n\tsz += mtr.Spare_20.Size()\n\n\tsz += mtr.Spare_21.Size()\n\n\tsz += mtr.Spare_22.Size()\n\n\tsz += mtr.Spare_23.Size()\n\n\tsz += mtr.Spare_24.Size()\n\n\tsz += mtr.Spare_25.Size()\n\n\tsz += mtr.Spare_26.Size()\n\n\tsz += mtr.Spare_27.Size()\n\n\tsz += mtr.Spare_28.Size()\n\n\tsz += mtr.Spare_29.Size()\n\n\tsz += mtr.Spare_30.Size()\n\n\tsz += mtr.Spare_31.Size()\n\n\treturn sz\n}", "func (a *api) Size() string { return a.Name(\"Size\") }", "func (c *ContainerContext) Size() string {\n\tif c.FieldsUsed == nil {\n\t\tc.FieldsUsed = map[string]interface{}{}\n\t}\n\tc.FieldsUsed[\"Size\"] = struct{}{}\n\tsrw := units.HumanSizeWithPrecision(float64(c.c.SizeRw), 3)\n\tsv := units.HumanSizeWithPrecision(float64(c.c.SizeRootFs), 3)\n\n\tsf := srw\n\tif c.c.SizeRootFs > 0 {\n\t\tsf = fmt.Sprintf(\"%s (virtual %s)\", srw, sv)\n\t}\n\treturn sf\n}", "func (mtr *MsmsintmiscMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.ElamCapEccUncorrectable.Size()\n\n\tsz += mtr.ElamCapEccCorrectable.Size()\n\n\tsz += mtr.Bl2RamEccUncorrectable.Size()\n\n\tsz += mtr.Bl2RamEccCorrectable.Size()\n\n\treturn sz\n}" ]
[ "0.61356664", "0.5796528", "0.57349265", "0.56754404", "0.56606096", "0.5638224", "0.5629771", "0.56017876", "0.55882335", "0.557032", "0.556939", "0.55675405", "0.55657023", "0.5536792", "0.55328375", "0.5525519", "0.5525519", "0.55015546", "0.54620117", "0.54553914", "0.5443475", "0.5439148", "0.5434323", "0.5420774", "0.54040927", "0.54024893", "0.53993297", "0.53976953", "0.53961784", "0.53903234", "0.5387062", "0.53870386", "0.5374907", "0.5363189", "0.536139", "0.5342495", "0.53418154", "0.53398985", "0.53243905", "0.53200024", "0.5315755", "0.53132486", "0.5309995", "0.5309995", "0.53058064", "0.53058064", "0.5292376", "0.5284645", "0.5284568", "0.52806735", "0.52795196", "0.52544063", "0.5250427", "0.5241748", "0.52349883", "0.5233037", "0.52259004", "0.52249724", "0.52190506", "0.5218868", "0.5204116", "0.5199701", "0.51917666", "0.5187856", "0.51849437", "0.5178702", "0.5176381", "0.51754737", "0.5171754", "0.5171317", "0.5169413", "0.5167154", "0.5155159", "0.5150673", "0.51486194", "0.51455176", "0.51432276", "0.5142235", "0.513128", "0.5128854", "0.5127068", "0.51182485", "0.51181114", "0.51048946", "0.51027906", "0.5095789", "0.50912046", "0.5084354", "0.50816435", "0.5081102", "0.5069281", "0.50687397", "0.50628006", "0.5062612", "0.50488645", "0.5038722", "0.50380796", "0.5035282", "0.50322956", "0.5031857", "0.5007695" ]
0.0
-1
Parse parses the result.
func (r *QueryResult) Parse(targets interface{}) error { byts, _ := json.Marshal(r.Records) return json.Unmarshal(byts, &targets) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (h *HTTPerf) Parse() {\n h.Results = RawParser(h.Raw)\n}", "func (r Results) Parse() telebot.Results {\n\tparsedResults := make(telebot.Results, len(r))\n\n\tfor i, result := range r {\n\t\tparsedResults[i] = &telebot.ArticleResult{\n\t\t\tURL: result.SiteUrl,\n\t\t\tThumbURL: result.CoverImage.Medium,\n\t\t\tTitle: result.Title.UserPreferred,\n\t\t\tText: result.SiteUrl,\n\t\t\tDescription: result.Description,\n\t\t}\n\t\tparsedResults[i].SetResultID(strconv.Itoa(i))\n\t}\n\n\treturn parsedResults\n}", "func Parse(output *bytes.Buffer) (*Result, error) {\n\tbuf := filter(output)\n\n\tset, err := parse.ParseSet(buf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresult := &Result{}\n\n\tfor name, values := range set {\n\t\t(*result)[name] = NewTestResult(values[0])\n\t}\n\n\treturn result, nil\n}", "func (op *OutputParserV1) Parse(result api.ExecResult, req messages.ExecutionRequest, err error) *messages.ExecutionResponse {\n\tresp := &messages.ExecutionResponse{}\n\tresp.Status = \"ok\"\n\tif err != nil {\n\t\tresp.Status = \"error\"\n\t\tresp.StatusMessage = fmt.Sprintf(\"%s\", err)\n\t\treturn resp\n\t}\n\tretained := []string{}\n\tif len(result.Stdout) > 0 {\n\t\tlines := strings.Split(strings.TrimSuffix(string(result.Stdout), \"\\n\"), \"\\n\")\n\t\tfor _, line := range lines {\n\t\t\tmatched := false\n\t\t\tif resp.IsJSON == false {\n\t\t\t\tfor re, cb := range op.matchers {\n\t\t\t\t\tif re.MatchString(line) {\n\t\t\t\t\t\tlines := re.FindStringSubmatch(line)\n\t\t\t\t\t\t// Drop the first match (which is the full\n\t\t\t\t\t\t// string); we're after the submatches. This\n\t\t\t\t\t\t// also implies that all the regexes capture\n\t\t\t\t\t\t// subgroups.\n\t\t\t\t\t\tcb(lines[1:], resp, req)\n\t\t\t\t\t\tmatched = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif matched == false {\n\t\t\t\t\tretained = append(retained, line)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tretained = append(retained, line)\n\t\t\t}\n\t\t}\n\t}\n\tif !result.GetSuccess() {\n\t\tresp.Status = \"error\"\n\t\tresp.StatusMessage = string(result.Stderr)\n\t\treturn resp\n\t}\n\n\tif resp.IsJSON == true {\n\t\tjsonBody := interface{}(nil)\n\t\tremaining := []byte(strings.Join(retained, \"\\n\"))\n\n\t\td := util.NewJSONDecoder(bytes.NewReader(remaining))\n\t\tif err := d.Decode(&jsonBody); err != nil {\n\t\t\tresp.Status = \"error\"\n\t\t\tresp.StatusMessage = \"Command returned invalid JSON.\"\n\t\t} else {\n\t\t\tresp.Body = jsonBody\n\t\t}\n\t} else {\n\t\tif len(retained) > 0 {\n\t\t\tresp.Body = []map[string][]string{\n\t\t\t\tmap[string][]string{\n\t\t\t\t\t\"body\": retained,\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\tif resp.Status == \"ok\" && resp.Aborted == true {\n\t\tresp.Status = \"abort\"\n\t}\n\treturn resp\n}", "func (h *HSTIMParser) ParseResult(msg []byte) (HSTIMResult, error) {\n\tr := HSTIMResult{}\n\n\t// Verify the first character is `R`, which indicates it's a result record\n\t// Probably redundant\n\tif msg[0] != 'R' {\n\t\treturn r, &ParseError{fmt.Sprintf(\"Not a result record\")}\n\t}\n\n\tmsgStr := removeTrailingValues(msg)\n\tsplits := strings.Split(msgStr[2:], \"|\")\n\tif len(splits) != 12 {\n\t\treturn r, &ParseError{fmt.Sprintf(\"Expected 12 fields, got %d\", len(splits))}\n\t}\n\n\tseqNum, err := strconv.Atoi(splits[0])\n\tif err != nil {\n\t\treturn r, err\n\t}\n\tr.SequenceNumber = seqNum\n\tr.AnalyteName = splits[1]\n\tr.TestValue = splits[2]\n\tr.TestUnits = splits[3]\n\tr.ReferenceRange = splits[4]\n\tr.TestFlag = splits[5]\n\tr.TestResultType = splits[7]\n\n\t// Parse the time\n\tt, err := time.Parse(hstimTimeFmt, splits[11])\n\tif err != nil {\n\t\treturn r, &ParseError{fmt.Sprintf(\"Cannot parse `%s` as valid timestamp\", splits[11])}\n\t}\n\tr.Timestamp = t\n\n\treturn r, nil\n}", "func resultParser(response *http.Response, shortURL string) ([]Structure, error) {\r\n\tdoc, err := goquery.NewDocumentFromResponse(response)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tresults := []Structure{}\r\n\t//if statement can change what to scrape depending on website chosen (fill in this case)\r\n\tif shortURL == \"fill\" {\r\n\t\tvar item = doc.Find(\"div.CopyProtected\")\r\n\r\n\t\t//the information we want\r\n\t\tclasses := [4]string{\"div.manga_canon\", \"div.mixed_canon/filler\", \"div.filler\", \"div.anime_canon\"}\r\n\r\n\t\tfor _, search := range classes {\r\n\r\n\t\t\t//searches for information\r\n\t\t\tselection := item.Find(search)\r\n\r\n\t\t\t//saves it as text\r\n\t\t\tepisodes := selection.Find(\"span.Episodes\")\r\n\t\t\tepisodestxt := episodes.Text()\r\n\r\n\t\t\tif episodestxt == \"\" {\r\n\t\t\t\tepisodestxt = \"0\"\r\n\t\t\t}\r\n\t\t\t//saves result in the structure struct\r\n\t\t\t//the %//DEVIDER//% is used for splitting the\r\n\t\t\t//information later\r\n\t\t\tresult := Structure{\r\n\t\t\t\t\"%//DEVIDER//%\",\r\n\t\t\t\tepisodestxt,\r\n\t\t\t}\r\n\t\t\t//append the results together\r\n\t\t\tresults = append(results, result)\r\n\t\t}\r\n\r\n\t}\r\n\treturn results, err\r\n}", "func (g getOutputFilesRequestType) ParseResult(rawString string) []string {\n\treturn splitOrEmpty(rawString, \", \")\n}", "func (r *Response) Parse(includePartialMatch bool, requireNumber bool) []Address {\n\tif r.Status != \"OK\" {\n\t\treturn nil\n\t}\n\n\tresult := make([]Address, 0, len(r.Results))\n\n\tfor _, re := range r.Results {\n\t\tif re.PartialMatch && !includePartialMatch {\n\t\t\tcontinue\n\t\t}\n\n\t\taddr := Address{}\n\n\t\taddr.AddrStr = re.Address\n\t\taddr.PlaceID = re.PlaceId\n\t\taddr.PartialMatch = re.PartialMatch\n\t\taddr.Lat = re.Geometry.Location.Lat\n\t\taddr.Lng = re.Geometry.Location.Lng\n\n\t\tfor _, part := range re.AddressParts {\n\t\t\tfor _, partType := range part.Types {\n\t\t\t\tswitch partType {\n\t\t\t\tcase \"premise\":\n\t\t\t\t\taddr.Premise = part.Name\n\t\t\t\tcase \"street_number\":\n\t\t\t\t\taddr.Number = part.Name\n\t\t\t\tcase \"route\":\n\t\t\t\t\taddr.Street = part.ShortName\n\t\t\t\tcase \"locality\":\n\t\t\t\t\taddr.City = part.Name\n\t\t\t\tcase \"postal_town\":\n\t\t\t\t\taddr.City = part.Name\n\t\t\t\tcase \"country\":\n\t\t\t\t\taddr.Country = part.ShortName\n\t\t\t\tcase \"postal_code\":\n\t\t\t\t\taddr.Postcode = part.Name\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif requireNumber && \"\" == addr.Number && \"\" == addr.Premise {\n\t\t\tcontinue\n\t\t}\n\n\t\tresult = append(result, addr)\n\t}\n\n\treturn result\n}", "func Parse(reader io.Reader) (Result, error) {\n\tabort := make(chan bool, 1)\n\n\tlexer, stream := newLexer(reader, abort)\n\tparser, success, failure := newParser(stream, abort)\n\n\tgo lexer.run()\n\tgo parser.run()\n\n\tselect {\n\tcase result := <-success:\n\t\treturn result, nil\n\tcase err := <-failure:\n\t\treturn Result{}, err\n\t}\n}", "func Parse(input string) (tree *ParseResult, err error) {\n\tprotobufTree, err := parser.ParseToProtobuf(input)\n\tif err != nil {\n\t\treturn\n\t}\n\n\ttree = &ParseResult{}\n\terr = proto.Unmarshal(protobufTree, tree)\n\treturn\n}", "func (p *Parser) Parse(sql string) (*Result, []error, error) {\n\tv := NewVisitor()\n\n\tstmtNodes, warns, err := p.Parser.Parse(sql, constant.EmptyString, constant.EmptyString)\n\tif warns != nil || err != nil {\n\t\treturn nil, warns, err\n\t}\n\n\tfor _, stmtNode := range stmtNodes {\n\t\tstmtNode.Accept(v)\n\t}\n\n\treturn v.Result, nil, nil\n}", "func RawParser(raw string) Results {\n results := Results{}\n results.Command = toS(find(raw, \"^(httperf .*)\"))\n results.MaxConnectBurstLength = toI(find(raw, \"Maximum connect burst length: ([0-9]*?\\\\.?[0-9]+)$\"))\n results.TotalConnections = toI(find(raw, \"^Total: connections ([0-9]*?\\\\.?[0-9]+) \"))\n results.TotalRequests = toI(find(raw, \"^Total: connections .+ requests ([0-9]*?\\\\.?[0-9]+) \"))\n results.TotalReplies = toI(find(raw, \"^Total: connections .+ replies ([0-9]*?\\\\.?[0-9]+) \"))\n results.TotalTestDuration = toF(find(raw, \"^Total: connections .+ test-duration ([0-9]*?\\\\.?[0-9]+) \"))\n results.ConnectionRatePerSec = toF(find(raw, \"^Connection rate: ([0-9]*?\\\\.?[0-9]+) \"))\n results.ConnectionRateMsConn = toF(find(raw, \"^Connection rate: .+ \\\\(([0-9]*?\\\\.?[0-9]+) ms\"))\n results.ConnectionTimeMin = toF(find(raw, \"^Connection time \\\\[ms\\\\]: min ([0-9]*?\\\\.?[0-9]+) \"))\n results.ConnectionTimeAvg = toF(find(raw, \"^Connection time \\\\[ms\\\\]: min .+ avg ([0-9]*?\\\\.?[0-9]+) \"))\n results.ConnectionTimeMax = toF(find(raw, \"^Connection time \\\\[ms\\\\]: min .+ max ([0-9]*?\\\\.?[0-9]+) \"))\n results.ConnectionTimeMedian = toF(find(raw, \"^Connection time \\\\[ms\\\\]: min .+ median ([0-9]*?\\\\.?[0-9]+) \"))\n results.ConnectionTimeStddev = toF(find(raw, \"^Connection time \\\\[ms\\\\]: min .+ stddev ([0-9]*?\\\\.?[0-9]+)$\"))\n results.ConnectionTimeConnect = toF(find(raw, \"^Connection time \\\\[ms\\\\]: connect ([0-9]*?\\\\.?[0-9]+)$\"))\n results.ConnectionLength = toF(find(raw, \"^Connection length \\\\[replies\\\\/conn\\\\]: ([0-9]*?\\\\.?[0-9]+)$\"))\n results.RequestRatePerSec = toF(find(raw, \"^Request rate: ([0-9]*?\\\\.?[0-9]+) req\"))\n results.RequestRateMsRequest = toF(find(raw, \"^Request rate: .+ \\\\(([0-9]*?\\\\.?[0-9]+) ms\"))\n results.RequestSize = toF(find(raw, \"^Request size \\\\[B\\\\]: ([0-9]*?\\\\.?[0-9]+)$\"))\n results.ReplyRateMin = toF(find(raw, \"^Reply rate \\\\[replies\\\\/s\\\\]: min ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyRateAvg = toF(find(raw, \"^Reply rate \\\\[replies\\\\/s\\\\]: min .+ avg ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyRateMax = toF(find(raw, \"^Reply rate \\\\[replies\\\\/s\\\\]: min .+ max ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyRateStddev = toF(find(raw, \"^Reply rate \\\\[replies\\\\/s\\\\]: min .+ stddev ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyRateSamples = toI(find(raw, \"^Reply rate \\\\[replies\\\\/s\\\\]: min .+ \\\\(([0-9]*?\\\\.?[0-9]+) samples\"))\n results.ReplyTimeResponse = toF(find(raw, \"^Reply time \\\\[ms\\\\]: response ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyTimeTransfer = toF(find(raw, \"^Reply time \\\\[ms\\\\]: response .+ transfer ([0-9]*?\\\\.?[0-9]+)$\"))\n results.ReplySizeHeader = toF(find(raw, \"^Reply size \\\\[B\\\\]: header ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplySizeContent = toF(find(raw, \"^Reply size \\\\[B\\\\]: header .+ content ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplySizeFooter = toF(find(raw, \"^Reply size \\\\[B\\\\]: header .+ footer ([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplySizeTotal = toF(find(raw, \"^Reply size \\\\[B\\\\]: header .+ \\\\(total ([0-9]*?\\\\.?[0-9]+)\\\\)\"))\n results.ReplyStatus1xx = toI(find(raw, \"^Reply status: 1xx=([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyStatus2xx = toI(find(raw, \"^Reply status: .+ 2xx=([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyStatus3xx = toI(find(raw, \"^Reply status: .+ 3xx=([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyStatus4xx = toI(find(raw, \"^Reply status: .+ 4xx=([0-9]*?\\\\.?[0-9]+) \"))\n results.ReplyStatus5xx = toI(find(raw, \"^Reply status: .+ 5xx=([0-9]*?\\\\.?[0-9]+)\"))\n results.CPUTimeUserSec = toF(find(raw, \"^CPU time \\\\[s\\\\]: user ([0-9]*?\\\\.?[0-9]+) \"))\n results.CPUTimeUserPct = toF(find(raw, \"^CPU time \\\\[s\\\\]: .+ \\\\(user ([0-9]*?\\\\.?[0-9]+)\\\\% \"))\n results.CPUTimeSystemSec = toF(find(raw, \"^CPU time \\\\[s\\\\]: .+ system ([0-9]*?\\\\.?[0-9]+) \"))\n results.CPUTimeSystemPct = toF(find(raw, \"^CPU time \\\\[s\\\\]: user .+ system .+ system ([0-9]*?\\\\.?[0-9]+)\\\\% \"))\n results.CPUTimeTotalPct = toF(find(raw, \"^CPU time \\\\[s\\\\]: user .+ total ([0-9]*?\\\\.?[0-9]+)\\\\%\"))\n results.NetIoKbSec = toF(find(raw, \"^Net I\\\\/O: ([0-9]*?\\\\.?[0-9]+) KB\"))\n results.NetIoBps = toS(find(raw, \"^Net I\\\\/O: .+ \\\\((.+) bps\\\\)\"))\n results.ErrorsTotal = toI(find(raw, \"^Errors: total ([0-9]*?\\\\.?[0-9]+) \"))\n results.ErrorsClientTimeout = toI(find(raw, \"^Errors: total .+ client-timo ([0-9]*?\\\\.?[0-9]+) \"))\n results.ErrorsSocketTimeout = toI(find(raw, \"^Errors: total .+ socket-timo ([0-9]*?\\\\.?[0-9]+) \"))\n results.ErrorsConnRefused = toI(find(raw, \"^Errors: total .+ connrefused ([0-9]*?\\\\.?[0-9]+) \"))\n results.ErrorsConnReset = toI(find(raw, \"^Errors: total .+ connreset ([0-9]*?\\\\.?[0-9]+)\"))\n results.ErrorsFdUnavail = toI(find(raw, \"^Errors: fd-unavail ([0-9]*?\\\\.?[0-9]+) \"))\n results.ErrorsAddrUnavail = toI(find(raw, \"^Errors: fd-unavail .+ addrunavail ([0-9]*?\\\\.?[0-9]+) \"))\n results.ErrorsFtabFull = toI(find(raw, \"^Errors: fd-unavail .+ ftab-full ([0-9]*?\\\\.?[0-9]+) \"))\n results.ErrorsOther = toI(find(raw, \"^Errors: fd-unavail .+ other ([0-9]*?\\\\.?[0-9]+)\"))\n results.ConnectionTimes = findConnectionTimes(raw)\n results.calculatePercentiles()\n\n return results\n}", "func (g getPythonBinaryRequestType) ParseResult(rawString string) string {\n\treturn rawString\n}", "func (p *Parser) Parse() error {\n\tchunks, err := p.chunks()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tp.data = chunks\n\treturn nil\n}", "func (da *DefaultAdvisor) parseResult(result string) (string, string, error) {\n\tvar (\n\t\tadvice string\n\t\tmessage string\n\t\terrMsg string\n\t)\n\n\tisLogMsg := true\n\tregExp, err := regexp.Compile(logExpression)\n\tif err != nil {\n\t\treturn constant.EmptyString, constant.EmptyString, err\n\t}\n\n\tlines := strings.Split(result, constant.CRLFString)\n\tfor _, line := range lines {\n\t\tif isLogMsg {\n\t\t\tisLogMsg = regExp.Match([]byte(line))\n\t\t}\n\n\t\tif isLogMsg {\n\t\t\tmessage += line + constant.CRLFString\n\t\t\tstringList := strings.Split(line, constant.SpaceString)\n\t\t\tif len(stringList) >= 3 {\n\t\t\t\tlogLevel := string(stringList[2][1])\n\t\t\t\tif logLevel == \"E\" || logLevel == \"F\" {\n\t\t\t\t\terrMsg += line + constant.CRLFString\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\tadvice += line\n\t}\n\n\tif errMsg != constant.EmptyString {\n\t\treturn constant.EmptyString, constant.EmptyString, errors.New(fmt.Sprintf(\"parse result failed. error:\\n%s\", errMsg))\n\t}\n\n\treturn advice, message, nil\n}", "func (_CommitteeManager *CommitteeManagerFilterer) ParseExecResult(log types.Log) (*CommitteeManagerExecResult, error) {\n\tevent := new(CommitteeManagerExecResult)\n\tif err := _CommitteeManager.contract.UnpackLog(event, \"execResult\", log); err != nil {\n\t\treturn nil, err\n\t}\n\treturn event, nil\n}", "func (b *BotParserAbstract) Parse(ua string) *BotMatchResult {\n\tif b.PreMatch(ua) {\n\t\tif b.discardDetails {\n\t\t\treturn EmptyBotMatchResult\n\t\t}\n\t\tfor _, regex := range b.Regexes {\n\t\t\tmatches := regex.MatchUserAgent(ua)\n\t\t\tif len(matches) > 0 {\n\t\t\t\treturn &regex.BotMatchResult\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (h *handler) Parse(host core.Host, method uint8, decoder *scale.Decoder) (core.ParseOutput, error) {\n\treturn core.ParseOutput{}, nil\n}", "func (a Analyzer) Parse(re *syntax.Regexp) *Node {\n\treturn analyze(re, true)\n}", "func (p *Parser) Parse() int {\n\tp.rootNode = nil\n\n\treturn yyParse(p)\n}", "func (p *Person) Parse(contents []byte, url string) (*Result, error) {\n\tperson := extractPerson(contents)\n\tres := Result{}\n\tmatches := guessPersonRe.FindAllSubmatch(contents, -1)\n\tfor _, m := range matches {\n\t\tres.Requests = append(res.Requests, Request{\n\t\t\tUrl: string(m[1]),\n\t\t\tParser: &Person{},\n\t\t})\n\t}\n\tres.Items = append(res.Items, Item{\n\t\tUrl: url,\n\t\tId: extractString([]byte(url), idRe),\n\t\tPayload: person,\n\t})\n\n\treturn &res, nil\n}", "func (d *Decoder) Parse() error {\n\treturn d.Decode()\n}", "func (msg *InformResponse) Parse(doc *string) {\n\t\n\t//TODO\n}", "func (r LastpassResponse) Parse() (logs []LastpassLog) {\n\tfor _, log := range r.Data {\n\t\tlogs = append(logs, log.ToLog())\n\t}\n\treturn\n}", "func (_CommitteeManager *CommitteeManagerSession) ParseExecResult(log types.Log) (*CommitteeManagerExecResult, error) {\n\treturn _CommitteeManager.Contract.ParseExecResult(log)\n}", "func (g getCcInfoType) ParseResult(rawString string) (CcInfo, error) {\n\tconst expectedLen = 10\n\tsplitString := strings.Split(rawString, \"|\")\n\tif len(splitString) != expectedLen {\n\t\treturn CcInfo{}, fmt.Errorf(\"Expected %d items, got %q\", expectedLen, splitString)\n\t}\n\toutputFilesString := splitString[0]\n\tccObjectsString := splitString[1]\n\tccSharedLibrariesString := splitString[2]\n\tccStaticLibrariesString := splitString[3]\n\tincludesString := splitString[4]\n\tsystemIncludesString := splitString[5]\n\theadersString := splitString[6]\n\trootStaticArchivesString := splitString[7]\n\trootDynamicLibrariesString := splitString[8]\n\ttocFile := splitString[9] // NOTE: Will be the empty string if there wasn't\n\n\toutputFiles := splitOrEmpty(outputFilesString, \", \")\n\tccObjects := splitOrEmpty(ccObjectsString, \", \")\n\tccSharedLibraries := splitOrEmpty(ccSharedLibrariesString, \", \")\n\tccStaticLibraries := splitOrEmpty(ccStaticLibrariesString, \", \")\n\tincludes := splitOrEmpty(includesString, \", \")\n\tsystemIncludes := splitOrEmpty(systemIncludesString, \", \")\n\theaders := splitOrEmpty(headersString, \", \")\n\trootStaticArchives := splitOrEmpty(rootStaticArchivesString, \", \")\n\trootDynamicLibraries := splitOrEmpty(rootDynamicLibrariesString, \", \")\n\treturn CcInfo{\n\t\tOutputFiles: outputFiles,\n\t\tCcObjectFiles: ccObjects,\n\t\tCcSharedLibraryFiles: ccSharedLibraries,\n\t\tCcStaticLibraryFiles: ccStaticLibraries,\n\t\tIncludes: includes,\n\t\tSystemIncludes: systemIncludes,\n\t\tHeaders: headers,\n\t\tRootStaticArchives: rootStaticArchives,\n\t\tRootDynamicLibraries: rootDynamicLibraries,\n\t\tTocFile: tocFile,\n\t}, nil\n}", "func (l *LinkHeaderPager) Parse(resp *http.Response) Paging {\n\tpaging := Paging{}\n\theader := resp.Header.Get(\"Link\")\n\tif header != \"\" {\n\t\tlinks := linkheader.Parse(header)\n\n\t\tfor _, link := range links.FilterByRel(\"next\") {\n\t\t\tpaging.Next = link.URL\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn paging\n}", "func (p *LogParser) Parse(address string, b []byte) {\n\t//p.Result = map[string]interface{}{}\n\tp.Raw = b\n\tvar r Parser\n\n\tif format := p.formatByAddress[address]; format != nil {\n\t\tr = format()\n\t} else {\n\t\tr = CreateParser(p.fmt)\n\t}\n\tp.Result, err = r.Parse(b)\n\tif err != nil {\n\t\tp.Result = map[string]interface{}{\n\t\t\t\"priority\": 0,\n\t\t\t\"facility\": 0,\n\t\t\t\"severity\": 0,\n\t\t\t\"version\": NO_VERSION,\n\t\t\t\"timestamp\": time.Now(),\n\t\t\t\"message\": string(b),\n\t\t}\n\t}\n}", "func Parse(pth string) (*ActionsInvocationRecord, []ActionTestPlanRunSummaries, error) {\n\tvar r ActionsInvocationRecord\n\tif err := xcresulttoolGet(pth, \"\", &r); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar summaries []ActionTestPlanRunSummaries\n\tfor _, action := range r.Actions.Values {\n\t\trefID := action.ActionResult.TestsRef.ID.Value\n\t\tvar s ActionTestPlanRunSummaries\n\t\tif err := xcresulttoolGet(pth, refID, &s); err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tsummaries = append(summaries, s)\n\t}\n\treturn &r, summaries, nil\n}", "func (p *Parser) Parse() (err error) {\n\t// for safe method usage\n\tif p == nil {\n\t\treturn errors.New(\"parser not initialized\")\n\t}\n\n\tfs := token.NewFileSet()\n\n\tp.asTree, err = parser.ParseFile(fs, p.filename, nil, 0)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse file error: %w\", err)\n\t}\n\n\t// because we have only one file and use start position\n\tp.file = fs.File(1)\n\n\tast.Walk(p, p.asTree) // syntax errors\n\n\tif len(p.fields) == 0 {\n\t\treturn fmt.Errorf(\"target %q not found in file %q\", p.target, p.filename)\n\t}\n\n\tp.checkConsistency() // consistence errors\n\n\tif len(p.errors) != 0 {\n\t\treturn p.errors\n\t}\n\n\treturn\n}", "func Parse(lexer *Lexer) int {\n\treturn yyParse(lexer)\n}", "func (s *Parser) Parse(pageBody io.Reader) ([]*slovnik.Word, error) {\n\tdoc, err := goquery.NewDocumentFromReader(pageBody)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresultsNode := doc.Find(\"#results\")\n\tresults := []*slovnik.Word{}\n\n\tif class, ok := resultsNode.Attr(\"class\"); ok && class == \"transl\" {\n\t\tw, err := parseOne(resultsNode)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresults = append(results, &w)\n\t} else {\n\t\tr, err := parseMultiple(resultsNode)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresults = r\n\t}\n\n\treturn results, nil\n}", "func (p defaultStdErrParser) parseResults(b []byte) (r DefaultStdErrResults) {\n\t// Split on =\n\tvar k string\n\tfor idx, i := range bytes.Split(b, []byte(\"=\")) {\n\t\t// Split on space\n\t\tvar items = bytes.Split(bytes.TrimSpace(i), []byte(\" \"))\n\n\t\t// Parse key/value\n\t\tif len(items[0]) > 0 && len(k) > 0 {\n\t\t\tv := string(items[0])\n\t\t\tswitch k {\n\t\t\tcase \"bitrate\":\n\t\t\t\t// There may be other suffix, but we only support this one for now\n\t\t\t\tv = strings.TrimSuffix(v, \"kbits/s\")\n\t\t\t\tif p, err := strconv.ParseFloat(v, 64); err == nil {\n\t\t\t\t\tr.Bitrate = astikit.Float64Ptr(p * 1000)\n\t\t\t\t}\n\t\t\tcase \"frame\":\n\t\t\t\tif p, err := strconv.Atoi(v); err == nil {\n\t\t\t\t\tr.Frame = astikit.IntPtr(p)\n\t\t\t\t}\n\t\t\tcase \"fps\":\n\t\t\t\tif p, err := strconv.ParseFloat(v, 64); err == nil {\n\t\t\t\t\tr.FPS = astikit.IntPtr(int(p))\n\t\t\t\t}\n\t\t\tcase \"q\":\n\t\t\t\tif p, err := strconv.ParseFloat(v, 64); err == nil {\n\t\t\t\t\tr.Q = astikit.Float64Ptr(p)\n\t\t\t\t}\n\t\t\tcase \"size\":\n\t\t\t\tif n, err := numberFromString(v); err == nil {\n\t\t\t\t\tr.Size = astikit.IntPtr(int(n.float64()))\n\t\t\t\t}\n\t\t\tcase \"speed\":\n\t\t\t\tif p, err := strconv.ParseFloat(strings.TrimSuffix(v, \"x\"), 64); err == nil {\n\t\t\t\t\tr.Speed = astikit.Float64Ptr(p)\n\t\t\t\t}\n\t\t\tcase \"time\":\n\t\t\t\t// Split on .\n\t\t\t\tvar d time.Duration\n\t\t\t\tps := strings.Split(v, \".\")\n\t\t\t\tif len(ps) > 1 {\n\t\t\t\t\tif p, err := strconv.Atoi(ps[1]); err == nil {\n\t\t\t\t\t\t// For now we make the assumption that milliseconds are in this format \".99\" and not \".999\"\n\t\t\t\t\t\td += time.Duration(p*10) * time.Millisecond\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Split on :\n\t\t\t\tps = strings.Split(ps[0], \":\")\n\t\t\t\tif len(ps) >= 3 {\n\t\t\t\t\tif p, err := strconv.Atoi(ps[0]); err == nil {\n\t\t\t\t\t\td += time.Duration(p) * time.Hour\n\t\t\t\t\t}\n\t\t\t\t\tif p, err := strconv.Atoi(ps[1]); err == nil {\n\t\t\t\t\t\td += time.Duration(p) * time.Minute\n\t\t\t\t\t}\n\t\t\t\t\tif p, err := strconv.Atoi(ps[2]); err == nil {\n\t\t\t\t\t\td += time.Duration(p) * time.Second\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tr.Time = astikit.DurationPtr(d)\n\t\t\t}\n\t\t}\n\n\t\t// Get key\n\t\tif len(items) > 1 && len(items[1]) > 0 {\n\t\t\tk = string(items[1])\n\t\t} else if len(items) == 1 && idx == 0 {\n\t\t\tk = string(items[0])\n\t\t}\n\t}\n\treturn\n}", "func parseResults(byteVal []byte) []NavResults {\n\tvar navResults NavResults\n\tvar navResultsSlice []NavResults\n\n\tvar output FfufOutput\n\tjson.Unmarshal(byteVal, &output)\n\n\tif DEBUGMODE {\n\t\tfmt.Printf(\"[debug] command line: %v\\n\", output.CommandLine)\n\t\tfmt.Printf(\"[debug] target: %v\\n\", output.Config.URL)\n\t\tfmt.Printf(\"[debug] method: %v\\n\", output.Config.Method)\n\t\tfmt.Printf(\"[debug] wordlist: %v\\n\", output.Config.InputProviders[0].Value)\n\t\tfmt.Printf(\"[debug] outputfile: %v\\n\", output.Config.Outputfile)\n\t\tfmt.Printf(\"[debug] time: %v\\n\", output.Time)\n\t\tfmt.Printf(\"[debug] url: %v\\n\", output.Results[0].URL)\n\t}\n\n\tnavResults.URL = output.Config.URL\n\tnavResults.Outputfile = output.Config.Outputfile\n\tnavResults.Wordlist = output.Config.InputProviders[0].Value\n\n\tif len(output.Results) == 0 {\n\t\t// handle storage of metadata for output file with no results\n\t\tnavResultsSlice = append(navResultsSlice, navResults)\n\t} else {\n\t\tfor i := 0; i < len(output.Results); i++ {\n\t\t\tnavResults.Endpoint = output.Results[i].URL\n\t\t\tnavResults.Status = output.Results[i].Status\n\t\t\tnavResults.Length = output.Results[i].Length\n\t\t\tnavResults.Words = output.Results[i].Words\n\t\t\tnavResults.Lines = output.Results[i].Lines\n\n\t\t\tif DEBUGMODE {\n\t\t\t\tfmt.Printf(\"%v [Status: %v, Size: %v, Words: %v, Lines: %v]\\n\", navResults.Endpoint, navResults.Status, navResults.Length, navResults.Words, navResults.Lines)\n\t\t\t}\n\n\t\t\tnavResultsSlice = append(navResultsSlice, navResults)\n\t\t}\n\t}\n\n\treturn navResultsSlice\n}", "func (j *J) Parse(s, name string) error {\n\treturn j.send(s, j.out)\n}", "func (a *API) Parse(t string, id int) (err error) {\n\tswitch t {\n\tcase constant.AnimeType:\n\t\terr = a.parseAnime(id)\n\tcase constant.MangaType:\n\t\terr = a.parseManga(id)\n\tcase constant.CharacterType:\n\t\terr = a.parseCharacter(id)\n\tcase constant.PeopleType:\n\t\terr = a.parsePeople(id)\n\tdefault:\n\t\terr = fmt.Errorf(\"invalid type [%s:%v]\", t, id)\n\t}\n\n\tif err != nil {\n\t\t// Re-queue if error.\n\t\tif errQ := a.enqueue(t, id); errQ != nil {\n\t\t\ta.logger.Error(errQ.Error())\n\t\t}\n\t}\n\n\tif a.es == nil {\n\t\treturn err\n\t}\n\n\tif errEs := a.es.Send(\"mal-db-parse\", queueLog{\n\t\tType: t,\n\t\tID: id,\n\t\tError: err,\n\t\tCreatedAt: time.Now(),\n\t}); errEs != nil {\n\t\ta.logger.Error(errEs.Error())\n\t}\n\n\treturn err\n}", "func (e *Engine) Parse(content []byte) ([]string, error) {\n\treturn e.parser.Parse(content)\n}", "func (m *Metric) Parse(output string) {\n\tmessage := \"\"\n\tparts := strings.SplitN(output, \"|\", 4)\n\ttags := make([]string, 0)\n\tif len(parts) > 2 {\n\t\tmessage = strings.TrimSpace(parts[2])\n\t\ttags = strings.SplitAfter(parts[3], \" \")\n\t}\n\tvalue, _ := strconv.ParseFloat(strings.TrimSpace(parts[1]), 64)\n\tm.Type = strings.TrimSpace(parts[0])\n\tm.Value = value\n\tm.Message = message\n\tm.Tags = tags\n}", "func (trh *taskRestartHandler) Parse(ctx context.Context, r *http.Request) error {\n\tprojCtx := MustHaveProjectContext(ctx)\n\tif projCtx.Task == nil {\n\t\treturn gimlet.ErrorResponse{\n\t\t\tMessage: \"task not found\",\n\t\t\tStatusCode: http.StatusNotFound,\n\t\t}\n\t}\n\tif projCtx.ProjectRef == nil {\n\t\treturn gimlet.ErrorResponse{\n\t\t\tMessage: \"project not found\",\n\t\t\tStatusCode: http.StatusNotFound,\n\t\t}\n\t}\n\ttrh.taskId = projCtx.Task.Id\n\tu := MustHaveUser(ctx)\n\ttrh.username = u.DisplayName()\n\n\tb, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"reading body\")\n\t}\n\tif len(b) > 0 {\n\t\tif err := json.Unmarshal(b, trh); err != nil {\n\t\t\treturn errors.Wrapf(err, \"parsing request's body as JSON for following task ID: '%s'.\", trh.taskId)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (p *DelegatingParser) Parse(output CommandOutput) ([]exporter.PartitionInfo, error) {\n\tvar err error\n\tvar partitions []exporter.PartitionInfo\n\n\tfor _, parser := range p.Parsers {\n\t\tpartitions, err = parser.Parse(output)\n\t\tif err == nil {\n\t\t\treturn partitions, err\n\t\t}\n\t}\n\n\treturn nil, errors.New(\"no parser could parse the output\")\n}", "func NewParsingResult(statusCode StatusCode, noOfDataStatusCodes int32, dataStatusCodes []StatusCode, noOfDataDiagnosticInfos int32, dataDiagnosticInfos []DiagnosticInfo) *_ParsingResult {\n\t_result := &_ParsingResult{\n\t\tStatusCode: statusCode,\n\t\tNoOfDataStatusCodes: noOfDataStatusCodes,\n\t\tDataStatusCodes: dataStatusCodes,\n\t\tNoOfDataDiagnosticInfos: noOfDataDiagnosticInfos,\n\t\tDataDiagnosticInfos: dataDiagnosticInfos,\n\t\t_ExtensionObjectDefinition: NewExtensionObjectDefinition(),\n\t}\n\t_result._ExtensionObjectDefinition._ExtensionObjectDefinitionChildRequirements = _result\n\treturn _result\n}", "func Parser() {\n\tif err = conf.Parse(configLocation); err != nil {\n\t\tlogger.Logger.Panicln(err)\n\t}\n\n\tparseMysql()\n\tparseGrpc()\n\tparseHTTP()\n\tparseVolumeHandle()\n}", "func (page *Page) Parse() (err error) {\n\tif page.doc == nil {\n\t\tif page.doc, err = goquery.NewDocumentFromReader(page.stream); err != nil {\n\t\t\terr = errors.Wrap(err, \"failed to create goquery from Page stream\")\n\t\t\treturn\n\t\t}\n\t\tif err = page.Close(); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (pCmd *Ps) Parse(args []string) error {\n\treturn nil\n}", "func (pCmd *Ps) Parse(args []string) error {\n\treturn nil\n}", "func Parse(s lexer.LexemeStream) (ast ast.AST, errors []error) {\n\tp := parser{stream: s}\n\treturn p.parse()\n}", "func (p *Printer) Parse() error {\n\treturn p.print(p.t.RootNode(), \"\", true, 0)\n}", "func (s *SelectParser) Parse() error {\n\tif s.Stmt.Distinct != \"\" {\n\t\treturn ErrDistinct\n\t}\n\ttname, err := s.parseFrom(s.Stmt.From)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttable, ok := findTableByName(tname)\n\tif !ok {\n\t\treturn ErrNotFoundTable\n\t}\n\ts.table = table\n\n\terr = s.parseCols(s.Stmt.SelectExprs)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif s.Stmt.Where != nil {\n\t\terr = util.PanicHandler(func() {\n\t\t\ts.where = s.parseWhere(s.Stmt.Where)\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif s.Stmt.GroupBy != nil {\n\t\treturn ErrGroupBy\n\t}\n\tif s.Stmt.Having != nil {\n\t\treturn ErrHaving\n\t}\n\tif s.Stmt.OrderBy != nil {\n\t\treturn ErrOrderBy\n\t}\n\tif s.Stmt.Limit != nil {\n\t\terr = util.PanicHandler(func() {\n\t\t\ts.offset, s.rows = s.parseLimit(s.Stmt.Limit)\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func parse(body io.ReadCloser) ([]Result, error) {\n\tdefer body.Close()\n\n\tdoc, err := goquery.NewDocumentFromReader(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresults := []Result{}\n\tfor _, parserMethod := range defaultParserFunctions {\n\t\tresults = parserMethod(doc)\n\t\tif len(results) != 0 {\n\t\t\treturn results, nil\n\t\t}\n\t}\n\n\treturn results, nil\n}", "func (p *parser) parse(cmdOutput string) []string {\n\tp.ips = []string{}\n\tp.scanner = bufio.NewScanner(strings.NewReader(cmdOutput))\n\tfor p.scanner.Scan() {\n\t\tline := p.scanner.Text()\n\t\tline = strings.TrimLeft(line, \" \\t\")\n\t\tp.parseLine(line)\n\t}\n\treturn p.ips\n}", "func (c *icmpCollector) Parse(ostype string, output string) (Icmp, error) {\n\t// if ostype != rpc.IOSXE && ostype != rpc.NXOS && ostype != rpc.IOS {\n\t// \treturn nil, errors.New(\"'show interface' is not implemented for \" + ostype)\n\t// }\n\n\ttargetRegexp := regexp.MustCompile(`^\\s*--- (.*) ping statistics ---.*$`) // target\n\tpacketLossRegexp := regexp.MustCompile(`^\\s*(?:(?:\\d+) packets transmitted, (?:\\d+) received, )?((?:[1-9][\\d]*|0)(?:\\.\\d+)?)% packet loss.*$`) // packet loss rate\n\trttRegexp := regexp.MustCompile(`^\\s*(?:rtt|round-trip)? min/avg/max(?:/mdev)? = ((?:[1-9][\\d]*|0)(?:\\.[\\d]+)?)/((?:[1-9][\\d]*|0)(?:\\.[\\d]+)?)/((?:[1-9][\\d]*|0)(?:\\.[\\d]+)?)(?:/.*)? ms.*$`)\n\n\tcurrent := Icmp{}\n\tlines := strings.Split(output, \"\\n\")\n\tfor _, line := range lines {\n\t\tif matches := targetRegexp.FindStringSubmatch(line); matches != nil {\n\t\t\tcurrent = Icmp{\n\t\t\t\tTarget: matches[1],\n\t\t\t}\n\t\t}\n\t\tif current == (Icmp{}) {\n\t\t\tcontinue\n\t\t}\n\t\tif matches := packetLossRegexp.FindStringSubmatch(line); matches != nil {\n\t\t\tcurrent.PacketLoss = util.Str2float64(matches[1])\n\t\t\tif current.PacketLoss == 100 {\n\t\t\t\tcurrent.PingStatus = \"down\"\n\t\t\t} else {\n\t\t\t\tcurrent.PingStatus = \"up\"\n\t\t\t}\n\t\t}\n\t\tif matches := rttRegexp.FindStringSubmatch(line); matches != nil {\n\t\t\tcurrent.RttMin = util.Str2float64(matches[1])\n\t\t\tcurrent.RttAvg = util.Str2float64(matches[2])\n\t\t\tcurrent.RttMax = util.Str2float64(matches[3])\n\t\t}\n\n\t}\n\treturn current, nil\n}", "func (omad *OutputMessageAccountabilityData) Parse(record string) {\n\tomad.tag = record[:6]\n\tomad.OutputCycleDate = omad.parseStringField(record[6:14])\n\tomad.OutputDestinationID = omad.parseStringField(record[14:22])\n\tomad.OutputSequenceNumber = omad.parseStringField(record[22:28])\n\tomad.OutputDate = omad.parseStringField(record[28:32])\n\tomad.OutputTime = omad.parseStringField(record[32:36])\n\tomad.OutputFRBApplicationIdentification = omad.parseStringField(record[36:40])\n}", "func Parse(stdout []byte) []runtests.TestCaseResult {\n\tlines := bytes.Split(stdout, []byte{'\\n'})\n\tres := []*regexp.Regexp{\n\t\tctsTestPreamblePattern,\n\t\tdartSystemTestPreamblePattern,\n\t\ttrfTestPreamblePattern,\n\t\tgoogleTestPreamblePattern,\n\t\tgoTestPreamblePattern,\n\t\trustTestPreamblePattern,\n\t\tzirconUtestPreamblePattern,\n\t\tparseoutput.TestPreamblePattern,\n\t}\n\tremainingLines, match := firstMatch(lines, res)\n\n\tvar cases []runtests.TestCaseResult\n\tswitch match {\n\tcase ctsTestPreamblePattern:\n\t\tcases = parseVulkanCtsTest(remainingLines)\n\tcase dartSystemTestPreamblePattern:\n\t\tcases = parseDartSystemTest(remainingLines)\n\tcase trfTestPreamblePattern:\n\t\tcases = parseTrfTest(lines)\n\tcase googleTestPreamblePattern:\n\t\tcases = parseGoogleTest(remainingLines)\n\tcase goTestPreamblePattern:\n\t\tcases = parseGoTest(remainingLines)\n\tcase rustTestPreamblePattern:\n\t\tcases = parseRustTest(remainingLines)\n\tcase zirconUtestPreamblePattern:\n\t\tcases = parseZirconUtest(remainingLines)\n\tcase parseoutput.TestPreamblePattern:\n\t\tcases = parseNetworkConformanceTest(remainingLines)\n\t}\n\n\t// Ensure that an empty set of cases is serialized to JSON as an empty\n\t// array, not as null.\n\tif cases == nil {\n\t\tcases = []runtests.TestCaseResult{}\n\t}\n\treturn cases\n}", "func ParseAnalysis(content string) (*AnalysisResult, error) {\n\tdec := json.NewDecoder(strings.NewReader(content))\n\tres := &AnalysisResult{}\n\terr := dec.Decode(res)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}", "func (parser *EarleyParser) Parse(words []string, rootCategory string, rootVariables []string) ([]*mentalese.ParseTreeNode, ParseResult) {\n\n\tchart := parser.buildChart(parser.grammarRules, words, rootCategory, rootVariables)\n\n\trootNodes := ExtractTreeRoots(chart)\n\terror := \"\"\n\terrorArg := \"\"\n\n\tif len(rootNodes) == 0 {\n\n\t\tnextWord := FindUnknownWord(chart)\n\n\t\tif nextWord != \"\" {\n\t\t\terror = common.UnknownWord\n\t\t\terrorArg = nextWord\n\t\t} else if len(words) == 0 {\n\t\t\terror = common.NoSentence\n\t\t\terrorArg = \"\"\n\t\t} else {\n\t\t\terror = common.NoUnderstandSentence\n\t\t\terrorArg = \"\"\n\t\t}\n\t}\n\n\tresult := ParseResult{\n\t\tRootNodes: rootNodes,\n\t\tError: error,\n\t\tErrorArg: errorArg,\n\t}\n\n\treturn rootNodes, result\n}", "func (p *Parser) Parse(r io.Reader) (doc *Document, err error) {\n\tp.doc = NewDocument()\n\tscanner := bufio.NewScanner(r)\n\tfor scanner.Scan() {\n\t\tline := []rune(scanner.Text())\n\t\tregCode := string(line[:2])\n\t\tswitch regCode {\n\t\tcase \"01\":\n\t\t\terr = p.parseInitiatingParty(line)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\t\tcase \"02\":\n\t\t\terr = p.parsePaymentHeader(line)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\t\tcase \"03\":\n\t\t\terr = p.parseDebitTransaction(line)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\t\tcase \"04\":\n\t\t\terr = p.parsePaymentTotals(line)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\t\tcase \"05\":\n\t\t\terr = p.parseCreditorTotals(line)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\t\tcase \"99\":\n\t\t\terr = p.parseTotals(line)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tdoc = p.doc\n\treturn\n}", "func (p *Parser) Parse(ctx context.Context, url string, body io.Reader) (urls []string, errs []error) {\n\tb, err := ioutil.ReadAll(body)\n\tif err != nil {\n\t\treturn nil, []error{err}\n\t}\n\tresult, ok := p.Results[string(b)]\n\tif !ok {\n\t\treturn nil, nil\n\t}\n\tfor _, e := range result.Errs {\n\t\terrs = append(errs, errors.New(e))\n\t}\n\treturn result.Urls, errs\n}", "func Parse(r io.Reader) ([]*bhpb.GoBenchmarkResult, error) {\n\tvar parsed []*parse.Benchmark\n\tscan := bufio.NewScanner(r)\n\tord := 0\n\tfor scan.Scan() {\n\t\tif b, err := parse.ParseLine(scan.Text()); err == nil {\n\t\t\tb.Ord = ord\n\t\t\tord++\n\t\t\tparsed = append(parsed, b)\n\t\t}\n\t}\n\tif err := scan.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\tvar converted []*bhpb.GoBenchmarkResult\n\tfor _, b := range parsed {\n\t\tconverted = append(converted, &bhpb.GoBenchmarkResult{\n\t\t\tPackage: \"\",\n\t\t\tName: b.Name,\n\t\t\tNOp: int64(b.N),\n\t\t\tNsPerOp: b.NsPerOp,\n\t\t\tAllocPerOp: b.AllocsPerOp,\n\t\t\tBytesAllocatedPerOp: b.AllocedBytesPerOp,\n\t\t\tMbPerSecond: b.MBPerS,\n\t\t\tMeasured: int64(b.Measured),\n\t\t\tOrd: uint32(b.Ord),\n\t\t\tDuration: int64(b.NsPerOp * float64(b.N)),\n\t\t\tCpu: 0,\n\t\t})\n\t}\n\terr := Convert(converted, ExtractCPU)\n\treturn converted, err\n}", "func (p *parser) parse() {\n\tp.Root = p.program()\n\tp.expect(TokenEOF)\n\t//if err := t.Root.Check(); err != nil {\n\t//\tt.error(err)\n\t//}\n}", "func (c *Config) Parse() (interface{}, error) {\n\treturn c.Execute()\n}", "func (p *Parser) Parse(input string) (criteria List) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tglog.Errorf(\"%v: %q\\n\", r, input)\n\t\t\tcriteria = NewList()\n\t\t}\n\t}()\n\tp.lexer = NewLexer(input)\n\tp.tokens = make([]*Token, 0)\n\tcriteria = p.parseSegment(tokenEOF)\n\tcriteria.TrimItems()\n\treturn\n}", "func (p *NasaParser) Parse(targetDate string) (string, error) {\n\tresp, err := p.httpClient.Get(fmt.Sprintf(p.apiURL, p.apiKey, targetDate))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t//defer func() {\n\t//\tcloseErr := resp.Body.Close()\n\t//\tif closeErr != nil {\n\t//\t\tp.logger.WithError(closeErr).Warnf(\"body close error\")\n\t//\t}\n\t//}()\n\n\tif resp.StatusCode == 429 {\n\t\treturn \"\", ErrOverRateLimit\n\t}\n\n\tif resp.StatusCode == 400 {\n\t\treturn \"\", ErrWrongDateInterval\n\t}\n\n\tvar picture NasaPicture\n\terr = json.Unmarshal(body, &picture)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn picture.URL, nil\n}", "func (g *Generator) Parse(schema avro.Schema) {\n\t_ = g.generate(schema)\n}", "func (t *TopTermCountTile) Parse(params map[string]interface{}) error {\n\terr := t.Bivariate.Parse(params)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn t.TopTerms.Parse(params)\n}", "func (p *Parser) Parse() *tree.Node {\n\treturn p.expr()\n}", "func (p *Parser) Parse() (ret []structConfig) {\n\tvar (\n\t\tdata []structConfig\n\t)\n\tp.getPackage()\n\tp.parseGoFiles()\n\tfor _, f := range p.parsedFiles {\n\t\tdata = append(data, p.parseTypes(f)...)\n\t}\n\treturn data\n}", "func (p *Parser) Parse(srcPath string, files []models.Path) (*Result, error) {\n\tb, err := p.readFile(srcPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfset := token.NewFileSet()\n\tf, err := p.parseFile(fset, srcPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfs, err := p.parseFiles(fset, f, files)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Result{\n\t\tHeader: &models.Header{\n\t\t\tComments: parseComment(f, f.Package),\n\t\t\tPackage: f.Name.String(),\n\t\t\tImports: parseImports(f.Imports),\n\t\t\tCode: goCode(b, f),\n\t\t},\n\t\tFuncs: p.parseFunctions(fset, f, fs),\n\t}, nil\n}", "func (p *Parser) Parse() {\n\tflag.Parse() // Parse the flags\n}", "func (t *Template) Parse(source interface{}) (*Template, error) {\n\t// TODO\n\treturn &Template{}, nil\n}", "func (p *Parser) Parse() ([]*unstructured.Unstructured, error) {\n\tvar result []*unstructured.Unstructured // nolint:prealloc\n\tfor _, s := range p.Streams {\n\t\tu, err := parseStream(s)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"cannot parse stream\")\n\t\t}\n\t\tresult = append(result, u...)\n\t}\n\tfor _, p := range p.FilePaths {\n\t\tf, err := os.Open(p)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"cannot open file in %s\", p)\n\t\t}\n\t\tu, err := parseStream(f)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"cannot parse file stream\")\n\t\t}\n\t\tresult = append(result, u...)\n\t}\n\treturn result, nil\n}", "func Parse(sql string) (idx int, err error) {\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second)\n\tdefer cancel()\n\tr, err := client.Parse(ctx, &CalciteParserRequest{Query: sql})\n\tif err != nil {\n\t\treturn -1, fmt.Errorf(\"gRPC call error: %v\", err)\n\t}\n\tif r.GetError() != \"\" {\n\t\treturn int(r.GetIndex()), fmt.Errorf(r.GetError())\n\t}\n\treturn int(r.GetIndex()), nil\n}", "func Parse(source StringSource) Parser {\n\treturn Parser{Source: source}\n}", "func parseResult(resultstring []byte) string {\n\tparsed := strings.Split(string(resultstring), \"\\r\")\n\treturn parsed[0]\n}", "func (p *Parser) Parse() *ast.Program {\n\tprg := &ast.Program{}\n\tprg.Statements = []ast.Statement{}\n\n\tfor !p.curToken.IsType(token.EOF) {\n\t\tstmt := p.parseStatement()\n\t\tif stmt != nil {\n\t\t\tprg.Statements = append(prg.Statements, stmt)\n\t\t}\n\t\tp.advance()\n\t}\n\treturn prg\n}", "func (t *Value) Parse(v interface{}) (err error) {\n\t//\tdefer func() {\n\t//\t\tif x := recover(); x != nil {\n\t//\t\t\terr = fmt.Errorf(\"value parse error: %v\", x)\n\t//\t\t\t//fmt.Println(err)\n\t//\t\t}\n\t//\t}()\n\treturn t.parse(valueOf(v))\n}", "func Parse() error {\n\tcfg, err := executor.Parse()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif cfg.General.ExternalUI != \"\" {\n\t\troute.SetUIPath(cfg.General.ExternalUI)\n\t}\n\n\tif cfg.General.ExternalController != \"\" {\n\t\tgo route.Start(cfg.General.ExternalController, cfg.General.Secret)\n\t}\n\n\texecutor.ApplyConfig(cfg, true)\n\treturn nil\n}", "func (reply *Response) Parse(bytes []byte) error {\n\treturn json.Unmarshal(bytes, reply)\n}", "func Parse(src string) (*Query, error) {\n\tvar query Query\n\tif err := parser.ParseString(src, &query); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &query, nil\n}", "func (t *TTFB) ParseResponse(res io.Reader, unique string) (Result, error) {\n\tvar data Result\n\n\tif err := json.NewDecoder(res).Decode(&data); err != nil {\n\t\treturn t.BasicResult(unique), err\n\t}\n\n\tif data.Status == 0 {\n\t\treturn t.BasicResult(unique), errors.New(unique + \":\\x20\" + data.Message)\n\t}\n\n\treturn data, nil\n}", "func Parser() {\n\tif err = conf.Parse(configLocation); err != nil {\n\t\tlogger.Logger.Panicln(err)\n\t}\n\n\tparseMysql()\n\tparseHTTP()\n\tparseIpmi()\n\tparseWOL()\n}", "func (p *parser) Parse() ([]ast.Definition, ast.Term, bool) {\n\t// Create any explicit or implicit definitions.\n\tfor !p.isAtEnd() {\n\t\tswitch p.peek().TType {\n\n\t\t// Explicit let\n\t\tcase lexer.LET:\n\t\t\tp.advance()\n\t\t\tp.definitions = append(p.definitions, p.definition())\n\t\t\tp.consume(lexer.NEWLINE, \"Expect newline after definition.\")\n\n\t\t// Implicity let or final expression\n\t\tdefault:\n\t\t\texpr := p.term()\n\t\t\tdef, ok := expr.(ast.Definition)\n\t\t\tif ok {\n\t\t\t\tp.definitions = append(p.definitions, def)\n\t\t\t\tp.consume(lexer.NEWLINE, \"Expect newline after definition.\")\n\t\t\t} else {\n\t\t\t\tp.expression = expr\n\t\t\t\treturn p.definitions, p.expression, p.errFlag\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return an error if there is no final expression.\n\treturn p.definitions, p.expression, true\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 (s *IndexQuery) Parse(req *http.Request) error {\n\tswitch req.Header.Get(contentType) {\n\tcase mimeJSON:\n\t\tbody, err := ioutil.ReadAll(req.Body)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := json.Unmarshal(body, s); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase mimeForm:\n\t\tif err := req.ParseForm(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor key, val := range req.Form {\n\t\t\tswitch key {\n\t\t\tcase \"jsonp\":\n\t\t\t\ts.JSONP = val[0]\n\t\t\t}\n\t\t}\n\t}\n\n\tparams := req.URL.Query()\n\tif len(params.Get(\"jsonp\")) != 0 {\n\t\ts.JSONP = params.Get(\"jsonp\")\n\t}\n\n\treturn nil\n}", "func (p *testOutputParser) Parse(input *bufio.Scanner) (*api.TestSuites, error) {\n\tsuites := &api.TestSuites{}\n\n\tvar testNameStack []string\n\tvar tests map[string]*api.TestCase\n\tvar output map[string][]string\n\tvar messages map[string][]string\n\tvar currentSuite *api.TestSuite\n\tvar state int\n\tvar count int\n\tvar orderedTests []string\n\n\tfor input.Scan() {\n\t\tline := input.Text()\n\t\tcount++\n\n\t\tlog(\"Line %03d: %d: %s\\n\", count, state, line)\n\n\t\tswitch state {\n\n\t\tcase stateBegin:\n\t\t\t// this is the first state\n\t\t\tname, ok := ExtractRun(line)\n\t\t\tif !ok {\n\t\t\t\t// A test that defines a test.M handler can write output prior to test execution. We will drop this because\n\t\t\t\t// we have no place to put it, although the first test case *could* use it in the future.\n\t\t\t\tlog(\" ignored output outside of suite\\n\")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlog(\" found run command %s\\n\", name)\n\n\t\t\tcurrentSuite = &api.TestSuite{}\n\t\t\ttests = make(map[string]*api.TestCase)\n\t\t\toutput = make(map[string][]string)\n\t\t\tmessages = make(map[string][]string)\n\n\t\t\torderedTests = []string{name}\n\t\t\ttestNameStack = []string{name}\n\t\t\ttests[testNameStack[0]] = &api.TestCase{\n\t\t\t\tName: name,\n\t\t\t}\n\n\t\t\tstate = stateOutput\n\n\t\tcase stateOutput:\n\t\t\t// open a new test for gathering output\n\t\t\tif name, ok := ExtractRun(line); ok {\n\t\t\t\tlog(\" found run command %s\\n\", name)\n\t\t\t\ttest, ok := tests[name]\n\t\t\t\tif !ok {\n\t\t\t\t\ttest = &api.TestCase{\n\t\t\t\t\t\tName: name,\n\t\t\t\t\t}\n\t\t\t\t\ttests[name] = test\n\t\t\t\t}\n\t\t\t\torderedTests = append(orderedTests, name)\n\t\t\t\ttestNameStack = []string{name}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// transition to result mode ONLY if it matches a result at the top level\n\t\t\tif result, name, depth, duration, ok := ExtractResult(line); ok && tests[name] != nil && depth == 0 {\n\t\t\t\ttest := tests[name]\n\t\t\t\tlog(\" found result %s %s %s\\n\", result, name, duration)\n\t\t\t\tswitch result {\n\t\t\t\tcase api.TestResultPass:\n\t\t\t\tcase api.TestResultFail:\n\t\t\t\t\ttest.FailureOutput = &api.FailureOutput{}\n\t\t\t\tcase api.TestResultSkip:\n\t\t\t\t\ttest.SkipMessage = &api.SkipMessage{}\n\t\t\t\t}\n\t\t\t\tif err := test.SetDuration(duration); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unexpected duration on line %d: %s\", count, duration)\n\t\t\t\t}\n\t\t\t\ttestNameStack = []string{name}\n\t\t\t\tstate = stateResults\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// in output mode, turn output lines into output on the particular test\n\t\t\tif _, _, ok := ExtractOutput(line); ok {\n\t\t\t\tlog(\" found output\\n\")\n\t\t\t\toutput[testNameStack[0]] = append(output[testNameStack[0]], line)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlog(\" fallthrough\\n\")\n\n\t\tcase stateResults:\n\t\t\toutput, depth, ok := ExtractOutput(line)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected output on line %d, can't grab results\", count)\n\t\t\t}\n\n\t\t\t// we're back to the root, we expect either a new RUN, a test suite end, or this is just an\n\t\t\t// output line that was chopped up\n\t\t\tif depth == 0 {\n\t\t\t\tif name, ok := ExtractRun(line); ok {\n\t\t\t\t\tlog(\" found run %s\\n\", name)\n\t\t\t\t\t// starting a new set of runs\n\t\t\t\t\torderedTests = append(orderedTests, name)\n\t\t\t\t\ttestNameStack = []string{name}\n\t\t\t\t\ttests[testNameStack[0]] = &api.TestCase{\n\t\t\t\t\t\tName: name,\n\t\t\t\t\t}\n\t\t\t\t\tstate = stateOutput\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch {\n\t\t\t\tcase line == \"PASS\", line == \"FAIL\":\n\t\t\t\t\tlog(\" found end of suite\\n\")\n\t\t\t\t\t// at the end of the suite\n\t\t\t\t\tstate = stateComplete\n\t\t\t\tdefault:\n\t\t\t\t\t// a broken output line that was not indented\n\t\t\t\t\tlog(\" found message\\n\")\n\t\t\t\t\tname := testNameStack[len(testNameStack)-1]\n\t\t\t\t\ttest := tests[name]\n\t\t\t\t\tswitch {\n\t\t\t\t\tcase test.FailureOutput != nil, test.SkipMessage != nil:\n\t\t\t\t\t\tmessages[name] = append(messages[name], output)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// if this is a result AND we have already declared this as a test, parse it\n\t\t\tif result, name, _, duration, ok := ExtractResult(output); ok && tests[name] != nil {\n\t\t\t\tlog(\" found result %s %s (%d)\\n\", result, name, depth)\n\t\t\t\ttest := tests[name]\n\t\t\t\tswitch result {\n\t\t\t\tcase api.TestResultPass:\n\t\t\t\tcase api.TestResultFail:\n\t\t\t\t\ttest.FailureOutput = &api.FailureOutput{}\n\t\t\t\tcase api.TestResultSkip:\n\t\t\t\t\ttest.SkipMessage = &api.SkipMessage{}\n\t\t\t\t}\n\t\t\t\tif err := test.SetDuration(duration); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unexpected duration on line %d: %s\", count, duration)\n\t\t\t\t}\n\t\t\t\tswitch {\n\t\t\t\tcase depth >= len(testNameStack):\n\t\t\t\t\t// we found a new, more deeply nested test\n\t\t\t\t\ttestNameStack = append(testNameStack, name)\n\t\t\t\tdefault:\n\t\t\t\t\tif depth < len(testNameStack)-1 {\n\t\t\t\t\t\t// the current result is less indented than our current test, so remove the deepest\n\t\t\t\t\t\t// items from the stack\n\t\t\t\t\t\ttestNameStack = testNameStack[:depth]\n\t\t\t\t\t}\n\t\t\t\t\ttestNameStack[len(testNameStack)-1] = name\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// treat as regular output at the appropriate depth\n\t\t\tlog(\" found message line %d %v\\n\", depth, testNameStack)\n\t\t\t// BUG: in go test, double nested output is double indented for some reason\n\t\t\tif depth >= len(testNameStack) {\n\t\t\t\tdepth = len(testNameStack) - 1\n\t\t\t}\n\t\t\tname := testNameStack[depth]\n\t\t\tlog(\" name %s\\n\", name)\n\t\t\tif test, ok := tests[name]; ok {\n\t\t\t\tswitch {\n\t\t\t\tcase test.FailureOutput != nil, test.SkipMessage != nil:\n\t\t\t\t\tmessages[name] = append(messages[name], output)\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase stateComplete:\n\t\t\t// suite exit line\n\t\t\tif name, duration, coverage, ok := ExtractPackage(line); ok {\n\t\t\t\tcurrentSuite.Name = name\n\t\t\t\tif props, ok := ExtractProperties(coverage); ok {\n\t\t\t\t\tfor k, v := range props {\n\t\t\t\t\t\tcurrentSuite.AddProperty(k, v)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor _, name := range orderedTests {\n\t\t\t\t\ttest := tests[name]\n\t\t\t\t\tmessageLines := messages[name]\n\t\t\t\t\tvar extraOutput []string\n\t\t\t\t\tfor i, s := range messageLines {\n\t\t\t\t\t\tif s == \"=== OUTPUT\" {\n\t\t\t\t\t\t\tlog(\"test %s has OUTPUT section, %d %d\\n\", name, i, len(messageLines))\n\t\t\t\t\t\t\tif i < len(messageLines) {\n\t\t\t\t\t\t\t\tlog(\" test %s add lines: %d\\n\", name, len(messageLines[i+1:]))\n\t\t\t\t\t\t\t\textraOutput = messageLines[i+1:]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmessageLines = messageLines[:i]\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch {\n\t\t\t\t\tcase test.FailureOutput != nil:\n\t\t\t\t\t\ttest.FailureOutput.Output = strings.Join(messageLines, \"\\n\")\n\n\t\t\t\t\t\tlines := append(output[name], extraOutput...)\n\t\t\t\t\t\ttest.SystemOut = strings.Join(lines, \"\\n\")\n\n\t\t\t\t\tcase test.SkipMessage != nil:\n\t\t\t\t\t\ttest.SkipMessage.Message = strings.Join(messageLines, \"\\n\")\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tlines := append(output[name], extraOutput...)\n\t\t\t\t\t\ttest.SystemOut = strings.Join(lines, \"\\n\")\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentSuite.AddTestCase(test)\n\t\t\t\t}\n\t\t\t\tif err := currentSuite.SetDuration(duration); err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unexpected duration on line %d: %s\", count, duration)\n\t\t\t\t}\n\t\t\t\tsuites.Suites = append(suites.Suites, currentSuite)\n\n\t\t\t\tstate = stateBegin\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// coverage only line\n\t\t\tif props, ok := ExtractProperties(line); ok {\n\t\t\t\tfor k, v := range props {\n\t\t\t\t\tcurrentSuite.AddProperty(k, v)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn suites, nil\n}", "func (b *Block) Parse() error {\n\tstartPos := uint64(0)\n\tb.subelements = []*Block{}\n\tfor startPos < uint64(len(b.value)) {\n\t\tblock, blockLen, err := DecodeBlock(b.value[startPos:])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb.subelements = append(b.subelements, block)\n\t\tstartPos += blockLen\n\t}\n\treturn nil\n}", "func (p *Parser) Parse(msg string) (err error) {\n\n\tif list := re.Operation.FindStringSubmatch(msg); list != nil {\n\t\terr = p.handleOperation(list[1:])\n\t} else if list := re.Begin.FindStringSubmatch(msg); list != nil {\n\t\terr = p.handleBegin(list[1:])\n\t} else if list := re.Commit.FindStringSubmatch(msg); list != nil {\n\t\terr = p.handleCommit(list[1:])\n\t} else {\n\t\terr = errors.Wrapf(ErrInvalidMessage, \"message: %s\", msg)\n\t}\n\n\treturn errors.WithStack(err)\n}", "func Parse(pageSizeRaw, currentPageRaw int) *Pagination {\n\tpageSize := int(math.Min(float64(pageSizeRaw), float64(maxPageSize)))\n\tif pageSize <= 0 {\n\t\tpageSize = defaultPageSize\n\t}\n\n\tcurrentPage := int(math.Max(1, float64(currentPageRaw)))\n\treturn &Pagination{\n\t\tPageSize: pageSize,\n\t\tLimit: pageSize,\n\t\tCurrentPage: currentPage,\n\t\tOffset: (currentPage - 1) * pageSize,\n\t}\n}", "func Parse(data interface{}) error {\n\treturn ParseWithExternal(data, &emptyExt{})\n}", "func (p *Parser) Parse() *ast.Program {\n\tprg := ast.Program{}\n\n\tfor p.current.Typ != token.EOF {\n\t\tst := p.parseStatement()\n\n\t\tif st != nil {\n\t\t\tprg.StNodes = append(prg.StNodes, st)\n\t\t} else {\n\t\t\tlog.Println(\"error: got nil statement during parsing\")\n\t\t}\n\t}\n\n\tp.printErrorsIfAny()\n\n\treturn &prg\n}", "func Parse(r io.Reader) (Type, error) {\n\tl := NewLexer(r)\n\tsesstypeParse(l)\n\tselect {\n\tcase err := <-l.Errors:\n\t\treturn nil, err\n\tdefault:\n\t\treturn local, nil\n\t}\n}", "func (p *parser) Parse(text string) (err error) {\n\tdefer p.recover(&err)\n\tp.lex = lex(text)\n\tp.Text = text\n\tp.parse()\n\tp.stopParse()\n\treturn nil\n}", "func TestParser(t *testing.T) {\n\n\ttype testPair struct {\n\t\tinput string\n\t\ttext string\n\t\terror error\n\t}\n\n\tvar tests = []testPair{\n\t\t{\"test/test.html\", `<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"><html lang=\"en\"><head><title>AWR Report for DB: ZP, Inst: k10szp_1, Snaps: 111755-111758</title> <style type=\"text/css\"> body.awr {font:bold 10pt Arial,Helvetica,Geneva,sans-serif;color:black; background:White;} pre.awr {font:8pt Courier;color:black; background:White;} .hidden {position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden;} .pad {margin-left:17px;} .doublepad {margin-left:34px;} </style></head><body class=\"awr\"><h1 class=\"awr\"> WORKLOAD REPOSITORY report for</h1><p /><table border=\"0\" width=\"600\" class=\"tdiff\" summary=\"This table displays database instance information\"> <tr><th class=\"awrbg\" scope=\"col\">DB Name</th><th class=\"awrbg\" scope=\"col\">DB Id</th><th class=\"awrbg\" scope=\"col\">Instance</th><th class=\"awrbg\" scope=\"col\">Inst num</th><th class=\"awrbg\" scope=\"col\">Startup Time</th><th class=\"awrbg\" scope=\"col\">Release</th><th class=\"awrbg\" scope=\"col\">RAC</th></tr> <tr><td scope=\"row\" class='awrnc'>ZP</td><td align=\"right\" class='awrnc'>2966226569</td><td class='awrnc'>sdf_test1</td><td align=\"right\" class='awrnc'>1</td><td class='awrnc'>08-Ноя-17 16:11</td><td class='awrnc'>12.1.0.2.0</td><td class='awrnc'>NO</td></tr></table><p /><p /><table border=\"0\" width=\"600\" class=\"tdiff\" summary=\"This table displays host information\"> <tr><th class=\"awrbg\" scope=\"col\">Host Name</th><th class=\"awrbg\" scope=\"col\">Platform</th><th class=\"awrbg\" scope=\"col\">CPUs</th><th class=\"awrbg\" scope=\"col\">Cores</th><th class=\"awrbg\" scope=\"col\">Sockets</th><th class=\"awrbg\" scope=\"col\">Memory (GB)</th></tr> <tr><td scope=\"row\" class='awrnc'>sdfeede</td><td class='awrnc'>Solaris[tm] OE (32-bit)</td><td align=\"right\" class='awrnc'> 256</td><td align=\"right\" class='awrnc'> 32</td><td align=\"right\" class='awrnc'> 1</td><td align=\"right\" class='awrnc'> 478.50</td></tr></table><p /><table border=\"0\" width=\"600\" class=\"tdiff\" summary=\"This table displays snapshot information\"> <tr><th class=\"awrnobg\" scope=\"col\"></th><th class=\"awrbg\" scope=\"col\">Snap Id</th><th class=\"awrbg\" scope=\"col\">Snap Time</th><th class=\"awrbg\" scope=\"col\">Sessions</th><th class=\"awrbg\" scope=\"col\">Cursors/Session</th></tr> <tr><td scope=\"row\" class='awrnc'>Begin Snap:</td><td align=\"right\" class='awrnc'>111755</td><td align=\"center\" class='awrnc'>10-Дек-17 13:30:55</td><td align=\"right\" class='awrnc'>951</td><td align=\"right\" class='awrnc'> 12.0</td></tr> <tr><td scope=\"row\" class='awrc'>End Snap:</td><td align=\"right\" class='awrc'>111758</td><td align=\"center\" class='awrc'>10-Дек-17 14:00:00</td><td align=\"right\" class='awrc'>1130</td><td align=\"right\" class='awrc'> 13.0</td></tr> <tr><td scope=\"row\" class='awrnc'>Elapsed:</td><td class='awrnc'>&#160;</td><td align=\"center\" class='awrnc'> 29.09 (mins)</td><td class='awrnc'>&#160;</td><td class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>DB Time:</td><td class='awrc'>&#160;</td><td align=\"center\" class='awrc'> 204.95 (mins)</td><td class='awrc'>&#160;</td><td class='awrc'>&#160;</td></tr></table><p /><h3 class=\"awr\"><a class=\"awr\" name=\"99999\"></a>Report Summary</h3><p />Top ADDM Findings by Average Active Sessions<p /><ul></ul><table border=\"0\" width=\"600\" class=\"tdiff\" summary=\"This table displays top ADDM findings by average active sessions\"><tr><th class=\"awrbg\" scope=\"col\">Finding Name</th><th class=\"awrbg\" scope=\"col\">Avg active sessions of the task</th><th class=\"awrbg\" scope=\"col\">Percent active sessions of finding</th><th class=\"awrbg\" scope=\"col\">Task Name</th><th class=\"awrbg\" scope=\"col\">Begin Snap Time</th><th class=\"awrbg\" scope=\"col\">End Snap Time</th></tr> <tr><td class='awrc'>Фиксации и откаты</td><td align=\"right\" class='awrc'>8.08</td><td align=\"right\" class='awrc'>50.71</td><td scope=\"row\" class='awrc'>ADDM:2926569_1_111758</td><td class='awrc'>10-Дек-17 13:50</td><td class='awrc'>10-Дек-17 14:00</td></tr> <tr><td class='awrnc'>Фиксации и откаты</td><td align=\"right\" class='awrnc'>7.07</td><td align=\"right\" class='awrnc'>57.14</td><td scope=\"row\" class='awrnc'>ADDM:2926569_1_111758</td><td class='awrnc'>10-Дек-17 13:40</td><td class='awrnc'>10-Дек-17 13:50</td></tr> <tr><td class='awrc'>Фиксации и откаты</td><td align=\"right\" class='awrc'>6.09</td><td align=\"right\" class='awrc'>48.90</td><td scope=\"row\" class='awrc'>ADDM:2926569_1_111758</td><td class='awrc'>10-Дек-17 13:30</td><td class='awrc'>10-Дек-17 13:40</td></tr> <tr><td class='awrnc'>Наиболее часто используемые операторы SQL</td><td align=\"right\" class='awrnc'>8.08</td><td align=\"right\" class='awrnc'>31.41</td><td scope=\"row\" class='awrnc'>ADDM:2966226569_1_111758</td><td class='awrnc'>10-Дек-17 13:50</td><td class='awrnc'>10-Дек-17 14:00</td></tr> <tr><td class='awrc'>Наиболее часто используемые операторы SQL</td><td align=\"right\" class='awrc'>7.07</td><td align=\"right\" class='awrc'>25.59</td><td scope=\"row\" class='awrc'>ADDM:2966226569_1_111757</td><td class='awrc'>10-Дек-17 13:40</td><td class='awrc'>10-Дек-17 13:50</td></tr></table><p /><p />Load Profile<p /><table border=\"0\" width=\"600\" class=\"tdiff\" summary=\"This table displays load profile\"> <tr><th class=\"awrnobg\" scope=\"col\"></th><th class=\"awrbg\" scope=\"col\">Per Second</th><th class=\"awrbg\" scope=\"col\">Per Transaction</th><th class=\"awrbg\" scope=\"col\">Per Exec</th><th class=\"awrbg\" scope=\"col\">Per Call</th></tr> <tr><td scope=\"row\" class='awrc'>DB Time(s):</td><td align=\"right\" class='awrc'> 7.1</td><td align=\"right\" class='awrc'> 0.0</td><td align=\"right\" class='awrc'> 0.00</td><td align=\"right\" class='awrc'> 0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>DB CPU(s):</td><td align=\"right\" class='awrnc'> 2.8</td><td align=\"right\" class='awrnc'> 0.0</td><td align=\"right\" class='awrnc'> 0.00</td><td align=\"right\" class='awrnc'> 0.00</td></tr> <tr><td scope=\"row\" class='awrc'>Background CPU(s):</td><td align=\"right\" class='awrc'> 0.4</td><td align=\"right\" class='awrc'> 0.0</td><td align=\"right\" class='awrc'> 0.00</td><td align=\"right\" class='awrc'> 0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>Redo size (bytes):</td><td align=\"right\" class='awrnc'> 5,048,931.5</td><td align=\"right\" class='awrnc'> 8,538.4</td><td class='awrnc'>&#160;</td><td class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>L</tr></table></p><h3 class=\"awr\">Background Wait Events</h3><ul> <li class=\"awr\"> ordered by wait time desc, waits desc (idle events last) </li> <li class=\"awr\"> Only events with Total Wait Time (s) &gt;= .001 are shown </li> <li class=\"awr\"> %Timeouts: value of 0 indicates value was &lt; .5%. Value of null is truly 0</li></ul><table border=\"0\" class=\"tdiff\" summary=\"This table displays background wait events statistics\"><tr><th class=\"awrbg\" scope=\"col\">Event</th><th class=\"awrbg\" scope=\"col\">Waits</th><th class=\"awrbg\" scope=\"col\">%Time -outs</th><th class=\"awrbg\" scope=\"col\">Total Wait Time (s)</th><th class=\"awrbg\" scope=\"col\">Avg wait (ms)</th><th class=\"awrbg\" scope=\"col\">Waits /txn</th><th class=\"awrbg\" scope=\"col\">% bg time</th></tr> <tr><td scope=\"row\" class='awrc'>log file parallel write</td><td align=\"right\" class='awrc'>1,085,250</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>482</td><td align=\"right\" class='awrc'>0.44</td><td align=\"right\" class='awrc'>1.05</td><td align=\"right\" class='awrc'>39.78</td></tr> <tr><td scope=\"row\" class='awrnc'>target log write size</td><td align=\"right\" class='awrnc'>498,563</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>164</td><td align=\"right\" class='awrnc'>0.33</td><td align=\"right\" class='awrnc'>0.48</td><td align=\"right\" class='awrnc'>13.53</td></tr> <tr><td scope=\"row\" class='awrc'>LGWR worker group ordering</td><td align=\"right\" class='awrc'>202</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>88</td><td align=\"right\" class='awrc'>437.54</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>7.29</td></tr> <tr><td scope=\"row\" class='awrnc'>LGWR any worker group</td><td align=\"right\" class='awrnc'>199</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>86</td><td align=\"right\" class='awrnc'>432.82</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>7.11</td></tr> <tr><td scope=\"row\" class='awrc'>db file parallel write</td><td align=\"right\" class='awrc'>617,149</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>82</td><td align=\"right\" class='awrc'>0.13</td><td align=\"right\" class='awrc'>0.60</td><td align=\"right\" class='awrc'>6.80</td></tr> <tr><td scope=\"row\" class='awrnc'>oracle thread bootstrap</td><td align=\"right\" class='awrnc'>103</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>4</td><td align=\"right\" class='awrnc'>40.41</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.34</td></tr> <tr><td scope=\"row\" class='awrc'>control file sequential read</td><td align=\"right\" class='awrc'>5,960</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>2</td><td align=\"right\" class='awrc'>0.28</td><td align=\"right\" class='awrc'>0.01</td><td align=\"right\" class='awrc'>0.14</td></tr> <tr><td scope=\"row\" class='awrnc'>cell single block physical read</td><td align=\"right\" class='awrnc'>1,188</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>1</td><td align=\"right\" class='awrnc'>1.05</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.10</td></tr> <tr><td scope=\"row\" class='awrc'>os thread creation</td><td align=\"right\" class='awrc'>103</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>1</td><td align=\"right\" class='awrc'>9.57</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.08</td></tr> <tr><td scope=\"row\" class='awrnc'>control file parallel write</td><td align=\"right\" class='awrnc'>1,043</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>1</td><td align=\"right\" class='awrnc'>0.57</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.05</td></tr> <tr><td scope=\"row\" class='awrc'>Disk file Mirror Read</td><td align=\"right\" class='awrc'>1,283</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>1</td><td align=\"right\" class='awrc'>0.44</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.05</td></tr> <tr><td scope=\"row\" class='awrnc'>reliable message</td><td align=\"right\" class='awrnc'>2,330</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.13</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.02</td></tr> <tr><td scope=\"row\" class='awrc'>ASM file metadata operation</td><td align=\"right\" class='awrc'>541</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.53</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.02</td></tr> <tr><td scope=\"row\" class='awrnc'>CGS wait for IPC msg</td><td align=\"right\" class='awrnc'>16,988</td><td align=\"right\" class='awrnc'>100</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.01</td><td align=\"right\" class='awrnc'>0.02</td><td align=\"right\" class='awrnc'>0.02</td></tr> <tr><td scope=\"row\" class='awrc'>db file async I/O submit</td><td align=\"right\" class='awrc'>528,782</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.51</td><td align=\"right\" class='awrc'>0.02</td></tr> <tr><td scope=\"row\" class='awrnc'>log file sync</td><td align=\"right\" class='awrnc'>8</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>18.77</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.01</td></tr> <tr><td scope=\"row\" class='awrc'>latch free</td><td align=\"right\" class='awrc'>207</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.62</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.01</td></tr> <tr><td scope=\"row\" class='awrnc'>log file sequential read</td><td align=\"right\" class='awrnc'>24</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>5.17</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.01</td></tr> <tr><td scope=\"row\" class='awrc'>cell statistics gather</td><td align=\"right\" class='awrc'>288</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.41</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.01</td></tr> <tr><td scope=\"row\" class='awrnc'>LGWR wait for redo copy</td><td align=\"right\" class='awrnc'>1,941</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.04</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.01</td></tr> <tr><td scope=\"row\" class='awrc'>undo segment extension</td><td align=\"right\" class='awrc'>7</td><td align=\"right\" class='awrc'>86</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>5.74</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>CSS operation: data update</td><td align=\"right\" class='awrnc'>54</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.70</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td></tr> <tr><td scope=\"row\" class='awrc'>CSS operation: data query</td><td align=\"right\" class='awrc'>54</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.46</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>CSS operation: action</td><td align=\"right\" class='awrnc'>70</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.34</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td></tr> <tr><td scope=\"row\" class='awrc'>CSS initialization</td><td align=\"right\" class='awrc'>6</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>3.05</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>log file single write</td><td align=\"right\" class='awrnc'>24</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.28</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td></tr> <tr><td scope=\"row\" class='awrc'>buffer busy waits</td><td align=\"right\" class='awrc'>251</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.03</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>KSV master wait</td><td align=\"right\" class='awrnc'>107</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.04</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td></tr> <tr><td scope=\"row\" class='awrc'>direct path write</td><td align=\"right\" class='awrc'>11</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.39</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>db file single write</td><td align=\"right\" class='awrnc'>12</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.35</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td></tr> <tr><td scope=\"row\" class='awrc'>cell multiblock physical read</td><td align=\"right\" class='awrc'>1</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>4.23</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>direct path read</td><td align=\"right\" class='awrnc'>1</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>3.65</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td></tr> <tr><td scope=\"row\" class='awrc'>CSS operation: query</td><td align=\"right\" class='awrc'>18</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>0.16</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>0.00</td></tr> <tr><td scope=\"row\" class='awrnc'>Disk file operations I/O</td><td align=\"right\" class='awrnc'>525</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>0.00</td></tr> <tr><td scope=\"row\" class='awrc'>rdbms ipc message</td><td align=\"right\" class='awrc'>1,463,811</td><td align=\"right\" class='awrc'>2</td><td align=\"right\" class='awrc'>37,964</td><td align=\"right\" class='awrc'>25.94</td><td align=\"right\" class='awrc'>1.42</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>Space Manager: slave idle wait</td><td align=\"right\" class='awrnc'>2,650</td><td align=\"right\" class='awrnc'>91</td><td align=\"right\" class='awrnc'>12,569</td><td align=\"right\" class='awrnc'>4742.92</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>EMON slave idle wait</td><td align=\"right\" class='awrc'>1,745</td><td align=\"right\" class='awrc'>100</td><td align=\"right\" class='awrc'>8,725</td><td align=\"right\" class='awrc'>5000.04</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>GCR sleep</td><td align=\"right\" class='awrnc'>12,273</td><td align=\"right\" class='awrnc'>7</td><td align=\"right\" class='awrnc'>3,455</td><td align=\"right\" class='awrnc'>281.48</td><td align=\"right\" class='awrnc'>0.01</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>DIAG idle wait</td><td align=\"right\" class='awrc'>18,337</td><td align=\"right\" class='awrc'>100</td><td align=\"right\" class='awrc'>3,422</td><td align=\"right\" class='awrc'>186.60</td><td align=\"right\" class='awrc'>0.02</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>LGWR worker group idle</td><td align=\"right\" class='awrnc'>1,085,206</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>2,881</td><td align=\"right\" class='awrnc'>2.65</td><td align=\"right\" class='awrnc'>1.05</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>AQPC idle</td><td align=\"right\" class='awrc'>59</td><td align=\"right\" class='awrc'>100</td><td align=\"right\" class='awrc'>1,770</td><td align=\"right\" class='awrc'>30000.36</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>heartbeat redo informer</td><td align=\"right\" class='awrnc'>1,746</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>1,746</td><td align=\"right\" class='awrnc'>1000.03</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>pmon timer</td><td align=\"right\" class='awrc'>582</td><td align=\"right\" class='awrc'>100</td><td align=\"right\" class='awrc'>1,746</td><td align=\"right\" class='awrc'>3000.04</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>ges remote message</td><td align=\"right\" class='awrnc'>1,344</td><td align=\"right\" class='awrnc'>100</td><td align=\"right\" class='awrnc'>1,746</td><td align=\"right\" class='awrnc'>1298.94</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>class slave wait</td><td align=\"right\" class='awrc'>429</td><td align=\"right\" class='awrc'>0</td><td align=\"right\" class='awrc'>1,745</td><td align=\"right\" class='awrc'>4068.00</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>wait for unread message on broadcast channel</td><td align=\"right\" class='awrnc'>581</td><td align=\"right\" class='awrnc'>100</td><td align=\"right\" class='awrnc'>1,745</td><td align=\"right\" class='awrnc'>3003.58</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>PING</td><td align=\"right\" class='awrc'>403</td><td align=\"right\" class='awrc'>33</td><td align=\"right\" class='awrc'>1,745</td><td align=\"right\" class='awrc'>4329.67</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>ASM background timer</td><td align=\"right\" class='awrnc'>350</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>1,744</td><td align=\"right\" class='awrnc'>4983.02</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>lreg timer</td><td align=\"right\" class='awrc'>581</td><td align=\"right\" class='awrc'>100</td><td align=\"right\" class='awrc'>1,743</td><td align=\"right\" class='awrc'>3000.48</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>smon timer</td><td align=\"right\" class='awrnc'>656</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>1,740</td><td align=\"right\" class='awrnc'>2652.90</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>Streams AQ: emn coordinator idle wait</td><td align=\"right\" class='awrc'>174</td><td align=\"right\" class='awrc'>100</td><td align=\"right\" class='awrc'>1,740</td><td align=\"right\" class='awrc'>10000.11</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>Streams AQ: qmn slave idle wait</td><td align=\"right\" class='awrnc'>62</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>1,736</td><td align=\"right\" class='awrnc'>28000.43</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrc'>Streams AQ: qmn coordinator idle wait</td><td align=\"right\" class='awrc'>124</td><td align=\"right\" class='awrc'>50</td><td align=\"right\" class='awrc'>1,736</td><td align=\"right\" class='awrc'>14000.21</td><td align=\"right\" class='awrc'>0.00</td><td align=\"right\" class='awrc'>&#160;</td></tr> <tr><td scope=\"row\" class='awrnc'>SQL*Net message from client</td><td align=\"right\" class='awrnc'>3,400</td><td align=\"right\" class='awrnc'>0</td><td align=\"right\" class='awrnc'>4</td><td align=\"right\" class='awrnc'>1.18</td><td align=\"right\" class='awrnc'>0.00</td><td align=\"right\" class='awrnc'>&#160;</td></tr></table><p /><hr align=\"left\" width=\"20%\" /><p /><a class=\"awr\" href=\"#21\">Back to Wait Events Statistics</a><br /><a class=\"awr\" href=\"#top\">Back to Top</a><p /><a class=\"exa\" href=\"#CELL_TOPDB\">Back to Exadata Top Database Consumers</a><br/><a class=\"exa\" href=\"#CELL_STATISTICS\">Back to Exadata Statistics</a></div><br /><a class=\"awr\" href=\"#top\">Back to Top</a><p /><p />End of Report</body></html>`, nil},\n\t\t//\t{\"fdsfsdf\", \"\", errors.New(` open fdsfsdf: The system cannot find the file specified. `)},\n\t}\n\n\tfor _, pair := range tests {\n\t\tv, err := readFile(pair.input)\n\t\tif (v != pair.text) || (err != pair.error) {\n\t\t\tt.Error(\n\t\t\t\t\"For\", pair.input,\n\t\t\t\t\"\\n expected:\", pair.text,\n\t\t\t\t\"\\n got text:\", v,\n\t\t\t\t\"\\n got err:\", err,\n\t\t\t)\n\t\t}\n\t}\n\n}", "func Parse(source common.Source) (*exprpb.ParsedExpr, *common.Errors) {\n\treturn mustNewParser(Macros(AllMacros...)).Parse(source)\n}", "func (c *Client) Parse(b []byte) (*Root, error) {\n\tx := new(Root)\n\terr := json.Unmarshal(b, &x)\n\treturn x, err\n}", "func Parse(input string) Output {\n\tvar buffer bytes.Buffer\n\n\tr := regexp.MustCompile(\"\\t[0-9a-f]+\")\n\tmatched := r.FindAllString(input, -1)\n\n\tfor _, e := range matched {\n\t\tbuffer.WriteString(strings.Trim(e, \"\\t\"))\n\t}\n\n\treturn Output{raw: buffer.String()}\n}", "func (pq *PatientQuery) Parse(u *url.URL) {\n\tq := u.Query()\n\tpq.ID = q.Get(\"id\")\n\tpq.BirthDate = q.Get(\"birth_date\")\n}", "func ParseResult(cursor *mongo.Cursor, ctx context.Context) ([]byte, error) {\n\tvar interfaces []interface{}\n\tdefer cursor.Close(ctx)\n\tfor cursor.Next(ctx) {\n\t\tvar temp map[string]interface{}\n\t\terr := cursor.Decode(&temp)\n\t\tif err != nil {\n\t\t\treturn []byte{}, errors.New(\"Encounter error while decoding cursor\")\n\t\t}\n\t\tinterfaces = append(interfaces, temp)\n\t}\n\tif err := cursor.Err(); err != nil {\n\t\treturn []byte{}, errors.New(\"Encounter error while traversing through cursor\")\n\t}\n\n\tbytes, err := json.Marshal(interfaces)\n\tif err != nil {\n\t\treturn []byte{}, errors.New(\"Encounter error while marshaling mongo result\")\n\t}\n\n\treturn bytes, nil\n}", "func Parse(sql string) (nodes.Node, error) {\n\tr, err := JSON(sql)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresult := &nodes.Root{}\n\n\terr = json.Unmarshal([]byte(r), result)\n\n\treturn result, err //nolint\n}", "func (c *CoordinatorHelper) Parse(\n\tctx context.Context,\n\tnetworkIdentifier *types.NetworkIdentifier,\n\tsigned bool,\n\ttransaction string,\n) ([]*types.Operation, []string, map[string]interface{}, error) {\n\tops, signers, metadata, fetchErr := c.offlineFetcher.ConstructionParse(\n\t\tctx,\n\t\tnetworkIdentifier,\n\t\tsigned,\n\t\ttransaction,\n\t)\n\n\tif fetchErr != nil {\n\t\treturn nil, nil, nil, fetchErr.Err\n\t}\n\n\treturn ops, signers, metadata, nil\n}", "func (_SimpleMultiSig *SimpleMultiSigFilterer) ParseExecute(log types.Log) (*SimpleMultiSigExecute, error) {\n\tevent := new(SimpleMultiSigExecute)\n\tif err := _SimpleMultiSig.contract.UnpackLog(event, \"Execute\", log); err != nil {\n\t\treturn nil, err\n\t}\n\treturn event, nil\n}" ]
[ "0.7564657", "0.72145206", "0.6883133", "0.67062014", "0.65949386", "0.6539672", "0.6453612", "0.64350474", "0.6362603", "0.62645894", "0.6230624", "0.62238795", "0.6221113", "0.61815053", "0.61756355", "0.61674684", "0.6121528", "0.6115988", "0.61028284", "0.6046812", "0.6023914", "0.6017898", "0.60065037", "0.60008144", "0.59708154", "0.5967205", "0.59496135", "0.5945215", "0.5923241", "0.5878031", "0.5866382", "0.586419", "0.58635896", "0.5858353", "0.58351535", "0.5796646", "0.577811", "0.5760215", "0.57478714", "0.573682", "0.57272655", "0.5723119", "0.57211435", "0.5696715", "0.5696715", "0.56919676", "0.56832147", "0.5682173", "0.5672625", "0.56661564", "0.5660778", "0.56592727", "0.565231", "0.5624288", "0.5620817", "0.5620237", "0.56030566", "0.55939233", "0.5592639", "0.5589801", "0.55866206", "0.55739504", "0.5572314", "0.556946", "0.55657077", "0.55584824", "0.55532604", "0.5549127", "0.55486953", "0.5544473", "0.5537527", "0.55310005", "0.5529811", "0.55258316", "0.55186015", "0.5514366", "0.5491851", "0.5488783", "0.5486306", "0.5485492", "0.548286", "0.5482464", "0.54792595", "0.547624", "0.54744554", "0.5451663", "0.5449785", "0.5448277", "0.54396963", "0.54292846", "0.5423338", "0.5420287", "0.5417683", "0.54170704", "0.54160017", "0.541077", "0.5409551", "0.54043037", "0.5390179", "0.53862345" ]
0.60989374
19
IsValid returns true if whereClause's condition is valid. In SOQL, condition in where clause can only be number, boolean or string.
func (c *whereClause) IsValid() bool { switch c.condition.(type) { case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64: return true case bool: return true case string: return true default: return false } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c Condition) Valid() bool {\n\t// TODO: pass in a ColumnSchema and do validation based on it\n\tswitch c.Function {\n\tcase FuncLt, FuncLe, FuncEq, FuncNe, FuncGt, FuncGe, FuncInc, FuncExc:\n\t\treturn true\n\t}\n\treturn false\n}", "func (c *compiledStatement) validateCondition(expr influxql.Expr) error {\n\tswitch expr := expr.(type) {\n\tcase *influxql.BinaryExpr:\n\t\t// Verify each side of the binary expression. We do not need to\n\t\t// verify the binary expression itself since that should have been\n\t\t// done by influxql.ConditionExpr.\n\t\tif err := c.validateCondition(expr.LHS); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := c.validateCondition(expr.RHS); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\tcase *influxql.Call:\n\t\tif !isMathFunction(expr) {\n\t\t\treturn fmt.Errorf(\"invalid function call in condition: %s\", expr)\n\t\t}\n\n\t\t// How many arguments are we expecting?\n\t\tnargs := 1\n\t\tswitch expr.Name {\n\t\tcase \"atan2\", \"pow\":\n\t\t\tnargs = 2\n\t\t}\n\n\t\t// Did we get the expected number of args?\n\t\tif got := len(expr.Args); got != nargs {\n\t\t\treturn fmt.Errorf(\"invalid number of arguments for %s, expected %d, got %d\", expr.Name, nargs, got)\n\t\t}\n\n\t\t// Are all the args valid?\n\t\tfor _, arg := range expr.Args {\n\t\t\tif err := c.validateCondition(arg); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn nil\n\t}\n}", "func (f *FactTypeFilter) WhereValidation(p entql.StringP) {\n\tf.Where(p.Field(facttype.FieldValidation))\n}", "func (m *Condition) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAnd(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateBetween(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEquals(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateGreaterThan(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateGreaterThanOrEquals(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateLessThan(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateLessThanOrEquals(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateNot(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateOr(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (q *QueryTop) IsValid() (bool, error) {\n\treturn true, nil\n}", "func (op *OpQuery) Where(field string, condition interface{}) *OpQuery {\n\twhere := whereClause{\n\t\tfield: field,\n\t\tcondition: condition,\n\t}\n\tif where.IsValid() {\n\t\top.whereClauses = append(op.whereClauses, where)\n\t}\n\treturn op\n}", "func IsInvalidQuery(err error) bool {\n\treturn unwrapError(err) == ErrInvalidQuery\n}", "func (r *RangeCondition) IsValid() bool {\n\treturn r.ub != nil && r.lb != nil\n}", "func ValidateQuery(query string) (bool, error) {\n\n\t// simple sql pattern\n\tpattern := \"(select|SELECT) ([a-zA-Z]+(,[a-zA-Z]+)*) (from|FROM) [a-zA-Z]+(\\\\.[a-zA-Z]+)* ((limit|LIMIT) [0-9]+)? ((orderby|ORDERBY) (asc|desc|ASC|DESC))?;\"\n\tmatched, err := regexp.MatchString(pattern, query)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn matched, nil\n}", "func (m *EntityFilterWhereInput) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAND(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateNOT(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateOR(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateClustersEvery(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateClustersNone(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateClustersSome(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityTypeIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityTypeNot(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityTypeNotIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateExecFailedClusterEvery(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateExecFailedClusterNone(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateExecFailedClusterSome(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateFilterStatus(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateFilterStatusIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateFilterStatusNot(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateFilterStatusNotIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (statement Statement) IsValid() error {\n\tif !statement.Effect.IsValid() {\n\t\treturn fmt.Errorf(\"invalid Effect %v\", statement.Effect)\n\t}\n\n\tif len(statement.Actions) == 0 {\n\t\treturn fmt.Errorf(\"Action must not be empty\")\n\t}\n\n\tif len(statement.Resources) == 0 {\n\t\treturn fmt.Errorf(\"Resource must not be empty\")\n\t}\n\n\treturn nil\n}", "func (q *Query) Validate() error {\n\tif q.rang.Start > q.rang.End {\n\t\treturn fmt.Errorf(\"range error: start time is greater than end time\")\n\t}\n\tif ok := tsdb.VerifyChainPathExists(q.dbPath); !ok {\n\t\treturn fmt.Errorf(\"dbpath error: path doesn't exists\")\n\t}\n\n\tif q.typ != TypeFirst && q.typ != TypeRange {\n\t\treturn fmt.Errorf(\"typ error: invalid query type\")\n\t}\n\treturn nil\n}", "func (q *Query) whereClause(i int) (string, []interface{}) {\n\tif i < 1 {\n\t\t// the numbering starts at $1 not $0\n\t\ti = 1\n\t}\n\n\tvals := make([]interface{}, 0, len(q.conditions))\n\n\tb := strings.Builder{}\n\n\t// get length of values since the numbering of the where clause starts after values\n\tstartPos := len(q.values) + i\n\n\tclauses := make([]string, 0, len(q.conditions))\n\tfor _, cond := range q.conditions {\n\t\tif cond.raw != \"\" {\n\t\t\tn := len(cond.rawVals)\n\t\t\tif n == 0 {\n\t\t\t\tclauses = append(clauses, cond.raw)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\treplacements := make([]interface{}, n)\n\t\t\tfor j, str := range placeHolders(startPos, n) {\n\t\t\t\treplacements[j] = str\n\t\t\t}\n\n\t\t\tc := fmt.Sprintf(cond.raw, replacements...)\n\t\t\tclauses = append(clauses, c)\n\n\t\t\tvals = append(vals, cond.rawVals...)\n\n\t\t\tstartPos += n\n\t\t\tcontinue\n\t\t}\n\n\t\t// Clause returns the clause string and the new position (start position + number of values)\n\t\tc, nextPos := cond.Clause(startPos)\n\t\tclauses = append(clauses, c)\n\n\t\tif startPos < nextPos {\n\t\t\t// if the next position is greater than the start then values need to be added\n\t\t\tif r, ok := cond.val.(Range); ok {\n\t\t\t\tvals = append(vals, r.Start, r.End)\n\t\t\t} else if err := verifyArray(reflect.TypeOf(cond.val)); err == nil {\n\t\t\t\ts := reflect.ValueOf(cond.val)\n\t\t\t\tn := s.Len()\n\t\t\t\tfor j := 0; j < n; j++ {\n\t\t\t\t\tv := s.Index(j).Interface()\n\t\t\t\t\tvals = append(vals, v)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvals = append(vals, cond.val)\n\t\t\t}\n\t\t\tstartPos = nextPos\n\t\t}\n\t}\n\n\tb.WriteString(strings.Join(clauses, \" AND \"))\n\n\twhere := b.String()\n\n\t// Ors\n\tif len(q.ors) > 0 {\n\t\tnewWhere, newVals := addQueries(where, \"OR\", startPos, q.ors)\n\t\tvals = append(vals, newVals...)\n\n\t\tstartPos += len(newVals)\n\t\twhere = newWhere\n\t}\n\n\t// Ands\n\tif len(q.ands) > 0 {\n\t\tnewWhere, newVals := addQueries(where, \"AND\", startPos, q.ands)\n\t\tvals = append(vals, newVals...)\n\n\t\tstartPos += len(newVals) //nolint:ineffassign\n\t\twhere = newWhere\n\t}\n\n\treturn where, vals\n}", "func (l Limit) Valid() error {\n\t_, err := strconv.Atoi(string(l))\n\tif err != nil {\n\t\tlog.Println(\"error while validating query param: limit\")\n\t\tlog.Printf(\"value: %s, error: %s\", string(l), err.Error())\n\t\treturn errors.New(\"invalid query param: limit\")\n\t}\n\treturn nil\n}", "func (m *RuleClause) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateField(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateOperation(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func isValidParam(data Data) (result bool, err error) {\n\t// check length of param From\n\tif len(data.From) > 3 || len(data.From) < 3 {\n\t\tresult = false\n\t\terr = ErrInvalidParamFrom\n\t\treturn\n\t}\n\n\t// check length of param To\n\tif len(data.To) > 3 || len(data.To) < 3 {\n\t\tresult = false\n\t\terr = ErrInvalidParamTo\n\t\treturn\n\t}\n\n\tresult = true\n\treturn\n}", "func (b Bool) Valid(v interface{}) error {\n\tval, ok := v.(bool)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"wrong data type, expected bool, got: %T\", v))\n\t}\n\n\tif val != b.Value {\n\t\treturn b.Err\n\t}\n\n\treturn nil\n}", "func IsValid(lhs Expression) Expression {\n\treturn NewCall(\"is_valid\", []Expression{lhs}, nil)\n}", "func (s SQLQuery) Validate() error {\n\tstr := strings.ToLower(string(s))\n\tif !strings.HasPrefix(str, \"select\") {\n\t\treturn ErrNotSQLQuery\n\t}\n\treturn nil\n}", "func (t *Transaction) IsValid() bool {\n\treturn t.Recipient.IsVaild() && t.Sender.IsVaild() && !t.BookingDate.IsZero() &&\n\t\tt.Currency != \"\" && t.ValueInSmallestUnit != 0 && t.IntendedUse != \"\"\n}", "func (n name) IsValid() bool {\n\tfor _, supn := range supportedConditions {\n\t\tif n == supn {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func matchesWhere(f influxql.Expr, fields map[string]interface{}) bool {\n\tif ok, _ := influxql.Eval(f, fields).(bool); !ok {\n\t\treturn false\n\t}\n\treturn true\n}", "func (self *TStatement) Where(query string, args ...interface{}) *TStatement {\r\n\tif !strings.Contains(query, self.session.orm.dialect.EqStr()) {\r\n\t\tquery = strings.Replace(query, \"=\", self.session.orm.dialect.EqStr(), -1)\r\n\t}\r\n\r\n\tself.Op(domain.AND_OPERATOR, query, args...)\r\n\r\n\treturn self\r\n}", "func (q BaseQuestion) Valid() bool {\n\treturn q.QuestionID != \"\" && q.QuestionTitle != \"\"\n}", "func (statement *Statement) Where(query interface{}, args ...interface{}) *Statement {\n\treturn statement.And(query, args...)\n}", "func (q *Query) Where(stmt string, args ...interface{}) *Query {\n\tif q.RawSQL.Fragment != \"\" {\n\t\tfmt.Println(\"Warning: Query is setup to use raw SQL\")\n\t\treturn q\n\t}\n\tif inRegex.MatchString(stmt) {\n\t\tvar inq []string\n\t\tfor i := 0; i < len(args); i++ {\n\t\t\tinq = append(inq, \"?\")\n\t\t}\n\t\tqs := fmt.Sprintf(\"(%s)\", strings.Join(inq, \",\"))\n\t\tstmt = strings.Replace(stmt, \"(?)\", qs, 1)\n\t}\n\tq.whereClauses = append(q.whereClauses, clause{stmt, args})\n\treturn q\n}", "func (f WeightField) Valid() (bool, error) {\n\tif f < 10 || f > 999 {\n\t\treturn false, ErrFieldInvalid{fmt.Sprintf(\"`%v` is an invalid weight value. Weight must be between 10 and 999\")}\n\t}\n\n\treturn true, nil\n}", "func (q *Query) Validate() error {\n\tif q.Project == \"\" {\n\t\treturn errors.New(\"Invalid query: missing project\")\n\t}\n\tif q.Cluster == \"\" {\n\t\treturn errors.New(\"Invalid query: missing cluster\")\n\t}\n\tif q.Namespace == \"\" {\n\t\treturn errors.New(\"Invalid query: missing namespace\")\n\t}\n\tif q.BuildID == \"\" {\n\t\treturn errors.New(\"Invalid query: missing build id\")\n\t}\n\treturn nil\n}", "func (r *QueryRequest) Valid() error {\n\tif !r.OrganizationID.Valid() {\n\t\treturn &errors.Error{\n\t\t\tMsg: \"organization_id is not valid\",\n\t\t\tCode: errors.EInvalid,\n\t\t}\n\t}\n\treturn r.Authorization.Valid()\n}", "func (q *query) Where(field string, op Operator, value any) Builder {\n\tq.filter.And(field, op, value)\n\treturn q\n}", "func (o Offset) Valid() error {\n\t_, err := strconv.Atoi(string(o))\n\tif err != nil {\n\t\tlog.Println(\"error while validating query param: offset\")\n\t\tlog.Printf(\"value: %s, error: %s\", string(o), err.Error())\n\t\treturn errors.New(\"invalid query param: offset\")\n\t}\n\treturn nil\n}", "func (q *TimeTableQuery) Validate() error {\n\tif q.OriginCountryCode == \"\" {\n\t\treturn errors.New(\"OriginCountryCode is required\")\n\t}\n\n\tif q.OriginPostCode == \"\" {\n\t\treturn errors.New(\"OriginPostCode is required\")\n\t}\n\n\tif q.DestinationCountryCode == \"\" {\n\t\treturn errors.New(\"DestinationCountryCode is required\")\n\t}\n\n\tif q.DestinationPostCode == \"\" {\n\t\treturn errors.New(\"DestinationPostCode is required\")\n\t}\n\n\tif q.Date == \"\" {\n\t\treturn errors.New(\"Date is required\")\n\t}\n\n\treturn nil\n}", "func hasValidColumn(query interface{}) error {\n\tif reflect.ValueOf(query).Kind() == reflect.Slice {\n\t\tcolumnData := query.([]interface{})\n\t\tfor _, column := range columnData {\n\t\t\tcolumn := column.(map[string]interface{})\n\t validateColumn(column)\n\t }\n\t} else {\n\t\tquery := query.(map[string]interface{})\n\t\tvalidateColumn(query)\n\t}\n\treturn nil\n}", "func NewValidCondition() *DetailedConditionBuilder {\n\tb := &DetailedConditionBuilder{\n\t\tCondition: v1.Condition{\n\t\t\tType: v1.ValidConditionType,\n\t\t},\n\t}\n\n\treturn b\n}", "func (v AccountSearchFieldFilter) IsValid() bool {\n\tfor _, existing := range allowedAccountSearchFieldFilterEnumValues {\n\t\tif existing == v {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (q *StatsPeriodQuery) Where(cond kallax.Condition) *StatsPeriodQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (v QuerySortOrder) IsValid() bool {\n\tfor _, existing := range allowedQuerySortOrderEnumValues {\n\t\tif existing == v {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (r QueryRequest) Validate() error {\n\tif r.Query == \"\" && r.Spec == nil && r.AST == nil {\n\t\treturn errors.New(`request body requires either query, spec, or AST`)\n\t}\n\n\tif r.Type != \"flux\" {\n\t\treturn fmt.Errorf(`unknown query type: %s`, r.Type)\n\t}\n\n\tif len(r.Dialect.CommentPrefix) > 1 {\n\t\treturn fmt.Errorf(\"invalid dialect comment prefix: must be length 0 or 1\")\n\t}\n\n\tif len(r.Dialect.Delimiter) != 1 {\n\t\treturn fmt.Errorf(\"invalid dialect delimeter: must be length 1\")\n\t}\n\n\trune, size := utf8.DecodeRuneInString(r.Dialect.Delimiter)\n\tif rune == utf8.RuneError && size == 1 {\n\t\treturn fmt.Errorf(\"invalid dialect delimeter character\")\n\t}\n\n\tfor _, a := range r.Dialect.Annotations {\n\t\tswitch a {\n\t\tcase \"group\", \"datatype\", \"default\":\n\t\tdefault:\n\t\t\treturn fmt.Errorf(`unknown dialect annotation type: %s`, a)\n\t\t}\n\t}\n\n\tswitch r.Dialect.DateTimeFormat {\n\tcase \"RFC3339\", \"RFC3339Nano\":\n\tdefault:\n\t\treturn fmt.Errorf(`unknown dialect date time format: %s`, r.Dialect.DateTimeFormat)\n\t}\n\n\treturn nil\n}", "func (q *Query) Where(column string, op Operator, value interface{}) *Query {\n\tcond := newCondition(AND, column, op, value)\n\n\tq.Binding.Conditions = append(q.Binding.Conditions, cond)\n\n\treturn q\n}", "func (sb *SQLBuilder) Where(field string, condition string, value interface{}) *SQLBuilder {\n\treturn sb.where(\"AND\", condition, field, value)\n}", "func (ft *FieldType) IsDecimalValid() bool {\n\tif ft.GetType() == mysql.TypeNewDecimal && (ft.decimal < 0 || ft.decimal > mysql.MaxDecimalScale || ft.flen <= 0 || ft.flen > mysql.MaxDecimalWidth || ft.flen < ft.decimal) {\n\t\treturn false\n\t}\n\treturn true\n}", "func (v TransactionTypeFilter) IsValid() bool {\n\tfor _, existing := range allowedTransactionTypeFilterEnumValues {\n\t\tif existing == v {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func isValidatable(c model.Column) bool {\n\t// validate FK\n\tif c.IsFK {\n\t\treturn true\n\t}\n\n\t// validate complex types\n\tif !c.Nullable && (c.IsArray || c.GoType == model.TypeMapInterface || c.GoType == model.TypeMapString) {\n\t\treturn true\n\t}\n\n\t// validate strings len\n\tif c.GoType == model.TypeString && c.MaxLen > 0 {\n\t\treturn true\n\t}\n\n\t// validate enum\n\tif len(c.Values) > 0 {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (con *EqualCondition) Valid(dataList ...interface{}) bool {\n\tif len(dataList) == 0 {\n\t\treturn false\n\t}\n\tdata := dataList[0]\n\n\treturn reflect.DeepEqual(con.target, data)\n}", "func (m *Query) Validate() error {\n\treturn m.validate(false)\n}", "func (q QuerySpec) Validate() error {\n\tif q.Statement == \"\" {\n\t\treturn errors.New(\"statement is required\")\n\t}\n\n\tswitch q.Result.Type {\n\tcase\n\t\tResultTypeNone,\n\t\tResultTypeRow,\n\t\tResultTypeRows,\n\t\t\"string\",\n\t\t\"int64\",\n\t\t\"float64\",\n\t\t\"bool\",\n\t\t\"sql.NullString\",\n\t\t\"sql.NullInt64\",\n\t\t\"sql.NullFloat64\",\n\t\t\"sql.NullBool\":\n\tdefault:\n\t\treturn errors.New(\"invalid result type: \" + q.Result.Type)\n\t}\n\n\tif q.Result.Struct.Name == \"\" && len(q.Result.Struct.Fields) != 0 {\n\t\treturn errors.New(\"result struct name is required\")\n\t}\n\n\tif q.Result.Struct.Name != \"\" && len(q.Result.Struct.Fields) == 0 {\n\t\treturn errors.New(\"result struct fields is required\")\n\t}\n\n\tif (q.Result.Struct.Name != \"\" || len(q.Result.Struct.Fields) != 0) && len(q.Result.Fields) != 0 {\n\t\treturn errors.New(\"result struct must not be set if result fields is set\")\n\t}\n\n\tswitch q.Result.Type {\n\tcase ResultTypeNone:\n\t\tif q.Result.Struct.Name != \"\" || len(q.Result.Struct.Fields) != 0 {\n\t\t\treturn errors.New(\"cannot set result struct while result type is 'None'\")\n\t\t}\n\t\tif len(q.Result.Fields) != 0 {\n\t\t\treturn errors.New(\"cannot set result fields while result type is 'None'\")\n\t\t}\n\tcase\n\t\t\"string\",\n\t\t\"int64\",\n\t\t\"float64\",\n\t\t\"bool\",\n\t\t\"sql.NullString\",\n\t\t\"sql.NullInt64\",\n\t\t\"sql.NullFloat64\",\n\t\t\"sql.NullBool\":\n\t\tif q.Result.Struct.Name != \"\" || len(q.Result.Struct.Fields) != 0 {\n\t\t\treturn fmt.Errorf(\"cannot set result struct while result type is '%s'\", q.Result.Type)\n\t\t}\n\t\tif len(q.Result.Fields) != 0 {\n\t\t\treturn fmt.Errorf(\"cannot set result fields while result type is '%s'\", q.Result.Type)\n\t\t}\n\t}\n\n\tfor _, f := range q.Result.Fields {\n\t\terr := f.Validate()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (handler *AllowAllHandler) CheckQuery(sqlQuery string, parsedQuery sqlparser.Statement) (bool, error) {\n\t// allow any query and stop further checks\n\thandler.logger.Infof(\"Query has been allowed by Allowall handler\")\n\treturn false, nil\n}", "func whereClause(o bool, w ...where) string {\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(fmt.Sprintf(\" where \"))\n\tfor c, wc := range w {\n\t\tif c == 0 {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s='%v' \", wc.field, wc.value))\n\t\t} else {\n\t\t\tif o {\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(\"OR %s='%v' \", wc.field, wc.value))\n\t\t\t} else {\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(\"AND %s='%v' \", wc.field, wc.value))\n\t\t\t}\n\t\t}\n\t}\n\treturn buffer.String()\n}", "func (q *Query) Where(cond string, args ...interface{}) *Query {\n\tq.whereParts = append(q.whereParts, newWherePart(cond, args...))\n\treturn q\n}", "func (self *TStatement) where_calc(node *domain.TDomainNode, active_test bool, context map[string]interface{}) (*TQuery, error) {\r\n\tif context == nil {\r\n\t\tcontext = make(map[string]interface{})\r\n\t}\r\n\r\n\t// domain = domain[:]\r\n\t// if the object has a field named 'active', filter out all inactive\r\n\t// records unless they were explicitely asked for\r\n\tif has := self.session.Statement.model.Obj().GetFieldByName(\"active\"); has != nil && active_test {\r\n\t\tif node != nil {\r\n\t\t\t// the item[0] trick below works for domain items and '&'/'|'/'!'\r\n\t\t\t// operators too\r\n\t\t\tvar hasfield bool\r\n\t\t\tfor _, node := range node.Nodes() {\r\n\t\t\t\tif node.String(0) == \"active\" {\r\n\t\t\t\t\thasfield = true\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif !hasfield {\r\n\t\t\t\t//domain.Insert(0, Query2StringList(`('active', '=', 1)`))\r\n\t\t\t\tnode, err := domain.String2Domain(`[('active', '=', 1)]`, nil)\r\n\t\t\t\tif err != nil {\r\n\t\t\t\t\tlog.Err(err)\r\n\t\t\t\t}\r\n\t\t\t\tnode.Insert(0, node)\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t//domain = Query2StringList(`[('active', '=', 1)]`)\r\n\t\t\tvar err error\r\n\t\t\tnode, err = domain.String2Domain(`[('active', '=', 1)]`, nil)\r\n\t\t\tif err != nil {\r\n\t\t\t\tlog.Err(err)\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\r\n\ttables := make([]string, 0)\r\n\tvar where_clause []string\r\n\tvar where_params []interface{}\r\n\tif node != nil && node.Count() > 0 {\r\n\t\texp, err := NewExpression(self.session.orm, self.session.Statement.model.GetBase(), node, context)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\r\n\t\ttables = exp.get_tables().Strings()\r\n\t\twhere_clause, where_params = exp.to_sql(self.Params...)\r\n\r\n\t} else {\r\n\t\twhere_clause, where_params, tables = nil, nil, append(tables, self.session.Statement.model.Table())\r\n\r\n\t}\r\n\r\n\treturn NewQuery(tables, where_clause, where_params, nil, nil), nil //self.Registry.r Query(tables, where_clause, where_params)\r\n}", "func WhereCondition(where *Condition) QueryOptions {\n\treturn func(query *Query) (*Query, error) {\n\t\tif where.IsEmpty() {\n\t\t\treturn nil, errors.New(\"condition can't be empty\")\n\t\t}\n\t\tojaiCondition, err := convertConditionMap(where.AsMap())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresMap, err := mergeQueryMaps(query.content,\n\t\t\tmap[string]interface{}{operations[WHERE]: ojaiCondition})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tquery.content = resMap.(map[string]interface{})\n\t\treturn query, nil\n\t}\n}", "func (c *conflictUpdate) WhereClause() ExpressionList {\n\treturn c.whereClause\n}", "func (db *DB) ValidPeriod(campus, category, period string) (bool, error) {\n\tconn, err := redishelper.GetRedisConn(db.RedisServer, db.RedisPassword)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer conn.Close()\n\n\tk := fmt.Sprintf(\"ming:%v:%v:periods\", campus, category)\n\tscore, err := redis.String(conn.Do(\"ZSCORE\", k, period))\n\tif err != nil && err != redis.ErrNil {\n\t\treturn false, err\n\t}\n\n\tif score == \"\" {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func (sc selectCriterion) Validate() error {\n\tif sc.name == \"\" {\n\t\treturn fmt.Errorf(\"name is empty\")\n\t}\n\tif i := strings.IndexAny(sc.name, InvalidCriterionRunes); i == 0 {\n\t\treturn fmt.Errorf(\"name starts with invalid character '%v'\", sc.name[i])\n\t}\n\tif sc.name == SelectAll {\n\t\tif sc.tagged {\n\t\t\treturn fmt.Errorf(\"cannot use '.' with special name 'v'\", SelectAll)\n\t\t}\n\t\tif sc.negated {\n\t\t\treturn fmt.Errorf(\"cannot use '!' with special name 'v'\", SelectAll)\n\t\t}\n\t}\n\treturn nil\n}", "func ValidateQueryParams(query interface{}, validators map[string]func(interface{}) bool) bool {\n\tqueryValue := reflect.ValueOf(query)\n\tif queryValue.Kind() == reflect.Ptr {\n\t\tqueryValue = queryValue.Elem()\n\t}\n\tqueryType := queryValue.Type()\n\n\tfor i := 0; i < queryValue.NumField(); i++ {\n\t\tfieldValue := queryValue.Field(i)\n\t\tfieldType := queryType.Field(i)\n\n\t\t// Skip non-pointer fields\n\t\tif fieldValue.Kind() != reflect.Ptr {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Skip nil fields\n\t\tif fieldValue.IsNil() {\n\t\t\tcontinue\n\t\t}\n\n\t\tfieldName := strings.Split(fieldType.Tag.Get(\"json\"), \",\")[0]\n\n\t\tvalidator, exists := validators[fieldName]\n\t\tif exists {\n\t\t\tif !validator(fieldValue.Interface()) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true\n}", "func (v Base) IsValid() bool {\n\treturn v.Ordinal() >= 0\n}", "func Where(clause string, args ...interface{}) QueryMod {\n\treturn func(q *queries.Query) {\n\t\tqueries.AppendWhere(q, clause, args...)\n\t}\n}", "func (c *commentsQueryBuilder) Where(filter string, values ...interface{}) *commentsQueryBuilder {\n\tif c.err != nil {\n\t\treturn c\n\t}\n\tc.builder.Where(filter, values...)\n\treturn c\n}", "func (c *condition) Clause(i int) (string, int) {\n\tvar condClause string\n\tif nullable, ok := c.val.(Nullable); c.val == nil || (ok && nullable.IsNull()) {\n\t\tcondClause = condClauseNull(c.negative)\n\t} else if _, ok := c.val.(Range); ok {\n\t\tcondClause, i = condClauseRange(i, c.negative)\n\t} else if err := verifyArray(reflect.TypeOf(c.val)); err == nil {\n\t\tcondClause, i = condClauseSlice(i, reflect.ValueOf(c.val).Len(), c.negative)\n\t} else {\n\t\tcondClause, i = condClauseVal(i, c.negative)\n\t}\n\n\tvar b StringsBuilder\n\tb.WriteStrings(Quote(c.col), \" \", condClause)\n\n\treturn b.String(), i\n}", "func validateQueryParameter(field *surface_v1.Field) {\n\t_, isScalar := protoBufScalarTypes[field.NativeType]\n\tif !(field.Kind == surface_v1.FieldKind_SCALAR ||\n\t\t(field.Kind == surface_v1.FieldKind_ARRAY && isScalar) ||\n\t\t(field.Kind == surface_v1.FieldKind_REFERENCE)) {\n\t\tlog.Println(\"The query parameter with the Name \" + field.Name + \" is invalid. \" +\n\t\t\t\"Note that fields which are mapped to URL query parameters must have a primitive type or\" +\n\t\t\t\" a repeated primitive type or a non-repeated message type. \" +\n\t\t\t\"See: https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L118 for more information.\")\n\t}\n\n}", "func (r *QueryRequest) Validate() error {\n\tif r.SQL == \"\" {\n\t\treturn fmt.Errorf(\"SQL was empty\")\n\t}\n\treturn nil\n}", "func validateIsBool(i interface{}) error {\n\t_, ok := i.(bool)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid parameter type: %T\", i)\n\t}\n\treturn nil\n}", "func (parameter *Parameter) IsValid() *u.AppError {\n\n\tif len(parameter.Local) == 0 || len(parameter.Local) > localMaxSize {\n\t\treturn u.NewLocAppError(\"Parameter.IsValid\", \"model.parameter.is_valid.parameter_local.app_error\", nil, \"\")\n\t}\n\n\tif len(parameter.TimeZone) == 0 || len(parameter.TimeZone) > timeZoneMaxSize {\n\t\treturn u.NewLocAppError(\"Parameter.IsValid\", \"model.parameter.is_valid.parameter_timezone.app_error\", nil, \"\")\n\t}\n\n\tif parameter.SleepStart < 0 || parameter.SleepStart > maxTime {\n\t\treturn u.NewLocAppError(\"Parameter.IsValid\", \"model.parameter.is_valid.parameter_sleep_start.app_error\", nil, \"\")\n\t}\n\n\tif parameter.SleepEnd < 0 || parameter.SleepEnd > maxTime {\n\t\treturn u.NewLocAppError(\"Parameter.IsValid\", \"model.parameter.is_valid.parameter_sleep_end.app_error\", nil, \"\")\n\t}\n\n\treturn nil\n}", "func (stmt *statement) Where(expr string, args ...interface{}) Statement {\n\tstmt.addPart(posWhere, \"WHERE\", expr, args, \" AND \")\n\treturn stmt\n}", "func ValidateSql(val string) (int, error) {\n\tstmt, err := sqlparser.Parse(val)\n\tif err != nil {\n\t\treturn BAD, fmt.Errorf(\"SQL Error in %s\", val)\n\t}\n\tswitch smt := stmt.(type) {\n\tcase *sqlparser.DDL:\n\t\tif smt.Action == \"drop\" {\n\t\t\treturn DROP, fmt.Errorf(\"DROP statements are not allowed\")\n\t\t}\n\tcase *sqlparser.Select:\n\t\treturn SELECT, nil\n\t}\n\treturn OTHER, nil\n}", "func (statement Statement) isValid() error {\n\tif !statement.Effect.IsValid() {\n\t\treturn Errorf(\"invalid Effect %v\", statement.Effect)\n\t}\n\n\tif !statement.Principal.IsValid() {\n\t\treturn Errorf(\"invalid Principal %v\", statement.Principal)\n\t}\n\n\tif len(statement.Actions) == 0 {\n\t\treturn Errorf(\"Action must not be empty\")\n\t}\n\n\tif len(statement.Resources) == 0 {\n\t\treturn Errorf(\"Resource must not be empty\")\n\t}\n\n\tfor action := range statement.Actions {\n\t\tif action.isObjectAction() {\n\t\t\tif !statement.Resources.objectResourceExists() {\n\t\t\t\treturn Errorf(\"unsupported Resource found %v for action %v\", statement.Resources, action)\n\t\t\t}\n\t\t} else {\n\t\t\tif !statement.Resources.bucketResourceExists() {\n\t\t\t\treturn Errorf(\"unsupported Resource found %v for action %v\", statement.Resources, action)\n\t\t\t}\n\t\t}\n\n\t\tkeys := statement.Conditions.Keys()\n\t\tkeyDiff := keys.Difference(actionConditionKeyMap[action])\n\t\tif !keyDiff.IsEmpty() {\n\t\t\treturn Errorf(\"unsupported condition keys '%v' used for action '%v'\", keyDiff, action)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (q *Query) isValidTableSelected() (valid bool) {\n\tfor _, value := range queryTypes {\n\n\t\tif value == q.QueryType.String() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (r *Range) IsValid(v Value) bool {\n\tif r.Kind() != v.Kind() {\n\t\treturn false\n\t}\n\tswitch r.Kind() {\n\tcase Integer:\n\t\treturn v.Int() >= r.Start.Int() && v.Int() < r.End.Int()\n\tcase Real:\n\t\treturn v.Float() >= r.Start.Float() && v.Float() < r.End.Float()\n\tdefault:\n\t\tpanic(r)\n\t}\n}", "func (a AuthService) ValidateQueryPerms(q string) (string, error) {\n\tvar newQ CDBQuery\n\t// Unmarshal in to a CDBQuery\n\tif err := json.Unmarshal([]byte(q), &newQ); err != nil {\n\t\treturn \"\", errQueryMarshal(err)\n\t}\n\n\t// Pick out the doctype from the query\n\tresource := newQ.Selector[\"docType\"]\n\n\tif resource == nil || resource == \"\" {\n\t\treturn \"\", errQueryDocType()\n\t}\n\n\tfor _, role := range a.userRoles {\n\t\t// Lookup permissions\n\t\truleFunc, ok := a.rolePermissions[role].QueryPermissions[resource.(string)]\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Construct rules from the ruleFunc callback\n\t\trules := ruleFunc(a.userID, a.userRoles)\n\t\tif !rules.Allow {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Enforce any selector appends\n\t\tfor k, v := range rules.SelectorAppend {\n\t\t\tnewQ.Selector[k] = v\n\t\t}\n\n\t\t// Enforce any filter queries (no need to check for nil first)\n\t\tnewQ.Fields = rules.FieldFilter\n\n\t\t// Marshal back to json bytes so it can be sent back as a string\n\t\tnewQBytes, err := json.Marshal(newQ)\n\t\tif err != nil {\n\t\t\treturn \"\", errMarshal(err)\n\t\t}\n\n\t\treturn string(newQBytes), nil\n\t}\n\n\treturn \"\", errQuery(resource.(string))\n}", "func Where(col, op string, expr Expr) Option {\n\treturn func(q Query) Query {\n\t\treturn realWhere(\"AND\", Ident(col), op, expr)(q)\n\t}\n}", "func (o Order) Valid() error {\n\t_, ok := orderOptions[o]\n\tif !ok {\n\t\tlog.Println(\"error while validating query param: order\")\n\t\tlog.Printf(\"value: %s\", string(o))\n\t\treturn errors.New(\"invalid query param: order\")\n\t}\n\treturn nil\n}", "func CheckCondition(cond Condition, pass string) bool {\n fmt.Printf(\"Checking pass: %s with %+v\\n\", pass, cond)\n count := strings.Count(pass, cond.letter)\n return (count <= cond.max) && (count >= cond.min)\n}", "func (t *Transaction) IsValid() bool {\n\treturn t.Id != uuid.Nil && t.SenderAddress.IsValid() && t.RecipientAddress.IsValid() && t.Value > 0\n}", "func validateBoolParam(ctx *HttpContext, param *HttpParam) {\n\n\tparam.Raw = retrieveParamValue(ctx, param).(string)\n\n\tif len(param.Raw) == 0 && param.Required {\n\t\tappendInvalidErrorCode(ctx, param)\n\t\treturn\n\t}\n\n\tif len(param.Raw) == 0 { return }\n\n\tif val, err := strconv.ParseBool(param.Raw); err != nil {\n\t\tappendInvalidErrorCode(ctx, param)\n\t} else {\n\t\tparam.setPresentValue(val)\n\t}\n}", "func (x *fastReflection_QueryParamsRequest) IsValid() bool {\n\treturn x != nil\n}", "func (v *budgetInputValidator) IsValid(_ context.Context, budget, days int) (bool, error) {\n\tif budget < budgetMinimal || budget > budgetMaximal {\n\t\treturn false, errors.Wrap(platform.ErrInvalidInputBudget, \"value must be between 100 and 2000\")\n\t}\n\n\tif budget/days < budgetMinimalPerDay {\n\t\treturn false, errors.Wrap(platform.ErrInvalidInputBudget, \"value allocated per day needs to be 50\")\n\t}\n\n\treturn true, nil\n}", "func IsClause(t Term) bool {\n\tswitch t.Type() {\n\tcase CompoundType:\n\t\tx := t.(*Compound)\n\t\treturn x.Arity() == 2 && x.Name() == \":-\"\n\tcase AtomType,\n\t\tVariableType,\n\t\tIntegerType,\n\t\tFloatType,\n\t\tErrorType:\n\t\treturn false\n\t}\n\tmsg := Sprintf(\"Unexpected term type: %#v\", t)\n\tpanic(msg)\n}", "func Condition(c query.Condition) bool {\n\treturn Evaluator{Strict: false}.Condition(c)\n}", "func hasValidSavedQuery(query interface{}) error {\n\tqueryConverted := query.(map[string]interface{})\n\tlistQueryTypes := []string{\"count/entity\", \"count/event\", \"count/entity/total\", \"aggregation\", \"top_values\"}\n\tif !stringInSlice(queryConverted[\"type\"].(string), listQueryTypes) {\n\t\treturn errors.New(\"Saved Query Validator: this dictionary don't have query type valid.\")\n\t}\n\treturn nil\n}", "func (q *SessionQuery) Where(cond kallax.Condition) *SessionQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (q *PersonQuery) Where(cond kallax.Condition) *PersonQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func Where(query string, args ...interface{}) QueryOption {\n\treturn newFuncQueryOption(func(wrapper *QueryWrapper) {\n\t\twrapper.where = Clause(query, args...)\n\n\t\twrapper.queryLen += 2\n\t\twrapper.bindsLen += len(args)\n\t})\n}", "func (m *VlanWhereInput) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAND(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateNOT(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateOR(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityAsyncStatusIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityAsyncStatusNotIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTypeIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTypeNotIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (d *Definition) IsValid() (bool, []string) {\n\tconditions := []validationCondition{\n\t\t{len(d.Image) == 0, \"string [image] must be specified\"},\n\t\t{len(d.GroupName) == 0, \"string [group_name] must be specified\"},\n\t\t{!validGroupName.MatchString(d.GroupName), \"Group name can only contain letters, numbers, hyphens, and underscores\"},\n\t\t{len(d.GroupName) > 255, \"Group name must be 255 characters or less\"},\n\t\t{len(d.Alias) == 0, \"string [alias] must be specified\"},\n\t\t{d.Memory == nil, \"int [memory] must be specified\"},\n\t\t{len(d.Command) == 0, \"string [command] must be specified\"},\n\t}\n\n\tvalid := true\n\tvar reasons []string\n\tfor _, cond := range conditions {\n\t\tif cond.condition {\n\t\t\tvalid = false\n\t\t\treasons = append(reasons, cond.reason)\n\t\t}\n\t}\n\treturn valid, reasons\n}", "func (m *UsbDeviceWhereInput) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAND(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateNOT(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateOR(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityAsyncStatus(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityAsyncStatusIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityAsyncStatusNot(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateEntityAsyncStatusNotIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateHost(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStatus(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStatusIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStatusNot(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStatusNotIn(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateVmsEvery(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateVmsNone(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateVmsSome(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (v *parameter) HasMinLength() bool {\n\treturn v.minLength != nil\n}", "func (p Position) Valid() bool {\n\tok := func(i int) bool { return 1 <= i && i <= 8 }\n\treturn ok(p[0]) && ok(p[1])\n}", "func (t *ReadinessCheckType) IsValid() bool {\n\tswitch *t {\n\tcase ReadinessCheckTypeNonEmpty, ReadinessCheckTypeMatchString, ReadinessCheckTypeMatchInteger, ReadinessCheckTypeMatchTrue, ReadinessCheckTypeMatchFalse, ReadinessCheckTypeMatchCondition, ReadinessCheckTypeNone:\n\t\treturn true\n\t}\n\treturn false\n}", "func Validate(conditions []meta.Condition, conditionType string, expectedStatus meta.ConditionStatus) bool {\n\tfor _, cond := range conditions {\n\t\tif cond.Type == conditionType {\n\t\t\treturn cond.Status == expectedStatus\n\t\t}\n\t}\n\treturn false\n}", "func (f *Filter) Validate() error {\n\tif f == nil {\n\t\treturn errors.ThrowPreconditionFailed(nil, \"REPO-z6KcG\", \"filter is nil\")\n\t}\n\tif f.Field <= 0 || f.Field >= fieldCount {\n\t\treturn errors.ThrowPreconditionFailed(nil, \"REPO-zw62U\", \"field not definded\")\n\t}\n\tif f.Value == nil {\n\t\treturn errors.ThrowPreconditionFailed(nil, \"REPO-GJ9ct\", \"no value definded\")\n\t}\n\tif f.Operation <= 0 || f.Operation >= operationCount {\n\t\treturn errors.ThrowPreconditionFailed(nil, \"REPO-RrQTy\", \"operation not definded\")\n\t}\n\treturn nil\n}", "func validateStatement(q string) error {\n\tif strings.TrimSpace(q) == \"\" {\n\t\treturn ERR_STMT_EMPTY\n\t}\n\treturn nil\n}", "func (b UpdateBuilder) Where(pred interface{}, args ...interface{}) WhereConditions {\n\treturn builder.Append(b, \"WhereParts\", newWherePart(pred, args...)).(UpdateBuilder)\n}", "func (builder *QueryBuilder[K, F]) Where(condition Condition[K, F]) *QueryBuilder[K, F] {\n\tbuilder.query.Conditions = append(builder.query.Conditions, condition)\n\treturn builder\n}", "func validateQueryValidatorFlags(flagSet *pflag.FlagSet) error {\n\tmoniker, err := flagSet.GetString(FlagMoniker)\n\tif err != nil {\n\t\treturn err\n\t}\n\taddr, err := flagSet.GetString(FlagAddr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvalAddr, err := flagSet.GetString(FlagValAddr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif moniker == \"\" && addr == \"\" && valAddr == \"\" {\n\t\treturn fmt.Errorf(\"at least one of flags (--moniker, --val-addr, --addr) needs to be set\")\n\t}\n\n\treturn nil\n}", "func ValidColumn(column string) bool {\n\tfor i := range Columns {\n\t\tif column == Columns[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor i := range ForeignKeys {\n\t\tif column == ForeignKeys[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidColumn(column string) bool {\n\tfor i := range Columns {\n\t\tif column == Columns[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor i := range ForeignKeys {\n\t\tif column == ForeignKeys[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidColumn(column string) bool {\n\tfor i := range Columns {\n\t\tif column == Columns[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor i := range ForeignKeys {\n\t\tif column == ForeignKeys[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidColumn(column string) bool {\n\tfor i := range Columns {\n\t\tif column == Columns[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor i := range ForeignKeys {\n\t\tif column == ForeignKeys[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidColumn(column string) bool {\n\tfor i := range Columns {\n\t\tif column == Columns[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor i := range ForeignKeys {\n\t\tif column == ForeignKeys[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidColumn(column string) bool {\n\tfor i := range Columns {\n\t\tif column == Columns[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor i := range ForeignKeys {\n\t\tif column == ForeignKeys[i] {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}" ]
[ "0.64737576", "0.6043885", "0.57372516", "0.5440292", "0.54174995", "0.5357616", "0.5356479", "0.52202374", "0.5218492", "0.51943374", "0.5133273", "0.51300323", "0.5097209", "0.5082896", "0.5081986", "0.5069481", "0.5067441", "0.5057074", "0.5036478", "0.5009793", "0.4987895", "0.49657863", "0.4952602", "0.49374703", "0.4924668", "0.49036023", "0.48792726", "0.48785168", "0.48709977", "0.48526102", "0.4837627", "0.48281804", "0.48154995", "0.47987366", "0.47987333", "0.47917855", "0.47884443", "0.47873712", "0.47823742", "0.47768426", "0.47755688", "0.4772284", "0.47692576", "0.4767964", "0.47669137", "0.47513333", "0.47411114", "0.47347277", "0.47315234", "0.47308362", "0.47289625", "0.4728469", "0.4716955", "0.47159526", "0.4713498", "0.47106358", "0.46951512", "0.46888354", "0.4680971", "0.4674242", "0.4661379", "0.46604508", "0.46540654", "0.4634815", "0.46341863", "0.46318045", "0.4628978", "0.46269175", "0.462553", "0.46210784", "0.46188915", "0.4616381", "0.4601474", "0.45945475", "0.45890605", "0.45860982", "0.45840174", "0.45817828", "0.4577725", "0.45757246", "0.45755768", "0.45734036", "0.45673597", "0.45506477", "0.45473534", "0.45388833", "0.4537344", "0.45306", "0.45283306", "0.45271444", "0.45176086", "0.45139164", "0.45123142", "0.45061395", "0.45025536", "0.45025536", "0.45025536", "0.45025536", "0.45025536", "0.45025536" ]
0.82517755
0
Make request by given request context.
func (op *OpQuery) Make(ctx *RequestCtx) (*Request, error) { switch { case op.sobjectName == "": return nil, errors.New("missing Sobject name") case len(op.selectFileds) <= 0: return nil, errors.New("missing select fields") default: return NewRequest(http.MethodGet, ctx.QueryURL(op.makeQueryStatment()), nil), nil } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) WithContext(ctx context.Context) *Request", "func (req *GetRequest) Context(ctx context.Context) *GetRequest {\n\treq.impl = req.impl.Context(ctx)\n\n\treturn req\n}", "func (r *Request) Context() context.Context", "func DoCtx(ctx context.Context, req *http.Request, resp interface{}) (*http.Response, error) {\n\tr := req.Clone(ctx)\n\n\treturn Do(r, resp)\n}", "func DoRequest(requestType string, uri string, target string) string {\n\t// Get the BaseURL from viper config\n\tBaseURL = viper.GetString(\"BaseURL\")\n\n\treturn DoRequestImpl(requestType, BaseURL, uri, target)\n}", "func DoRequest(t *testing.T, r *gin.Engine, method, path, reqBody string, headers ...http.Header) *httptest.ResponseRecorder {\n\tt.Helper()\n\n\tvar body io.Reader\n\tif reqBody != \"\" {\n\t\tbody = bytes.NewBufferString(reqBody)\n\t}\n\treq, _ := http.NewRequestWithContext(context.TODO(), method, path, body)\n\tif len(headers) == 0 {\n\t\treq.Header.Set(\"content-type\", \"application/json\")\n\t} else {\n\t\tfor _, header := range headers {\n\t\t\treq.Header = header\n\t\t}\n\t}\n\tresp := newCloseNotifyingRecorder()\n\tr.ServeHTTP(resp, req)\n\treturn resp.ResponseRecorder\n}", "func requestWithLaunchIDContext(r *http.Request, launchID string) *http.Request {\n\treturn requestWithNewContextValue(r, launchIDKey, launchID)\n}", "func (c *auth) request(ctx context.Context, method string, url string, data string, target interface{}) error {\n\tauthorization := buildBasicAuthorization(c.clientID, c.clientSecret)\n\n\treturn c.sC.Call(backendClientParams{\n\t\tctx: ctx,\n\t\tmethod: method,\n\t\turl: url,\n\t\tauthorization: authorization,\n\t\tbody: strings.NewReader(data),\n\t\ttarget: target,\n\t})\n}", "func (context *Context) Request(req map[string]interface{}) (err error) {\n\t_, err = context.Transaction(req)\n\treturn\n}", "func (c *Client) doRequest(\n method string,\n route string,\n queryValues map[string]string,\n body []byte,\n) (*RawResponse, error) {\n req := fasthttp.AcquireRequest()\n resp := fasthttp.AcquireResponse()\n defer func() {\n if req != nil {\n req.SetConnectionClose()\n fasthttp.ReleaseRequest(req)\n }\n if resp != nil {\n resp.SetConnectionClose()\n fasthttp.ReleaseResponse(resp)\n }\n }()\n\n uri, err := utils.GetUri(c.apiUrl, []string{route}, queryValues)\n if err != nil {\n return nil, err\n }\n req.SetRequestURI(uri.String())\n\n if body != nil {\n req.Header.SetContentType(\"application/json\")\n req.SetBody(body)\n }\n\n req.Header.SetMethod(method)\n\n err = c.fastHttpClient.Do(req, resp)\n if err != nil {\n return nil, err\n }\n\n return &RawResponse{\n StatusCode: resp.StatusCode(),\n Body: resp.Body(),\n }, nil\n}", "func (ri *RestInvoker) ContextDo(ctx context.Context, req *rest.Request, options ...InvocationOption) (*rest.Response, error) {\n\topts := getOpts(string(req.GetRequest().Host()), options...)\n\topts.Protocol = common.ProtocolRest\n\tif len(opts.Filters) == 0 {\n\t\topts.Filters = ri.opts.Filters\n\t}\n\tif string(req.GetRequest().URI().Scheme()) != \"cse\" {\n\t\treturn nil, fmt.Errorf(\"Scheme invalid: %s, only support cse://\", req.GetRequest().URI().Scheme())\n\t}\n\tif req.GetHeader(\"Content-Type\") == \"\" {\n\t\treq.SetHeader(\"Content-Type\", \"application/json\")\n\t}\n\tnewReq := req.Copy()\n\tdefer newReq.Close()\n\tresp := rest.NewResponse()\n\tnewReq.SetHeader(common.HeaderSourceName, config.SelfServiceName)\n\tinv := invocation.CreateInvocation()\n\twrapInvocationWithOpts(inv, opts)\n\tinv.AppID = config.GlobalDefinition.AppID\n\tinv.MicroServiceName = string(req.GetRequest().Host())\n\tinv.Args = newReq\n\tinv.Reply = resp\n\tinv.Ctx = ctx\n\tinv.URLPathFormat = req.Req.URI().String()\n\tinv.MethodType = req.GetMethod()\n\tc, err := handler.GetChain(common.Consumer, ri.opts.ChainName)\n\tif err != nil {\n\t\tlager.Logger.Errorf(err, \"Handler chain init err.\")\n\t\treturn nil, err\n\t}\n\tc.Next(inv, func(ir *invocation.InvocationResponse) error {\n\t\terr = ir.Err\n\t\treturn err\n\t})\n\treturn resp, err\n}", "func RequestFromContext(ctx context.Context) Request {\n\tif p, ok := ctx.Value(consumerKey).(Request); ok {\n\t\treturn p\n\t}\n\treturn Request{}\n}", "func ReqFromContext(ctx context.Context) (*http.Request, bool) {\n\tr, ok := ctx.Value(requestKey).(*http.Request)\n\treturn r, ok\n}", "func RequestFromContext(ctx context.Context) (*http.Request, bool) {\n\tr, ok := ctx.Value(requestKey).(*http.Request)\n\treturn r, ok\n}", "func (ri *RestInvoker) ContextDo(ctx context.Context, req *rest.Request, options ...InvocationOption) (*rest.Response, error) {\n\tif string(req.GetRequest().URL.Scheme) != \"cse\" {\n\t\treturn nil, fmt.Errorf(\"scheme invalid: %s, only support cse://\", req.GetRequest().URL.Scheme)\n\t}\n\n\topts := getOpts(req.GetRequest().Host, options...)\n\topts.Protocol = common.ProtocolRest\n\n\tresp := rest.NewResponse()\n\n\tinv := invocation.New(ctx)\n\twrapInvocationWithOpts(inv, opts)\n\tinv.MicroServiceName = req.GetRequest().Host\n\t// TODO load from openAPI schema\n\t// inv.SchemaID = schemaID\n\t// inv.OperationID = operationID\n\tinv.Args = req\n\tinv.Reply = resp\n\tinv.URLPathFormat = req.Req.URL.Path\n\n\tinv.SetMetadata(common.RestMethod, req.GetMethod())\n\n\terr := ri.invoke(inv)\n\treturn resp, err\n}", "func (ri *RestInvoker) ContextDo(ctx context.Context, req *http.Request, options ...InvocationOption) (*http.Response, error) {\n\tif req.URL.Scheme != HTTP && req.URL.Scheme != HTTPS {\n\t\treturn nil, fmt.Errorf(\"scheme invalid: %s, only support http(s)://\", req.URL.Scheme)\n\t}\n\tcommon.SetXCSEContext(map[string]string{common.HeaderSourceName: runtime.ServiceName}, req)\n\t// set headers to Ctx\n\tif len(req.Header) > 0 {\n\t\tm, ok := ctx.Value(common.ContextHeaderKey{}).(map[string]string)\n\t\tif !ok {\n\t\t\tm = make(map[string]string)\n\t\t}\n\t\tctx = context.WithValue(ctx, common.ContextHeaderKey{}, m)\n\t\tfor k := range req.Header {\n\t\t\tm[k] = req.Header.Get(k)\n\t\t}\n\t}\n\n\topts := getOpts(options...)\n\tservice, port, err := util.ParseServiceAndPort(req.Host)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\topts.Protocol = common.ProtocolRest\n\topts.Port = port\n\n\tresp := rest.NewResponse()\n\n\tinv := invocation.New(ctx)\n\tinv.MicroServiceName = service\n\twrapInvocationWithOpts(inv, opts)\n\n\t//TODO load from openAPI schema\n\tinv.SchemaID = port\n\tif inv.SchemaID == \"\" {\n\t\tinv.SchemaID = \"rest\"\n\t}\n\tinv.OperationID = req.URL.Path\n\tinv.Args = req\n\tinv.Reply = resp\n\tinv.URLPath = req.URL.Path\n\n\tinv.SetMetadata(common.RestMethod, req.Method)\n\n\terr = ri.invoke(inv)\n\tif err == nil {\n\t\tsetCookieToCache(*inv, getNamespaceFromMetadata(opts.Metadata))\n\t}\n\treturn resp, err\n}", "func (c *Client) DoRequest(ctx context.Context, method, path string, headers map[string]string, body interface{}) (*http.Response, error) {\n\tlogger := c.logger.With(zap.String(\"method\", method), zap.String(\"path\", path))\n\n\tvar buf io.Reader\n\tif body != nil {\n\t\tb, err := json.Marshal(body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlogger.Debug(\"create http request body\", zap.Any(\"payload\", string(b)))\n\t\tbuf = bytes.NewBuffer(b)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, method, fmt.Sprintf(\"%s/%s\", c.endpoint.String(), path), buf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor key, value := range headers {\n\t\treq.Header.Add(key, value)\n\t}\n\n\treturn c.httpClient.Do(req)\n}", "func (vr *VirtualResource) doRequest(method, id string, data interface{}) (*http.Response, error) {\n\treq, err := vr.c.MakeRequest(method, BasePath+VirtualEndpoint+\"/\"+id, data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp, err := vr.c.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn resp, nil\n}", "func Request(ctx context.Context) *http.Request {\n\treturn ctx.Value(reqKey).(*http.Request)\n}", "func requestWithNewContextValue(r *http.Request, key ltiContextKey, value interface{}) *http.Request {\n\tnewRequest := r.WithContext(context.WithValue(r.Context(), key, value))\n\treturn newRequest\n}", "func HttpRequestFromContext(ctx context.Context) (*http.Request, error) {\n\thttpVal := ctx.Value(contextKeyHttpRequest)\n\n\tif httpVal == nil {\n\t\treturn nil, oidc.ErrServerError()\n\t}\n\n\thttpRequest := httpVal.(*http.Request)\n\n\tif httpRequest == nil {\n\t\treturn nil, oidc.ErrServerError()\n\t}\n\n\treturn httpRequest, nil\n}", "func (c *Client) DoRequest(ctx context.Context, method, url string, data ...interface{}) (resp *Response, err error) {\n\treq, err := c.prepareRequest(ctx, method, url, data...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Client middleware.\n\tif len(c.middlewareHandler) > 0 {\n\t\tmdlHandlers := make([]HandlerFunc, 0, len(c.middlewareHandler)+1)\n\t\tmdlHandlers = append(mdlHandlers, c.middlewareHandler...)\n\t\tmdlHandlers = append(mdlHandlers, func(cli *Client, r *http.Request) (*Response, error) {\n\t\t\treturn cli.callRequest(r)\n\t\t})\n\t\tctx = context.WithValue(req.Context(), clientMiddlewareKey, &clientMiddleware{\n\t\t\tclient: c,\n\t\t\thandlers: mdlHandlers,\n\t\t\thandlerIndex: -1,\n\t\t})\n\t\treq = req.WithContext(ctx)\n\t\tresp, err = c.Next(req)\n\t} else {\n\t\tresp, err = c.callRequest(req)\n\t}\n\treturn resp, err\n}", "func (c *Executor) do(request *http.Request, followRedirects bool) (*http.Response, error) {\n\tclient, err := c.clientProvider.Client(followRedirects)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error executing request, failed to get the underlying HTTP client: %w\", err)\n\t}\n\tr, err := client.Do(request)\n\tif err != nil {\n\t\t// if we get an error because the context was cancelled, the context's error is more useful.\n\t\tctx := request.Context()\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, ctx.Err()\n\t\tdefault:\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error executing request, failed during HTTP request send: %w\", err)\n\t}\n\treturn r, nil\n}", "func (c *Client) request(ctx context.Context, method string, url string, result interface{}, body interface{}) error {\n\tdefer c.timeTrack(time.Now(), fmt.Sprintf(\"[%s] %s\", method, url))\n\n\tctx, cancel := context.WithTimeout(ctx, c.requestTimeout)\n\tdefer cancel()\n\n\trequest, err := c.getRequestWithToken(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif result != nil {\n\t\trequest.SetResult(result)\n\t}\n\n\tif body != nil {\n\t\trequest.SetBody(body)\n\t}\n\n\tresponse, err := c.executeRequestWithMethod(request, method, url)\n\tif err != nil {\n\t\tc.logger.Errorf(err.Error())\n\n\t\treturn fmt.Errorf(err.Error())\n\t}\n\n\treturn c.checkResponseStatus(response)\n}", "func (c *Context) Request(body interface{}) (req *Request, err error) {\n\tdefer c.Req.Body.Close()\n\n\treq, err = RequestReader(c.Req.Body, body)\n\treturn\n}", "func doRequest(requestMethod, requestUrl,\n\trequestData string) (*http.Response, error) {\n\t// These will hold the return value.\n\tvar res *http.Response\n\tvar err error\n\n\t\n\t// Convert method to uppercase for easier checking.\n\tupperRequestMethod := strings.ToUpper(requestMethod)\n\tswitch upperRequestMethod {\n\tcase \"GET\":\n\t\t// Use the HTTP library Get() method.\n\t\tres, err = http.Get(requestUrl)\n\t\t//fmt.Printf(\"!!! res=\", res)\n\t\t//fmt.Printf(\"error=\", err.Error())\n\n\tdefault:\n\t\t// We doń't know how to handle this request.\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"invalid --request_method provided : %s\",\n\t\t\t\trequestMethod)\n\t}\n\n\treturn res, err\n}", "func newRequestContext(ctx context.Context, req *http.Request) context.Context {\n\treturn context.WithValue(ctx, requestKey, req)\n}", "func (r *Search) HttpRequest(ctx context.Context) (*http.Request, error) {\n\tvar path strings.Builder\n\tvar method string\n\tvar req *http.Request\n\n\tvar err error\n\n\tif len(r.deferred) > 0 {\n\t\tfor _, f := range r.deferred {\n\t\t\tdeferredErr := f(r.req)\n\t\t\tif deferredErr != nil {\n\t\t\t\treturn nil, deferredErr\n\t\t\t}\n\t\t}\n\t}\n\n\tif r.raw != nil {\n\t\tr.buf.ReadFrom(r.raw)\n\t} else if r.req != nil {\n\n\t\tdata, err := json.Marshal(r.req)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not serialise request for Search: %w\", err)\n\t\t}\n\n\t\tr.buf.Write(data)\n\n\t}\n\n\tr.path.Scheme = \"http\"\n\n\tswitch {\n\tcase r.paramSet == 0:\n\t\tpath.WriteString(\"/\")\n\t\tpath.WriteString(\"_search\")\n\n\t\tmethod = http.MethodPost\n\tcase r.paramSet == indexMask:\n\t\tpath.WriteString(\"/\")\n\n\t\tpath.WriteString(r.index)\n\t\tpath.WriteString(\"/\")\n\t\tpath.WriteString(\"_search\")\n\n\t\tmethod = http.MethodPost\n\t}\n\n\tr.path.Path = path.String()\n\tr.path.RawQuery = r.values.Encode()\n\n\tif r.path.Path == \"\" {\n\t\treturn nil, ErrBuildPath\n\t}\n\n\tif ctx != nil {\n\t\treq, err = http.NewRequestWithContext(ctx, method, r.path.String(), r.buf)\n\t} else {\n\t\treq, err = http.NewRequest(method, r.path.String(), r.buf)\n\t}\n\n\treq.Header = r.headers.Clone()\n\n\tif req.Header.Get(\"Content-Type\") == \"\" {\n\t\tif r.buf.Len() > 0 {\n\t\t\treq.Header.Set(\"Content-Type\", \"application/vnd.elasticsearch+json;compatible-with=8\")\n\t\t}\n\t}\n\n\tif req.Header.Get(\"Accept\") == \"\" {\n\t\treq.Header.Set(\"Accept\", \"application/vnd.elasticsearch+json;compatible-with=8\")\n\t}\n\n\tif err != nil {\n\t\treturn req, fmt.Errorf(\"could not build http.Request: %w\", err)\n\t}\n\n\treturn req, nil\n}", "func (r *Request) doRequest(client httpOperations) (*http.Response, error) {\n\n\treqBody := func(body []byte) *bytes.Buffer {\n\t\tif len(body) != 0 {\n\t\t\treturn bytes.NewBuffer(body)\n\t\t}\n\t\treturn &bytes.Buffer{}\n\t}(r.requestBody)\n\n\trequest, err := http.NewRequest(r.httpVerb, r.url, reqBody)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Error While Creating Request\")\n\t}\n\tfor k, v := range r.headers {\n\t\trequest.Header.Set(k, v)\n\t}\n\n\t//Add Basic auth\n\tif !reflect.DeepEqual(r.basicAuth, basicAuth{}) {\n\t\trequest.SetBasicAuth(r.basicAuth.username, r.basicAuth.password)\n\t\tr.basicAuth = basicAuth{}\n\t}\n\n\t// command, _ := GetCurlCommand(request)\n\t// r.Hammer.logMessage(command.String())\n\n\trequest = request.WithContext(r.ctx)\n\tvar response *http.Response\n\n\tdoerr := httpDo(r.ctx, client, request, func(resp *http.Response, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tresponse = resp\n\t\treturn nil\n\t})\n\tif doerr != nil {\n\t\treturn response, doerr\n\t}\n\n\treturn response, err\n}", "func (hr HttpRequest) makeRequest(path string, method string) (*http.Response, error) {\n\treq, err := http.NewRequest(method, path, nil)\n\treq.Header.Set(\"User-Agent\", hr.UserAgent())\n\tresp, err := hr.client.Do(req)\n\tif err != nil {\n\t\tlog.Fatalf(\"Do Request: %s\", err)\n\t\treturn nil, err\n\t}\n\tfor _, h := range hr.handlers {\n\t\terr = h(resp)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn resp, nil\n}", "func (t *TokensServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"TokensClient.BeginCreate\":\n\t\tresp, err = t.dispatchBeginCreate(req)\n\tcase \"TokensClient.BeginDelete\":\n\t\tresp, err = t.dispatchBeginDelete(req)\n\tcase \"TokensClient.Get\":\n\t\tresp, err = t.dispatchGet(req)\n\tcase \"TokensClient.NewListPager\":\n\t\tresp, err = t.dispatchNewListPager(req)\n\tcase \"TokensClient.BeginUpdate\":\n\t\tresp, err = t.dispatchBeginUpdate(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (k *Client) doRequest(r *request) (*http.Response, error) {\n\treq, err := http.NewRequest(r.method, k.baseURL+r.url, r.body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tif r.query != nil {\n\t\treq.URL.RawQuery = r.query.Encode()\n\t}\n\treturn k.httpClient.Do(req)\n}", "func (r InboundRequest) WithContext(ctx context.Context) *InboundRequest {\n return &InboundRequest{\n Request: *r.Request.WithContext(ctx),\n PathParams: r.PathParams,\n }\n}", "func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error) {\n\treturn DoRequestWithClient(ctx, http.DefaultClient, req)\n}", "func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error) {\n\treturn DoRequestWithClient(ctx, http.DefaultClient, req)\n}", "func (req MinRequest) Context(ctx context.Context) MinRequest {\n\treq.impl = req.impl.Context(ctx)\n\n\treturn req\n}", "func (r *RouteFiltersServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"RouteFiltersClient.BeginCreateOrUpdate\":\n\t\tresp, err = r.dispatchBeginCreateOrUpdate(req)\n\tcase \"RouteFiltersClient.BeginDelete\":\n\t\tresp, err = r.dispatchBeginDelete(req)\n\tcase \"RouteFiltersClient.Get\":\n\t\tresp, err = r.dispatchGet(req)\n\tcase \"RouteFiltersClient.NewListPager\":\n\t\tresp, err = r.dispatchNewListPager(req)\n\tcase \"RouteFiltersClient.NewListByResourceGroupPager\":\n\t\tresp, err = r.dispatchNewListByResourceGroupPager(req)\n\tcase \"RouteFiltersClient.UpdateTags\":\n\t\tresp, err = r.dispatchUpdateTags(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (c *client) request(r *request, ret interface{}) (int, error) {\n\treturn c.requestWithContext(context.Background(), r, ret)\n}", "func makeContext(ctx *context, path *string, headers, queryParams map[string][]string, pathParams map[string]string, sourceIP string, rawBody *string) {\n\theaders, rawCookies := filterHeaders(headers)\n\tcookies := parseCookies(rawCookies)\n\tbody := parseBody(headers, rawBody)\n\t*ctx = context{\n\t\trequestSourceIP: sourceIP,\n\t\trequestRawURI: path,\n\t\trequestHeaders: headers,\n\t\trequestCookies: cookies,\n\t\trequestQuery: queryParams,\n\t\trequestPathParams: pathParams,\n\t\trequestBody: body,\n\t}\n}", "func executeRequest(method string, url string, body *bytes.Buffer, asAdmin bool) *http.Response {\n\tconfig, err := loadConfig(testConfigPath)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to load config %s\", err))\n\t}\n\n\th := handler{\n\t\tlogger: log.NewNopLogger(),\n\t\tnewCredentialsProvider: newMockProvider,\n\t\targo: mockWorkflowSvc{},\n\t\tconfig: config,\n\t\tgitClient: newMockGitClient(),\n\t\tnewCredsProviderSvc: mockCredsProvSvc,\n\t\tenv: env.Vars{\n\t\t\tAdminSecret: testPassword,\n\t\t},\n\t\tdbClient: newMockDB(),\n\t}\n\n\tvar router = setupRouter(h)\n\treq, _ := http.NewRequest(method, url, body)\n\tauthorizationHeader := \"vault:user:\" + testPassword\n\tif asAdmin {\n\t\tauthorizationHeader = \"vault:admin:\" + testPassword\n\t}\n\treq.Header.Add(\"Authorization\", authorizationHeader)\n\tw := httptest.NewRecorder()\n\trouter.ServeHTTP(w, req)\n\treturn w.Result()\n}", "func (d *Dao) doHTTPRequest(c context.Context, uri, ip string, params url.Values, res interface{}) (err error) {\n\tenc, err := d.sign(params)\n\tif err != nil {\n\t\terr = pkgerr.Wrapf(err, \"uri:%s,params:%v\", uri, params)\n\t\treturn\n\t}\n\tif enc != \"\" {\n\t\turi = uri + \"?\" + enc\n\t}\n\n\treq, err := xhttp.NewRequest(xhttp.MethodGet, uri, nil)\n\tif err != nil {\n\t\terr = pkgerr.Wrapf(err, \"method:%s,uri:%s\", xhttp.MethodGet, uri)\n\t\treturn\n\t}\n\treq.Header.Set(_userAgent, \"[email protected] \"+env.AppID)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn d.client.Do(c, req, res)\n}", "func DoRequestWithTrace(client *http.Client, req *http.Request) (*Trace, *http.Response, error) {\n\tclientTrace, ctx := NewTrace(req.URL.String())\n\treq = req.WithContext(ctx)\n\n\tresp, err := client.Do(req)\n\tif resp != nil {\n\t\tresp.Body = spyBodyReader{\n\t\t\tReadCloser: resp.Body,\n\t\t\tbodyReadTime: &clientTrace.BodyReadTime,\n\t\t}\n\t}\n\n\treturn clientTrace, resp, err\n}", "func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"Client.Create\":\n\t\tresp, err = s.dispatchCreate(req)\n\tcase \"Client.GetScript\":\n\t\tresp, err = s.dispatchGetScript(req)\n\tcase \"Client.NewListPager\":\n\t\tresp, err = s.dispatchNewListPager(req)\n\tcase \"Client.PolicyAssignment\":\n\t\tresp, err = s.dispatchPolicyAssignment(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func Request(ctx context.Context) *events.APIGatewayProxyRequest {\n\trequest, _ := ctx.Value(ctxKeyEventContext).(*events.APIGatewayProxyRequest)\n\treturn request\n}", "func (f Factory) Request(method string, arguments interface{}) (request Request) {\n\trequest.Token = f.Token\n\trequest.Method = method\n\tif arguments != nil {\n\t\tvar err error\n\t\trequest.Values, err = query.Values(arguments)\n\t\tmust(err)\n\t}\n\treturn request\n}", "func (r *tee) Request(fc filters.FilterContext) {\n\treq := fc.Request()\n\tcopyOfRequest, tr, err := cloneRequest(r, req)\n\tif err != nil {\n\t\tfc.Logger().Warnf(\"tee: error while cloning the tee request %v\", err)\n\t\treturn\n\t}\n\n\treq.Body = tr\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif r.shadowRequestDone != nil {\n\t\t\t\tr.shadowRequestDone()\n\t\t\t}\n\t\t}()\n\n\t\trsp, err := r.client.Do(copyOfRequest)\n\t\tif err != nil {\n\t\t\tfc.Logger().Warnf(\"tee: error while tee request %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\trsp.Body.Close()\n\t}()\n}", "func request(w http.ResponseWriter, r *http.Request, srv *Server) *Request {\n\treq := new(Request)\n\treq.W = w\n\treq.R = r\n\treq.Vars = gmux.Vars(r)\n\treq.Method = r.Method\n\treq.srv = srv\n\treturn req\n}", "func (clientHandler) Request(ctx context.Context, conn *jsonrpc2.Conn, direction jsonrpc2.Direction, r *jsonrpc2.WireRequest) context.Context {\n\treturn ctx\n}", "func (c *Customer) makeRequest(d *Dispatcher) {\n\td.enqueueCustomerRequest(c)\n}", "func makeRequest(r request) *http.Response {\n\n\treq := bakeRequest(r)\n\tclient := &http.Client{}\n\n\tresp, err := client.Do(req)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn resp\n}", "func UseRequest(r *http.Request) context.Context {\n\treturn useRDS(useMC(useTQ(useGI(appengine.NewContext(r)))))\n}", "func sendWithContext(ctx context.Context, httpClient *http.Client, url string, body io.Reader, opt *Options) (*http.Response, error) {\n\tv, _ := query.Values(opt)\n\n\t// fmt.Print(v.Encode()) will output: \"city=0&mr=1&pb=4&pro=0&yys=0\"\n\tAPIEndpoint := fmt.Sprintf(\"%s&%s\", url, v.Encode())\n\tfmt.Println(APIEndpoint)\n\t// Change NewRequest to NewRequestWithContext and pass context it\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, APIEndpoint, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// http.DefaultClient\n\tres, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "func (c *Client) doRequest(method string, fullUrl string, body io.Reader) (*http.Response, error) {\n\tc.headers[\"Accept\"] = \"application/json\"\n\tclient := &http.Client{}\n\tlog.Println(\"teamcity-sdk Request:\", method, fullUrl)\n\treq, _ := http.NewRequest(method, fullUrl, body)\n\tfor k, v := range c.headers {\n\t\treq.Header.Add(k, v)\n\t}\n\treturn client.Do(req)\n}", "func (r *Forecast) HttpRequest(ctx context.Context) (*http.Request, error) {\n\tvar path strings.Builder\n\tvar method string\n\tvar req *http.Request\n\n\tvar err error\n\n\tif r.raw != nil {\n\t\tr.buf.ReadFrom(r.raw)\n\t} else if r.req != nil {\n\t\tdata, err := json.Marshal(r.req)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not serialise request for Forecast: %w\", err)\n\t\t}\n\n\t\tr.buf.Write(data)\n\t}\n\n\tr.path.Scheme = \"http\"\n\n\tswitch {\n\tcase r.paramSet == jobidMask:\n\t\tpath.WriteString(\"/\")\n\t\tpath.WriteString(\"_ml\")\n\t\tpath.WriteString(\"/\")\n\t\tpath.WriteString(\"anomaly_detectors\")\n\t\tpath.WriteString(\"/\")\n\n\t\tpath.WriteString(r.jobid)\n\t\tpath.WriteString(\"/\")\n\t\tpath.WriteString(\"_forecast\")\n\n\t\tmethod = http.MethodPost\n\t}\n\n\tr.path.Path = path.String()\n\tr.path.RawQuery = r.values.Encode()\n\n\tif r.path.Path == \"\" {\n\t\treturn nil, ErrBuildPath\n\t}\n\n\tif ctx != nil {\n\t\treq, err = http.NewRequestWithContext(ctx, method, r.path.String(), r.buf)\n\t} else {\n\t\treq, err = http.NewRequest(method, r.path.String(), r.buf)\n\t}\n\n\treq.Header = r.headers.Clone()\n\n\tif req.Header.Get(\"Content-Type\") == \"\" {\n\t\tif r.buf.Len() > 0 {\n\t\t\treq.Header.Set(\"Content-Type\", \"application/vnd.elasticsearch+json;compatible-with=8\")\n\t\t}\n\t}\n\n\tif req.Header.Get(\"Accept\") == \"\" {\n\t\treq.Header.Set(\"Accept\", \"application/vnd.elasticsearch+json;compatible-with=8\")\n\t}\n\n\tif err != nil {\n\t\treturn req, fmt.Errorf(\"could not build http.Request: %w\", err)\n\t}\n\n\treturn req, nil\n}", "func (c *ApiClient) request(ctx context.Context, method, uri, meta string, args map[string]string) (*http.Response, error) {\n\treq, err := http.NewRequestWithContext(ctx, method, uri, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to generate clickhouse %s request: %s\", meta, err)\n\t}\n\n\tq := req.URL.Query()\n\tfor key, value := range args {\n\t\tq.Add(key, value)\n\t}\n\treq.URL.RawQuery = q.Encode()\n\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to make clickhouse %s request: %s\", meta, err)\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\tb, err := ioutil.ReadAll(resp.Body)\n\t\tdefer resp.Body.Close()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read clieckhouse %s request body: %s\", meta, err)\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"clickhouse %s request failed with status code %d and body: \\\"%s\\\"\",\n\t\t\tmeta, resp.StatusCode, string(b),\n\t\t)\n\t}\n\n\tc.logger.Printf(\"clickhouse %s request success\", meta)\n\n\treturn resp, nil\n}", "func (r *restClient) doWithContext(ctx context.Context, method string, path string, body []byte, headers []Header) (*http.Response, error) {\n\n\tbodyBytes := bytes.NewBuffer(body)\n\n\t// Create the request\n\tvar request *http.Request\n\tvar err error\n\tif ctx == nil {\n\t\trequest, err = http.NewRequest(method, r.baseURL+path, bodyBytes)\n\t} else {\n\n\t\trequest, err = http.NewRequestWithContext(ctx, method, r.baseURL+path, bodyBytes)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add header\n\tfor _, header := range headers {\n\t\trequest.Header.Add(header.Key, header.Value)\n\t}\n\n\tresponse, err := r.Client.Do(request)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Cookie can potentially be expired. If we are unauthorized to send a request, we should try to login again.\n\tif response.StatusCode == http.StatusForbidden {\n\t\terr = r.login()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tbodyBytes = bytes.NewBuffer(body)\n\n\t\trequest, err := http.NewRequest(method, r.baseURL+path, bodyBytes)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, header := range headers {\n\t\t\trequest.Header.Add(header.Key, header.Value)\n\t\t}\n\n\t\tresponse, err := r.Client.Do(request)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn response, nil\n\t}\n\n\treturn response, nil\n}", "func (v *VPNSiteLinksServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"VPNSiteLinksClient.Get\":\n\t\tresp, err = v.dispatchGet(req)\n\tcase \"VPNSiteLinksClient.NewListByVPNSitePager\":\n\t\tresp, err = v.dispatchNewListByVPNSitePager(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (c *Client) do(req *http.Request, v interface{}) error {\n\treturn do(c.httpClient, req, v)\n}", "func makeContext(request *http.Request, responseWriter http.ResponseWriter, pathParams ParameterValueMap) *Context {\n\n\tvar context *Context = new(Context)\n\n\t// set the parameters\n\tcontext.Request = request\n\tcontext.ResponseWriter = responseWriter\n\tcontext.PathParams = pathParams\n\n\t// note the format\n\tcontext.Format = getFormatForRequest(request)\n\n\t// <temporary fix for app engine>\n\t// do we need to fix the cookies?\n\tif request.Header != nil {\n\t\tif request.Header[\"Cookie\"] != nil {\n\t\t\tif len(request.Header[\"Cookie\"]) > 0 {\n\t\t\t\tparseCookieHeader(request.Header[\"Cookie\"][0], request)\n\t\t\t}\n\t\t}\n\t}\n\t// </temporary fix for app engine>\n\n\t// return the new context\n\treturn context\n}", "func execRequest(_ int, p *gop.Context) {\n\tret, ret1 := cgi.Request()\n\tp.Ret(0, ret, ret1)\n}", "func (req *SelectRequest) Context(ctx context.Context) *SelectRequest {\n\treq.impl = req.impl.Context(ctx)\n\n\treturn req\n}", "func (c *ActionController) Request(ctx *app.RequestActionContext) error {\n\t// ActionController_Request: start_implement\n\n\t// Put your logic here\n\n\t// Retrieve the token claims\n\ttoken := jwt.ContextJWT(ctx)\n\tif token == nil {\n\t\treturn fmt.Errorf(\"JWT token is missing from context\") // internal error\n\t}\n\tclaims := token.Claims.(jwtgo.MapClaims)\n\tfmt.Println(claims)\n\t// Use the claims to authorize\n\tsubject := claims[\"user\"]\n\tif subject != \"subject\" {\n\t\t// A real app would probably use an \"Unauthorized\" response here\n\n\t\treturn ctx.OK([]byte(\"OK Unauthorized\"))\n\t}\n\n\treturn ctx.OK([]byte(\"OK\"))\n\t// ActionController_Request: end_implement\n}", "func (r *restClient) do(method string, path string, body []byte, headers []Header) (*http.Response, error) {\n\n\treturn r.doWithContext(nil, method, path, body, headers)\n}", "func (fhp *FastHTTPProvider) Do(ctx context.Context, request *fasthttp.Request) (*fasthttp.Response, error) {\n\treturn fhp.request(ctx, request, nil)\n}", "func Context(r *http.Request) context.Context {\n\treturn getContext(r)\n}", "func (c *Client) request(ctx context.Context, method, uri string, reqBody io.Reader, headers http.Header) (*http.Response, error) {\n\treq, err := http.NewRequestWithContext(ctx, method, c.BaseURL.String()+uri, reqBody)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"HTTP request creation failed: %w\", err)\n\t}\n\n\tcombinedHeaders := make(http.Header)\n\tcopyHeader(combinedHeaders, c.Headers)\n\tcopyHeader(combinedHeaders, headers)\n\treq.Header = combinedHeaders\n\n\tif c.Key == \"\" && c.Email == \"\" && c.Token == \"\" && c.UserServiceKey == \"\" {\n\t\treturn nil, ErrMissingCredentials\n\t}\n\n\tif c.Key != \"\" {\n\t\treq.Header.Set(\"X-Auth-Key\", c.ClientParams.Key)\n\t\treq.Header.Set(\"X-Auth-Email\", c.ClientParams.Email)\n\t}\n\n\tif c.UserServiceKey != \"\" {\n\t\treq.Header.Set(\"X-Auth-User-Service-Key\", c.ClientParams.UserServiceKey)\n\t}\n\n\tif c.Token != \"\" {\n\t\treq.Header.Set(\"Authorization\", \"Bearer \"+c.ClientParams.Token)\n\t}\n\n\tif c.UserAgent != \"\" {\n\t\treq.Header.Set(\"User-Agent\", c.ClientParams.UserAgent)\n\t}\n\n\tif req.Header.Get(\"Content-Type\") == \"\" {\n\t\treq.Header.Set(\"Content-Type\", \"application/json\")\n\t}\n\n\tresp, err := c.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"HTTP request failed: %w\", err)\n\t}\n\n\treturn resp, nil\n}", "func (v *VirtualMachinesServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"VirtualMachinesClient.BeginAssessPatches\":\n\t\tresp, err = v.dispatchBeginAssessPatches(req)\n\tcase \"VirtualMachinesClient.BeginCapture\":\n\t\tresp, err = v.dispatchBeginCapture(req)\n\tcase \"VirtualMachinesClient.BeginConvertToManagedDisks\":\n\t\tresp, err = v.dispatchBeginConvertToManagedDisks(req)\n\tcase \"VirtualMachinesClient.BeginCreateOrUpdate\":\n\t\tresp, err = v.dispatchBeginCreateOrUpdate(req)\n\tcase \"VirtualMachinesClient.BeginDeallocate\":\n\t\tresp, err = v.dispatchBeginDeallocate(req)\n\tcase \"VirtualMachinesClient.BeginDelete\":\n\t\tresp, err = v.dispatchBeginDelete(req)\n\tcase \"VirtualMachinesClient.Generalize\":\n\t\tresp, err = v.dispatchGeneralize(req)\n\tcase \"VirtualMachinesClient.Get\":\n\t\tresp, err = v.dispatchGet(req)\n\tcase \"VirtualMachinesClient.BeginInstallPatches\":\n\t\tresp, err = v.dispatchBeginInstallPatches(req)\n\tcase \"VirtualMachinesClient.InstanceView\":\n\t\tresp, err = v.dispatchInstanceView(req)\n\tcase \"VirtualMachinesClient.NewListPager\":\n\t\tresp, err = v.dispatchNewListPager(req)\n\tcase \"VirtualMachinesClient.NewListAllPager\":\n\t\tresp, err = v.dispatchNewListAllPager(req)\n\tcase \"VirtualMachinesClient.NewListAvailableSizesPager\":\n\t\tresp, err = v.dispatchNewListAvailableSizesPager(req)\n\tcase \"VirtualMachinesClient.NewListByLocationPager\":\n\t\tresp, err = v.dispatchNewListByLocationPager(req)\n\tcase \"VirtualMachinesClient.BeginPerformMaintenance\":\n\t\tresp, err = v.dispatchBeginPerformMaintenance(req)\n\tcase \"VirtualMachinesClient.BeginPowerOff\":\n\t\tresp, err = v.dispatchBeginPowerOff(req)\n\tcase \"VirtualMachinesClient.BeginReapply\":\n\t\tresp, err = v.dispatchBeginReapply(req)\n\tcase \"VirtualMachinesClient.BeginRedeploy\":\n\t\tresp, err = v.dispatchBeginRedeploy(req)\n\tcase \"VirtualMachinesClient.BeginReimage\":\n\t\tresp, err = v.dispatchBeginReimage(req)\n\tcase \"VirtualMachinesClient.BeginRestart\":\n\t\tresp, err = v.dispatchBeginRestart(req)\n\tcase \"VirtualMachinesClient.RetrieveBootDiagnosticsData\":\n\t\tresp, err = v.dispatchRetrieveBootDiagnosticsData(req)\n\tcase \"VirtualMachinesClient.BeginRunCommand\":\n\t\tresp, err = v.dispatchBeginRunCommand(req)\n\tcase \"VirtualMachinesClient.SimulateEviction\":\n\t\tresp, err = v.dispatchSimulateEviction(req)\n\tcase \"VirtualMachinesClient.BeginStart\":\n\t\tresp, err = v.dispatchBeginStart(req)\n\tcase \"VirtualMachinesClient.BeginUpdate\":\n\t\tresp, err = v.dispatchBeginUpdate(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (i *instance) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error) {\n\treq, err := http.NewRequest(method, urlStr, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Make a context for this request.\n\tc := &context{\n\t\treq: req,\n\t\tsession: newSessionID(),\n\t\tinstance: i,\n\t}\n\n\t// Associate this request.\n\trelease := appengine_internal.RegisterTestContext(req, c)\n\ti.relFuncs = append(i.relFuncs, release)\n\n\treturn req, nil\n}", "func WithRequest(ctx context.Context, req *http.Request) context.Context {\n\treturn context.WithValue(ctx, reqKey, req)\n}", "func (x *XMLServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"XMLClient.GetACLs\":\n\t\tresp, err = x.dispatchGetACLs(req)\n\tcase \"XMLClient.GetBytes\":\n\t\tresp, err = x.dispatchGetBytes(req)\n\tcase \"XMLClient.GetComplexTypeRefNoMeta\":\n\t\tresp, err = x.dispatchGetComplexTypeRefNoMeta(req)\n\tcase \"XMLClient.GetComplexTypeRefWithMeta\":\n\t\tresp, err = x.dispatchGetComplexTypeRefWithMeta(req)\n\tcase \"XMLClient.GetEmptyChildElement\":\n\t\tresp, err = x.dispatchGetEmptyChildElement(req)\n\tcase \"XMLClient.GetEmptyList\":\n\t\tresp, err = x.dispatchGetEmptyList(req)\n\tcase \"XMLClient.GetEmptyRootList\":\n\t\tresp, err = x.dispatchGetEmptyRootList(req)\n\tcase \"XMLClient.GetEmptyWrappedLists\":\n\t\tresp, err = x.dispatchGetEmptyWrappedLists(req)\n\tcase \"XMLClient.GetHeaders\":\n\t\tresp, err = x.dispatchGetHeaders(req)\n\tcase \"XMLClient.GetRootList\":\n\t\tresp, err = x.dispatchGetRootList(req)\n\tcase \"XMLClient.GetRootListSingleItem\":\n\t\tresp, err = x.dispatchGetRootListSingleItem(req)\n\tcase \"XMLClient.GetServiceProperties\":\n\t\tresp, err = x.dispatchGetServiceProperties(req)\n\tcase \"XMLClient.GetSimple\":\n\t\tresp, err = x.dispatchGetSimple(req)\n\tcase \"XMLClient.GetURI\":\n\t\tresp, err = x.dispatchGetURI(req)\n\tcase \"XMLClient.GetWrappedLists\":\n\t\tresp, err = x.dispatchGetWrappedLists(req)\n\tcase \"XMLClient.GetXMsText\":\n\t\tresp, err = x.dispatchGetXMsText(req)\n\tcase \"XMLClient.JSONInput\":\n\t\tresp, err = x.dispatchJSONInput(req)\n\tcase \"XMLClient.JSONOutput\":\n\t\tresp, err = x.dispatchJSONOutput(req)\n\tcase \"XMLClient.ListBlobs\":\n\t\tresp, err = x.dispatchListBlobs(req)\n\tcase \"XMLClient.ListContainers\":\n\t\tresp, err = x.dispatchListContainers(req)\n\tcase \"XMLClient.PutACLs\":\n\t\tresp, err = x.dispatchPutACLs(req)\n\tcase \"XMLClient.PutBinary\":\n\t\tresp, err = x.dispatchPutBinary(req)\n\tcase \"XMLClient.PutComplexTypeRefNoMeta\":\n\t\tresp, err = x.dispatchPutComplexTypeRefNoMeta(req)\n\tcase \"XMLClient.PutComplexTypeRefWithMeta\":\n\t\tresp, err = x.dispatchPutComplexTypeRefWithMeta(req)\n\tcase \"XMLClient.PutEmptyChildElement\":\n\t\tresp, err = x.dispatchPutEmptyChildElement(req)\n\tcase \"XMLClient.PutEmptyList\":\n\t\tresp, err = x.dispatchPutEmptyList(req)\n\tcase \"XMLClient.PutEmptyRootList\":\n\t\tresp, err = x.dispatchPutEmptyRootList(req)\n\tcase \"XMLClient.PutEmptyWrappedLists\":\n\t\tresp, err = x.dispatchPutEmptyWrappedLists(req)\n\tcase \"XMLClient.PutRootList\":\n\t\tresp, err = x.dispatchPutRootList(req)\n\tcase \"XMLClient.PutRootListSingleItem\":\n\t\tresp, err = x.dispatchPutRootListSingleItem(req)\n\tcase \"XMLClient.PutServiceProperties\":\n\t\tresp, err = x.dispatchPutServiceProperties(req)\n\tcase \"XMLClient.PutSimple\":\n\t\tresp, err = x.dispatchPutSimple(req)\n\tcase \"XMLClient.PutURI\":\n\t\tresp, err = x.dispatchPutURI(req)\n\tcase \"XMLClient.PutWrappedLists\":\n\t\tresp, err = x.dispatchPutWrappedLists(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (c client) newRequest(ctx context.Context, method string, url string, body io.Reader) (*http.Request, error) {\n\treq, err := http.NewRequestWithContext(ctx, method, url, body)\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to build request %w\", err)\n\t}\n\n\treturn req, nil\n}", "func (c *Client) Request(verb, spath string, ro *RequestOptions) (*http.Request, error) {\n\tlog.Printf(\"[INFO] request: %s %s\", verb, spath)\n\n\tif ro == nil {\n\t\tro = new(RequestOptions)\n\t}\n\n\tu := *c.URL\n\tu.Path = path.Join(c.URL.Path, spath)\n\n\tif c.Token != \"\" {\n\t\tif ro.Headers == nil {\n\t\t\tro.Headers = make(map[string]string)\n\t\t}\n\t\tro.Headers[\"Authorization\"] = fmt.Sprintf(\"Bearer %s\", c.Token)\n\t}\n\n\treturn c.rawRequest(verb, &u, ro)\n}", "func (i *Instance) doRequest(ctx context.Context, url string) (map[string]interface{}, error) {\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf(\"%s%s\", i.address, url), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := i.client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode >= 200 && resp.StatusCode < 300 {\n\t\tvar data map[string]interface{}\n\n\t\terr = json.NewDecoder(resp.Body).Decode(&data)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn data, nil\n\t}\n\n\tvar res ResponseError\n\n\terr = json.NewDecoder(resp.Body).Decode(&res)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(res.Errors) > 0 {\n\t\treturn nil, fmt.Errorf(res.Errors[0].Msg)\n\t}\n\n\treturn nil, fmt.Errorf(\"%v\", res)\n}", "func (c *Executor) newHTTPRequest(request *Request) (*http.Request, error) {\n\tif request.context == nil {\n\t\treturn nil, errNilContext\n\t}\n\tif !isSupportedHTTPMethod(request.method) {\n\t\treturn nil, fmt.Errorf(\"error executing request, found unsupport HTTP method %s\", request.method)\n\t}\n\n\t// JSON encode the object and use that as the body if specified, otherwise use the body as-is\n\treqBody := request.body\n\tif request.object != nil {\n\t\tb, err := encodeBody(request.object)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error executing request, failed to encode the request object to JSON: %w\", err)\n\t\t}\n\t\treqBody = b\n\t}\n\tu := path.Join(c.apiAddress, request.pathAndQuery)\n\n\tr, err := http.NewRequestWithContext(request.context, request.method, u, reqBody)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error executing request, failed to create a new underlying HTTP request: %w\", err)\n\t}\n\tr.Header.Set(\"User-Agent\", c.userAgent)\n\tif request.contentType != \"\" {\n\t\tr.Header.Set(\"Content-type\", request.contentType)\n\t}\n\tif request.contentLength != nil {\n\t\tr.ContentLength = *request.contentLength\n\t}\n\tfor k, v := range request.headers {\n\t\tr.Header.Set(k, v)\n\t}\n\n\treturn r, nil\n}", "func DoHttpRequest(cfg *config.Configuration, req *http.Request, useCreds bool) (*http.Response, error) {\n\tvar creds auth.Creds\n\tif useCreds {\n\t\tc, err := auth.GetCreds(cfg, req)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcreds = c\n\t}\n\n\treturn doHttpRequest(cfg, req, creds)\n}", "func (c *Client) sendRequest(ctx context.Context, req *http.Request, result interface{}, overrideToken ...string) error {\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Accept\", \"application/json; charset=utf-8\")\n\n\tvar token string\n\tif len(overrideToken) > 0 {\n\t\ttoken = overrideToken[0]\n\t} else {\n\t\taccessToken, err := c.getAccessToken(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\ttoken = accessToken\n\t}\n\n\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", token))\n\treq = req.WithContext(ctx)\n\n\tres, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer res.Body.Close()\n\n\tif res.StatusCode < 200 || res.StatusCode >= 300 {\n\t\treturn c.parseError(res)\n\t}\n\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tlogrus.WithFields(logrus.Fields{\n\t\t\"status_code\": res.StatusCode,\n\t\t\"url\": req.URL.String(),\n\t}).Info(string(body))\n\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (p *ProvidersServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"ProvidersClient.Get\":\n\t\tresp, err = p.dispatchGet(req)\n\tcase \"ProvidersClient.GetAtTenantScope\":\n\t\tresp, err = p.dispatchGetAtTenantScope(req)\n\tcase \"ProvidersClient.NewListPager\":\n\t\tresp, err = p.dispatchNewListPager(req)\n\tcase \"ProvidersClient.NewListAtTenantScopePager\":\n\t\tresp, err = p.dispatchNewListAtTenantScopePager(req)\n\tcase \"ProvidersClient.ProviderPermissions\":\n\t\tresp, err = p.dispatchProviderPermissions(req)\n\tcase \"ProvidersClient.Register\":\n\t\tresp, err = p.dispatchRegister(req)\n\tcase \"ProvidersClient.RegisterAtManagementGroupScope\":\n\t\tresp, err = p.dispatchRegisterAtManagementGroupScope(req)\n\tcase \"ProvidersClient.Unregister\":\n\t\tresp, err = p.dispatchUnregister(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (fh *fetchHTTP) DoRequest(args *esitag.ResourceArgs) (http.Header, []byte, error) {\n\tif err := args.Validate(); err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"[esibackend] FetchHTTP.args.Validate\")\n\t}\n\n\t// TODO(CyS) external POST requests or GET with query string should forward\n\t// this data. So the http.NewRequest should then change to POST if the\n\t// configuration for this specific Tag tag allows it.\n\n\treq, err := http.NewRequest(\"GET\", args.URL, nil)\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrapf(err, \"[esibackend] Failed NewRequest for %q\", args.URL)\n\t}\n\n\tfor hdr, i := args.PrepareForwardHeaders(), 0; i < len(hdr); i = i + 2 {\n\t\treq.Header.Set(hdr[i], hdr[i+1])\n\t}\n\n\t// do we overwrite here the Timeout from args.ExternalReq ? or just adding our\n\t// own timeout?\n\tctx, cancel := context.WithTimeout(args.ExternalReq.Context(), args.Tag.Timeout)\n\tdefer cancel()\n\n\tresp, err := fh.client.Do(req.WithContext(ctx))\n\tif resp != nil && resp.Body != nil {\n\t\tdefer resp.Body.Close()\n\t}\n\t// If we got an error, and the context has been canceled,\n\t// the context's error is probably more useful.\n\tif err != nil {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tif cncl, ok := fh.client.Transport.(requestCanceller); ok {\n\t\t\t\tif args.Tag.Log.IsInfo() {\n\t\t\t\t\targs.Tag.Log.Info(\"esibackend.FetchHTTP.DoRequest.client.Transport.requestCanceller\",\n\t\t\t\t\t\tlog.String(\"url\", args.URL), loghttp.Request(\"backend_request\", req),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tcncl.CancelRequest(req)\n\t\t\t}\n\t\t\terr = errors.Wrap(ctx.Err(), \"[esibackend] Context Done\")\n\t\tdefault:\n\t\t}\n\t\treturn nil, nil, errors.Wrapf(err, \"[esibackend] FetchHTTP error for URL %q\", args.URL)\n\t}\n\n\tif resp.StatusCode != http.StatusOK { // this can be made configurable in an Tag tag\n\t\treturn nil, nil, errors.NotSupported.Newf(\"[backend] FetchHTTP: Response Code %q not supported for URL %q\", resp.StatusCode, args.URL)\n\t}\n\n\t// not yet worth to put the resp.Body reader into its own goroutine\n\n\tbuf := new(bytes.Buffer)\n\tmbs := int64(args.Tag.MaxBodySize) // overflow of uint into int ?\n\tn, err := buf.ReadFrom(io.LimitReader(resp.Body, mbs))\n\tif err != nil && err != io.EOF {\n\t\treturn nil, nil, errors.Wrapf(err, \"[esibackend] FetchHTTP.ReadFrom Body for URL %q failed\", args.URL)\n\t}\n\tif n >= mbs && args.Tag.Log != nil && args.Tag.Log.IsInfo() { // body has been cut off\n\t\targs.Tag.Log.Info(\"esibackend.FetchHTTP.LimitReader\",\n\t\t\tlog.String(\"url\", args.URL), log.Int64(\"bytes_read\", n), log.Int64(\"bytes_max_read\", mbs),\n\t\t)\n\t}\n\n\t//buf := new(bytes.Buffer) // no pool possible\n\t//mbs := int64(args.MaxBodySize) // overflow of uint into int ?\n\t//\n\t//done := make(chan struct{})\n\t//go func() {\n\t//\tvar n int64\n\t//\tn, err = buf.ReadFrom(io.LimitReader(resp.Body, mbs))\n\t//\tif err != nil && err != io.EOF {\n\t//\t\terr = errors.Wrapf(err, \"[esibackend] FetchHTTP.ReadFrom Body for URL %q failed\", args.URL)\n\t//\t}\n\t//\tif n >= mbs && args.Log != nil && args.Log.IsInfo() { // body has been cut off\n\t//\t\targs.Log.Info(\"esibackend.FetchHTTP.LimitReader\",\n\t//\t\t\tlog.String(\"url\", args.URL), log.Int64(\"bytes_read\", n), log.Int64(\"bytes_max_read\", mbs),\n\t//\t\t)\n\t//\t}\n\t//\n\t//\tdone <- struct{}{}\n\t//}()\n\t//<-done\n\n\treturn args.PrepareReturnHeaders(resp.Header), buf.Bytes(), nil\n}", "func Context(h http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// user service\n\t\tu := user.New(cognitoID, cognitoSecret)\n\t\tcontext.Set(r, \"userService\", u)\n\n\t\t// session helper\n\t\ts := session.New()\n\t\tcontext.Set(r, \"session\", s)\n\n\t\tvar netTransport = &http.Transport{\n\t\t\tDial: (&net.Dialer{\n\t\t\t\tTimeout: 5 * time.Second,\n\t\t\t}).Dial,\n\t\t\tTLSHandshakeTimeout: 5 * time.Second,\n\t\t}\n\n\t\t// support timeout and net transport.\n\t\tc := &http.Client{\n\t\t\tTimeout: time.Second * 10,\n\t\t\tTransport: netTransport,\n\t\t}\n\n\t\t// http client\n\t\tcontext.Set(r, \"client\", c)\n\n\t\tp := post.New(dynamoTablePosts, dynamoEndpoint, nil)\n\t\tcontext.Set(r, \"postService\", p)\n\n\t\tl := like.New(dynamoTableLikes, dynamoEndpoint, nil)\n\t\tcontext.Set(r, \"likeService\", l)\n\n\t\th.ServeHTTP(w, r)\n\t})\n}", "func (req *MinRequest) Context(ctx context.Context) *MinRequest {\n\treq.impl = req.impl.Context(ctx)\n\n\treturn req\n}", "func (ctx *Context) Request() *http.Request {\n\treturn ctx.r\n}", "func WithContext(ctx context.Context) RequestOptionFunc {\n\treturn func(req *retryablehttp.Request) error {\n\t\t*req = *req.WithContext(ctx)\n\t\treturn nil\n\t}\n}", "func HTTPReq(args models.Action, msg *models.Message) (*models.HTTPResponse, error) {\n\tlog.Info().Msgf(\"executing http request for action %#q\", args.Name)\n\n\tif args.Timeout == 0 {\n\t\t// Default HTTP Timeout of 10 seconds\n\t\targs.Timeout = 10\n\t}\n\n\tclient := &http.Client{\n\t\tTimeout: time.Duration(args.Timeout) * time.Second,\n\t}\n\n\t// check the URL string from defined action has a variable, try to substitute it\n\turl, err := utils.Substitute(args.URL, msg.Vars)\n\tif err != nil {\n\t\tlog.Error().Msg(\"failed substituting variables in url parameter\")\n\t\treturn nil, err\n\t}\n\n\t// TODO: refactor querydata\n\t// this is a temp fix for scenarios where\n\t// substitution above may have introduced spaces in the URL\n\turl = strings.ReplaceAll(url, \" \", \"%20\")\n\n\turl, payload, err := prepRequestData(url, args.Type, args.QueryData, msg)\n\tif err != nil {\n\t\tlog.Error().Msg(\"failed preparing the request data for the http request\")\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequestWithContext(context.Background(), args.Type, url, payload)\n\tif err != nil {\n\t\tlog.Error().Msg(\"failed to create a new http request\")\n\t\treturn nil, err\n\t}\n\n\treq.Close = true\n\n\t// Add custom headers to request\n\tfor k, v := range args.CustomHeaders {\n\t\tvalue, err := utils.Substitute(v, msg.Vars)\n\t\tif err != nil {\n\t\t\tlog.Error().Msg(\"failed substituting variables in custom headers\")\n\t\t\treturn nil, err\n\t\t}\n\n\t\treq.Header.Add(k, value)\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Error().Msg(\"failed to execute the http request\")\n\t\treturn nil, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tbodyBytes, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Error().Msg(\"failed to read response from http request\")\n\t\treturn nil, err\n\t}\n\n\tfields := extractFields(bodyBytes)\n\n\tresult := models.HTTPResponse{\n\t\tStatus: resp.StatusCode,\n\t\tRaw: string(bodyBytes),\n\t\tData: fields,\n\t}\n\n\tlog.Info().Msgf(\"http request for action %#q completed\", args.Name)\n\n\treturn &result, nil\n}", "func ContextRequest(ctx context.Context) (request *http.Request) {\n\tif d, ok := ctx.Value(contextHandlerDetailsKey).(*handlerDetails); ok {\n\t\trequest = d.request\n\t}\n\treturn\n}", "func makeRequest(req *http.Request) (*http.Response, error) {\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\treturn resp, err\n}", "func (i *IntServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"IntClient.GetInvalid\":\n\t\tresp, err = i.dispatchGetInvalid(req)\n\tcase \"IntClient.GetInvalidUnixTime\":\n\t\tresp, err = i.dispatchGetInvalidUnixTime(req)\n\tcase \"IntClient.GetNull\":\n\t\tresp, err = i.dispatchGetNull(req)\n\tcase \"IntClient.GetNullUnixTime\":\n\t\tresp, err = i.dispatchGetNullUnixTime(req)\n\tcase \"IntClient.GetOverflowInt32\":\n\t\tresp, err = i.dispatchGetOverflowInt32(req)\n\tcase \"IntClient.GetOverflowInt64\":\n\t\tresp, err = i.dispatchGetOverflowInt64(req)\n\tcase \"IntClient.GetUnderflowInt32\":\n\t\tresp, err = i.dispatchGetUnderflowInt32(req)\n\tcase \"IntClient.GetUnderflowInt64\":\n\t\tresp, err = i.dispatchGetUnderflowInt64(req)\n\tcase \"IntClient.GetUnixTime\":\n\t\tresp, err = i.dispatchGetUnixTime(req)\n\tcase \"IntClient.PutMax32\":\n\t\tresp, err = i.dispatchPutMax32(req)\n\tcase \"IntClient.PutMax64\":\n\t\tresp, err = i.dispatchPutMax64(req)\n\tcase \"IntClient.PutMin32\":\n\t\tresp, err = i.dispatchPutMin32(req)\n\tcase \"IntClient.PutMin64\":\n\t\tresp, err = i.dispatchPutMin64(req)\n\tcase \"IntClient.PutUnixTimeDate\":\n\t\tresp, err = i.dispatchPutUnixTimeDate(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (k *KeKahu) doRequest(req *http.Request) (*http.Response, error) {\n\tres, err := k.client.Do(req)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"could not make http request: %s\", err)\n\t\treturn res, err\n\t}\n\n\tdebug(\"%s %s %s\", req.Method, req.URL.String(), res.Status)\n\n\t// Check the status from the client\n\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\tres.Body.Close()\n\t\treturn res, fmt.Errorf(\"could not access Kahu service: %s\", res.Status)\n\t}\n\n\treturn res, nil\n}", "func (i *Idb) request(r *http.Request) (*http.Response, error) {\n\tquery := r.URL.Query()\n\tquery.Add(\"idb_api_token\", i.apiToken)\n\tr.URL.RawQuery = query.Encode()\n\n\tif i.Debug {\n\t\tlog.Printf(\"Request: %+v\\n\", r)\n\t}\n\tclient := &http.Client{Transport: i.transport}\n\n\tresponse, err := client.Do(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif i.Debug {\n\t\tlog.Printf(\"Response: %+v\\n\", response)\n\t}\n\n\treturn response, err\n}", "func (d *DictionaryServerTransport) Do(req *http.Request) (*http.Response, error) {\n\trawMethod := req.Context().Value(runtime.CtxAPINameKey{})\n\tmethod, ok := rawMethod.(string)\n\tif !ok {\n\t\treturn nil, nonRetriableError{errors.New(\"unable to dispatch request, missing value for CtxAPINameKey\")}\n\t}\n\n\tvar resp *http.Response\n\tvar err error\n\n\tswitch method {\n\tcase \"DictionaryClient.GetEmpty\":\n\t\tresp, err = d.dispatchGetEmpty(req)\n\tcase \"DictionaryClient.GetNotProvided\":\n\t\tresp, err = d.dispatchGetNotProvided(req)\n\tcase \"DictionaryClient.GetNull\":\n\t\tresp, err = d.dispatchGetNull(req)\n\tcase \"DictionaryClient.GetValid\":\n\t\tresp, err = d.dispatchGetValid(req)\n\tcase \"DictionaryClient.PutEmpty\":\n\t\tresp, err = d.dispatchPutEmpty(req)\n\tcase \"DictionaryClient.PutValid\":\n\t\tresp, err = d.dispatchPutValid(req)\n\tdefault:\n\t\terr = fmt.Errorf(\"unhandled API %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (c *RESTClient) do(req *http.Request) (*http.Response, error) {\n\tif c.Err != nil {\n\t\treturn nil, c.Err\n\t}\n\tc.Req = req\n\tif c.Client != nil {\n\t\treturn c.Client.Do(req)\n\t}\n\treturn c.Resp, nil\n}", "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v8.1.0\")\n\treturn req, nil\n}", "func makeRequest(req *http.Request) (*http.Response, error) {\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\n\treturn resp, err\n}", "func (cl *Client) Do(c context.Context, req *Request) (*Response, error) {\n\t// if the context has been canceled or the deadline exceeded, don't start the request\n\tif c.Err() != nil {\n\t\treturn nil, c.Err()\n\t}\n\n\t// if per request loggers haven't been set, inherit from the client\n\tif cl.debugLogFunc != nil && req.debugLogFunc == nil {\n\t\treq.debugLogFunc = cl.debugLogFunc\n\t\treq.debugf(\"request using client debugLogFunc\")\n\t}\n\tif cl.errorLogFunc != nil && req.errorLogFunc == nil {\n\t\treq.errorLogFunc = cl.errorLogFunc\n\t\treq.debugf(\"request using client errorLogFunc\")\n\t}\n\n\t// inject user provided ClientTrace into the context\n\tif req.clientTrace != nil {\n\t\treq.debugf(\"injecting ClientTrace into context\")\n\t\tc = httptrace.WithClientTrace(c, req.clientTrace)\n\t}\n\n\t// set the context deadline if one was provided in the request options\n\tif !req.deadline.IsZero() {\n\t\treq.debugf(\"setting context deadline to %s\", req.deadline)\n\t\tvar cancelFunc context.CancelFunc\n\t\tc, cancelFunc = context.WithDeadline(c, req.deadline)\n\t\tdefer cancelFunc()\n\t}\n\n\treq.client = cl\n\n\thttpResp, err := doWithRetries(c, req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp := NewResponse(c, req, httpResp)\n\n\t// execute all afterDoFuncs\n\tfor _, afterDo := range req.afterDoFuncs {\n\t\tif err = afterDo(req, resp); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn resp, nil\n}", "func RunOneRequest(ctx context.Context, r *Request) {\n\tjoinedCtx, joinedCancel := ctx, context.CancelFunc(nil)\n\tif ctx != r.Context {\n\t\tjoinedCtx, joinedCancel = joincontext.Join(ctx, r.Context)\n\t}\n\tval, err := r.Func(joinedCtx)\n\tif joinedCancel != nil {\n\t\tjoinedCancel()\n\t}\n\tif r.result != nil {\n\t\tr.result <- &result{\n\t\t\tval: val,\n\t\t\terr: err,\n\t\t}\n\t\tclose(r.result)\n\t}\n}", "func (s *Service) routeRequest(rsp http.ResponseWriter, req *Request, pln Pipeline) (interface{}, error) {\n s.router.ServeHTTP(rsp, req.Request)\n return nil, nil\n}", "func HTTPRequest(req *web.Request) *http.Request {\n\treturn req.Env[\"twister.adapter.request\"].(*http.Request)\n}", "func DoRequestImpl(requestType string, BaseURL string, uri string, target string) string {\n\t// Build the URL\n\trequestURL := fmt.Sprintf(\"%s%s%s\", BaseURL, uri, target)\n\t//fmt.Printf(requestURL)\n\t// Make an insecure request\n\tclient := &http.Client{}\n\thttp.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}\n\treq, err := http.NewRequest(requestType, requestURL, nil)\n\n\t// Prepare for auth\n\tUsername = viper.GetString(\"Username\")\n\tPassword = viper.GetString(\"Password\")\n\treq.SetBasicAuth(Username, Password)\n\n\t// Do the request\n\trs, err := client.Do(req)\n\n\t// Process response\n\tif err != nil {\n\t\tpanic(err) // More idiomatic way would be to print the error and die unless it's a serious error\n\t}\n\tdefer rs.Body.Close()\n\n\tbodyBytes, err := ioutil.ReadAll(rs.Body)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tbodyString := string(bodyBytes)\n\n\treturn bodyString\n}", "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v5.4.1\")\n\treturn req, nil\n}", "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v7.1.0\")\n\treturn req, nil\n}", "func executeRequest(method string, path string, contact c.Contact) *httptest.ResponseRecorder {\n\tresponse := httptest.NewRecorder()\n\tif (c.Contact{})==contact {\n\t\treq, _ := http.NewRequest(method, path, nil)\n\t\tserver.GetRouter().ServeHTTP(response, req)\n\t} else {\n\t\tpayload,_:= json.Marshal(contact)\n\t\treq, _ := http.NewRequest(method, path, bytes.NewBuffer(payload))\n\t\tserver.GetRouter().ServeHTTP(response, req)\n\t}\n\treturn response\n}", "func (r *ActivityStarRepoForAuthenticatedUserReq) HTTPRequest(ctx context.Context, opt ...RequestOption) (*http.Request, error) {\n\treturn buildHTTPRequest(ctx, r, opt)\n}" ]
[ "0.66820943", "0.64559156", "0.6442738", "0.64160204", "0.6373162", "0.6330858", "0.63197917", "0.63101447", "0.62860614", "0.626401", "0.62520146", "0.62121326", "0.61617136", "0.6160791", "0.61565435", "0.6135405", "0.60810935", "0.6061468", "0.60367745", "0.6032127", "0.60314125", "0.60039395", "0.5999806", "0.59753615", "0.5973561", "0.5970413", "0.59139204", "0.5911658", "0.59050655", "0.5890241", "0.5880687", "0.5872578", "0.585248", "0.5848045", "0.5848045", "0.5847041", "0.5843158", "0.58352697", "0.58348274", "0.5828854", "0.5828096", "0.5807091", "0.58064693", "0.5802513", "0.5784266", "0.5773868", "0.5773592", "0.577324", "0.5764777", "0.57638174", "0.57620895", "0.5752367", "0.5750437", "0.5738572", "0.5734218", "0.57335496", "0.5717345", "0.5709135", "0.57060605", "0.5705447", "0.57008994", "0.56980884", "0.5693949", "0.5687962", "0.5686876", "0.5685424", "0.5682924", "0.5680961", "0.5678424", "0.5673023", "0.56728435", "0.56669456", "0.56609976", "0.56589776", "0.56515193", "0.5637846", "0.56235695", "0.5618626", "0.56099635", "0.56097955", "0.5608119", "0.5607537", "0.5605679", "0.560486", "0.55967236", "0.55900514", "0.5589966", "0.5583393", "0.55825", "0.5582244", "0.55801076", "0.5579762", "0.5569941", "0.55641836", "0.55630136", "0.55609006", "0.5553291", "0.55489814", "0.5548473", "0.5548211", "0.55466557" ]
0.0
-1
Handle success response from salesforce.
func (op *OpQuery) Handle(resp *http.Response) error { if resp.StatusCode != http.StatusOK { return fmt.Errorf("get operator can't handle response with code %d, expect %d", resp.StatusCode, http.StatusOK) } return json.NewDecoder(resp.Body).Decode(&op.result) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *STS) sendSuccessfulResponse(w http.ResponseWriter, tokenData []byte) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tif _, err := w.Write(tokenData); err != nil {\n\t\tlog.Printf(\"failure in sending STS success response: %v\", err)\n\t\treturn\n\t}\n}", "func HandleSuccess(w *http.ResponseWriter, result interface{}) {\n\twriter := *w\n\tmarshalled, err := json.Marshal(result)\n\tif err != nil {\n\t\tHandleError(w, 500, \"Internal Server Error\", \"Error marshalling response JSON\", err)\n\t\treturn\n\t}\n\twriter.Write(marshalled)\n\treturn\n}", "func Success(c echo.Context) error {\n\treturn c.String(http.StatusOK, \"Operation was fine\")\n}", "func (c DBaseController) SuccessResponse(data interface{}, message string, code int, s serializers.Serializer) revel.Result {\n\tc.Response.Status = http.StatusOK\n\n\treturn c.RenderJSON(serializers.SuccessResponse(data, message, code, s))\n}", "func SendSuccessReponse(res http.ResponseWriter, responseBody interface{}) {\n\tres.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(res).Encode(responseBody)\n}", "func ResponseSuccess(w http.ResponseWriter, result *Result, message string) {\n\tresponseData := httpResponse{\n\t\tSuccess: true,\n\t\tData: result.Data,\n\t\tMessage: message,\n\t\tCode: http.StatusOK,\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(w).Encode(responseData)\n\treturn\n}", "func SendSuccessResponse(w http.ResponseWriter, m string) {\n\tresponse := Response{\n\t\tStatus: \"Success\",\n\t\tMessage: m,\n\t}\n\n\tSendResponse(w, response, http.StatusOK)\n}", "func Success(w http.ResponseWriter, code int, msg string, data interface{}) error {\n\treturn sendResponse(w, Resp{SUCCESS, code, msg, data, SuccessHttpCode})\n}", "func HandleSuccessResponse(w http.ResponseWriter, data interface{}) {\n\tr := Response{\n\t\tMessage: \"success\",\n\t\tData: data,\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.Header().Set(\"X-Content-Type-Options\", \"nosniff\")\n\n\tjson.NewEncoder(w).Encode(r)\n}", "func ResponseSuccess(c *fiber.Ctx, fn interface{}, request interface{}) error {\n\tctx := context.New(c)\n\terr := ctx.BindValue(request, true)\n\tif err != nil {\n\t\tlogrus.Errorf(\"bind value error: %s\", err)\n\t\treturn render.Error(c, err)\n\t}\n\n\tout := reflect.ValueOf(fn).Call([]reflect.Value{\n\t\treflect.ValueOf(ctx),\n\t\treflect.ValueOf(request),\n\t})\n\terrObj := out[0].Interface()\n\tif errObj != nil {\n\t\tlogrus.Errorf(\"call service error: %s\", errObj)\n\t\treturn errObj.(error)\n\t}\n\treturn render.JSON(c, models.NewSuccessMessage())\n}", "func (c *Ctx) Success(body interface{}) error {\n\tc.Respond(http.StatusOK, body)\n\treturn nil\n}", "func ResponseSuccess(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(JSONSuccess{true})\n}", "func UpdateSuccessHandler(w http.ResponseWriter, r *http.Request) {\n\n\t// prevent CORS error\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Access-Control-Allow-Headers\", \"Content-Type\")\n\n\teventid, err := strconv.Atoi(r.FormValue(\"eventid\"))\n\tsuccess, err := strconv.ParseBool(r.FormValue(\"success\"))\n\n\tfmt.Println(eventid)\n\n\tjsonFile, err := os.Open(\"datastore/events.json\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tdefer jsonFile.Close()\n\n\tbyteValue, _ := ioutil.ReadAll(jsonFile)\n\n\tvar data []EventBlock\n\tjson.Unmarshal(byteValue, &data)\n\tif err != nil {\n\t\tfmt.Println(\"err\")\n\t}\n\n\tfor i := 0; i < len(data); i++ {\n\n\t\tif eventid == data[i].EventID {\n\t\t\tdata[i].Success = success\n\t\t\tbreak\n\t\t}\n\t}\n\n\tresult, err := json.Marshal(data)\n\terr = ioutil.WriteFile(\"datastore/events.json\", result, 0777)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tw.Write([]byte(`success field updated`))\n\n}", "func Success(ctx *fiber.Ctx, msg string, data interface{}, status int) error {\n\treturn response(ctx, http.StatusOK, fiber.Map{\n\t\t\"success\": true,\n\t\t\"message\": msg,\n\t\t\"data\": data,\n\t})\n}", "func writeSuccessResponse(w http.ResponseWriter, bikes []common.Bike) {\n\tresponse := Response{true, bikes, \"\"}\n\twriteResponse(w, response)\n}", "func SuccessResult(Response model.Response) model.Response {\n\tResponse.Code = Success\n\tResponse.Description = StatusCodes(Success)\n\n\treturn Response\n}", "func (o *PostEntitiesEntityFidEventsOK) IsSuccess() bool {\n\treturn true\n}", "func Success(w http.ResponseWriter) {\n\tw.Write(JSON(SuccessResponse{Message: \"success\", Code: 200}))\n}", "func (v *View) Success(w http.ResponseWriter, r *http.Request, yield interface{}, message string) {\n\tw.Header().Set(\"Content-Type\", \"text/html\")\n\n\tvar vd Data\n\tvd.User.ID = r.Header.Get(\"userID\")\n\tadmin, err := strconv.ParseBool(r.Header.Get(\"admin\"))\n\tif err != nil {\n\t\tvd.User.Admin = false\n\t} else {\n\t\tvd.User.Admin = admin\n\t}\n\tvd.Yield = yield\n\tvd.Messages.Success = message\n\n\tv.Template.ExecuteTemplate(w, v.Layout, vd)\n}", "func Success(w http.ResponseWriter, message string, code int) {\n\tif code == 0 {\n\t\tcode = http.StatusOK\n\t}\n\tw.WriteHeader(code)\n\tjson.NewEncoder(w).Encode(map[string]string{\"success\": message})\n}", "func (this *commonResult) Succeed() {\n\tthis.was_successful = true\n}", "func SendSuccess(w http.ResponseWriter, message string) (int, error) {\n\tdata := struct {\n\t\tMessage string `json:\"message\"`\n\t}{\n\t\tMessage: message,\n\t}\n\tpayload, err := json.Marshal(data)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"Could not marshal data into payload, %v\", err)\n\t\tlog.Printf(msg)\n\t\treturn 0, errors.New(msg)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tbytesWritten, err := w.Write(payload)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"There was an error sending the response, %v\", err)\n\t\tlog.Printf(msg)\n\t\treturn 0, errors.New(msg)\n\t}\n\n\tlog.Printf(\"Sent %s\", string(payload))\n\n\treturn bytesWritten, nil\n}", "func ReturnSuccess(w http.ResponseWriter, statusCode int, data interface{}) {\n\tsend(w, statusCode, data, nil)\n}", "func SuccessSave(c *gin.Context, data interface{}, msg string) {\n\tc.JSON(http.StatusOK, &Result{\n\t\tData: data,\n\t\tMessage: msg,\n\t})\n}", "func Success(c *gin.Context, data interface{}) {\n\tc.JSON(http.StatusOK, &Result{\n\t\tData: data,\n\t})\n}", "func (r *Router) Success(ctx context.Context, w http.ResponseWriter, code int) {\n\treqID := r.GetRequestID(ctx)\n\n\tr.setDefaultHeaders(ctx, w)\n\n\tif code != http.StatusOK {\n\t\tw.WriteHeader(code)\n\t}\n\n\tr.logger.Debugw(\"response\",\n\t\t\"request_id\", reqID,\n\t\t\"status_code\", code,\n\t)\n}", "func Success(body string) (events.APIGatewayProxyResponse, error) {\n\treturn events.APIGatewayProxyResponse{StatusCode: 200, Body: body}, nil\n}", "func writeSuccessResponse(w http.ResponseWriter, data interface{}) {\n\tw.WriteHeader(http.StatusOK)\n\tbs, err := json.Marshal(data)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn\n\t}\n\tif _, err := w.Write(bs); err != nil {\n\t\tlog.Error(err)\n\t}\n}", "func Success(c *gin.Context, data interface{}) {\n\tGinCorsHeaders(c)\n\tresponse := gin.H{\"code\": 20000, \"message\": \"success\", \"data\": data}\n\tc.JSON(http.StatusOK, response)\n}", "func (m *Manager) Success() {\n\tm.errCnt = 0\n}", "func (o *PutCustomersCustomerFidContactsContactFidOK) IsSuccess() bool {\n\treturn true\n}", "func CreateSuccessResponse(w http.ResponseWriter, data interface{}) {\n\tif data != nil {\n\t\tbytes, err := json.Marshal(data)\n\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\n\t\tw.Write(bytes)\n\t}\n}", "func SendSuccessCreatedResponse(res http.ResponseWriter, responseBody interface{}) {\n\tres.WriteHeader(http.StatusCreated)\n\tjson.NewEncoder(res).Encode(responseBody)\n}", "func SuccessResponse(msg string, writer http.ResponseWriter) {\n\ttype errdata struct {\n\t\tStatusCode int\n\t\tMessage string\n\t}\n\ttemp := &errdata{StatusCode: 200, Message: msg}\n\n\t//Send header, status code and output to writer\n\twriter.Header().Set(\"Content-Type\", \"application/json\")\n\twriter.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(writer).Encode(temp)\n}", "func Success(ctx context.Context, responseStatusCode int, statusCode, statusMessage string, data interface{}) Output {\n\tres := response{}\n\tres.StatusCode = responseStatusCode\n\tres.Status.Error = false\n\tres.Status.Code = statusCode\n\tres.Status.Message = statusMessage\n\n\t// send to logger before set data to response\n\tlogger.Response(ctx, responseStatusCode, res, nil, nil)\n\tlogger.ResponseMessage(ctx, statusMessage)\n\n\tres.Data = data\n\n\treturn &res\n}", "func RespondSuccess(w http.ResponseWriter, code int, success bool, message string, messageBody string) {\n\tRespondJSON(w, code, success, message, map[string]string{\"success\": messageBody})\n}", "func successResult(namespacedName string, timeToDeploy time.Duration, inSync bool) objectResult {\n\treturn objectResult{NamespacedName: namespacedName, TimeToDeploy: timeToDeploy, InSync: inSync}\n}", "func (c *Context) Success(name string) {\n\tc.HTML(http.StatusOK, name)\n}", "func WriteSuccessResponse(w http.ResponseWriter) {\n\tjson, _ := json.Marshal(NewSuccessResponse())\n\n\tw.WriteHeader(http.StatusOK)\n\tw.Header().Add(\"content-type\", \"application/json\")\n\tw.Write(json)\n}", "func UploadSuccessHandler(w http.ResponseWriter, r *http.Request) {\n\t_, _ = io.WriteString(w, \"upload succeed\")\n}", "func respond_with_success(w http.ResponseWriter,\n\tstatus int,\n\tmessage string) {\n\tdetail := fmt.Sprintf(\"Success (%d). Sending response: %s\", status, message)\n\tif logutil.GPS_DEBUG > 0 {\n\t\tlogutil.LogRestResponse(detail)\n\t}\n\tadd_json_header(w)\n\tset_response_status(w, status)\n\tfmt.Fprintf(w, \"%s\\n\", message)\n}", "func (r *Result) Success() {\n\tr.Pass = true\n}", "func SuccessRespond(fields interface{}, writer http.ResponseWriter) {\n\t_, err := json.Marshal(fields)\n\ttype data struct {\n\t\tData interface{}\n\t\tStatusCode int\n\t\tMessage string\n\t}\n\ttemp := &data{Data: fields, StatusCode: 200, Message: \"success\"}\n\tif err != nil {\n\t\tlog.Println(fields)\n\t\tServerErrResponse(err.Error(), writer)\n\t\treturn\n\t}\n\n\t//Send header, status code and output to writer\n\twriter.Header().Set(\"Content-Type\", \"application/json\")\n\twriter.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(writer).Encode(temp)\n}", "func (o *DeleteServiceIDOK) IsSuccess() bool {\n\treturn true\n}", "func UploadSuccessHandler(w http.ResponseWriter, r *http.Request) {\n\tio.WriteString(w, \"uploaded successfully!\")\n}", "func (o *PostEntitiesEntityFidEventsDefault) IsSuccess() bool {\n\treturn o._statusCode/100 == 2\n}", "func (u *Slack) OnSuccess(s *types.Service) error {\n\tif u.Enabled {\n\t\t//message := slackMessage{\n\t\t//\tService: s,\n\t\t//\tTime: time.Now().Unix(),\n\t\t//}\n\t\t//SendSlack(SUCCESS_TEMPLATE, message)\n\t}\n\treturn nil\n}", "func CreateSuccessResponse(result interface{}) *Response {\n\treturn &Response{Success: true, Result: result}\n}", "func (cc *CosmosProvider) LogSuccessTx(res *sdk.TxResponse, msgs []provider.RelayerMessage) {\n\t// Include the chain_id\n\tfields := []zapcore.Field{zap.String(\"chain_id\", cc.ChainId())}\n\n\t// Extract the channels from the events, if present\n\tif res != nil {\n\t\tevents := parseEventsFromTxResponse(res)\n\t\tfields = append(fields, getChannelsIfPresent(events)...)\n\t}\n\n\t// Include the gas used\n\tfields = append(fields, zap.Int64(\"gas_used\", res.GasUsed))\n\n\t// Extract fees and fee_payer if present\n\tir := types.NewInterfaceRegistry()\n\tvar m sdk.Msg\n\tif err := ir.UnpackAny(res.Tx, &m); err == nil {\n\t\tif tx, ok := m.(*typestx.Tx); ok {\n\t\t\tfields = append(fields, zap.Stringer(\"fees\", tx.GetFee()))\n\t\t\tif feePayer := getFeePayer(tx); feePayer != \"\" {\n\t\t\t\tfields = append(fields, zap.String(\"fee_payer\", feePayer))\n\t\t\t}\n\t\t} else {\n\t\t\tcc.log.Debug(\n\t\t\t\t\"Failed to convert message to Tx type\",\n\t\t\t\tzap.Stringer(\"type\", reflect.TypeOf(m)),\n\t\t\t)\n\t\t}\n\t} else {\n\t\tcc.log.Debug(\"Failed to unpack response Tx into sdk.Msg\", zap.Error(err))\n\t}\n\n\t// Include the height, msgType, and tx_hash\n\tfields = append(fields,\n\t\tzap.Int64(\"height\", res.Height),\n\t\tmsgTypesField(msgs),\n\t\tzap.String(\"tx_hash\", res.TxHash),\n\t)\n\n\t// Log the succesful transaction with fields\n\tcc.log.Info(\n\t\t\"Successful transaction\",\n\t\tfields...,\n\t)\n}", "func (o *GetCustomersCustomerFidInvoicesInvoiceFidOK) IsSuccess() bool {\n\treturn true\n}", "func (r *ReportTaskRequest) SetSuccess(success bool) {\n r.Success = &success\n}", "func (o *PutCustomersCustomerFidContactsContactFidDefault) IsSuccess() bool {\n\treturn o._statusCode/100 == 2\n}", "func (o *SearchAclsInternalServerError) IsSuccess() bool {\n\treturn false\n}", "func (o *QueryAWSAccountsForIDsInternalServerError) IsSuccess() bool {\n\treturn false\n}", "func (r *ModifyTaskRequest) SetSuccess(success bool) {\n r.Success = success\n}", "func (response BasicJSONResponse) Success(writer http.ResponseWriter) {\n\tSuccess(writer, response)\n}", "func BebDeleteResponseSuccess(w http.ResponseWriter) {\n\tw.WriteHeader(http.StatusNoContent)\n}", "func (o *PutCustomersCustomerFidLocationOK) IsSuccess() bool {\n\treturn true\n}", "func (o *PutCustomersCustomerFidLocationDefault) IsSuccess() bool {\n\treturn o._statusCode/100 == 2\n}", "func SendSuccessValueReponse(res http.ResponseWriter, value interface{}) {\n\tres.WriteHeader(http.StatusOK)\n\tvar body = make(map[string]interface{})\n\tbody[\"value\"] = value\n\tjson.NewEncoder(res).Encode(body)\n}", "func (a *apiServer) handleSAMLResponse(w http.ResponseWriter, req *http.Request) {\n\tvar subject, authCode string\n\tvar err *errutil.HTTPError\n\n\tlogRequest := \"SAML login request\"\n\ta.LogReq(logRequest)\n\tdefer func(start time.Time) {\n\t\tif subject != \"\" {\n\t\t\tlogRequest = fmt.Sprintf(\"SAML login request for %s\", subject)\n\t\t}\n\t\ta.LogResp(logRequest, errutil.PrettyPrintCode(err), err, time.Since(start))\n\t}(time.Now())\n\n\tsubject, authCode, err = a.handleSAMLResponseInternal(req)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), err.Code())\n\t\treturn\n\t}\n\n\t// Redirect caller back to dash with auth code\n\tu := *defaultDashRedirectURL\n\tif a.redirectAddress != nil {\n\t\tu = *a.redirectAddress\n\t}\n\tu.RawQuery = url.Values{\"auth_code\": []string{authCode}}.Encode()\n\tw.Header().Set(\"Location\", u.String())\n\tw.WriteHeader(http.StatusFound) // Send redirect\n}", "func WriteSuccess(w http.ResponseWriter, data interface{}, status int) {\n\tres := response.BuildSuccess(data, response.MetaInfo{HTTPStatus: status})\n\tresponse.Write(w, res, status)\n}", "func (o *UpdateMTOServiceItemStatusOK) IsSuccess() bool {\n\treturn true\n}", "func (c *Context) JSONSuccess(data interface{}) {\n\tc.JSON(http.StatusOK, data)\n}", "func (o *NvmeServiceDeleteOK) IsSuccess() bool {\n\treturn true\n}", "func (o *SearchAclsOK) IsSuccess() bool {\n\treturn true\n}", "func HandleCreateSuccessfully(t *testing.T, output string) {\n\tth.Mux.HandleFunc(\"/software_configs\", func(w http.ResponseWriter, r *http.Request) {\n\t\tth.TestMethod(t, r, \"POST\")\n\t\tth.TestHeader(t, r, \"X-Auth-Token\", fake.TokenID)\n\t\tth.TestHeader(t, r, \"Accept\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tfmt.Fprintf(w, output)\n\t})\n}", "func (client *KeyVaultClient) updateSasDefinitionHandleResponse(resp *http.Response) (KeyVaultClientUpdateSasDefinitionResponse, error) {\n\tresult := KeyVaultClientUpdateSasDefinitionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SasDefinitionBundle); err != nil {\n\t\treturn KeyVaultClientUpdateSasDefinitionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (r *Response) Success(w http.ResponseWriter, status int, data interface{}) {\n\tw.WriteHeader(status)\n\ts := successResponse{\n\t\tStatus: \"OK\",\n\t\tResult: data,\n\t}\n\tout, err := json.Marshal(s)\n\tif err != nil {\n\t\tr.logger.Error(\"Failed to unmarshal data \", err)\n\t\tw.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\tw.Write(out)\n}", "func genericSuccess(caller, inp, msg string) error {\n\tresp, err := json.Marshal(&Response{Status: \"Success\", Message: msg})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprintAndLog(caller, inp, string(resp))\n\treturn nil\n}", "func (o *InstallEventsInternalServerError) IsSuccess() bool {\n\treturn false\n}", "func (r *Request) RespondSuccess(result interface{}) {\n\tr.Respond(struct {\n\t\tResult interface{} `json:\"result\"`\n\t}{\n\t\tResult: result,\n\t})\n}", "func Success(r *ghttp.Request, data ...interface{}) *apiResp {\n\treturn NewResp(r, SUCCESS, \"\", data...)\n}", "func (r *SubscriptionRepository) Success() {\n\tlog.Printf(\"Finalize transaction\")\n\tdefer r.sessionMutex.Unlock()\n\tr.session.EndSession(context.Background())\n}", "func (a *APIResponse) Success(data interface{}) {\n\ta.Status = HttpStatus{Code: http.StatusOK, Message: http.StatusText(http.StatusOK)}\n\ta.Data = data\n}", "func SendLoginSuccess(w http.ResponseWriter, r *http.Request, client *http.Client, hydraAdminURL, challenge, subject, stateID string, extra map[string]interface{}) {\n\taddr, err := LoginSuccess(r, client, hydraAdminURL, challenge, subject, stateID, extra)\n\tif err != nil {\n\t\thttputils.WriteError(w, err)\n\t\treturn\n\t}\n\thttputils.WriteRedirect(w, r, addr)\n}", "func (o *DeleteServiceIDNotFound) IsSuccess() bool {\n\treturn false\n}", "func SuccessMessage(c *gin.Context, msg string) {\n\tc.JSON(http.StatusOK, &Result{\n\t\tMessage: msg,\n\t})\n}", "func WriteSuccessResponse(w http.ResponseWriter, status int, payload interface{}) error {\n\tif status >= 200 && status <= 299 {\n\t\treturn WriteJSON(w, status, payload)\n\t}\n\treturn errors.Newf(errors.Internal, \"not valid status code %d for success response\", status)\n}", "func (ctx *PutEventContext) OK(r *AntResult) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.result+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 200, r)\n}", "func (o *PutACLOK) IsSuccess() bool {\n\treturn true\n}", "func (o *UpdateMTOServiceItemStatusInternalServerError) IsSuccess() bool {\n\treturn false\n}", "func SuccessfulResponse(bodyContent string) events.APIGatewayProxyResponse {\n\tbody, _ := json.Marshal(map[string]string{\"body\": bodyContent})\n\treturn events.APIGatewayProxyResponse{\n\t\tStatusCode: http.StatusOK,\n\t\tBody: string(body),\n\t\tHeaders: headers,\n\t}\n}", "func (o *CreateMoveTaskOrderInternalServerError) IsSuccess() bool {\n\treturn false\n}", "func NewSuccessResponse() Response {\n\treturn Response{Type: TypeSuccess}\n}", "func (o *PostCustomersCustomerFidPaymentMethodsPaypalCompleteOK) IsSuccess() bool {\n\treturn true\n}", "func (client *SpatialAnchorsAccountsClient) updateHandleResponse(resp *http.Response) (SpatialAnchorsAccountsClientUpdateResponse, error) {\n\tresult := SpatialAnchorsAccountsClientUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccount); err != nil {\n\t\treturn SpatialAnchorsAccountsClientUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (o *GetV1IntegrationsZendeskSearchOK) IsSuccess() bool {\n\treturn true\n}", "func HandleDeleteSuccessfully(t *testing.T) {\n\tth.Mux.HandleFunc(\"/software_configs/e2fe5553-a481-4549-9d0f-e208de3d98d1\", func(w http.ResponseWriter, r *http.Request) {\n\t\tth.TestMethod(t, r, \"DELETE\")\n\t\tth.TestHeader(t, r, \"X-Auth-Token\", fake.TokenID)\n\t\tth.TestHeader(t, r, \"Accept\", \"application/json\")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusNoContent)\n\t})\n}", "func IrisSuccess(c iris.Context, data interface{}) {\n\tencodelog(c, &Response{ErrNo: 10000, ErrMsg: \"\", Data: data}, \"success response\")\n}", "func writeSuccessResponseXML(w http.ResponseWriter, response []byte) {\n\twriteResponse(w, http.StatusOK, response, mimeXML)\n}", "func SuccessResponse(c echo.Context, content echo.Map) Response {\n\treturn NewResponse(c, true, 0, ResponseMessageOk, content)\n}", "func (o *GetProductsOffersOK) IsSuccess() bool {\n\treturn true\n}", "func Success(ctx ...interface{}) {\n\tlogNormal(successStatus, time.Now(), ctx...)\n}", "func (ctx *PostEventContext) OK(r *AntResult) error {\n\tctx.ResponseData.Header().Set(\"Content-Type\", \"vnd.ant.result+json\")\n\treturn ctx.ResponseData.Service.Send(ctx.Context, 200, r)\n}", "func (o *DeleteServiceIDFailure) IsSuccess() bool {\n\treturn false\n}", "func (o *GetCustomersCustomerFidInvoicesInvoiceFidDefault) IsSuccess() bool {\n\treturn o._statusCode/100 == 2\n}", "func (client HTTPSuccessClient) Post200Responder(resp *http.Response) (result autorest.Response, err error) { \n err = autorest.Respond(\n resp,\n client.ByInspecting(),\n azure.WithErrorUnlessStatusCode(http.StatusOK),\n autorest.ByClosing())\n result.Response = resp\n return\n}", "func (o *PostCustomersCustomerFidPaymentMethodsPaypalCompleteDefault) IsSuccess() bool {\n\treturn o._statusCode/100 == 2\n}", "func (o *GetAlertsInternalServerError) IsSuccess() bool {\n\treturn false\n}", "func (o *PostEntitiesEntityFidAttachmentsUploadURLOK) IsSuccess() bool {\n\treturn true\n}" ]
[ "0.6574858", "0.63047427", "0.62137634", "0.6155782", "0.6146457", "0.6141689", "0.60377365", "0.59824455", "0.5981291", "0.59637105", "0.5942656", "0.5931414", "0.5924862", "0.5917695", "0.5870379", "0.5833002", "0.5802651", "0.5802538", "0.5785916", "0.5780289", "0.5776209", "0.5770915", "0.57677263", "0.57620513", "0.5740867", "0.57406163", "0.57293445", "0.5727857", "0.57121855", "0.5705114", "0.5701077", "0.5700821", "0.56991345", "0.5696541", "0.56931734", "0.5681932", "0.5681551", "0.56809413", "0.5674031", "0.56614375", "0.5636387", "0.5635266", "0.56291455", "0.5607381", "0.56022555", "0.55718166", "0.5543912", "0.5535323", "0.5515853", "0.5507931", "0.5504178", "0.54938126", "0.54895055", "0.54827464", "0.54826725", "0.54775584", "0.5472304", "0.54710793", "0.5470387", "0.54583865", "0.544681", "0.5446295", "0.544287", "0.54421955", "0.54414046", "0.5430448", "0.5420314", "0.5419485", "0.54121834", "0.5398237", "0.53976846", "0.53879267", "0.53816295", "0.5377803", "0.5376397", "0.53688157", "0.5359938", "0.5357021", "0.5340764", "0.53320295", "0.5329442", "0.5327059", "0.52938324", "0.52851737", "0.5282364", "0.5276785", "0.52630067", "0.52567846", "0.5256439", "0.52563703", "0.52405727", "0.52385026", "0.52368766", "0.5234424", "0.52310246", "0.5228264", "0.5225842", "0.5225724", "0.52233833", "0.5220857", "0.52193695" ]
0.0
-1
Select defines which columns of SObject will be return in result.
func (op *OpQuery) Select(fields ...string) *OpQuery { if op.selectFileds == nil { op.selectFileds = make([]string, 0) } op.selectFileds = append(op.selectFileds, fields...) return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (q *PersonQuery) Select(columns ...kallax.SchemaField) *PersonQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func (s *TableQuery) Select(args ...interface{}) drivers.ITableQuery {\n\ts.SelectSQL = NewColumn().GetSelectColumns(args...)\n\treturn s\n}", "func Select(columns ...string) QueryOption {\n\treturn newFuncQueryOption(func(wrapper *QueryWrapper) {\n\t\twrapper.columns = columns\n\t\twrapper.queryLen += 2\n\t})\n}", "func (s *Session) Select(columns ...string) *Session {\n\ts.initStatemnt()\n\ts.statement.Select(columns...)\n\treturn s\n}", "func (q *SessionQuery) Select(columns ...kallax.SchemaField) *SessionQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func (db *Database) Select(cols ...string) *Database {\n\tdb.Query.Action = \"SELECT\"\n\tdb.Query.Columns = columns(cols)\n\n\treturn db\n}", "func (api *MysqlAPI) Select(option QueryOption) (rs []map[string]interface{}, err error) {\n\tvar sql string\n\tfor _, f := range option.Fields {\n\t\tif !api.databaseMetadata.TableHaveField(option.Table, f) {\n\t\t\terr = fmt.Errorf(\"Table '%s' not have '%s' field !/n\", option.Table, f)\n\t\t\treturn\n\t\t}\n\t}\n\tif option.Id != \"\" {\n\t\tsql, err = api.sql.GetByTableAndID(option)\n\t} else {\n\t\tsql, err = api.sql.GetByTable(option)\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\treturn api.query(sql)\n}", "func (t *ColumnsType) Select(f ...qb.Field) *qb.SelectBuilder {\n\treturn t.table.Select(f)\n}", "func (q *PetQuery) Select(columns ...kallax.SchemaField) *PetQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func (t CustomerTable) SelectCols() string {\n\treturn `customer_id,name,created_at,archived_at`\n}", "func Select(columns ...string) QueryMod {\n\treturn func(q *queries.Query) {\n\t\tqueries.AppendSelect(q, columns...)\n\t}\n}", "func (q *UserQuery) Select(columns ...kallax.SchemaField) *UserQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func Select(fields ...string) *Query {\n\tquery := newQuery()\n\tquery.action = action_select\n\n\treturn query.Select(fields...)\n}", "func (q *PollQuery) Select(columns ...kallax.SchemaField) *PollQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func (t *PgAttributeType) Select(f ...qb.Field) *qb.SelectBuilder {\n\treturn t.table.Select(f)\n}", "func (sb *SQLBuilder) Select(cols ...string) *SQLBuilder {\n\tvar buf strings.Builder\n\n\tfor k, col := range cols {\n\n\t\tbuf.WriteString(col)\n\n\t\tif k != len(cols)-1 {\n\t\t\tbuf.WriteString(\",\")\n\t\t}\n\t}\n\n\tsb._select = buf.String()\n\n\treturn sb\n}", "func Select(columns ...string) *SelectBuilder {\n\treturn NewSelectBuilder(columns...)\n}", "func (b *SqliteBuilder) Select(cols ...string) *SelectQuery {\n\treturn NewSelectQuery(b, b.db).Select(cols...)\n}", "func (q *StatsPeriodQuery) Select(columns ...kallax.SchemaField) *StatsPeriodQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func (table *Table) Select(db DB, selector sqlbuilder.Selector, args ...interface{}) ([]Map, error) {\n\tif err := table.Open(); err != nil {\n\t\treturn nil, err\n\t}\n\tquery := selector.Columns(table.cols...).From(table.Name).SQL()\n\treturn MapQuery(table.keysMap, db, query, args...)\n}", "func (q *PollOptionQuery) Select(columns ...kallax.SchemaField) *PollOptionQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func Select(fields ...interface{}) QueryOptions {\n\treturn func(query *Query) (*Query, error) {\n\t\tif len(fields) == 0 {\n\t\t\treturn query, nil\n\t\t}\n\t\tvar fieldPaths []interface{}\n\t\tfor _, field := range fields {\n\t\t\tif _, ok := field.(string); !ok {\n\t\t\t\treturn nil, errors.New(\"field path type can be only string\")\n\t\t\t}\n\t\t\tfieldPaths = append(fieldPaths, field)\n\t\t}\n\t\tresMap, err := mergeQueryMaps(query.content,\n\t\t\tmap[string]interface{}{operations[SELECT]: fieldPaths})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tquery.content = resMap.(map[string]interface{})\n\t\treturn query, nil\n\t}\n}", "func (q *PollVoteQuery) Select(columns ...kallax.SchemaField) *PollVoteQuery {\n\tif len(columns) == 0 {\n\t\treturn q\n\t}\n\tq.BaseQuery.Select(columns...)\n\treturn q\n}", "func (s *Schema) Select(tableName string) IQuery {\n\treturn s.newQuery(tableName, \"select\")\n}", "func (db *DB) Select(model interface{}) error {\n\treturn db.inner.Select(model)\n}", "func (rdq *ResultsDefinitionQuery) Select(fields ...string) *ResultsDefinitionSelect {\n\trdq.fields = append(rdq.fields, fields...)\n\tselbuild := &ResultsDefinitionSelect{ResultsDefinitionQuery: rdq}\n\tselbuild.label = resultsdefinition.Label\n\tselbuild.flds, selbuild.scan = &rdq.fields, selbuild.Scan\n\treturn selbuild\n}", "func Select(top uint64, distinct bool, columns []string, table string, where string, groupby []string, orderby []string, terminate bool) string {\n\n\tif table == \"\" {\n\t\treturn \"\"\n\t}\n\n\tvar stmt bytes.Buffer\n\n\tstmt.WriteString(`SELECT`)\n\n\t// top\n\tif top > 0 {\n\t\tstmt.WriteString(` TOP `)\n\t\tstmt.WriteString(strconv.FormatUint(top, 10))\n\t}\n\n\tif distinct {\n\t\tstmt.WriteString(` DISTINCT`)\n\t}\n\n\t// columns\n\tif len(columns) > 0 {\n\t\tstmt.WriteString(\" \" + strings.Join(columns, `, `))\n\t} else {\n\t\tstmt.WriteString(\" *\")\n\t}\n\n\t// table\n\tstmt.WriteString(` FROM ` + table)\n\n\t// where\n\tif where != \"\" {\n\t\tstmt.WriteString(` WHERE ` + where)\n\t}\n\n\t// Group by\n\tif len(groupby) > 0 {\n\t\tstmt.WriteString(\" GROUP BY \" + strings.Join(groupby, \", \") )\n\t}\n\n\t// order by\n\tif len(orderby) > 0 {\n\t\tstmt.WriteString(\" ORDER BY \" + strings.Join(orderby, \", \") )\n\t}\n\n\t// terminate statement\n\tif terminate {\n\t\tstmt.WriteString(\";\")\n\t}\n\n\treturn stmt.String()\n}", "func (suo *SkillUpdateOne) Select(field string, fields ...string) *SkillUpdateOne {\n\tsuo.fields = append([]string{field}, fields...)\n\treturn suo\n}", "func (cuo *CarUpdateOne) Select(field string, fields ...string) *CarUpdateOne {\n\tcuo.fields = append([]string{field}, fields...)\n\treturn cuo\n}", "func Select(\n\tdb *sql.DB, params map[string]interface{},\n\tfieldMap map[string]string, table string, orderBy string,\n) ([]map[string]interface{}, error) {\n\tvar (\n\t\trows *sql.Rows\n\t\tcondition string\n\t\tlimit string\n\t)\n\tvalues := []interface{}{}\n\tresult := []map[string]interface{}{}\n\tcolumns, keys, processColumn, err := prepareSelectVariables(fieldMap)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif PK, ok := params[\"PK\"]; ok {\n\t\tif pk, ok := PK.(map[string]interface{}); ok {\n\t\t\tif condition, err = WherePK(pk, fieldMap, keys, &values, 0); err != nil {\n\t\t\t\tif err != ErrorZeroParamsInPK {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcondition = fmt.Sprintf(\"where %s\", condition)\n\t\t\t}\n\t\t}\n\t}\n\n\tif Limit, ok := params[\"Limit\"]; ok {\n\t\tif l, ok := Limit.(float64); ok {\n\t\t\tli := int64(l)\n\t\t\tlimit = fmt.Sprintf(\"limit %d\", li)\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"Cannot convert limit param %v into integer\", Limit)\n\t\t}\n\t}\n\n\tob := \"\"\n\tif orderBy != \"\" {\n\t\tob = fmt.Sprintf(`order by %s`, orderBy)\n\t}\n\tquery := fmt.Sprintf(`select %s from \"%s\" %s %s %s`,\n\t\tstrings.Join(columns, \",\"), table, condition, ob, limit)\n\trows, err = db.Query(query, values...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tcount := len(columns)\n\tslots := make([]interface{}, count)\n\tslotsPtrs := make([]interface{}, count)\n\tfor i := range slots {\n\t\tslotsPtrs[i] = &slots[i]\n\t}\n\tfor rows.Next() {\n\t\tif err := rows.Scan(slotsPtrs...); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\trow := map[string]interface{}{}\n\t\tfor i, key := range keys {\n\t\t\tif err := processColumn[i](slots[i], row, key); err != nil {\n\t\t\t\tlog.Println(err, \"at\", table)\n\t\t\t}\n\t\t}\n\t\tresult = append(result, row)\n\t}\n\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn result, nil\n}", "func (mnuo *MetricNameUpdateOne) Select(field string, fields ...string) *MetricNameUpdateOne {\n\tmnuo.fields = append([]string{field}, fields...)\n\treturn mnuo\n}", "func Select(mock sqlmock.Sqlmock, table string, columns []string, err error, values ...[]driver.Value) {\n\tsql := fmt.Sprintf(\"SELECT (.+) FROM %s\", table)\n\n\tif err != nil {\n\t\tmock.ExpectQuery(sql).WillReturnError(err)\n\t\treturn\n\t}\n\n\tif values == nil || len(values) == 0 {\n\t\tmock.ExpectQuery(sql).WillReturnRows(&sqlmock.Rows{})\n\t\treturn\n\t}\n\n\trows := sqlmock.NewRows(columns)\n\tfor _, value := range values {\n\t\trows.AddRow(value...)\n\t}\n\n\tmock.ExpectQuery(sql).WillReturnRows(rows)\n}", "func (suo *StateUpdateOne) Select(field string, fields ...string) *StateUpdateOne {\n\tsuo.fields = append([]string{field}, fields...)\n\treturn suo\n}", "func (b *Builder) Select(cols ...string) *Builder {\r\n\tb.selects = cols\r\n\tb.optype = selectType\r\n\treturn b\r\n}", "func (dbi *DB) Select(sqls string, arg ...string) ([]map[string]string, error) {\r\n\tif dbi.status == false {\r\n\t\treturn nil, errors.New(\"database was not opened.\")\r\n\t}\r\n\r\n\trows, err := dbi.Cursor(sqls, arg...)\r\n\tif err != nil {\r\n\t\treturn nil, errors.New(\"Cannot open cursor for sql: \" + sqls)\r\n\t}\r\n\r\n\tvar resvar []map[string]string\r\n\tfor {\r\n\t\tcolvar, rowerr := rows.Next()\r\n\t\tif rowerr != nil {\r\n\t\t\trows.Close()\r\n\t\t\treturn nil, errors.New(\"Cannot fetch records for sql: \" + sqls)\r\n\t\t} else if colvar == nil && rowerr == nil {\r\n\t\t\t// no records found\r\n\t\t\trows.status = false\r\n\t\t\tbreak\r\n\t\t}\r\n\r\n\t\tline := make(map[string]string)\r\n\t\tfor i := 0; i < len(rows.Cols); i++ {\r\n\t\t\tline[rows.Cols[i]] = colvar[i]\r\n\t\t}\r\n\t\tresvar = append(resvar, line)\r\n\t}\r\n\treturn resvar, nil\r\n}", "func (t LocationTable) SelectCols() string {\n\treturn `dataset_id,location_hash,location_string,parsed_country_code,parsed_postal_code,geonames_postal_codes,geoname_id,geonames_hierarchy,approved,created_at,name,population,country_code,parent_name,parent_population,parent_geoname_id`\n}", "func (gsuo *GameServerUpdateOne) Select(field string, fields ...string) *GameServerUpdateOne {\n\tgsuo.fields = append([]string{field}, fields...)\n\treturn gsuo\n}", "func (db *DB) Select(funcName string, dest interface{}, query string, args ...interface{}) error {\n\n\terr := db.DB.Select(dest, query, args...)\n\treturn err\n}", "func (oiuo *OrderInfoUpdateOne) Select(field string, fields ...string) *OrderInfoUpdateOne {\n\toiuo.fields = append([]string{field}, fields...)\n\treturn oiuo\n}", "func (t *TablesType) Select(f ...qb.Field) *qb.SelectBuilder {\n\treturn t.table.Select(f)\n}", "func (duo *DocUpdateOne) Select(field string, fields ...string) *DocUpdateOne {\n\tduo.fields = append([]string{field}, fields...)\n\treturn duo\n}", "func (suo *SettingUpdateOne) Select(field string, fields ...string) *SettingUpdateOne {\n\tsuo.fields = append([]string{field}, fields...)\n\treturn suo\n}", "func (truo *TradeRecordUpdateOne) Select(field string, fields ...string) *TradeRecordUpdateOne {\n\ttruo.fields = append([]string{field}, fields...)\n\treturn truo\n}", "func (b *QueryBuilder) Select(nodes ...NodeI) {\n\tif b.GroupBys != nil {\n\t\tpanic(\"You cannot have Select and GroupBy statements in the same query. The GroupBy columns will automatically be selected.\")\n\t}\n\tfor _, n := range nodes {\n\t\tif NodeGetType(n) != ColumnNodeType {\n\t\t\tpanic(\"you can only select column nodes\")\n\t\t}\n\t}\n\tb.Selects = append(b.Selects, nodes...)\n}", "func (tuo *TransactionUpdateOne) Select(field string, fields ...string) *TransactionUpdateOne {\n\ttuo.fields = append([]string{field}, fields...)\n\treturn tuo\n}", "func (sd *SelectDataset) Select(selects ...interface{}) *SelectDataset {\n\tif len(selects) == 0 {\n\t\treturn sd.ClearSelect()\n\t}\n\treturn sd.copy(sd.clauses.SetSelect(exp.NewColumnListExpression(selects...)))\n}", "func (isrtuo *IPStaticRoutingTableUpdateOne) Select(field string, fields ...string) *IPStaticRoutingTableUpdateOne {\n\tisrtuo.fields = append([]string{field}, fields...)\n\treturn isrtuo\n}", "func (t TagAppTable) SelectCols() string {\n\treturn `tag_app_id,name,weight,archived_at`\n}", "func (dbi *DB) SelectRow(sqls string, arg ...string) (map[string]string, error) {\r\n\tif dbi.status == false {\r\n\t\treturn nil, errors.New(\"database was not opened.\")\r\n\t}\r\n\r\n\t// start select\r\n\tdbi.createOperation(\"DB_SELECT\")\r\n\tdbi.data.reqSql = sqls\r\n\tdbi.data.inVar = arg\r\n\t// data\r\n\tdbi.data.commPrepare()\r\n\t// communicate\r\n\tif dbi.data.comm() == false {\r\n\t\tmylog.Println(dbi.data.sqlCode, \":\", dbi.data.sqlErrm)\r\n\t\tdbi.Close()\r\n\t\treturn nil, errors.New(dbi.Sqlerrm)\r\n\t}\r\n\t// parse\r\n\tdbi.data.commParse()\r\n\tdbi.parseError()\r\n\tif dbi.Sqlcode != 0 {\r\n\t\treturn nil, errors.New(dbi.Sqlerrm)\r\n\t}\r\n\r\n\t// get column name list\r\n\tdbi.createOperation(\"DB_COLUMNS\")\r\n\t// data\r\n\tdbi.data.curId = -1\r\n\tdbi.data.commPrepare()\r\n\t// communicate\r\n\tif dbi.data.comm() == false {\r\n\t\tdbi.Close()\r\n\t\treturn nil, errors.New(dbi.Sqlerrm)\r\n\t}\r\n\t// parse\r\n\tdbi.data.commParse()\r\n\t// no need to change dbi.sqlcode\r\n\r\n\tcolvar := make(map[string]string)\r\n\tfor i := 0; i < len(dbi.data.colName); i++ {\r\n\t\tcolvar[strings.ToLower(dbi.data.colName[i])] = dbi.data.outVar[i]\r\n\t}\r\n\treturn colvar, nil\r\n}", "func (auo *AdministratorUpdateOne) Select(field string, fields ...string) *AdministratorUpdateOne {\n\tauo.fields = append([]string{field}, fields...)\n\treturn auo\n}", "func (muo *ModelUpdateOne) Select(field string, fields ...string) *ModelUpdateOne {\n\tmuo.fields = append([]string{field}, fields...)\n\treturn muo\n}", "func (ouo *OtherUpdateOne) Select(field string, fields ...string) *OtherUpdateOne {\n\touo.fields = append([]string{field}, fields...)\n\treturn ouo\n}", "func (e *SqlExecutor) Select(i interface{}, query string, args ...interface{}) ([]interface{}, error) {\n\thook := e.db.ExecutorHook()\n\thook.BeforeSelect(e.ctx, query, args...)\n\tv, err := e.SqlExecutor.Select(i, query, args...)\n\thook.AfterSelect(e.ctx, query, args...)\n\treturn v, err\n}", "func (c *commentsQueryBuilder) Select(fields ...string) *commentsQueryBuilder {\n\tif c.err != nil {\n\t\treturn c\n\t}\n\tvar fieldSet []*mapping.StructField\n\tfor _, field := range fields {\n\t\tstructField, ok := NRN_Comments.Model.FieldByName(field)\n\t\tif !ok {\n\t\t\tc.err = errors.Wrapf(mapping.ErrInvalidModelField, \"field: '%s' is not valid for model: '_Comments'\", field)\n\t\t\treturn c\n\t\t}\n\t\tfieldSet = append(fieldSet, structField)\n\t}\n\tc.builder.Select(fieldSet...)\n\treturn c\n}", "func (ttruo *TradeTimeRangeUpdateOne) Select(field string, fields ...string) *TradeTimeRangeUpdateOne {\n\tttruo.fields = append([]string{field}, fields...)\n\treturn ttruo\n}", "func (duo *DealUpdateOne) Select(field string, fields ...string) *DealUpdateOne {\n\tduo.fields = append([]string{field}, fields...)\n\treturn duo\n}", "func (srmuo *SysRoleMenuUpdateOne) Select(field string, fields ...string) *SysRoleMenuUpdateOne {\n\tsrmuo.fields = append([]string{field}, fields...)\n\treturn srmuo\n}", "func (session *Session) Select(str string) *Session {\n\tsession.Statement.Select(str)\n\treturn session\n}", "func (db *DB) Select(dest interface{}, query string, args ...interface{}) error {\n return Select(db, dest, query, args...)\n}", "func (auo *ArticleUpdateOne) Select(field string, fields ...string) *ArticleUpdateOne {\n\tauo.fields = append([]string{field}, fields...)\n\treturn auo\n}", "func (ouo *OrganizationUpdateOne) Select(field string, fields ...string) *OrganizationUpdateOne {\n\touo.fields = append([]string{field}, fields...)\n\treturn ouo\n}", "func (vuuo *VacUserUpdateOne) Select(field string, fields ...string) *VacUserUpdateOne {\n\tvuuo.fields = append([]string{field}, fields...)\n\treturn vuuo\n}", "func (ruo *RevisionUpdateOne) Select(field string, fields ...string) *RevisionUpdateOne {\n\truo.fields = append([]string{field}, fields...)\n\treturn ruo\n}", "func (s SelectStatement) Fields() []string {\n\treturn s.fields\n}", "func (ocuo *OAuthConnectionUpdateOne) Select(field string, fields ...string) *OAuthConnectionUpdateOne {\n\tocuo.fields = append([]string{field}, fields...)\n\treturn ocuo\n}", "func (gq *GoodsQuery) Select(field string, fields ...string) *GoodsSelect {\n\tselector := &GoodsSelect{config: gq.config}\n\tselector.fields = append([]string{field}, fields...)\n\tselector.path = func(ctx context.Context) (prev *dsl.Traversal, err error) {\n\t\tif err := gq.prepareQuery(ctx); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn gq.gremlinQuery(), nil\n\t}\n\treturn selector\n}", "func Select(trans sqtables.Transaction, tkns *tokens.TokenList) (string, *sqtables.DataSet, error) {\n\n\tq, err := SelectParse(trans.Profile(), tkns)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tdata, err := SelectExecute(trans.Profile(), q)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn fmt.Sprintf(\"%d rows found\", data.Len()), data, err\n}", "func (druo *DeviceRequestUpdateOne) Select(field string, fields ...string) *DeviceRequestUpdateOne {\n\tdruo.fields = append([]string{field}, fields...)\n\treturn druo\n}", "func (oliuo *OrderLineItemUpdateOne) Select(field string, fields ...string) *OrderLineItemUpdateOne {\n\toliuo.fields = append([]string{field}, fields...)\n\treturn oliuo\n}", "func (db *DB) Select(\n\tctx *Context,\n\tid int64,\n) (\n\tni *msg.NewsItem,\n\terr error,\n) {\n\n\tconst selectNewsItem = `SELECT * FROM ` + tableName + ` WHERE id = $1`\n\n\tni = new(msg.NewsItem)\n\terr = db.DB.QueryRowContext(ctx.Ctx, selectNewsItem, id).Scan(\n\t\t&ni.ID,\n\t\t&ni.Header,\n\t\t&ni.Data,\n\t)\n\treturn\n}", "func (tuo *TeamUpdateOne) Select(field string, fields ...string) *TeamUpdateOne {\n\ttuo.fields = append([]string{field}, fields...)\n\treturn tuo\n}", "func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {\n\tuuo.fields = append([]string{field}, fields...)\n\treturn uuo\n}", "func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {\n\tuuo.fields = append([]string{field}, fields...)\n\treturn uuo\n}", "func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {\n\tuuo.fields = append([]string{field}, fields...)\n\treturn uuo\n}", "func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {\n\tuuo.fields = append([]string{field}, fields...)\n\treturn uuo\n}", "func Select(c runner.Client) *Query {\n\treturn NewQuery(types.Select, c)\n}", "func (luuo *LastUpdatedUpdateOne) Select(field string, fields ...string) *LastUpdatedUpdateOne {\n\tluuo.fields = append([]string{field}, fields...)\n\treturn luuo\n}", "func (fuo *FriendshipUpdateOne) Select(field string, fields ...string) *FriendshipUpdateOne {\n\tfuo.fields = append([]string{field}, fields...)\n\treturn fuo\n}", "func (aruo *AuthRequestUpdateOne) Select(field string, fields ...string) *AuthRequestUpdateOne {\n\taruo.fields = append([]string{field}, fields...)\n\treturn aruo\n}", "func (ceuo *CloudEventsUpdateOne) Select(field string, fields ...string) *CloudEventsUpdateOne {\n\tceuo.fields = append([]string{field}, fields...)\n\treturn ceuo\n}", "func (b *Book) Select(id int) error {\n\tconn, ctx, err := domain.GetConn()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\tstmt, err := conn.PrepareContext(ctx, selectQuery)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trow := stmt.QueryRowContext(ctx, id)\n\n\tif err := row.Scan(&b.ID, &b.Name, &b.Genre, &b.AuthorID); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (puo *PostUpdateOne) Select(field string, fields ...string) *PostUpdateOne {\n\tpuo.fields = append([]string{field}, fields...)\n\treturn puo\n}", "func (puo *PostUpdateOne) Select(field string, fields ...string) *PostUpdateOne {\n\tpuo.fields = append([]string{field}, fields...)\n\treturn puo\n}", "func Select(cols ...string) *Builder {\r\n\tbuilder := &Builder{cond: NewCond()}\r\n\treturn builder.Select(cols...)\r\n}", "func (oupuo *OrgUnitPositionUpdateOne) Select(field string, fields ...string) *OrgUnitPositionUpdateOne {\n\toupuo.fields = append([]string{field}, fields...)\n\treturn oupuo\n}", "func (db *DB) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error {\n\trows, err := db.Query(ctx, query, args...)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// if something happens here, we want to make sure the rows are Closed\n\tdefer rows.Close()\n\treturn scanAll(rows, dest, false)\n}", "func (oumuo *OrgUnitMemberUpdateOne) Select(field string, fields ...string) *OrgUnitMemberUpdateOne {\n\toumuo.fields = append([]string{field}, fields...)\n\treturn oumuo\n}", "func (q *OperationsQ) Select(dest interface{}) error {\n\tif q.Err != nil {\n\t\treturn q.Err\n\t}\n\n\tq.Err = q.parent.Select(dest, q.sql)\n\treturn q.Err\n}", "func (nuo *NodeUpdateOne) Select(field string, fields ...string) *NodeUpdateOne {\n\tnuo.fields = append([]string{field}, fields...)\n\treturn nuo\n}", "func (p *postsQueryBuilder) Select(fields ...string) *postsQueryBuilder {\n\tif p.err != nil {\n\t\treturn p\n\t}\n\tvar fieldSet []*mapping.StructField\n\tfor _, field := range fields {\n\t\tstructField, ok := NRN_Posts.Model.FieldByName(field)\n\t\tif !ok {\n\t\t\tp.err = errors.Wrapf(mapping.ErrInvalidModelField, \"field: '%s' is not valid for model: '_Posts'\", field)\n\t\t\treturn p\n\t\t}\n\t\tfieldSet = append(fieldSet, structField)\n\t}\n\tp.builder.Select(fieldSet...)\n\treturn p\n}", "func (cq *CartQuery) Select(field string, fields ...string) *CartSelect {\n\tselector := &CartSelect{config: cq.config}\n\tselector.fields = append([]string{field}, fields...)\n\tselector.path = func(ctx context.Context) (prev *sql.Selector, err error) {\n\t\tif err := cq.prepareQuery(ctx); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn cq.sqlQuery(), nil\n\t}\n\treturn selector\n}", "func (dao *UserPresencesDAO) Select(user_id int32) *dataobject.UserPresencesDO {\n\tvar query = \"select id, user_id, last_seen_at from user_presences where user_id = ?\"\n\trows, err := dao.db.Queryx(query, user_id)\n\n\tif err != nil {\n\t\terrDesc := fmt.Sprintf(\"Queryx in Select(_), error: %v\", err)\n\t\tglog.Error(errDesc)\n\t\tpanic(mtproto.NewRpcError(int32(mtproto.TLRpcErrorCodes_DBERR), errDesc))\n\t}\n\n\tdefer rows.Close()\n\n\tdo := &dataobject.UserPresencesDO{}\n\tif rows.Next() {\n\t\terr = rows.StructScan(do)\n\t\tif err != nil {\n\t\t\terrDesc := fmt.Sprintf(\"StructScan in Select(_), error: %v\", err)\n\t\t\tglog.Error(errDesc)\n\t\t\tpanic(mtproto.NewRpcError(int32(mtproto.TLRpcErrorCodes_DBERR), errDesc))\n\t\t}\n\t} else {\n\t\treturn nil\n\t}\n\n\terr = rows.Err()\n\tif err != nil {\n\t\terrDesc := fmt.Sprintf(\"rows in Select(_), error: %v\", err)\n\t\tglog.Error(errDesc)\n\t\tpanic(mtproto.NewRpcError(int32(mtproto.TLRpcErrorCodes_DBERR), errDesc))\n\t}\n\n\treturn do\n}", "func Select(db *sql.DB, q Queryer, filters string) ([]Queryer, error) {\n\tquery := fmt.Sprintf(\"SELECT * FROM %s %s\", q.TableName(), filters)\n\trows, err := db.Query(query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tqs, err := receive(q, rows)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn qs, nil\n}", "func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOne {\n\tguo.fields = append([]string{field}, fields...)\n\treturn guo\n}", "func (t *Transaction) Select(dest interface{}, query string, args ...interface{}) error {\n\treturn hookedselect(t.dbmap, t, dest, query, args...)\n}", "func (tuo *TagUpdateOne) Select(field string, fields ...string) *TagUpdateOne {\n\ttuo.fields = append([]string{field}, fields...)\n\treturn tuo\n}", "func (db *DB) Select(table string, cb RowCB, columns ...string) error {\n\tinnerCB := func(row Row) bool {\n\t\tcb(row)\n\t\treturn false // not done\n\t}\n\treturn db.SelectDone(table, innerCB, columns...)\n}", "func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) {\n\ttx = db.getInstance()\n\n\tswitch v := query.(type) {\n\tcase []string:\n\t\ttx.Statement.Selects = v\n\n\t\tfor _, arg := range args {\n\t\t\tswitch arg := arg.(type) {\n\t\t\tcase string:\n\t\t\t\ttx.Statement.Selects = append(tx.Statement.Selects, arg)\n\t\t\tcase []string:\n\t\t\t\ttx.Statement.Selects = append(tx.Statement.Selects, arg...)\n\t\t\tdefault:\n\t\t\t\ttx.AddError(fmt.Errorf(\"unsupported select args %v %v\", query, args))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tdelete(tx.Statement.Clauses, \"SELECT\")\n\tcase string:\n\t\tif strings.Count(v, \"?\") >= len(args) && len(args) > 0 {\n\t\t\ttx.Statement.AddClause(clause.Select{\n\t\t\t\tDistinct: db.Statement.Distinct,\n\t\t\t\tExpression: clause.Expr{SQL: v, Vars: args},\n\t\t\t})\n\t\t} else if strings.Count(v, \"@\") > 0 && len(args) > 0 {\n\t\t\ttx.Statement.AddClause(clause.Select{\n\t\t\t\tDistinct: db.Statement.Distinct,\n\t\t\t\tExpression: clause.NamedExpr{SQL: v, Vars: args},\n\t\t\t})\n\t\t} else {\n\t\t\ttx.Statement.Selects = []string{v}\n\n\t\t\tfor _, arg := range args {\n\t\t\t\tswitch arg := arg.(type) {\n\t\t\t\tcase string:\n\t\t\t\t\ttx.Statement.Selects = append(tx.Statement.Selects, arg)\n\t\t\t\tcase []string:\n\t\t\t\t\ttx.Statement.Selects = append(tx.Statement.Selects, arg...)\n\t\t\t\tdefault:\n\t\t\t\t\ttx.Statement.AddClause(clause.Select{\n\t\t\t\t\t\tDistinct: db.Statement.Distinct,\n\t\t\t\t\t\tExpression: clause.Expr{SQL: v, Vars: args},\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdelete(tx.Statement.Clauses, \"SELECT\")\n\t\t}\n\tdefault:\n\t\ttx.AddError(fmt.Errorf(\"unsupported select args %v %v\", query, args))\n\t}\n\n\treturn\n}", "func (kcuo *K8sContainerUpdateOne) Select(field string, fields ...string) *K8sContainerUpdateOne {\n\tkcuo.fields = append([]string{field}, fields...)\n\treturn kcuo\n}", "func (upuo *UnsavedPostUpdateOne) Select(field string, fields ...string) *UnsavedPostUpdateOne {\n\tupuo.fields = append([]string{field}, fields...)\n\treturn upuo\n}" ]
[ "0.72090787", "0.7190675", "0.71419865", "0.7098499", "0.70653456", "0.7048921", "0.70345056", "0.7005074", "0.69855535", "0.690301", "0.6891688", "0.6752438", "0.67426044", "0.6661285", "0.66525835", "0.6647796", "0.6607657", "0.65955967", "0.65814257", "0.6540316", "0.65068686", "0.6473954", "0.640869", "0.6389745", "0.6386461", "0.63826483", "0.6369348", "0.6368302", "0.63644457", "0.63596773", "0.63316095", "0.633028", "0.6315887", "0.6308722", "0.6306441", "0.6303019", "0.6298048", "0.62505794", "0.6239338", "0.6237285", "0.6220628", "0.6192116", "0.6186379", "0.6182264", "0.61776924", "0.6177504", "0.6171383", "0.6138389", "0.612227", "0.61211616", "0.6117362", "0.6108265", "0.6104386", "0.6096431", "0.6091807", "0.60750526", "0.6071309", "0.60477495", "0.60263264", "0.6023747", "0.60192055", "0.6008667", "0.5999094", "0.5982844", "0.5969585", "0.5969014", "0.59642726", "0.59564644", "0.5943822", "0.59377825", "0.5926806", "0.5915693", "0.5915693", "0.5915693", "0.5915693", "0.59057236", "0.5898781", "0.58788085", "0.5869262", "0.58646286", "0.5850032", "0.58453304", "0.58453304", "0.58428925", "0.58307785", "0.58239514", "0.5802992", "0.5802288", "0.57815975", "0.5765115", "0.5761657", "0.576065", "0.5741602", "0.5737542", "0.57183194", "0.5718288", "0.57175267", "0.5715598", "0.57125473", "0.56972325" ]
0.6302345
36
From defines which SObject will be query.
func (op *OpQuery) From(sobjectName string) *OpQuery { op.sobjectName = sobjectName return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Search) From(from int) *Search {\n\tr.req.From = &from\n\n\treturn r\n}", "func From(from string) QueryMod {\n\treturn func(q *queries.Query) {\n\t\tqueries.AppendFrom(q, from)\n\t}\n}", "func (q *Query) From(from time.Time) *Query {\n\tq.from, q.to = from, time.Time{}\n\treturn q\n}", "func (sp *ServicePoint) QueryFrom() *BookborrowQuery {\n\treturn (&ServicePointClient{config: sp.config}).QueryFrom(sp)\n}", "func (stmt *statement) From(expr string, args ...interface{}) Statement {\n\tstmt.addPart(posFrom, \"FROM\", expr, args, \", \")\n\treturn stmt\n}", "func (g *Graph) From(ss source.Sources) {\n\tg.from = ss\n}", "func (tx *Tx) From(name string) *Query {\n\t// TODO: stop loading ALL relations just to get one\n\tq := new(Query)\n\trel, err := tx.db.Relation(name)\n\tif err != nil {\n\t\tq.err = err\n\t\treturn q\n\t}\n\tq.from = rel\n\tq.tx = tx\n\treturn q\n}", "func From(table string) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, fromClause{\n\t\t\ttable: table,\n\t\t})\n\t\treturn q\n\t}\n}", "func (app *fetchRegistryBuilder) From(from string) FetchRegistryBuilder {\n\tapp.from = from\n\treturn app\n}", "func (qb *HuxQueryBuilder) FilterFrom() *HuxQueryBuilder {\n\tqb.filterDirection = \"from\"\n\treturn qb\n}", "func From(address string) (string, string) {\n\treturn \"From\", address\n}", "func (s *Session) From(table string) *Session {\n\ts.initStatemnt()\n\ts.statement.From(table)\n\treturn s\n}", "func (def *Definition) From() source.Sources {\n\treturn def.g.from\n}", "func (q *Query) From(t time.Time) *Query {\n\t// Subtract 1 nanosecond form the specified time\n\t// Leads to an inclusive date search\n\tt = t.Add(-1 * time.Nanosecond)\n\n\tq.from = gouuidv6.NewFromTime(t)\n\treturn q\n}", "func (sp *SkillPath) GetFrom(origin int64) {\n\tdb := sp.DB.Get()\n\n\titems := []Item{}\n\terr := db.Select(&items, `SELECT \"typeID\", \"groupID\", \"typeName\" FROM evesde.\"invTypes\"`)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"Length of items: %d\\n\", len(items))\n\tfor _, item := range items {\n\t\tfmt.Printf(\"ItemID: %d\\tGroupID: %d\\tName: %v\\n\", item.TypeID, item.GroupID, item.Name)\n\t}\n}", "func (c *Chainable) From(args ...Argument) *Chainable {\n\tc.from = args\n\treturn c\n}", "func (r *ListMessagesRequest) From(from time.Time) *ListMessagesRequest {\n\tr.request.Add(\"date_from\", from.UTC().Format(\"2006-01-02 15:04:05\"))\n\treturn r\n}", "func (r *ListTemplatesRequest) From(from time.Time) *ListTemplatesRequest {\n\tr.request.Add(\"date_from\", from.UTC().Format(\"2006-01-02 15:04:05\"))\n\treturn r\n}", "func (q *Query) From(tableOrQuery interface{}) *Query {\n\tif tableName, ok := tableOrQuery.(string); ok {\n\t\tq.tables = append(q.tables, &table{\n\t\t\tname: tableName,\n\t\t})\n\t} else if provider, ok := tableOrQuery.(SQLProvider); ok {\n\t\tq.tables = append(q.tables, &table{\n\t\t\tsubQuery: provider,\n\t\t})\n\t} else {\n\t\tpanic(\"From must be a table name (string) or a subquery!\")\n\t}\n\n\treturn q\n}", "func (sd *SelectDataset) From(from ...interface{}) *SelectDataset {\n\tvar sources []interface{}\n\tnumSources := 0\n\tfor _, source := range from {\n\t\tif ds, ok := source.(*SelectDataset); ok && !ds.clauses.HasAlias() {\n\t\t\tnumSources++\n\t\t\tsources = append(sources, ds.As(fmt.Sprintf(\"t%d\", numSources)))\n\t\t} else {\n\t\t\tsources = append(sources, source)\n\t\t}\n\t}\n\treturn sd.copy(sd.clauses.SetFrom(exp.NewColumnListExpression(sources...)))\n}", "func (data DataList) From(name string) DataList {\n\treturn data.As(name)\n}", "func (self Accessor) From(relation *nodes.RelationNode) *SelectManager {\n\treturn Selection(relation)\n}", "func (c *OrganizationsHostQueriesListCall) From(from string) *OrganizationsHostQueriesListCall {\n\tc.urlParams_.Set(\"from\", from)\n\treturn c\n}", "func (wbs *impl) From(from time.Time) Interface {\n\tif from.IsZero() {\n\t\treturn wbs\n\t}\n\twbs.fromAt = from\n\twbs.inc.From(wbs.fromAt)\n\twbs.ods.From(wbs.fromAt)\n\twbs.sle.From(wbs.fromAt)\n\twbs.stk.From(wbs.fromAt)\n\twbs.mds.From(wbs.fromAt)\n\n\treturn wbs\n}", "func CommandFrom(from *south.CoreCommand) *north.Command {\n\tif from == nil {\n\t\treturn nil\n\t}\n\n\treturn &north.Command{\n\t\tName: from.Name,\n\t\tGet: CommandGetFrom(from.Get),\n\t\tPut: CommandPutFrom(from.Put),\n\t}\n}", "func (c *OrganizationsHostSecurityReportsListCall) From(from string) *OrganizationsHostSecurityReportsListCall {\n\tc.urlParams_.Set(\"from\", from)\n\treturn c\n}", "func (o *EventQueryResult) SetFrom(v int64) {\n\to.From = &v\n}", "func (s *Stream) From(src api.StreamSource) *Stream {\n\ts.source = src\n\treturn s\n}", "func (d *AuditDTO) GetFrom(s Audit) {\n\td.transfer(s)\n}", "func (o *InventoryStocktakingSearchParams) SetFrom(from *int64) {\n\to.From = from\n}", "func (c *Contribution) From() string {\n\treturn c.from\n}", "func (c *OrganizationsEnvironmentsQueriesListCall) From(from string) *OrganizationsEnvironmentsQueriesListCall {\n\tc.urlParams_.Set(\"from\", from)\n\treturn c\n}", "func (s *MessagesSearchCounter) FillFrom(from interface {\n\tGetInexact() (value bool)\n\tGetFilter() (value MessagesFilterClass)\n\tGetCount() (value int)\n}) {\n\ts.Inexact = from.GetInexact()\n\ts.Filter = from.GetFilter()\n\ts.Count = from.GetCount()\n}", "func (obj *expense) From() []hash.Hash {\n\treturn obj.from\n}", "func (e *Element) From() string {\n\treturn e.attrs.Get(\"from\")\n}", "func (o *SearchAbsoluteParams) SetFrom(from string) {\n\to.From = from\n}", "func (tx *Hello) From() common.Address {\n\treturn tx.From_\n}", "func (sq *ServerQuery) QueryTemplateFrom() *TemplateQuery {\n\tquery := &TemplateQuery{config: sq.config}\n\tquery.path = func(ctx context.Context) (fromU *sql.Selector, err error) {\n\t\tif err := sq.prepareQuery(ctx); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tselector := sq.sqlQuery()\n\t\tif err := selector.Err(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(server.Table, server.FieldID, selector),\n\t\t\tsqlgraph.To(template.Table, template.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.M2M, false, server.TemplateFromTable, server.TemplateFromPrimaryKey...),\n\t\t)\n\t\tfromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step)\n\t\treturn fromU, nil\n\t}\n\treturn query\n}", "func (s *BasePlSqlParserListener) EnterFrom_clause(ctx *From_clauseContext) {}", "func (e Edge) From() string {\n\treturn e.from\n}", "func (g *MessagesGetScheduledMessagesRequest) FillFrom(from interface {\n\tGetPeer() (value InputPeerClass)\n\tGetID() (value []int)\n}) {\n\tg.Peer = from.GetPeer()\n\tg.ID = from.GetID()\n}", "func (m *Message) From() string {\n\treturn m.from\n}", "func (c *OrganizationsEnvironmentsSecurityReportsListCall) From(from string) *OrganizationsEnvironmentsSecurityReportsListCall {\n\tc.urlParams_.Set(\"from\", from)\n\treturn c\n}", "func (u *AuthUserDetailSerializer) From(user *models.User) {\n\tu.ID = user.ID\n\tu.Username = user.Username\n\tu.Email = user.Email\n\tu.Name = user.Name\n\tu.IsActive = user.IsActive\n\tu.IsSuperuser = user.IsSuperuser\n\tu.DateAdded = user.DateAdded\n\tu.LastLogin = user.LastLogin\n}", "func From(other genericd.T) T {\n\treturn T{other.Get(0, 0), other.Get(0, 1)}\n}", "func (o *ResolveBatchParams) SetFrom(from *string) {\n\to.From = from\n}", "func (b *MessagesGetHistoryAttachmentsBuilder) StartFrom(v string) *MessagesGetHistoryAttachmentsBuilder {\n\tb.Params[\"start_from\"] = v\n\treturn b\n}", "func (c *customerio) From(name, from string) Mailer {\n\tc.from = address{Name: name, Email: from}\n\treturn c\n}", "func (m *MailYak) From(addr string) {\n\tm.fromAddr = m.trimRegex.ReplaceAllString(addr, \"\")\n}", "func (selSt *State) SelectFrom(currSt *State) {\n\tfor key, data := range *currSt {\n\t\t(*selSt)[key] = data\n\t}\n}", "func (g *Graph) Query(from ...rdf.Term) Query {\n\treturn Query{g: g, terms: from}\n}", "func (s *Transaction) SetFrom(v string) *Transaction {\n\ts.From = &v\n\treturn s\n}", "func (op *InvoicesListOp) FromDate(val time.Time) *InvoicesListOp {\n\tif op != nil {\n\t\top.QueryOpts.Set(\"from_date\", val.Format(time.RFC3339))\n\t}\n\treturn op\n}", "func (m *ChatMessage) SetFrom(value ChatMessageFromIdentitySetable)() {\n m.from = value\n}", "func ExampleZSelectBuilder_From() {\n\tuser := q.T(\"user\")\n\tfmt.Println(\"Simple: \", q.Select().From(user))\n\tpost := q.T(\"post\")\n\tfmt.Println(\"Complex:\", q.Select().From(user, post).Where(\n\t\tq.Eq(user.C(\"id\"), post.C(\"user_id\")),\n\t))\n\tfmt.Println(\"Builder:\", q.Select().From(q.Select().From(q.T(\"post\")).T(\"p\")))\n\t// Output:\n\t// Simple: SELECT * FROM \"user\" []\n\t// Complex: SELECT * FROM \"user\", \"post\" WHERE \"user\".\"id\" = \"post\".\"user_id\" []\n\t// Builder: SELECT * FROM (SELECT * FROM \"post\") AS \"p\" []\n}", "func (o *QueryUserExpGrantHistoryParams) SetFrom(fromVar *string) {\n\to.From = fromVar\n}", "func (o *JourneyJourneyResultsParams) SetFrom(from string) {\n\to.From = from\n}", "func (hl HistoryLog) PrintFrom(obj HistoryLogger) {\n\thl.l.Println(obj.GenSummary())\n}", "func (o *GetLogsParams) SetFrom(from *string) {\n\to.From = from\n}", "func From(i time.Time) func(*ListOptions) {\n\treturn func(l *ListOptions) {\n\t\tl.From = i\n\t}\n}", "func (b DeleteBuilder) From(from string) DeleteCondition {\n\treturn builder.Set(b, \"From\", from).(DeleteBuilder)\n}", "func (r *StoriesReportRequest) FillFrom(from interface {\n\tGetUserID() (value InputUserClass)\n\tGetID() (value []int)\n\tGetReason() (value ReportReasonClass)\n\tGetMessage() (value string)\n}) {\n\tr.UserID = from.GetUserID()\n\tr.ID = from.GetID()\n\tr.Reason = from.GetReason()\n\tr.Message = from.GetMessage()\n}", "func (u *UpdateShortSentMessage) FillFrom(from interface {\n\tGetOut() (value bool)\n\tGetID() (value int)\n\tGetPts() (value int)\n\tGetPtsCount() (value int)\n\tGetDate() (value int)\n\tGetMedia() (value MessageMediaClass, ok bool)\n\tGetEntities() (value []MessageEntityClass, ok bool)\n\tGetTTLPeriod() (value int, ok bool)\n}) {\n\tu.Out = from.GetOut()\n\tu.ID = from.GetID()\n\tu.Pts = from.GetPts()\n\tu.PtsCount = from.GetPtsCount()\n\tu.Date = from.GetDate()\n\tif val, ok := from.GetMedia(); ok {\n\t\tu.Media = val\n\t}\n\n\tif val, ok := from.GetEntities(); ok {\n\t\tu.Entities = val\n\t}\n\n\tif val, ok := from.GetTTLPeriod(); ok {\n\t\tu.TTLPeriod = val\n\t}\n\n}", "func (t *MessagesTranslateTextRequest) FillFrom(from interface {\n\tGetPeer() (value InputPeerClass, ok bool)\n\tGetID() (value []int, ok bool)\n\tGetText() (value []TextWithEntities, ok bool)\n\tGetToLang() (value string)\n}) {\n\tif val, ok := from.GetPeer(); ok {\n\t\tt.Peer = val\n\t}\n\n\tif val, ok := from.GetID(); ok {\n\t\tt.ID = val\n\t}\n\n\tif val, ok := from.GetText(); ok {\n\t\tt.Text = val\n\t}\n\n\tt.ToLang = from.GetToLang()\n}", "func (t *T) From(filters ...Filter) *T {\n\tfor _, filter := range filters {\n\t\tt.sources = filter(t.sources)\n\t}\n\treturn t\n}", "func (s *BaseGraffleParserListener) EnterFrom_to_stmnt(ctx *From_to_stmntContext) {}", "func (j *Job) From(t time.Time) *Job {\n\tj.from = t\n\treturn j\n}", "func (r *MessagesReportRequest) FillFrom(from interface {\n\tGetPeer() (value InputPeerClass)\n\tGetID() (value []int)\n\tGetReason() (value ReportReasonClass)\n\tGetMessage() (value string)\n}) {\n\tr.Peer = from.GetPeer()\n\tr.ID = from.GetID()\n\tr.Reason = from.GetReason()\n\tr.Message = from.GetMessage()\n}", "func (i *Invoice) FillFrom(from interface {\n\tGetTest() (value bool)\n\tGetNameRequested() (value bool)\n\tGetPhoneRequested() (value bool)\n\tGetEmailRequested() (value bool)\n\tGetShippingAddressRequested() (value bool)\n\tGetFlexible() (value bool)\n\tGetPhoneToProvider() (value bool)\n\tGetEmailToProvider() (value bool)\n\tGetRecurring() (value bool)\n\tGetCurrency() (value string)\n\tGetPrices() (value []LabeledPrice)\n\tGetMaxTipAmount() (value int64, ok bool)\n\tGetSuggestedTipAmounts() (value []int64, ok bool)\n\tGetRecurringTermsURL() (value string, ok bool)\n}) {\n\ti.Test = from.GetTest()\n\ti.NameRequested = from.GetNameRequested()\n\ti.PhoneRequested = from.GetPhoneRequested()\n\ti.EmailRequested = from.GetEmailRequested()\n\ti.ShippingAddressRequested = from.GetShippingAddressRequested()\n\ti.Flexible = from.GetFlexible()\n\ti.PhoneToProvider = from.GetPhoneToProvider()\n\ti.EmailToProvider = from.GetEmailToProvider()\n\ti.Recurring = from.GetRecurring()\n\ti.Currency = from.GetCurrency()\n\ti.Prices = from.GetPrices()\n\tif val, ok := from.GetMaxTipAmount(); ok {\n\t\ti.MaxTipAmount = val\n\t}\n\n\tif val, ok := from.GetSuggestedTipAmounts(); ok {\n\t\ti.SuggestedTipAmounts = val\n\t}\n\n\tif val, ok := from.GetRecurringTermsURL(); ok {\n\t\ti.RecurringTermsURL = val\n\t}\n\n}", "func NewFromCommand(index int, rawArgs string) (*FromCommand, error) {\n\tif err := validateRawArgs(CmdFrom, rawArgs); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// If params are not provided, assume nameless params format:\n\t// FROM addr.1 addr.2 addr.etc\n\tvar argMap map[string]string\n\tif !strings.Contains(rawArgs, \"hosts:\") &&\n\t\t!strings.Contains(rawArgs, \"nodes:\") &&\n\t\t!strings.Contains(rawArgs, \"source:\") &&\n\t\t!strings.Contains(rawArgs, \"port:\") {\n\t\trawArgs = makeNamedPram(\"hosts\", rawArgs)\n\t}\n\n\targMap, err := mapArgs(rawArgs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"FROM: %v\", err)\n\t}\n\n\t// add missing params\n\tif _, ok := argMap[\"port\"]; !ok {\n\t\targMap[\"port\"] = Defaults.ServicePort\n\t}\n\n\tif _, ok := argMap[\"retries\"]; !ok {\n\t\targMap[\"retries\"] = Defaults.ConnectionRetries\n\t}\n\n\tif _, ok := argMap[\"timeout\"]; !ok {\n\t\targMap[\"timeout\"] = Defaults.ConnectionTimeout\n\t}\n\n\tif len(argMap[\"hosts\"]) == 0 && len(argMap[\"nodes\"]) == 0 {\n\t\treturn nil, fmt.Errorf(\"FROM: must have hosts or nodes\")\n\t}\n\n\tcmd := &FromCommand{cmd: cmd{index: index, name: CmdFrom, args: argMap}}\n\tif err := validateCmdArgs(CmdFrom, argMap); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn cmd, nil\n}", "func (b *EmailBuilder) From(from string) *EmailBuilder {\n\tif !strings.Contains(from, \"@\") {\n\t\tpanic(\"email should contain @\")\n\t}\n\tb.email.from = from\n\treturn b\n}", "func (s *MessagesSendMessageRequest) FillFrom(from interface {\n\tGetNoWebpage() (value bool)\n\tGetSilent() (value bool)\n\tGetBackground() (value bool)\n\tGetClearDraft() (value bool)\n\tGetNoforwards() (value bool)\n\tGetUpdateStickersetsOrder() (value bool)\n\tGetPeer() (value InputPeerClass)\n\tGetReplyTo() (value InputReplyToClass, ok bool)\n\tGetMessage() (value string)\n\tGetRandomID() (value int64)\n\tGetReplyMarkup() (value ReplyMarkupClass, ok bool)\n\tGetEntities() (value []MessageEntityClass, ok bool)\n\tGetScheduleDate() (value int, ok bool)\n\tGetSendAs() (value InputPeerClass, ok bool)\n}) {\n\ts.NoWebpage = from.GetNoWebpage()\n\ts.Silent = from.GetSilent()\n\ts.Background = from.GetBackground()\n\ts.ClearDraft = from.GetClearDraft()\n\ts.Noforwards = from.GetNoforwards()\n\ts.UpdateStickersetsOrder = from.GetUpdateStickersetsOrder()\n\ts.Peer = from.GetPeer()\n\tif val, ok := from.GetReplyTo(); ok {\n\t\ts.ReplyTo = val\n\t}\n\n\ts.Message = from.GetMessage()\n\ts.RandomID = from.GetRandomID()\n\tif val, ok := from.GetReplyMarkup(); ok {\n\t\ts.ReplyMarkup = val\n\t}\n\n\tif val, ok := from.GetEntities(); ok {\n\t\ts.Entities = val\n\t}\n\n\tif val, ok := from.GetScheduleDate(); ok {\n\t\ts.ScheduleDate = val\n\t}\n\n\tif val, ok := from.GetSendAs(); ok {\n\t\ts.SendAs = val\n\t}\n\n}", "func (s Stream) NextFrom(from int, inFi FileInfo, inRc io.ReadCloser) (\n\tfi FileInfo, rc io.ReadCloser, err error) {\n\n\tfi = inFi\n\trc = inRc\n\tfor ; from < len(s); from++ {\n\t\tfi, rc, err = s[from].Next(fi, rc)\n\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif fi == nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (m Move) From() square.Square {\n\treturn m.Source\n}", "func (b *BotApp) FillFrom(from interface {\n\tGetID() (value int64)\n\tGetAccessHash() (value int64)\n\tGetShortName() (value string)\n\tGetTitle() (value string)\n\tGetDescription() (value string)\n\tGetPhoto() (value PhotoClass)\n\tGetDocument() (value DocumentClass, ok bool)\n\tGetHash() (value int64)\n}) {\n\tb.ID = from.GetID()\n\tb.AccessHash = from.GetAccessHash()\n\tb.ShortName = from.GetShortName()\n\tb.Title = from.GetTitle()\n\tb.Description = from.GetDescription()\n\tb.Photo = from.GetPhoto()\n\tif val, ok := from.GetDocument(); ok {\n\t\tb.Document = val\n\t}\n\n\tb.Hash = from.GetHash()\n}", "func (s *BaseSelectStatementParserListener) EnterFromClause(ctx *FromClauseContext) {}", "func (s *TransactionEvent) SetFrom(v string) *TransactionEvent {\n\ts.From = &v\n\treturn s\n}", "func (r *ChannelsReportSpamRequest) FillFrom(from interface {\n\tGetChannel() (value InputChannelClass)\n\tGetParticipant() (value InputPeerClass)\n\tGetID() (value []int)\n}) {\n\tr.Channel = from.GetChannel()\n\tr.Participant = from.GetParticipant()\n\tr.ID = from.GetID()\n}", "func (s *state4) From() (address.Address, error) {\n\treturn s.State.From, nil\n}", "func (c *UserClient) QueryFromClub(u *User) *ClubQuery {\n\tquery := &ClubQuery{config: c.config}\n\tquery.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {\n\t\tid := u.ID\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(user.Table, user.FieldID, id),\n\t\t\tsqlgraph.To(club.Table, club.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.M2O, true, user.FromClubTable, user.FromClubColumn),\n\t\t)\n\t\tfromV = sqlgraph.Neighbors(u.driver.Dialect(), step)\n\t\treturn fromV, nil\n\t}\n\treturn query\n}", "func (o *EventQueryResult) HasFrom() bool {\n\tif o != nil && o.From != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (g *testExpectedGraph) From(id int64) graph.Nodes {\n\tif _, ok := g.from[id]; !ok {\n\t\treturn graph.Empty\n\t}\n\n\tfrom := make([]graph.Node, len(g.from[id]))\n\ti := 0\n\tfor vid := range g.from[id] {\n\t\tfrom[i] = g.nodes[vid]\n\t\ti++\n\t}\n\tif len(from) == 0 {\n\t\treturn graph.Empty\n\t}\n\treturn iterator.NewOrderedNodes(from)\n}", "func (c *ChatParticipantAdmin) FillFrom(from interface {\n\tGetUserID() (value int)\n\tGetInviterID() (value int)\n\tGetDate() (value int)\n}) {\n\tc.UserID = from.GetUserID()\n\tc.InviterID = from.GetInviterID()\n\tc.Date = from.GetDate()\n}", "func (o *ScalarFormulaRequestAttributes) SetFrom(v int64) {\n\to.From = v\n}", "func (msg *Message) MessageFrom() string {\n\treturn msg.from\n}", "func (lt *LineTask) From() Entity {\n\treturn lt.FromNode()\n}", "func (sw *scanWrap) StartFrom(key dynamo.PagingKey) Scan {\n\treturn &scanWrap{\n\t\tscan: sw.scan.StartFrom(key),\n\t}\n}", "func (m *ChatMessage) GetFrom()(ChatMessageFromIdentitySetable) {\n return m.from\n}", "func From(table, column string, v ...interface{}) StepOption {\n\treturn func(s *Step) {\n\t\ts.From.Table = table\n\t\ts.From.Column = column\n\t\tif len(v) > 0 {\n\t\t\ts.From.V = v[0]\n\t\t}\n\t}\n}", "func (d *DialogFilterSuggested) FillFrom(from interface {\n\tGetFilter() (value DialogFilterClass)\n\tGetDescription() (value string)\n}) {\n\td.Filter = from.GetFilter()\n\td.Description = from.GetDescription()\n}", "func (p *Pet) SetFrom(model mapping.Model) error {\n\tif model == nil {\n\t\treturn errors.Wrap(query.ErrInvalidInput, \"provided nil model to set from\")\n\t}\n\tfrom, ok := model.(*Pet)\n\tif !ok {\n\t\treturn errors.WrapDetf(mapping.ErrModelNotMatch, \"provided model doesn't match the input: %T\", model)\n\t}\n\t*p = *from\n\treturn nil\n}", "func (u *UpdateShortMessage) FillFrom(from interface {\n\tGetOut() (value bool)\n\tGetMentioned() (value bool)\n\tGetMediaUnread() (value bool)\n\tGetSilent() (value bool)\n\tGetID() (value int)\n\tGetUserID() (value int64)\n\tGetMessage() (value string)\n\tGetPts() (value int)\n\tGetPtsCount() (value int)\n\tGetDate() (value int)\n\tGetFwdFrom() (value MessageFwdHeader, ok bool)\n\tGetViaBotID() (value int64, ok bool)\n\tGetReplyTo() (value MessageReplyHeaderClass, ok bool)\n\tGetEntities() (value []MessageEntityClass, ok bool)\n\tGetTTLPeriod() (value int, ok bool)\n}) {\n\tu.Out = from.GetOut()\n\tu.Mentioned = from.GetMentioned()\n\tu.MediaUnread = from.GetMediaUnread()\n\tu.Silent = from.GetSilent()\n\tu.ID = from.GetID()\n\tu.UserID = from.GetUserID()\n\tu.Message = from.GetMessage()\n\tu.Pts = from.GetPts()\n\tu.PtsCount = from.GetPtsCount()\n\tu.Date = from.GetDate()\n\tif val, ok := from.GetFwdFrom(); ok {\n\t\tu.FwdFrom = val\n\t}\n\n\tif val, ok := from.GetViaBotID(); ok {\n\t\tu.ViaBotID = val\n\t}\n\n\tif val, ok := from.GetReplyTo(); ok {\n\t\tu.ReplyTo = val\n\t}\n\n\tif val, ok := from.GetEntities(); ok {\n\t\tu.Entities = val\n\t}\n\n\tif val, ok := from.GetTTLPeriod(); ok {\n\t\tu.TTLPeriod = val\n\t}\n\n}", "func (g Undirect) From(uid int64) Nodes {\n\tif g.G.Node(uid) == nil {\n\t\treturn Empty\n\t}\n\treturn newNodeIteratorPair(g.G.From(uid), g.G.To(uid))\n}", "func (b *Builder) From(tableName string) *Builder {\r\n\tb.tableName = tableName\r\n\treturn b\r\n}", "func (g *MessagesGetMessagesViewsRequest) FillFrom(from interface {\n\tGetPeer() (value InputPeerClass)\n\tGetID() (value []int)\n\tGetIncrement() (value bool)\n}) {\n\tg.Peer = from.GetPeer()\n\tg.ID = from.GetID()\n\tg.Increment = from.GetIncrement()\n}", "func (e *EncryptedChatDiscarded) FillFrom(from interface {\n\tGetHistoryDeleted() (value bool)\n\tGetID() (value int)\n}) {\n\te.HistoryDeleted = from.GetHistoryDeleted()\n\te.ID = from.GetID()\n}", "func (s *SponsoredWebPage) FillFrom(from interface {\n\tGetURL() (value string)\n\tGetSiteName() (value string)\n\tGetPhoto() (value PhotoClass, ok bool)\n}) {\n\ts.URL = from.GetURL()\n\ts.SiteName = from.GetSiteName()\n\tif val, ok := from.GetPhoto(); ok {\n\t\ts.Photo = val\n\t}\n\n}", "func (m *Manager) From() error {\n\treturn m.b.Save()\n}", "func (s *StickerPack) FillFrom(from interface {\n\tGetEmoticon() (value string)\n\tGetDocuments() (value []int64)\n}) {\n\ts.Emoticon = from.GetEmoticon()\n\ts.Documents = from.GetDocuments()\n}", "func (c *StickersChangeStickerRequest) FillFrom(from interface {\n\tGetSticker() (value InputDocumentClass)\n\tGetEmoji() (value string, ok bool)\n\tGetMaskCoords() (value MaskCoords, ok bool)\n\tGetKeywords() (value string, ok bool)\n}) {\n\tc.Sticker = from.GetSticker()\n\tif val, ok := from.GetEmoji(); ok {\n\t\tc.Emoji = val\n\t}\n\n\tif val, ok := from.GetMaskCoords(); ok {\n\t\tc.MaskCoords = val\n\t}\n\n\tif val, ok := from.GetKeywords(); ok {\n\t\tc.Keywords = val\n\t}\n\n}" ]
[ "0.67133564", "0.66742694", "0.6646103", "0.64490926", "0.6409074", "0.6370014", "0.63413197", "0.62121135", "0.61973435", "0.6066253", "0.60305166", "0.5998385", "0.59610677", "0.5934918", "0.58969045", "0.5894441", "0.58907807", "0.58899057", "0.5863759", "0.584637", "0.58362067", "0.5811277", "0.57843095", "0.5727607", "0.56774443", "0.5654918", "0.56182534", "0.55764806", "0.5559185", "0.5541522", "0.5515073", "0.55065835", "0.55015254", "0.54746646", "0.5462792", "0.5416741", "0.54103935", "0.5390384", "0.53741837", "0.53668904", "0.53483343", "0.53345597", "0.53202826", "0.531675", "0.5316269", "0.53098476", "0.53087544", "0.5306465", "0.5305609", "0.52976096", "0.5281421", "0.5274332", "0.5271833", "0.5266918", "0.5265213", "0.5264439", "0.5259893", "0.5248268", "0.5248025", "0.52394825", "0.5236076", "0.523093", "0.52231354", "0.5215006", "0.52148235", "0.5195511", "0.51860714", "0.51856065", "0.5182452", "0.5171938", "0.517107", "0.5167908", "0.516583", "0.51581305", "0.5157109", "0.5153916", "0.5152199", "0.5148262", "0.5146969", "0.51319575", "0.5129873", "0.5126893", "0.511349", "0.5111782", "0.5108185", "0.5101917", "0.51011914", "0.5091146", "0.50785416", "0.50778663", "0.5047874", "0.5043798", "0.50375485", "0.5034136", "0.50339043", "0.5031692", "0.50289166", "0.5026834", "0.50202703", "0.50177187" ]
0.7508155
0
Where defines what condition will be appended to the query.
func (op *OpQuery) Where(field string, condition interface{}) *OpQuery { where := whereClause{ field: field, condition: condition, } if where.IsValid() { op.whereClauses = append(op.whereClauses, where) } return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (q *Query) Where(cond string, args ...interface{}) *Query {\n\tq.whereParts = append(q.whereParts, newWherePart(cond, args...))\n\treturn q\n}", "func Where(clause string, args ...interface{}) QueryMod {\n\treturn func(q *queries.Query) {\n\t\tqueries.AppendWhere(q, clause, args...)\n\t}\n}", "func (stmt *statement) Where(expr string, args ...interface{}) Statement {\n\tstmt.addPart(posWhere, \"WHERE\", expr, args, \" AND \")\n\treturn stmt\n}", "func (q *queryImpl) Where(preds ...interface{}) Query {\n\tq.whereParts = q.whereParts.Append(preds...)\n\treturn q\n}", "func (builder *QueryBuilder[K, F]) Where(condition Condition[K, F]) *QueryBuilder[K, F] {\n\tbuilder.query.Conditions = append(builder.query.Conditions, condition)\n\treturn builder\n}", "func (q *query) Where(field string, op Operator, value any) Builder {\n\tq.filter.And(field, op, value)\n\treturn q\n}", "func (self *TStatement) Where(query string, args ...interface{}) *TStatement {\r\n\tif !strings.Contains(query, self.session.orm.dialect.EqStr()) {\r\n\t\tquery = strings.Replace(query, \"=\", self.session.orm.dialect.EqStr(), -1)\r\n\t}\r\n\r\n\tself.Op(domain.AND_OPERATOR, query, args...)\r\n\r\n\treturn self\r\n}", "func (statement *Statement) Where(query interface{}, args ...interface{}) *Statement {\n\treturn statement.And(query, args...)\n}", "func (q *Query) Where(column string, op Operator, value interface{}) *Query {\n\tcond := newCondition(AND, column, op, value)\n\n\tq.Binding.Conditions = append(q.Binding.Conditions, cond)\n\n\treturn q\n}", "func (rq *RentQuery) Where(ps ...predicate.Rent) *RentQuery {\n\trq.predicates = append(rq.predicates, ps...)\n\treturn rq\n}", "func (q *Query) Where(stmt string, args ...interface{}) *Query {\n\tif q.RawSQL.Fragment != \"\" {\n\t\tfmt.Println(\"Warning: Query is setup to use raw SQL\")\n\t\treturn q\n\t}\n\tif inRegex.MatchString(stmt) {\n\t\tvar inq []string\n\t\tfor i := 0; i < len(args); i++ {\n\t\t\tinq = append(inq, \"?\")\n\t\t}\n\t\tqs := fmt.Sprintf(\"(%s)\", strings.Join(inq, \",\"))\n\t\tstmt = strings.Replace(stmt, \"(?)\", qs, 1)\n\t}\n\tq.whereClauses = append(q.whereClauses, clause{stmt, args})\n\treturn q\n}", "func (c *UpdateBuilder) Where(condition conditionBuilder) *UpdateBuilder {\n\tc.whereConditions = append(c.whereConditions, condition)\n\n\treturn c\n}", "func (w *Wrapper) Where(args ...interface{}) *Wrapper {\n\tw.saveCondition(\"WHERE\", \"AND\", args...)\n\treturn w\n}", "func Where(query string, args ...interface{}) QueryOption {\n\treturn newFuncQueryOption(func(wrapper *QueryWrapper) {\n\t\twrapper.where = Clause(query, args...)\n\n\t\twrapper.queryLen += 2\n\t\twrapper.bindsLen += len(args)\n\t})\n}", "func (c *commentsQueryBuilder) Where(filter string, values ...interface{}) *commentsQueryBuilder {\n\tif c.err != nil {\n\t\treturn c\n\t}\n\tc.builder.Where(filter, values...)\n\treturn c\n}", "func (q *SessionQuery) Where(cond kallax.Condition) *SessionQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (l *LiveQuery) Where(conds ...utils.M) *LiveQuery {\n\tif len(conds) == 1 {\n\t\tl.find = utils.GenerateFind(conds[0])\n\t} else {\n\t\tl.find = utils.GenerateFind(utils.And(conds...))\n\t}\n\treturn l\n}", "func (s *Delete) Where(stmt string, args ...interface{}) *Delete {\n\ts.condition.Where(stmt, args...)\n\treturn s\n}", "func (eq *EntryQuery) Where(ps ...predicate.Entry) *EntryQuery {\n\teq.predicates = append(eq.predicates, ps...)\n\treturn eq\n}", "func (q *PersonQuery) Where(cond kallax.Condition) *PersonQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (c *Connection) Where(stmt string, args ...interface{}) *Query {\n\tq := Q(c)\n\treturn q.Where(stmt, args...)\n}", "func (rq *RemedyQuery) Where(ps ...predicate.Remedy) *RemedyQuery {\n\trq.predicates = append(rq.predicates, ps...)\n\treturn rq\n}", "func (f *APIAuditFilter) Where(p entql.P) {\n\tf.addPredicate(func(s *sql.Selector) {\n\t\tif err := schemaGraph.EvalP(schemaGraph.Nodes[0].Type, p, s); err != nil {\n\t\t\ts.AddError(err)\n\t\t}\n\t})\n}", "func (p *postsQueryBuilder) Where(filter string, values ...interface{}) *postsQueryBuilder {\n\tif p.err != nil {\n\t\treturn p\n\t}\n\tp.builder.Where(filter, values...)\n\treturn p\n}", "func (sq *ServerQuery) Where(ps ...predicate.Server) *ServerQuery {\n\tsq.predicates = append(sq.predicates, ps...)\n\treturn sq\n}", "func (q *BlobQuery) Where(where string, args ...interface{}) *BlobQuery {\n\tq.whereQuery = where\n\tq.args = args //TODO: check if already have args, then add instead of set.\n\treturn q\n}", "func (gq *GoodsQuery) Where(ps ...predicate.Goods) *GoodsQuery {\n\tgq.predicates = append(gq.predicates, ps...)\n\treturn gq\n}", "func (f *GrantFilter) Where(p entql.P) {\n\tf.addPredicate(func(s *sql.Selector) {\n\t\tif err := schemaGraph.EvalP(schemaGraph.Nodes[3].Type, p, s); err != nil {\n\t\t\ts.AddError(err)\n\t\t}\n\t})\n}", "func (q *PollQuery) Where(cond kallax.Condition) *PollQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (eq *EntityQuery) Where(ps ...predicate.Entity) *EntityQuery {\n\teq.predicates = append(eq.predicates, ps...)\n\treturn eq\n}", "func (ths *deleteQueryBuilder) AddWhere(where ...string) *deleteQueryBuilder {\n\tths.whereFragments = append(ths.whereFragments, where...)\n\n\treturn ths\n}", "func (b *Builder) Where(cond Cond) *Builder {\r\n\tb.cond = b.cond.And(cond)\r\n\treturn b\r\n}", "func (lq *LocationQuery) Where(ps ...predicate.Location) *LocationQuery {\n\tlq.predicates = append(lq.predicates, ps...)\n\treturn lq\n}", "func (f *ScopeFilter) Where(p entql.P) {\n\tf.addPredicate(func(s *sql.Selector) {\n\t\tif err := schemaGraph.EvalP(schemaGraph.Nodes[4].Type, p, s); err != nil {\n\t\t\ts.AddError(err)\n\t\t}\n\t})\n}", "func (mu *MannerUpdate) Where(ps ...predicate.Manner) *MannerUpdate {\n\tmu.predicates = append(mu.predicates, ps...)\n\treturn mu\n}", "func (session *Session) Where(query interface{}, args ...interface{}) *Session {\n\tsession.Statement.Where(query, args...)\n\treturn session\n}", "func (deq *DentalExpenseQuery) Where(ps ...predicate.DentalExpense) *DentalExpenseQuery {\n\tdeq.predicates = append(deq.predicates, ps...)\n\treturn deq\n}", "func (wq *WorkflowQuery) Where(ps ...predicate.Workflow) *WorkflowQuery {\n\twq.predicates = append(wq.predicates, ps...)\n\treturn wq\n}", "func (liq *LineItemQuery) Where(ps ...predicate.LineItem) *LineItemQuery {\n\tliq.predicates = append(liq.predicates, ps...)\n\treturn liq\n}", "func (hq *HarborQuery) Where(ps ...predicate.Harbor) *HarborQuery {\n\thq.predicates = append(hq.predicates, ps...)\n\treturn hq\n}", "func (tq *TweetQuery) Where(ps ...predicate.Tweet) *TweetQuery {\n\ttq.predicates = append(tq.predicates, ps...)\n\treturn tq\n}", "func (q *PollOptionQuery) Where(cond kallax.Condition) *PollOptionQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func Where(col, op string, expr Expr) Option {\n\treturn func(q Query) Query {\n\t\treturn realWhere(\"AND\", Ident(col), op, expr)(q)\n\t}\n}", "func (wq *WidgetQuery) Where(ps ...predicate.Widget) *WidgetQuery {\n\twq.predicates = append(wq.predicates, ps...)\n\treturn wq\n}", "func (pq *PersonQuery) Where(ps ...predicate.Person) *PersonQuery {\n\tpq.predicates = append(pq.predicates, ps...)\n\treturn pq\n}", "func (ub *UpdateBuilder) Where(\n\tpred interface{},\n\targs ...interface{},\n) *UpdateBuilder {\n\tub.sql = ub.sql.Where(pred, args...)\n\treturn ub\n}", "func (q ReleaseQuery) Where(cmd string, args ...interface{}) ReleaseQuery {\n\tq.builder = q.builder.Where(cmd, args...)\n\treturn q\n}", "func (cq *ConfirmationQuery) Where(ps ...predicate.Confirmation) *ConfirmationQuery {\n\tcq.predicates = append(cq.predicates, ps...)\n\treturn cq\n}", "func (wq *WordQuery) Where(ps ...predicate.Word) *WordQuery {\n\twq.predicates = append(wq.predicates, ps...)\n\treturn wq\n}", "func (tdq *TCPDetectorQuery) Where(ps ...predicate.TCPDetector) *TCPDetectorQuery {\n\ttdq.predicates = append(tdq.predicates, ps...)\n\treturn tdq\n}", "func (bq *BrowserQuery) Where(ps ...predicate.Browser) *BrowserQuery {\n\tbq.predicates = append(bq.predicates, ps...)\n\treturn bq\n}", "func (wq *WifiQuery) Where(ps ...predicate.Wifi) *WifiQuery {\n\twq.predicates = append(wq.predicates, ps...)\n\treturn wq\n}", "func (hdq *HTTPDetectorQuery) Where(ps ...predicate.HTTPDetector) *HTTPDetectorQuery {\n\thdq.predicates = append(hdq.predicates, ps...)\n\treturn hdq\n}", "func (u *Update) Where(conds ...utils.M) *Update {\n\tif len(conds) == 1 {\n\t\tu.find = utils.GenerateFind(conds[0])\n\t} else {\n\t\tu.find = utils.GenerateFind(utils.And(conds...))\n\t}\n\treturn u\n}", "func (wfq *WithFieldsQuery) Where(ps ...predicate.WithFields) *WithFieldsQuery {\n\twfq.predicates = append(wfq.predicates, ps...)\n\treturn wfq\n}", "func (du *DoctorUpdate) Where(ps ...predicate.Doctor) *DoctorUpdate {\n\tdu.predicates = append(du.predicates, ps...)\n\treturn du\n}", "func (ub *UpdateBuilder) Where(andExpr ...string) *UpdateBuilder {\n\tub.whereExprs = append(ub.whereExprs, andExpr...)\n\tub.marker = updateMarkerAfterWhere\n\treturn ub\n}", "func (daq *DrugAllergyQuery) Where(ps ...predicate.DrugAllergy) *DrugAllergyQuery {\n\tdaq.predicates = append(daq.predicates, ps...)\n\treturn daq\n}", "func (b *blogsQueryBuilder) Where(filter string, values ...interface{}) *blogsQueryBuilder {\n\tif b.err != nil {\n\t\treturn b\n\t}\n\tb.builder.Where(filter, values...)\n\treturn b\n}", "func (f *FactFilter) Where(p entql.P) {\n\tf.addPredicate(func(s *sql.Selector) {\n\t\tif err := schemaGraph.EvalP(schemaGraph.Nodes[1].Type, p, s); err != nil {\n\t\t\ts.AddError(err)\n\t\t}\n\t})\n}", "func (q *UserQuery) Where(cond kallax.Condition) *UserQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (b *DeleteBuilder) Where(expr BoolExpr) *DeleteBuilder {\n\tb.Delete.Where = &Where{\n\t\tType: astWhere,\n\t\tExpr: unwrapBoolExpr(expr),\n\t}\n\treturn b\n}", "func (b *SelectBuilder) Where(expr BoolExpr) *SelectBuilder {\n\tb.Select.Where = &Where{\n\t\tType: astWhere,\n\t\tExpr: unwrapBoolExpr(expr),\n\t}\n\treturn b\n}", "func (dqu *DNSBLQueryUpdate) Where(ps ...predicate.DNSBLQuery) *DNSBLQueryUpdate {\n\tdqu.mutation.predicates = append(dqu.mutation.predicates, ps...)\n\treturn dqu\n}", "func (sq *ShopQuery) Where(ps ...predicate.Shop) *ShopQuery {\n\tsq.predicates = append(sq.predicates, ps...)\n\treturn sq\n}", "func (du *DoctorinfoUpdate) Where(ps ...predicate.Doctorinfo) *DoctorinfoUpdate {\n\tdu.predicates = append(du.predicates, ps...)\n\treturn du\n}", "func (q *PetQuery) Where(cond kallax.Condition) *PetQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (u *Update) Where(conds ...types.M) *Update {\n\tif len(conds) == 1 {\n\t\tu.find = types.GenerateFind(conds[0])\n\t} else {\n\t\tu.find = types.GenerateFind(types.And(conds...))\n\t}\n\treturn u\n}", "func (au *AntenatalinformationUpdate) Where(ps ...predicate.Antenatalinformation) *AntenatalinformationUpdate {\n\tau.mutation.predicates = append(au.mutation.predicates, ps...)\n\treturn au\n}", "func (b UpdateBuilder) Where(pred interface{}, args ...interface{}) WhereConditions {\n\treturn builder.Append(b, \"WhereParts\", newWherePart(pred, args...)).(UpdateBuilder)\n}", "func (b *Builder) Where(pred ...Cond) *Builder {\n\treturn b\n}", "func (stmt DeleteStmt) Where(clauses ...Clause) DeleteStmt {\n\tif len(clauses) > 1 {\n\t\t// By default, multiple where clauses will be joined will AllOf\n\t\tstmt.where = AllOf(clauses...)\n\t} else if len(clauses) == 1 {\n\t\tstmt.where = clauses[0]\n\t}\n\treturn stmt\n}", "func (q *StatsPeriodQuery) Where(cond kallax.Condition) *StatsPeriodQuery {\n\tq.BaseQuery.Where(cond)\n\treturn q\n}", "func (sqd *SurveyQuestionDelete) Where(ps ...predicate.SurveyQuestion) *SurveyQuestionDelete {\n\tsqd.predicates = append(sqd.predicates, ps...)\n\treturn sqd\n}", "func (ksq *KqiSourceQuery) Where(ps ...predicate.KqiSource) *KqiSourceQuery {\n\tksq.predicates = append(ksq.predicates, ps...)\n\treturn ksq\n}", "func (tq *TenantQuery) Where(ps ...predicate.Tenant) *TenantQuery {\n\ttq.predicates = append(tq.predicates, ps...)\n\treturn tq\n}", "func (eu *ExtradoctorUpdate) Where(ps ...predicate.Extradoctor) *ExtradoctorUpdate {\n\teu.predicates = append(eu.predicates, ps...)\n\treturn eu\n}", "func (esq *EventSeverityQuery) Where(ps ...predicate.EventSeverity) *EventSeverityQuery {\n\tesq.predicates = append(esq.predicates, ps...)\n\treturn esq\n}", "func (b *UpdateBuilder) Where(expr BoolExpr) *UpdateBuilder {\n\tb.Update.Where = &Where{\n\t\tType: astWhere,\n\t\tExpr: unwrapBoolExpr(expr),\n\t}\n\treturn b\n}", "func (sb *SQLBuilder) Where(field string, condition string, value interface{}) *SQLBuilder {\n\treturn sb.where(\"AND\", condition, field, value)\n}", "func (fq *ForumQuery) Where(ps ...predicate.Forum) *ForumQuery {\n\tfq.predicates = append(fq.predicates, ps...)\n\treturn fq\n}", "func (mu *MedicalfileUpdate) Where(ps ...predicate.Medicalfile) *MedicalfileUpdate {\n\tmu.predicates = append(mu.predicates, ps...)\n\treturn mu\n}", "func (lbq *LatestBlockQuery) Where(ps ...predicate.LatestBlock) *LatestBlockQuery {\n\tlbq.predicates = append(lbq.predicates, ps...)\n\treturn lbq\n}", "func (ulq *UserLogQuery) Where(ps ...predicate.UserLog) *UserLogQuery {\n\tulq.predicates = append(ulq.predicates, ps...)\n\treturn ulq\n}", "func (au *AppUpdate) Where(ps ...predicate.App) *AppUpdate {\n\tau.predicates = append(au.predicates, ps...)\n\treturn au\n}", "func (squ *SurveyQuestionUpdate) Where(ps ...predicate.SurveyQuestion) *SurveyQuestionUpdate {\n\tsqu.predicates = append(squ.predicates, ps...)\n\treturn squ\n}", "func (rd *RecipeDelete) Where(ps ...predicate.Recipe) *RecipeDelete {\n\trd.predicates = append(rd.predicates, ps...)\n\treturn rd\n}", "func (tq *TeamQuery) Where(ps ...predicate.Team) *TeamQuery {\n\ttq.predicates = append(tq.predicates, ps...)\n\treturn tq\n}", "func (ouq *OrgUnitQuery) Where(ps ...predicate.OrgUnit) *OrgUnitQuery {\n\touq.predicates = append(ouq.predicates, ps...)\n\treturn ouq\n}", "func (ecpq *EntityContactPointQuery) Where(ps ...predicate.EntityContactPoint) *EntityContactPointQuery {\n\tecpq.predicates = append(ecpq.predicates, ps...)\n\treturn ecpq\n}", "func (pq *PrizeQuery) Where(ps ...predicate.Prize) *PrizeQuery {\n\tpq.predicates = append(pq.predicates, ps...)\n\treturn pq\n}", "func (wtq *WorkerTypeQuery) Where(ps ...predicate.WorkerType) *WorkerTypeQuery {\n\twtq.predicates = append(wtq.predicates, ps...)\n\treturn wtq\n}", "func (ou *OperationroomUpdate) Where(ps ...predicate.Operationroom) *OperationroomUpdate {\n\tou.predicates = append(ou.predicates, ps...)\n\treturn ou\n}", "func (sd *SelectDataset) Where(expressions ...exp.Expression) *SelectDataset {\n\treturn sd.copy(sd.clauses.WhereAppend(expressions...))\n}", "func (b DeleteBuilder) Where(pred interface{}, args ...interface{}) WhereConditions {\n\treturn builder.Append(b, \"WhereParts\", newWherePart(pred, args...)).(DeleteBuilder)\n}", "func (fdq *FurnitureDetailQuery) Where(ps ...predicate.FurnitureDetail) *FurnitureDetailQuery {\n\tfdq.predicates = append(fdq.predicates, ps...)\n\treturn fdq\n}", "func (f *FactTypeFilter) Where(p entql.P) {\n\tf.addPredicate(func(s *sql.Selector) {\n\t\tif err := schemaGraph.EvalP(schemaGraph.Nodes[2].Type, p, s); err != nil {\n\t\t\ts.AddError(err)\n\t\t}\n\t})\n}", "func (rq *ReceiptQuery) Where(ps ...predicate.Receipt) *ReceiptQuery {\n\trq.predicates = append(rq.predicates, ps...)\n\treturn rq\n}", "func (evsq *ExValueScanQuery) Where(ps ...predicate.ExValueScan) *ExValueScanQuery {\n\tevsq.predicates = append(evsq.predicates, ps...)\n\treturn evsq\n}", "func (pu *PatientrecordUpdate) Where(ps ...predicate.Patientrecord) *PatientrecordUpdate {\n\tpu.predicates = append(pu.predicates, ps...)\n\treturn pu\n}" ]
[ "0.8228763", "0.81684643", "0.81154907", "0.80740434", "0.7836893", "0.7744843", "0.7743522", "0.773382", "0.77259666", "0.7711289", "0.767306", "0.76619434", "0.7660566", "0.76269233", "0.7623534", "0.7593027", "0.75879514", "0.75751895", "0.7567398", "0.75500625", "0.75490975", "0.7547061", "0.75384825", "0.7538055", "0.75362253", "0.7526409", "0.7507962", "0.7506875", "0.7485772", "0.7484159", "0.74764", "0.7461509", "0.74552774", "0.74423575", "0.74259", "0.74163777", "0.7415746", "0.74136233", "0.74127406", "0.74099445", "0.7409617", "0.74031556", "0.73983675", "0.7389734", "0.73848915", "0.73844683", "0.7380592", "0.7376927", "0.73764306", "0.73746395", "0.7371859", "0.7368066", "0.7366455", "0.7352203", "0.7343553", "0.73412436", "0.733553", "0.7335486", "0.73340017", "0.73326594", "0.7331235", "0.73307455", "0.7328516", "0.73238486", "0.7314148", "0.7313368", "0.7313311", "0.730684", "0.73061514", "0.73035187", "0.72946125", "0.72894883", "0.72879946", "0.7277835", "0.7269014", "0.72676206", "0.7264073", "0.72585976", "0.72491866", "0.72410953", "0.7236469", "0.72261757", "0.72243065", "0.7220112", "0.72174025", "0.7212467", "0.7196901", "0.7190468", "0.7186297", "0.7180715", "0.71767694", "0.71755594", "0.71733844", "0.71706635", "0.7167503", "0.7163459", "0.7161906", "0.715824", "0.71567845", "0.7154648" ]
0.7458407
32
OrderDesc defines the order column to sort results descendant.
func (op *OpQuery) OrderDesc(field string) *OpQuery { op.order = fmt.Sprintf("%s DESC", field) return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (builder QueryBuilder) OrderDesc(predicate interface{}) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, orderBy{\n\t\tDirection: OrderDirectionDesc,\n\t\tPredicate: predicate,\n\t})\n\treturn builder\n}", "func OrderDesc(cols ...string) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, orderClause{\n\t\t\tcols: cols,\n\t\t\tdir: \"DESC\",\n\t\t})\n\t\treturn q\n\t}\n}", "func (self *TStatement) Desc(fileds ...string) *TStatement {\r\n\tself.DescFields = append(self.DescFields, fileds...)\r\n\t/*\r\n\t\tvar buf bytes.Buffer\r\n\t\tif len(self.OrderByClause) > 0 {\r\n\t\t\tfmt.Fprint(&buf, self.OrderByClause, \", \")\r\n\t\t}\r\n\t\t//newColNames := statement.col2NewColsWithQuote(colNames...)\r\n\t\tfmt.Fprintf(&buf, \"%v DESC\", strings.Join(fileds, \" DESC, \"))\r\n\t\tself.OrderByClause = buf.String()\r\n\t*/\r\n\treturn self\r\n}", "func (ub *UpdateBuilder) Desc() *UpdateBuilder {\n\tub.order = \"DESC\"\n\tub.marker = updateMarkerAfterOrderBy\n\treturn ub\n}", "func (u *__GroupOrderdUser_Selector) OrderBy_OrderId_Desc() *__GroupOrderdUser_Selector {\n\tu.orderBy = \" ORDER BY OrderId DESC \"\n\treturn u\n}", "func SortDesc(field string) SortQuery {\n\treturn SortQuery{\n\t\tField: field,\n\t\tSort: -1,\n\t}\n}", "func (s *GeoDistanceSort) Desc() *GeoDistanceSort {\n\ts.ascending = false\n\treturn s\n}", "func Desc(fields ...string) Order {\n\treturn Order(\n\t\tfunc(s *sql.Selector) {\n\t\t\tfor _, f := range fields {\n\t\t\t\ts.OrderBy(sql.Desc(f))\n\t\t\t}\n\t\t},\n\t)\n}", "func (u *__Comment_Selector) OrderBy_CommentId_Desc() *__Comment_Selector {\n\tu.orderBy = \" ORDER BY CommentId DESC \"\n\treturn u\n}", "func (b ValExprBuilder) Descending() *Order {\n\treturn &Order{\n\t\tExpr: b.ValExpr,\n\t\tDirection: \" DESC\",\n\t}\n}", "func OrderValueDesc(column string, opts ...Option) func(*sql.Selector) {\n\treturn func(s *sql.Selector) {\n\t\ts.OrderExpr(\n\t\t\tsql.DescExpr(ValuePath(column, opts...)),\n\t\t)\n\t}\n}", "func (s *FieldSort) Desc() *FieldSort {\n\ts.ascending = false\n\treturn s\n}", "func (u *__DirectToMessage_Selector) OrderBy_Id_Desc() *__DirectToMessage_Selector {\n\tu.orderBy = \" ORDER BY Id DESC \"\n\treturn u\n}", "func (session *Session) Desc(colNames ...string) *Session {\n\tsession.Statement.Desc(colNames...)\n\treturn session\n}", "func OrderLenDesc(column string, opts ...Option) func(*sql.Selector) {\n\treturn func(s *sql.Selector) {\n\t\ts.OrderExpr(\n\t\t\tsql.DescExpr(LenPath(column, opts...)),\n\t\t)\n\t}\n}", "func (f BooleanField) Desc() BooleanField {\n\tdesc := true\n\tf.descending = &desc\n\treturn f\n}", "func (qs ControlQS) OrderByKdDesc() ControlQS {\n\tqs.order = append(qs.order, `\"kd\" DESC`)\n\n\treturn qs\n}", "func descOrder(order krakenapi.Order) (string, error) {\n\tparts := strings.Split(order.Description.Order, \" \")\n\tif len(parts) != 6 {\n\t\treturn \"\", fmt.Errorf(\"invalid description %q\", order.Description.Order)\n\t}\n\tdirection := parts[0]\n\tamount, err := strconv.ParseFloat(parts[1], 64)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid amount %q\", parts[1])\n\t}\n\tticker := parts[2]\n\n\tprice, err := strconv.ParseFloat(parts[5], 64)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid amount %q\", parts[5])\n\t}\n\n\tt := order.CloseT\n\tif order.Status == \"open\" {\n\t\tt = order.OpenT\n\t}\n\ttick1 := ticker[:3]\n\ttick2 := ticker[3:]\n\tdesc := fmt.Sprintf(\" %s: %s %s order of %f %s at %f for %f %s\", t, order.Status, direction, amount, tick1, price, amount*price, tick2)\n\treturn desc, nil\n}", "func (s *ScoreSort) Desc() *ScoreSort {\n\ts.ascending = false\n\treturn s\n}", "func Descending(field string) Direction {\n\treturn direction{\n\t\tfield: field,\n\t\tdirection: \"desc\",\n\t}\n}", "func Desc(fields ...string) OrderFunc {\n\treturn func(tr *dsl.Traversal) {\n\t\tfor _, f := range fields {\n\t\t\ttr.By(f, dsl.Decr)\n\t\t}\n\t}\n}", "func (session *Session) Desc(colNames ...string) *Session {\n\tsession.Session = session.Session.Desc(colNames...)\n\treturn session\n}", "func (u *__Notify_Selector) OrderBy_NotifyId_Desc() *__Notify_Selector {\n\tu.orderBy = \" ORDER BY NotifyId DESC \"\n\treturn u\n}", "func (p *Page) InvertedOrder() string {\n\tswitch p.Order {\n\tcase \"asc\":\n\t\treturn \"desc\"\n\tcase \"desc\":\n\t\treturn \"asc\"\n\tdefault:\n\t\treturn \"asc\"\n\t}\n}", "func (p *Page) InvertedOrder() string {\n\tswitch p.Order {\n\tcase \"asc\":\n\t\treturn \"desc\"\n\tcase \"desc\":\n\t\treturn \"asc\"\n\tdefault:\n\t\treturn \"asc\"\n\t}\n}", "func (u *__Room_Selector) OrderBy_RoomId_Desc() *__Room_Selector {\n\tu.orderBy = \" ORDER BY RoomId DESC \"\n\treturn u\n}", "func (sq SortQuery) Desc() bool {\n\treturn sq.Sort < 0\n}", "func (ql *QueueHistoryList) SortDESC() {\n\tsort.Sort(QueueHistoryByCreatedTimeDESC(ql.Items))\n}", "func (o *Operator) Desc() string {\n\treturn o.desc\n}", "func (u *__XfileServiceMetricLog_Selector) OrderBy_Id_Desc() *__XfileServiceMetricLog_Selector {\n\tu.orderBy = \" ORDER BY Id DESC \"\n\treturn u\n}", "func (s *ScriptSort) Desc() *ScriptSort {\n\ts.ascending = false\n\treturn s\n}", "func (m *PromotionMutation) DESC() (r string, exists bool) {\n\tv := m._DESC\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func (u *__FileStorage_Selector) OrderBy_Zdata_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" zdata DESC\")\n\treturn u\n}", "func (u *__FileStorage_Selector) OrderBy_Height_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" height DESC\")\n\treturn u\n}", "func (qs DaytypeQS) OrderByNameDesc() DaytypeQS {\n\tqs.order = append(qs.order, `\"name\" DESC`)\n\n\treturn qs\n}", "func (qs ControlQS) OrderByKiDesc() ControlQS {\n\tqs.order = append(qs.order, `\"ki\" DESC`)\n\n\treturn qs\n}", "func (qs ControlQS) OrderByKpDesc() ControlQS {\n\tqs.order = append(qs.order, `\"kp\" DESC`)\n\n\treturn qs\n}", "func (c *ColumnChunkMetaDataBuilder) Descr() *schema.Column { return c.column }", "func (c *column) Asc() orderByExpression {\n\treturn orderByExpression(c.asSql() + \" ASC\")\n}", "func (u *__FileStorage_Selector) OrderBy_ZdataThumb_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" zdata_thumb DESC\")\n\treturn u\n}", "func (u *__FileStorage_Selector) OrderBy_Extension_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" extension DESC\")\n\treturn u\n}", "func (e Elements) SortByFloat64Desc(key string) {\n\ts := SortByFloat64{Elements: e, key: key}\n\tsort.Sort(sort.Reverse(s))\n}", "func (*OrderBy) Descriptor() ([]byte, []int) {\n\treturn file_proto_ssql_proto_rawDescGZIP(), []int{12}\n}", "func (dbv DiskBlockDevice) Order() string {\n\treturn dbv.lsd.Order()\n}", "func (me TSortDirection) IsDescending() bool { return me.String() == \"Descending\" }", "func (ref *UIElement) SortDirection() string {\n\tret, _ := ref.StringAttr(SortDirectionAttribute)\n\treturn ret\n}", "func (qs SysDBQuerySet) OrderDescByPort() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"port DESC\"))\n}", "func (o *Operator) SetDesc(desc string) {\n\to.desc = desc\n}", "func (status ExtractStatus) Desc() string {\n\tif status > DELETED {\n\t\treturn \"Unknown\"\n\t}\n\n\treturn []string{\n\t\t// The order must not be be faulty.\n\t\t\"Waiting, pre-Queue\",\n\t\t\"Queued\",\n\t\t\"Extracting\",\n\t\t\"Extraction Failed\",\n\t\t\"Extracted, Awaiting Import\",\n\t\t\"Imported\",\n\t\t\"Deleting\",\n\t\t\"Delete Failed\",\n\t\t\"Deleted\",\n\t}[status]\n}", "func (u *__StorageUsage_Selector) OrderBy_FileRefId_Desc() *__StorageUsage_Selector {\n\tu.orderBy = append(u.orderBy, \" file_ref_id DESC\")\n\treturn u\n}", "func (*ListOperationOptions_OrderByField) Descriptor() ([]byte, []int) {\n\treturn file_ml_metadata_proto_metadata_store_proto_rawDescGZIP(), []int{31, 0}\n}", "func (u *__FileStorage_Selector) OrderBy_Width_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" width DESC\")\n\treturn u\n}", "func (q *Query) Order(spec string) *Query {\n\tdirection := Ascending\n\tif strings.HasPrefix(spec, \"-\") {\n\t\tspec = spec[1:]\n\t\tdirection = Descending\n\t}\n\tattr := q.kind + \"/\" + spec\n\tq.order = append(q.order, order{Attribute: attr, Direction: direction})\n\treturn q\n}", "func (qs SysDBQuerySet) OrderDescByID() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"id DESC\"))\n}", "func (builder QueryBuilder) Order(order DQLizer) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, order)\n\treturn builder\n}", "func (u *__FileStorage_Selector) OrderBy_Length_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" length DESC\")\n\treturn u\n}", "func (*OrderDetail) Descriptor() ([]byte, []int) {\n\treturn file_model_order_proto_rawDescGZIP(), []int{1}\n}", "func (qs GroupQuerySet) OrderDescByAutTransferObjectType() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"aut_transfer_object_type DESC\"))\n}", "func (sd *SelectDataset) Order(order ...exp.OrderedExpression) *SelectDataset {\n\treturn sd.copy(sd.clauses.SetOrder(order...))\n}", "func (u *__FileStorage_Selector) OrderBy_UserId_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" user_id DESC\")\n\treturn u\n}", "func (u *__FileStorage_Selector) OrderBy_MimeType_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" mime_type DESC\")\n\treturn u\n}", "func (_TableManager *TableManagerCaller) Desc(opts *bind.CallOpts, tableName string) (TableInfo, error) {\n\tvar (\n\t\tret0 = new(TableInfo)\n\t)\n\tout := ret0\n\terr := _TableManager.contract.Call(opts, out, \"desc\", tableName)\n\treturn *ret0, err\n}", "func (*Order_Data_OrderInfo_OrderDetail) Descriptor() ([]byte, []int) {\n\treturn file_order_proto_rawDescGZIP(), []int{0, 0, 3, 0}\n}", "func (m *PromotionMutation) SetDESC(s string) {\n\tm._DESC = &s\n}", "func TestColumn_Order(t *testing.T) {\n\ttype fields struct {\n\t\tName string\n\t\tAsc bool\n\t}\n\ttests := []struct {\n\t\tname string\n\t\tfields fields\n\t\twant string\n\t}{\n\t\t// TODO: Add test cases.\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tc := &main.Column{\n\t\t\t\tName: tt.fields.Name,\n\t\t\t\tAsc: tt.fields.Asc,\n\t\t\t}\n\t\t\tif got := c.Order(); got != tt.want {\n\t\t\t\tt.Errorf(\"Order() = %v, want %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}", "func (self Accessor) Order(expr interface{}) *SelectManager {\n\treturn self.From(self.Relation()).Order(expr)\n}", "func orderByToGitHubOrder(desc bool) githubv4.OrderDirection {\n\tif desc {\n\t\treturn githubv4.OrderDirectionDesc\n\t} else {\n\t\treturn githubv4.OrderDirectionAsc\n\t}\n}", "func (qs DaytypeQS) OrderByIDDesc() DaytypeQS {\n\tqs.order = append(qs.order, `\"id\" DESC`)\n\n\treturn qs\n}", "func (*SortType) Descriptor() ([]byte, []int) {\n\treturn file_protos_sortType_proto_rawDescGZIP(), []int{0}\n}", "func (qs GroupQuerySet) OrderDescByDeletedAt() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"deleted_at DESC\"))\n}", "func (qs SysDBQuerySet) OrderDescByUpdatedAt() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at DESC\"))\n}", "func (q *PollQuery) Order(cols ...kallax.ColumnOrder) *PollQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (qs ConstraintQuerySet) OrderDescBySegmentID() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"segment_id DESC\"))\n}", "func (g *Graph) Order() int {\n\treturn len(g.mx.Colptr) - 1\n}", "func (qs GroupQuerySet) OrderDescByOwnerID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"owner_id DESC\"))\n}", "func (g *DiGraph) Order() int {\n\treturn len(g.fmx.Colptr) - 1\n}", "func (ub *UpdateBuilder) Asc() *UpdateBuilder {\n\tub.order = \"ASC\"\n\tub.marker = updateMarkerAfterOrderBy\n\treturn ub\n}", "func (md MappedDisk) Order() string {\n\treturn md.sectorDisk.Order()\n}", "func (qs ConstraintQuerySet) OrderDescByUpdatedAt() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at DESC\"))\n}", "func (qs ConstraintQuerySet) OrderDescByDeletedAt() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"deleted_at DESC\"))\n}", "func (q *PollOptionQuery) Order(cols ...kallax.ColumnOrder) *PollOptionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (d *DeploymentKeyMetadataResolver) Desc() string {\n\treturn d.desc\n}", "func (*AccessOrderBy_MetricOrderBy) Descriptor() ([]byte, []int) {\n\treturn file_google_analytics_admin_v1alpha_access_report_proto_rawDescGZIP(), []int{11, 0}\n}", "func (*Order) Descriptor() ([]byte, []int) {\n\treturn file_model_order_proto_rawDescGZIP(), []int{0}\n}", "func (c *Counter) Desc() string {\n\treturn c.desc\n}", "func (p *Pagination) Order() string {\n\treturn p.order\n}", "func (f BooleanField) Asc() BooleanField {\n\tdesc := false\n\tf.descending = &desc\n\treturn f\n}", "func (*AccessOrderBy_DimensionOrderBy) Descriptor() ([]byte, []int) {\n\treturn file_google_analytics_admin_v1alpha_access_report_proto_rawDescGZIP(), []int{11, 1}\n}", "func (q *Query) Order(order string) *Query {\n\tq.order = strings.ToUpper(order)\n\treturn q\n}", "func (*OrderDetail) Descriptor() ([]byte, []int) {\n\treturn file_order_proto_rawDescGZIP(), []int{1}\n}", "func OrderAsc(cols ...string) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, orderClause{\n\t\t\tcols: cols,\n\t\t\tdir: \"ASC\",\n\t\t})\n\t\treturn q\n\t}\n}", "func (q *StatsPeriodQuery) Order(cols ...kallax.ColumnOrder) *StatsPeriodQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (_TableManager *TableManagerSession) Desc(tableName string) (TableInfo, error) {\n\treturn _TableManager.Contract.Desc(&_TableManager.CallOpts, tableName)\n}", "func (qs GroupQuerySet) OrderDescByUpdatedAt() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at DESC\"))\n}", "func (qs GroupQuerySet) OrderDescByID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"id DESC\"))\n}", "func (q *PersonQuery) Order(cols ...kallax.ColumnOrder) *PersonQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (*GetOrderByOrderIdResp) Descriptor() ([]byte, []int) {\n\treturn file_proto_order_order_proto_rawDescGZIP(), []int{5}\n}", "func (qs ConstraintQuerySet) OrderDescByID() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"id DESC\"))\n}", "func (qs ControlQS) OrderByIDDesc() ControlQS {\n\tqs.order = append(qs.order, `\"id\" DESC`)\n\n\treturn qs\n}", "func (qs GroupQuerySet) OrderDescByAutoTransferObjectID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"auto_transfer_object_id DESC\"))\n}" ]
[ "0.74827576", "0.72914994", "0.6598838", "0.6589177", "0.63501024", "0.63361025", "0.6326321", "0.6254213", "0.6189498", "0.6155316", "0.6123717", "0.6116668", "0.6116172", "0.60371745", "0.60003346", "0.5966971", "0.5953216", "0.5950294", "0.5940716", "0.5934457", "0.59010845", "0.58937764", "0.5822442", "0.58117485", "0.58117485", "0.5795682", "0.57432836", "0.5629291", "0.5487783", "0.54856116", "0.54780537", "0.5472582", "0.54432744", "0.540651", "0.53987956", "0.53288114", "0.5312007", "0.53027874", "0.53018683", "0.52703846", "0.52378774", "0.52103823", "0.51850593", "0.517083", "0.5157102", "0.5148495", "0.5137372", "0.5133609", "0.51201475", "0.5110882", "0.50981504", "0.50887674", "0.5074776", "0.5066819", "0.5066065", "0.50621235", "0.5048332", "0.5048015", "0.50414526", "0.5023331", "0.5021647", "0.5011019", "0.5009321", "0.49937567", "0.4959524", "0.49515843", "0.49400797", "0.49337438", "0.49291056", "0.49270353", "0.49168223", "0.49133492", "0.49128926", "0.48890844", "0.48852944", "0.48802137", "0.4875088", "0.48733142", "0.48648238", "0.48629677", "0.48620367", "0.48534405", "0.48507532", "0.4846708", "0.48409596", "0.4838891", "0.48377323", "0.48228675", "0.48172295", "0.48133248", "0.480569", "0.48032287", "0.48014706", "0.47991014", "0.47976702", "0.4794055", "0.47874525", "0.47600135", "0.47538522", "0.47517315" ]
0.7447665
1
OrderAsc defines the order column to sort results ascendant.
func (op *OpQuery) OrderAsc(field string) *OpQuery { op.order = fmt.Sprintf("%s ASC", field) return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func OrderAsc(cols ...string) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, orderClause{\n\t\t\tcols: cols,\n\t\t\tdir: \"ASC\",\n\t\t})\n\t\treturn q\n\t}\n}", "func (c *column) Asc() orderByExpression {\n\treturn orderByExpression(c.asSql() + \" ASC\")\n}", "func (builder QueryBuilder) OrderAsc(predicate interface{}) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, orderBy{\n\t\tDirection: OrderDirectionAsc,\n\t\tPredicate: predicate,\n\t})\n\treturn builder\n}", "func (s *FieldSort) Asc() *FieldSort {\n\ts.ascending = true\n\treturn s\n}", "func Asc(fields ...string) Order {\n\treturn Order(\n\t\tfunc(s *sql.Selector) {\n\t\t\tfor _, f := range fields {\n\t\t\t\ts.OrderBy(sql.Asc(f))\n\t\t\t}\n\t\t},\n\t)\n}", "func (ub *UpdateBuilder) Asc() *UpdateBuilder {\n\tub.order = \"ASC\"\n\tub.marker = updateMarkerAfterOrderBy\n\treturn ub\n}", "func (s *GeoDistanceSort) Asc() *GeoDistanceSort {\n\ts.ascending = true\n\treturn s\n}", "func (s *ScoreSort) Asc() *ScoreSort {\n\ts.ascending = true\n\treturn s\n}", "func SortAsc(field string) SortQuery {\n\treturn SortQuery{\n\t\tField: field,\n\t\tSort: 1,\n\t}\n}", "func (o *Output) SortIssuesAsc() {\n\tsort.Slice(o.Issues, func(i, j int) bool {\n\t\treturn o.Issues[i].CreatedAt.Before(o.Issues[j].CreatedAt)\n\t})\n}", "func (session *Session) Asc(colNames ...string) *Session {\n\tsession.Statement.Asc(colNames...)\n\treturn session\n}", "func (session *Session) Asc(colNames ...string) *Session {\n\tsession.Session = session.Session.Asc(colNames...)\n\treturn session\n}", "func (q *BlobQuery) SortAscendingBy(column string) *BlobQuery {\n\tq.orderColumns = append(q.orderColumns, column)\n\tq.orderDirection = append(q.orderDirection, 1)\n\treturn q\n}", "func (s *ScriptSort) Asc() *ScriptSort {\n\ts.ascending = true\n\treturn s\n}", "func (b ValExprBuilder) Ascending() *Order {\n\treturn &Order{\n\t\tExpr: b.ValExpr,\n\t\tDirection: \" ASC\",\n\t}\n}", "func TestColumn_Order(t *testing.T) {\n\ttype fields struct {\n\t\tName string\n\t\tAsc bool\n\t}\n\ttests := []struct {\n\t\tname string\n\t\tfields fields\n\t\twant string\n\t}{\n\t\t// TODO: Add test cases.\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tc := &main.Column{\n\t\t\t\tName: tt.fields.Name,\n\t\t\t\tAsc: tt.fields.Asc,\n\t\t\t}\n\t\t\tif got := c.Order(); got != tt.want {\n\t\t\t\tt.Errorf(\"Order() = %v, want %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}", "func (qs SysDBQuerySet) OrderAscByCreatedAt() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"created_at ASC\"))\n}", "func (s *ListJobsByPipelineInput) SetAscending(v string) *ListJobsByPipelineInput {\n\ts.Ascending = &v\n\treturn s\n}", "func (s *ListJobsByStatusInput) SetAscending(v string) *ListJobsByStatusInput {\n\ts.Ascending = &v\n\treturn s\n}", "func Asc(fields ...string) OrderFunc {\n\treturn func(tr *dsl.Traversal) {\n\t\tfor _, f := range fields {\n\t\t\ttr.By(f, dsl.Incr)\n\t\t}\n\t}\n}", "func (s *ListProfileTimesInput) SetOrderBy(v string) *ListProfileTimesInput {\n\ts.OrderBy = &v\n\treturn s\n}", "func (s *ScoreSort) Order(ascending bool) *ScoreSort {\n\ts.ascending = ascending\n\treturn s\n}", "func (s *GeoDistanceSort) Order(ascending bool) *GeoDistanceSort {\n\ts.ascending = ascending\n\treturn s\n}", "func (o *MicrosoftGraphWorkbookSortField) SetAscending(v bool) {\n\to.Ascending = &v\n}", "func (f BooleanField) Asc() BooleanField {\n\tdesc := false\n\tf.descending = &desc\n\treturn f\n}", "func (s *ListPipelinesInput) SetAscending(v string) *ListPipelinesInput {\n\ts.Ascending = &v\n\treturn s\n}", "func (sq SortQuery) Asc() bool {\n\treturn sq.Sort >= 0\n}", "func (s *FieldSort) Order(ascending bool) *FieldSort {\n\ts.ascending = ascending\n\treturn s\n}", "func OrderBy(field string, asc bool) Query {\n\treturn func(db *gorm.DB) *gorm.DB {\n\t\tif asc {\n\t\t\treturn db.Order(field + \" ASC\")\n\t\t}\n\n\t\treturn db.Order(field + \" DESC\")\n\t}\n}", "func (q *Query) Order(spec string) *Query {\n\tdirection := Ascending\n\tif strings.HasPrefix(spec, \"-\") {\n\t\tspec = spec[1:]\n\t\tdirection = Descending\n\t}\n\tattr := q.kind + \"/\" + spec\n\tq.order = append(q.order, order{Attribute: attr, Direction: direction})\n\treturn q\n}", "func (op *OpQuery) OrderDesc(field string) *OpQuery {\n\top.order = fmt.Sprintf(\"%s DESC\", field)\n\treturn op\n}", "func (o *MicrosoftGraphWorkbookSortField) GetAscending() bool {\n\tif o == nil || o.Ascending == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Ascending\n}", "func (q *UserQuery) Order(cols ...kallax.ColumnOrder) *UserQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (qs ConstraintQuerySet) OrderAscByCreatedAt() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"created_at ASC\"))\n}", "func (qs GroupQuerySet) OrderAscByCreatedAt() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"created_at ASC\"))\n}", "func (o *MicrosoftGraphWorkbookSortField) GetAscendingOk() (bool, bool) {\n\tif o == nil || o.Ascending == nil {\n\t\tvar ret bool\n\t\treturn ret, false\n\t}\n\treturn *o.Ascending, true\n}", "func (q *PollQuery) Order(cols ...kallax.ColumnOrder) *PollQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *PersonQuery) Order(cols ...kallax.ColumnOrder) *PersonQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *StatsPeriodQuery) Order(cols ...kallax.ColumnOrder) *StatsPeriodQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func Ascending(field string) Direction {\n\treturn direction{\n\t\tfield: field,\n\t\tdirection: \"asc\",\n\t}\n}", "func (s *ListPresetsInput) SetAscending(v string) *ListPresetsInput {\n\ts.Ascending = &v\n\treturn s\n}", "func (c *Condition) Order(order ...string) *Condition {\n\t// skipping empty call or string\n\tif len(order) == 0 || (len(order) == 1 && order[0] == \"\") {\n\t\treturn c\n\t}\n\n\tc.Reset(ORDER)\n\tfor _, stmt := range order {\n\n\t\tif c.order != \"\" {\n\t\t\tc.order += \", \"\n\t\t}\n\n\t\t// uppercase user asc,desc inserts\n\t\tstmt = strings.Replace(stmt, \" asc\", \" ASC\", 1)\n\t\tstmt = strings.Replace(stmt, \" desc\", \" DESC\", 1)\n\n\t\tif strings.HasPrefix(stmt, \"-\") {\n\t\t\tstmt = stmt[1:] + \" DESC\"\n\t\t} else if !strings.HasSuffix(strings.ToUpper(stmt), \"ASC\") && !strings.HasSuffix(strings.ToUpper(stmt), \"DESC\") {\n\t\t\tstmt = stmt + \" ASC\"\n\t\t}\n\n\t\tc.order = c.order + stmt\n\t}\n\n\tc.order = \"ORDER BY \" + c.order\n\treturn c\n}", "func (q *PollOptionQuery) Order(cols ...kallax.ColumnOrder) *PollOptionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (qs SysDBQuerySet) OrderAscByPort() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"port ASC\"))\n}", "func (qs SysDBQuerySet) OrderAscByID() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"id ASC\"))\n}", "func (qs SysDBQuerySet) OrderAscByUpdatedAt() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at ASC\"))\n}", "func (qs ConstraintQuerySet) OrderAscBySegmentID() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"segment_id ASC\"))\n}", "func (q *PetQuery) Order(cols ...kallax.ColumnOrder) *PetQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *PollVoteQuery) Order(cols ...kallax.ColumnOrder) *PollVoteQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *SessionQuery) Order(cols ...kallax.ColumnOrder) *SessionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *Query) Order(order string) *Query {\n\tq.order = strings.ToUpper(order)\n\treturn q\n}", "func (qs ConstraintQuerySet) OrderAscByUpdatedAt() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at ASC\"))\n}", "func (qs GroupQuerySet) OrderAscByAutTransferObjectType() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"aut_transfer_object_type ASC\"))\n}", "func (qs GroupQuerySet) OrderAscByOwnerID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"owner_id ASC\"))\n}", "func (qs GroupQuerySet) OrderAscByAutoTransferObjectID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"auto_transfer_object_id ASC\"))\n}", "func asc(v1, v2 int) bool {\n\treturn v1 < v2\n}", "func OrderDesc(cols ...string) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, orderClause{\n\t\t\tcols: cols,\n\t\t\tdir: \"DESC\",\n\t\t})\n\t\treturn q\n\t}\n}", "func (bcq *BaselineClassQuery) Order(o ...OrderFunc) *BaselineClassQuery {\n\tbcq.order = append(bcq.order, o...)\n\treturn bcq\n}", "func (q *Query) OrderBy(expression string, asc bool) *Query {\n\tq.ordering = append(q.ordering, &order{expression, asc})\n\treturn q\n}", "func (s *ListConfigurationsInput) SetOrderBy(v []*OrderByElement) *ListConfigurationsInput {\n\ts.OrderBy = v\n\treturn s\n}", "func (i *Item) OrderBy() string {\n\tif i.orderBy != \"\" {\n\t\treturn i.orderBy\n\t}\n\tswitch key := i.Key.(type) {\n\tcase Order:\n\t\ti.orderBy = key.OrderBy()\n\tcase string:\n\t\ti.orderBy = key\n\tcase fmt.Stringer:\n\t\ti.orderBy = key.String()\n\tdefault:\n\t\ti.orderBy = fmt.Sprint(key)\n\t}\n\treturn i.orderBy\n}", "func (s *TabularConditions) SetOrderBy(v []*OrderBy) *TabularConditions {\n\ts.OrderBy = v\n\treturn s\n}", "func (qs GroupQuerySet) OrderAscByID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"id ASC\"))\n}", "func (me TSortDirection) IsAscending() bool { return me.String() == \"Ascending\" }", "func (qs ConstraintQuerySet) OrderAscByID() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"id ASC\"))\n}", "func (p *queryPlan) orderBy() {\n\torder := p.stm.OrderByConfig()\n\tif len(order) <= 0 {\n\t\treturn\n\t}\n\ttracer.V(2).Trace(p.tracer, func() *tracer.Arguments {\n\t\treturn &tracer.Arguments{\n\t\t\tMsgs: []string{\"Ordering by \" + order.String()},\n\t\t}\n\t})\n\tp.tbl.Sort(order)\n}", "func (qs GroupQuerySet) OrderAscByUpdatedAt() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at ASC\"))\n}", "func (o *SingleSelectFieldField) SetOrder(v int32) {\n\to.Order = v\n}", "func (q *Query) OrderBy(field_name string, desc bool) *Query {\n\tq.order_by = append(q.order_by, query.Order{\n\t\tField: field_name,\n\t\tDesc: desc,\n\t})\n\treturn q\n}", "func SortAscending(q [][]byte) {\n\tsort.Slice(q, func(i, j int) bool {\n\t\treturn bytes.Compare(q[i], q[j]) < 0\n\t})\n}", "func (o *QtreeCollectionGetParams) SetOrderBy(orderBy []string) {\n\to.OrderBy = orderBy\n}", "func (qs ConstraintQuerySet) OrderAscByDeletedAt() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"deleted_at ASC\"))\n}", "func (qs GroupQuerySet) OrderAscByDeletedAt() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"deleted_at ASC\"))\n}", "func (builder QueryBuilder) Order(order DQLizer) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, order)\n\treturn builder\n}", "func (q *Query) Order(stmt string) *Query {\n\tif q.RawSQL.Fragment != \"\" {\n\t\tfmt.Println(\"Warning: Query is setup to use raw SQL\")\n\t\treturn q\n\t}\n\tq.orderClauses = append(q.orderClauses, clause{stmt, []interface{}{}})\n\treturn q\n}", "func (s *ScriptSort) Order(ascending bool) *ScriptSort {\n\ts.ascending = ascending\n\treturn s\n}", "func (eq *EntityQuery) Order(o ...OrderFunc) *EntityQuery {\n\teq.order = append(eq.order, o...)\n\treturn eq\n}", "func (self Accessor) Order(expr interface{}) *SelectManager {\n\treturn self.From(self.Relation()).Order(expr)\n}", "func (sb *SQLBuilder) OrderBy(operator string, fields ...string) *SQLBuilder {\n\tvar buf strings.Builder\n\n\tbuf.WriteString(\"ORDER BY \")\n\n\tfor k, field := range fields {\n\n\t\tbuf.WriteString(field)\n\n\t\tif k != len(fields)-1 {\n\t\t\tbuf.WriteString(\",\")\n\t\t}\n\t}\n\n\tbuf.WriteString(\" \")\n\tbuf.WriteString(operator)\n\n\tsb._orderBy = buf.String()\n\n\treturn sb\n}", "func (o *ListScansParams) SetOrderBy(orderBy *string) {\n\to.OrderBy = orderBy\n}", "func (ouq *OrgUnitQuery) Order(o ...OrderFunc) *OrgUnitQuery {\n\touq.order = append(ouq.order, o...)\n\treturn ouq\n}", "func (s *Select) OrderBy(fieldName ...string) *Select {\n\ts.orderBy = fieldName\n\treturn s\n}", "func Order(q *query.Query) *query.Query {\n\treturn q.Order(\"status desc\")\n}", "func (p *Pagination) Order() string {\n\treturn p.order\n}", "func (evsq *ExValueScanQuery) Order(o ...exvaluescan.OrderOption) *ExValueScanQuery {\n\tevsq.order = append(evsq.order, o...)\n\treturn evsq\n}", "func (ub *UpdateBuilder) OrderBy(col ...string) *UpdateBuilder {\n\tub.orderByCols = col\n\tub.marker = updateMarkerAfterOrderBy\n\treturn ub\n}", "func (oupq *OrgUnitPositionQuery) Order(o ...OrderFunc) *OrgUnitPositionQuery {\n\toupq.order = append(oupq.order, o...)\n\treturn oupq\n}", "func (p *Page) InvertedOrder() string {\n\tswitch p.Order {\n\tcase \"asc\":\n\t\treturn \"desc\"\n\tcase \"desc\":\n\t\treturn \"asc\"\n\tdefault:\n\t\treturn \"asc\"\n\t}\n}", "func (p *Page) InvertedOrder() string {\n\tswitch p.Order {\n\tcase \"asc\":\n\t\treturn \"desc\"\n\tcase \"desc\":\n\t\treturn \"asc\"\n\tdefault:\n\t\treturn \"asc\"\n\t}\n}", "func (o *FileInfoCollectionGetParams) SetOrderBy(orderBy []string) {\n\to.OrderBy = orderBy\n}", "func (c *Sizes) Asc() []float64 {\n\tc.mux.RLock()\n\n\tdefer c.mux.RUnlock()\n\n\treturn c.sizesASC\n}", "func (o *MicrosoftGraphWorkbookSortField) HasAscending() bool {\n\tif o != nil && o.Ascending != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (bq *BrowserQuery) Order(o ...OrderFunc) *BrowserQuery {\n\tbq.order = append(bq.order, o...)\n\treturn bq\n}", "func (o *EmsEventCollectionGetParams) SetOrderBy(orderBy []string) {\n\to.OrderBy = orderBy\n}", "func (ecpq *EntityContactPointQuery) Order(o ...OrderFunc) *EntityContactPointQuery {\n\tecpq.order = append(ecpq.order, o...)\n\treturn ecpq\n}", "func (o *ListNodesParams) SetSortAscending(sortAscending *bool) {\n\to.SortAscending = sortAscending\n}", "func (c *Connection) Order(stmt string) *Query {\n\treturn Q(c).Order(stmt)\n}", "func (o *GetSMSitemsParams) SetOrderBy(orderBy string) {\n\to.OrderBy = orderBy\n}", "func ExampleZSelectBuilder_OrderBy() {\n\tuser := q.T(\"user\")\n\tfmt.Println(\n\t\t\"Single order: \",\n\t\tq.Select().From(user).OrderBy(user.C(\"age\"), true),\n\t)\n\tfmt.Println(\n\t\t\"Multiple order:\",\n\t\tq.Select().From(user).OrderBy(user.C(\"age\"), true).OrderBy(\n\t\t\tq.CharLength(user.C(\"name\")), false),\n\t)\n\t// Output:\n\t// Single order: SELECT * FROM \"user\" ORDER BY \"user\".\"age\" ASC []\n\t// Multiple order: SELECT * FROM \"user\" ORDER BY \"user\".\"age\" ASC, CHAR_LENGTH(\"user\".\"name\") DESC []\n}", "func (o GoogleCloudRetailV2alphaSearchRequestFacetSpecFacetKeyPtrOutput) OrderBy() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *GoogleCloudRetailV2alphaSearchRequestFacetSpecFacetKey) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.OrderBy\n\t}).(pulumi.StringPtrOutput)\n}" ]
[ "0.78143317", "0.7525152", "0.7338644", "0.6839009", "0.67874277", "0.6700575", "0.65920097", "0.65069413", "0.6502752", "0.64526", "0.63834435", "0.6323034", "0.6193146", "0.61448115", "0.6070924", "0.6051124", "0.59214026", "0.58528703", "0.58476794", "0.58287406", "0.58260024", "0.5824829", "0.58196694", "0.5807138", "0.57982147", "0.57924956", "0.5778105", "0.5774389", "0.5772615", "0.5738731", "0.57242835", "0.5716764", "0.571666", "0.5715608", "0.571349", "0.57096136", "0.5686843", "0.56853527", "0.5681912", "0.56728655", "0.5671647", "0.56644434", "0.5657901", "0.56400174", "0.5639541", "0.56199086", "0.5601704", "0.5582766", "0.5580087", "0.5579562", "0.5579198", "0.5574807", "0.5567946", "0.5546557", "0.55356383", "0.54909426", "0.54761183", "0.546428", "0.5411456", "0.5406093", "0.53979844", "0.5390727", "0.53831726", "0.53809214", "0.5380844", "0.53750294", "0.53655285", "0.53488207", "0.5340048", "0.5339186", "0.53364134", "0.53334373", "0.5320304", "0.530473", "0.53043157", "0.52993596", "0.52977407", "0.5283898", "0.52704054", "0.5269062", "0.5267595", "0.5250222", "0.522824", "0.52186096", "0.5200502", "0.5186465", "0.518037", "0.5178837", "0.5178837", "0.5178175", "0.5177645", "0.5175176", "0.5159918", "0.51537186", "0.51535296", "0.51435626", "0.51428956", "0.513692", "0.51157224", "0.5114311" ]
0.77456623
1
OrderReset resets the order statment=="".
func (op *OpQuery) OrderReset() *OpQuery { op.order = "" return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *ReviewMutation) ResetOrder() {\n\tm._order = nil\n\tm.cleared_order = false\n}", "func (m *TodoItemMutation) ResetOrder() {\n\tm._order = nil\n\tm.add_order = nil\n}", "func (t *txLookUp) ResetOrder() {\n\tt.mu.RLock()\n\tdefer t.mu.RUnlock()\n\tt.resetOrder()\n}", "func (m *RestaurantMutation) ResetOrders() {\n\tm.orders = nil\n\tm.clearedorders = false\n\tm.removedorders = nil\n}", "func (t *acksTracker) reset() {\n\tt.mx.Lock()\n\tdefer t.mx.Unlock()\n\tt.order = nil\n}", "func (o orderbook) reset() {\n\to.Lock() \n\to.Asks = rbtree.NewTree(compareOrders)\n\to.Bids = rbtree.NewTree(compareOrders)\n\to.Unlock()\n}", "func (m *OrderMutation) ResetOrderAt() {\n\tm.order_at = nil\n}", "func (m *ReviewMutation) ClearOrder() {\n\tm.cleared_order = true\n}", "func (o *TransactionSplit) UnsetOrder() {\n\to.Order.Unset()\n}", "func (m *OrderMutation) ResetItems() {\n\tm.items = nil\n\tm.cleareditems = false\n\tm.removeditems = nil\n}", "func (t *Tx) Reset() {\n\tt.Status = TxNone\n\tif !t.IsEmpty() {\n\t\tt.Ops = nil\n\t}\n}", "func (m *ReviewMutation) OrderCleared() bool {\n\treturn m.cleared_order\n}", "func (m *RestaurantMutation) ClearOrders() {\n\tm.clearedorders = true\n}", "func (p *Permutator) Reset() {\n\t<- p.idle\n\tsort.Sort(sortable{ p.value, p.less })\n\tp.index = 1\n\tp.idle <- true\n}", "func (v *RelatedTransaction) Reset() {\n\tv.Direction = \"\"\n\tv.NetworkIdentifier.Value.Reset()\n\tv.NetworkIdentifier.Set = false\n\tv.TransactionIdentifier.Reset()\n}", "func (c *Condition) Reset(reset ...int) {\n\n\tif len(reset) == 0 {\n\t\treset = []int{ON, WHERE, GROUP, HAVING, ORDER, LIMIT, OFFSET}\n\t}\n\n\tfor _, fn := range reset {\n\t\tswitch fn {\n\t\tcase WHERE:\n\t\t\tc.where = \"\"\n\t\t\tif c.args[WHERE] != nil {\n\t\t\t\tc.args[WHERE] = []interface{}{}\n\t\t\t}\n\t\tcase HAVING:\n\t\t\tc.having = \"\"\n\t\t\tif c.args[HAVING] != nil {\n\t\t\t\tc.args[HAVING] = []interface{}{}\n\t\t\t}\n\t\tcase LIMIT:\n\t\t\tc.limit = \"\"\n\t\tcase ORDER:\n\t\t\tc.order = \"\"\n\t\tcase OFFSET:\n\t\t\tc.offset = \"\"\n\t\tcase GROUP:\n\t\t\tc.group = \"\"\n\t\tcase ON:\n\t\t\tc.on = \"\"\n\t\t\tif c.args[ON] != nil {\n\t\t\t\tc.args[ON] = []interface{}{}\n\t\t\t}\n\t\t}\n\t}\n}", "func (sd *SelectDataset) ClearOrder() *SelectDataset {\n\treturn sd.copy(sd.clauses.ClearOrder())\n}", "func (m *OrderonlineMutation) ResetStock() {\n\tm.stock = nil\n\tm.addstock = nil\n}", "func (m *OrderMutation) ResetWhere() {\n\tm.where = nil\n\tm.clearedwhere = false\n}", "func (m *OrderMutation) ResetEdge(name string) error {\n\treturn fmt.Errorf(\"unknown Order edge %s\", name)\n}", "func (m *OrderproductMutation) ResetStock() {\n\tm.stock = nil\n\tm.addstock = nil\n}", "func (hd *Headers) SaveResetOrder(Save bool, headers []string) {\n\t// Reset header value\n\thd.Values = make([]string, 0)\n\n\t// Save value if found\n\tif Save {\n\t\thd.Values = headers\n\t}\n}", "func (bs *Scope) Reset() {\n\tbs.call([]byte(\"!\"))\n}", "func (v *Operation) Reset() {\n\tv.Account.Value.Reset()\n\tv.Account.Set = false\n\tv.Amount.Value.Reset()\n\tv.Amount.Set = false\n\tv.CoinChange.Value.Reset()\n\tv.CoinChange.Set = false\n\tv.Metadata = v.Metadata[:0]\n\tv.OperationIdentifier.Reset()\n\tv.RelatedOperations = v.RelatedOperations[:0]\n\tv.Status.Value = \"\"\n\tv.Status.Set = false\n\tv.Type = \"\"\n}", "func (m *OrderproductMutation) ResetManagers() {\n\tm.managers = nil\n\tm.clearedmanagers = false\n}", "func (o *TransactionSplit) SetOrderNil() {\n\to.Order.Set(nil)\n}", "func (m *OrderonlineMutation) ResetAddedtime() {\n\tm.addedtime = nil\n}", "func (e *Expression) Reset() {\n\te.lText = \"\"\n\te.rText = \"\"\n\te.prefix = false\n\te.suffix = false\n\te.not = false\n\te.in = false\n\te.completed = false\n}", "func (m *OrderMutation) ResetCookingAt() {\n\tm.cooking_at = nil\n\tdelete(m.clearedFields, order.FieldCookingAt)\n}", "func (d *state) Reset() {\n\t// Zero the permutation's state.\n\tfor i := range d.a {\n\t\td.a[i] = 0\n\t}\n\td.state = spongeAbsorbing\n\td.buf = d.storage[:0]\n}", "func (m *TradeRecordMutation) ResetExchange() {\n\tm.exchange = nil\n\tm.clearedexchange = false\n\tm.removedexchange = nil\n}", "func (bt *BackTest) Reset() {\n\tbt.EventQueue.Reset()\n\tbt.Datas.Reset()\n\tbt.Portfolio.Reset()\n\tbt.Statistic.Reset()\n\tbt.Exchange.Reset()\n\tbt.Funding.Reset()\n\tbt.exchangeManager = nil\n\tbt.orderManager = nil\n\tbt.databaseManager = nil\n}", "func Reset() {\n\treset()\n}", "func (o *Optional[T]) Reset() {\n\to.set = false\n}", "func (s *FrozenSuite) TestResetSame() {\n\thits := []int{}\n\n\tt := AfterFunc(100, func() { hits = append(hits, 1) })\n\tAfterFunc(100, func() { hits = append(hits, 2) })\n\tAfterFunc(100, func() { hits = append(hits, 3) })\n\tAfterFunc(101, func() { hits = append(hits, 4) })\n\tAdvance(9)\n\n\t// When\n\tactive := t.Reset(91)\n\n\t// Then\n\ts.Require().Equal(true, active)\n\n\tAdvance(90)\n\ts.Require().Equal([]int{}, hits)\n\tAdvance(1)\n\ts.Require().Equal([]int{2, 3, 1}, hits)\n}", "func (t *TokenTransactionObject) Reset() bool {\n\tt.TokenTransactionState = NewTokenTransactionState()\n\treturn true\n}", "func restoreOrder(ps *[LEAF_SIZE]vpoint) {\n\tfor i := range ps {\n\t\tif ps[i].zeroed() {\n\t\t\tfor j := i + 1; j < len(ps); j++ {\n\t\t\t\tif !ps[j].zeroed() {\n\t\t\t\t\tps[i] = ps[j]\n\t\t\t\t\tps[j].zeroOut()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (m *OperativerecordMutation) ResetOperative() {\n\tm._Operative = nil\n\tm.cleared_Operative = false\n}", "func (m *OrderMutation) ResetField(name string) error {\n\treturn fmt.Errorf(\"unknown Order field %s\", name)\n}", "func (h *handlerImpl) reset(adjMatrix adjacencyMatrix) {\n\tfor from := range adjMatrix {\n\t\tfor to := range adjMatrix[from] {\n\t\t\tadjMatrix[from][to].disabled = false\n\t\t}\n\t}\n}", "func (m *OrderproductMutation) ResetCompany() {\n\tm.company = nil\n\tm.clearedcompany = false\n}", "func (hc *cmdCollector) Reset() {\n}", "func (euo *EquipmentUpdateOne) ClearWorkOrder() *EquipmentUpdateOne {\n\teuo.clearedWorkOrder = true\n\treturn euo\n}", "func (m *OrderproductMutation) ResetAddedtime() {\n\tm.addedtime = nil\n}", "func (m *OrderFieldMutation) ResetCount() {\n\tm.count = nil\n\tm.addcount = nil\n}", "func (m *OperativerecordMutation) ResetOperativeTime() {\n\tm._OperativeTime = nil\n}", "func (m *OrderMutation) ResetEdge(name string) error {\n\tswitch name {\n\tcase order.EdgeWho:\n\t\tm.ResetWho()\n\t\treturn nil\n\tcase order.EdgeWhere:\n\t\tm.ResetWhere()\n\t\treturn nil\n\tcase order.EdgeItems:\n\t\tm.ResetItems()\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Order edge %s\", name)\n}", "func TestReset(t *testing.T) {\n\tqd, err := New(QFILE)\n\tif nil != err {\n\t\tt.Error(err)\n\t}\n\tt.Logf(\"%s: %d unused, and %d used quotes\", QFILE, qd.Unused(), qd.Used())\n\tqd.ResetAndSave()\n\tt.Logf(\"%s: %d unused, and %d used quotes\", QFILE, qd.Unused(), qd.Used())\n}", "func (m *StockMutation) ResetAmount() {\n\tm._Amount = nil\n\tm.add_Amount = nil\n}", "func (m *Model) Reset() bool {\n\tm.value = nil\n\treturn m.setCursor(0)\n}", "func (bbo *TabularBBO) Reset(rng *mathlib.Random) {\n\tbbo.ep.Wipe()\n}", "func (o *Once) Reset() {\n\to.m.Lock()\n\tdefer o.m.Unlock()\n\tatomic.StoreUint32(&o.done, 0)\n}", "func (m *OrderonlineMutation) ResetAccountnumber() {\n\tm.accountnumber = nil\n}", "func (c *Calculator) Reset() {\n\tlog.Printf(\"Reset.\\n\")\n\tvalue = 0\n\tc.returnResult()\n}", "func (e *Engine) clear() {\n\te.Orderbook.Asks = e.Orderbook.Asks[:0]\n\te.Orderbook.Bids = e.Orderbook.Bids[:0]\n}", "func (m *MockImpl) Reset() {\n\tm.recording = make([]Transaction, 0)\n\tm.simulateGetError = nil\n\tm.simulateAddError = nil\n\tm.simulateUpdateError = nil\n}", "func (c *cmdCollector) Reset() {}", "func (m *PromotionMutation) ResetPrice() {\n\tm._Price = nil\n\tm.add_Price = nil\n}", "func (e *Encoder) Reset(buf []byte) {\n\tfor k := range e.syms {\n\t\tdelete(e.syms, k)\n\t}\n\te.buf = buf[:0]\n}", "func (g Generator) setOrderStatuses(o *ir.Order, r *pathway.Results) {\n\tswitch {\n\tcase r.OrderStatus != \"\":\n\t\t// Use status value overridden in the pathway.\n\t\t// NOTE: if OrderStatus is set, ResultStatus is set too, or else the pathway would fail the validation.\n\t\to.OrderStatus = r.OrderStatus\n\t\to.ResultsStatus = r.ResultStatus\n\tcase len(o.Results) > 0 && (o.ResultsStatus == g.MessageConfig.ResultStatus.Final || o.ResultsStatus == g.MessageConfig.ResultStatus.Corrected):\n\t\t// If the results were previously set to \"F\" (Final) or \"C\" (Corrected), this is a correction.\n\t\to.OrderStatus = g.MessageConfig.OrderStatus.Completed\n\t\to.ResultsStatus = g.MessageConfig.ResultStatus.Corrected\n\tdefault:\n\t\t// Otherwise this is a final result.\n\t\t// NOTE: there might be some results for this order already, with a different status, eg.: Preliminary.\n\t\to.OrderStatus = g.MessageConfig.OrderStatus.Completed\n\t\to.ResultsStatus = g.MessageConfig.ResultStatus.Final\n\t}\n}", "func (tto *TtoT) Reset() {\n\ttto.PutChar(dg.ASCIIFF)\n\tlog.Println(\"INFO: TTO Reset\")\n}", "func Reset() {\n\tfmt.Println(\"----------------> Reset\")\n\n\tbuf := bytes.NewBufferString(\"hello\")\n\n\t//buf=hello\n\tfmt.Println(buf.String())\n\n\tbuf.Reset()\n\n\t//buf=\n\tfmt.Println(buf.String())\n}", "func (m *OperativeMutation) ResetOperativeOperativerecord() {\n\tm._Operative_Operativerecord = nil\n\tm.removed_Operative_Operativerecord = nil\n}", "func (t *MCTS) Reset() {\n\tt.Lock()\n\tdefer t.Unlock()\n\n\tt.freelist = t.freelist[:0]\n\tt.freeables = t.freeables[:0]\n\tfor i := range t.nodes {\n\t\tt.nodes[i].move = -1\n\t\tt.nodes[i].visits = 0\n\t\tt.nodes[i].status = 0\n\t\tt.nodes[i].psa = 0\n\t\tt.nodes[i].hasChildren = false\n\t\tt.nodes[i].qsa = 0\n\t\tt.freelist = append(t.freelist, t.nodes[i].id)\n\t}\n\n\tfor i := range t.children {\n\t\tt.children[i] = t.children[i][:0]\n\t}\n\n\tt.nodes = t.nodes[:0]\n\tt.policies = nil\n\truntime.GC()\n}", "func (txn *Txn) Reset() {\n\tC.mdb_txn_reset(txn._txn)\n}", "func (mcts *MCTS) Reset() {\n\tmcts.ExpandedNodes = make([]*Node, 0)\n}", "func (m *MockImpl) Reset() {\n\tm.recording = make([]Transaction, 0)\n\tm.simulateGetError = nil\n\tm.simulateAddError = nil\n}", "func (_EtherDelta *EtherDeltaSession) OrderFills(arg0 common.Address, arg1 [32]byte) (*big.Int, error) {\n\treturn _EtherDelta.Contract.OrderFills(&_EtherDelta.CallOpts, arg0, arg1)\n}", "func (m *PromotionMutation) ResetPromotionamount() {\n\tm.promotionamount = nil\n\tm.clearedpromotionamount = false\n}", "func (m *OrderonlineMutation) ResetCustomer() {\n\tm.customer = nil\n\tm.clearedcustomer = false\n}", "func (v *SyncStatus) Reset() {\n\tv.CurrentIndex.Value = 0\n\tv.CurrentIndex.Set = false\n\tv.Stage.Value = \"\"\n\tv.Stage.Set = false\n\tv.Synced.Value = false\n\tv.Synced.Set = false\n\tv.TargetIndex.Value = 0\n\tv.TargetIndex.Set = false\n}", "func (m *PromotionamountMutation) ResetPromotion() {\n\tm.promotion = nil\n\tm.removedpromotion = nil\n}", "func (s *FrozenSuite) TestResetSame(c *C) {\n\thits := []int{}\n\n\tt := AfterFunc(100, func() { hits = append(hits, 1) })\n\tAfterFunc(100, func() { hits = append(hits, 2) })\n\tAfterFunc(100, func() { hits = append(hits, 3) })\n\tAfterFunc(101, func() { hits = append(hits, 4) })\n\tAdvance(9)\n\n\t// When\n\tactive := t.Reset(91)\n\n\t// Then\n\tc.Assert(active, Equals, true)\n\n\tAdvance(90)\n\tc.Assert(hits, DeepEquals, []int{})\n\tAdvance(1)\n\tc.Assert(hits, DeepEquals, []int{2, 3, 1})\n}", "func (m *TradeRecordMutation) ResetConditions() {\n\tm.conditions = nil\n\tm.clearedconditions = false\n\tm.removedconditions = nil\n}", "func (m *OrderMutation) ResetCompleteAt() {\n\tm.complete_at = nil\n\tdelete(m.clearedFields, order.FieldCompleteAt)\n}", "func (mu *MuHash) Reset() {\n\tmu.numerator.SetToOne()\n\tmu.denominator.SetToOne()\n}", "func (m *AmbulanceMutation) ResetEnginepower() {\n\tm.enginepower = nil\n\tm.addenginepower = nil\n}", "func (m *TransportMutation) ResetSymptom() {\n\tm.symptom = nil\n}", "func (m *OrderproductMutation) ResetProduct() {\n\tm.product = nil\n\tm.clearedproduct = false\n}", "func (m *TodoItemMutation) SetOrder(i int) {\n\tm._order = &i\n\tm.add_order = nil\n}", "func (t *CustodianStateObject) Reset() bool {\n\tt.custodianState = NewCustodianState()\n\treturn true\n}", "func (m *FinancialMutation) ResetStock() {\n\tm.stock = nil\n\tm.clearedstock = false\n\tm.removedstock = nil\n}", "func (m *OrderonlineMutation) ResetCvv() {\n\tm.cvv = nil\n}", "func (s *Solution) reset() {\n\ts.Unique = nil\n\ts.Triples = nil\n\ts.Pairs = [3]CoinSet{nil, nil, nil}\n\ts.Structure = [3]Structure{nil, nil, nil}\n\ts.encoding = encoding{\n\t\tZeroCoin: s.encoding.ZeroCoin,\n\t\tFlip: s.encoding.Flip,\n\t}\n\ts.flags = s.flags &^ (GROUPED | ANALYSED | CANONICALISED)\n}", "func (oiuo *OrderInfoUpdateOne) ClearOrderAddress() *OrderInfoUpdateOne {\n\toiuo.mutation.ClearOrderAddress()\n\treturn oiuo\n}", "func (m *BillMutation) ResetPrice() {\n\tm.price = nil\n\tm.addprice = nil\n}", "func (c *calculon) Reset(ctx context.Context, arg calculator.Empty) (calculator.Result, error) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\tc.current = 0\n\treturn calculator.Result{c.current }, nil\n}", "func (m *RepairinvoiceMutation) ResetEmtell() {\n\tm.emtell = nil\n}", "func (t *State) resetChanges() {\n\tt.dirty = make(map[int]bool)\n\tt.changed = 0\n}", "func (m *PaymentMutation) ResetPromotion() {\n\tm.promotion = nil\n\tm.clearedpromotion = false\n}", "func (m *RestaurantMutation) OrdersCleared() bool {\n\treturn m.clearedorders\n}", "func (q *Query) Reset() {\n\tq.FieldMeasures = q.FieldMeasures[:0]\n\tq.Criteria = q.Criteria[:0]\n}", "func (s *Store) Reset(newEntities []workloadmeta.Entity, source workloadmeta.Source) {\n\tpanic(\"not implemented\")\n}", "func (m *SplitMutation) ResetStock() {\n\tm.stock = nil\n\tm.clearedstock = false\n}", "func (m *OrderMutation) ResetWho() {\n\tm.who = nil\n\tm.clearedwho = false\n}", "func (m *HarborMutation) ResetSettlement() {\n\tm.settlement = nil\n\tm.clearedsettlement = false\n}", "func (m *PromotiontypeMutation) ResetPromotion() {\n\tm.promotion = nil\n\tm.removedpromotion = nil\n}", "func (m *RoomdetailMutation) ResetRoomprice() {\n\tm.roomprice = nil\n\tm.addroomprice = nil\n}", "func (m *OrderonlineMutation) ResetProduct() {\n\tm.product = nil\n\tm.clearedproduct = false\n}", "func (_EtherDelta *EtherDeltaCallerSession) OrderFills(arg0 common.Address, arg1 [32]byte) (*big.Int, error) {\n\treturn _EtherDelta.Contract.OrderFills(&_EtherDelta.CallOpts, arg0, arg1)\n}" ]
[ "0.7494716", "0.732402", "0.71533674", "0.702815", "0.6776591", "0.6715659", "0.6569579", "0.65285724", "0.6491999", "0.60279214", "0.5953112", "0.59416157", "0.5916235", "0.58786863", "0.58506453", "0.5834124", "0.57945484", "0.5742576", "0.5716395", "0.56950414", "0.5656402", "0.5635857", "0.5632787", "0.5613302", "0.55849147", "0.55807745", "0.5573149", "0.5549469", "0.55221266", "0.55108607", "0.55064565", "0.5497617", "0.5490142", "0.54711795", "0.54584515", "0.54526293", "0.54445934", "0.5442944", "0.5440015", "0.54367393", "0.5433184", "0.5425655", "0.5425268", "0.5419383", "0.5412238", "0.5411934", "0.54056215", "0.5403157", "0.5401717", "0.5398576", "0.5393272", "0.53868884", "0.53739095", "0.5372073", "0.53719896", "0.53716767", "0.53667593", "0.53633386", "0.5359357", "0.5358781", "0.53567934", "0.5356307", "0.53538543", "0.53502524", "0.53480065", "0.5343572", "0.5341626", "0.5338785", "0.5331613", "0.53310555", "0.53301954", "0.5320463", "0.5318495", "0.53152215", "0.53105634", "0.53012335", "0.5301104", "0.52983665", "0.52980256", "0.5297248", "0.52874464", "0.5285268", "0.5268775", "0.5267799", "0.52666056", "0.5261379", "0.52606833", "0.5258492", "0.52580184", "0.5248114", "0.5246321", "0.5245959", "0.52376515", "0.5233465", "0.52248853", "0.5221817", "0.5219811", "0.5213113", "0.5205937", "0.5204691" ]
0.7746023
0
OrderNullFirst make null null column value first in query results when given order column.
func (op *OpQuery) OrderNullFirst() *OpQuery { op.nullPriority = "NULL FIRST" return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (op *OpQuery) OrderNullLast() *OpQuery {\n\top.nullPriority = \"NULL LAST\"\n\treturn op\n}", "func OrderAsc(cols ...string) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, orderClause{\n\t\t\tcols: cols,\n\t\t\tdir: \"ASC\",\n\t\t})\n\t\treturn q\n\t}\n}", "func (q *Query) Order(stmt string) *Query {\n\tif q.RawSQL.Fragment != \"\" {\n\t\tfmt.Println(\"Warning: Query is setup to use raw SQL\")\n\t\treturn q\n\t}\n\tq.orderClauses = append(q.orderClauses, clause{stmt, []interface{}{}})\n\treturn q\n}", "func (c *column) Asc() orderByExpression {\n\treturn orderByExpression(c.asSql() + \" ASC\")\n}", "func MergeWithDefaultOrder(defaultOrder []OrderBy, order []OrderBy) []OrderBy {\n\tresult := make([]OrderBy, 0, len(order)+len(defaultOrder))\n\tseenColumns := make(map[string]struct{})\n\tfor _, o := range order {\n\t\tresult = append(result, o)\n\t\tseenColumns[o.FieldPath.String()] = struct{}{}\n\t}\n\tfor _, o := range defaultOrder {\n\t\tif _, ok := seenColumns[o.FieldPath.String()]; !ok {\n\t\t\tresult = append(result, o)\n\t\t}\n\t}\n\treturn result\n}", "func (op *OpQuery) makeOrderStatment() string {\n\tif op.order == \"\" {\n\t\treturn \"\"\n\t}\n\n\tvar nullPriority = op.nullPriority\n\tif op.nullPriority == \"\" {\n\t\tnullPriority = \"NULL FIRST\"\n\t}\n\treturn fmt.Sprintf(\"ORDER BY %s %s\", op.order, nullPriority)\n}", "func (qs ConstraintQuerySet) OrderAscByID() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"id ASC\"))\n}", "func (op *OpQuery) OrderAsc(field string) *OpQuery {\n\top.order = fmt.Sprintf(\"%s ASC\", field)\n\treturn op\n}", "func (builder QueryBuilder) OrderAsc(predicate interface{}) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, orderBy{\n\t\tDirection: OrderDirectionAsc,\n\t\tPredicate: predicate,\n\t})\n\treturn builder\n}", "func (p *queryPlan) orderBy() {\n\torder := p.stm.OrderByConfig()\n\tif len(order) <= 0 {\n\t\treturn\n\t}\n\ttracer.V(2).Trace(p.tracer, func() *tracer.Arguments {\n\t\treturn &tracer.Arguments{\n\t\t\tMsgs: []string{\"Ordering by \" + order.String()},\n\t\t}\n\t})\n\tp.tbl.Sort(order)\n}", "func (c *Connection) Order(stmt string) *Query {\n\treturn Q(c).Order(stmt)\n}", "func (qs SysDBQuerySet) OrderAscByID() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"id ASC\"))\n}", "func (op *OpQuery) OrderReset() *OpQuery {\n\top.order = \"\"\n\treturn op\n}", "func (qs GroupQuerySet) OrderAscByAutTransferObjectType() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"aut_transfer_object_type ASC\"))\n}", "func (sd *SelectDataset) OrderPrepend(order ...exp.OrderedExpression) *SelectDataset {\n\treturn sd.copy(sd.clauses.OrderPrepend(order...))\n}", "func (qs GroupQuerySet) OrderAscByAutoTransferObjectID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"auto_transfer_object_id ASC\"))\n}", "func (q *PersonQuery) Order(cols ...kallax.ColumnOrder) *PersonQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (eq *EntityQuery) Order(o ...OrderFunc) *EntityQuery {\n\teq.order = append(eq.order, o...)\n\treturn eq\n}", "func (o *StatsQuery) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (qs ConstraintQuerySet) OrderAscByCreatedAt() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"created_at ASC\"))\n}", "func (q *PollQuery) Order(cols ...kallax.ColumnOrder) *PollQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (tx *Transaction) First(record interface{}, where string, args ...interface{}) error {\n\tctx := tx.Context(&Context{})\n\treturn ctx.First(record, where, args...)\n}", "func (qs GroupQuerySet) OrderAscByID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"id ASC\"))\n}", "func (q *Query) Order(order string) storage.Query {\n\treturn &Query{query: q.query.Order(order)}\n}", "func (qs SysDBQuerySet) OrderAscByCreatedAt() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"created_at ASC\"))\n}", "func (q *Query) Order(order string) *Query {\n\tq.order = strings.ToUpper(order)\n\treturn q\n}", "func (q *PollOptionQuery) Order(cols ...kallax.ColumnOrder) *PollOptionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *SessionQuery) Order(cols ...kallax.ColumnOrder) *SessionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *UserQuery) Order(cols ...kallax.ColumnOrder) *UserQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (qs ConstraintQuerySet) OrderAscByUpdatedAt() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at ASC\"))\n}", "func (o *MetricsQuery) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (builder QueryBuilder) Order(order DQLizer) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, order)\n\treturn builder\n}", "func (oupq *OrgUnitPositionQuery) Order(o ...OrderFunc) *OrgUnitPositionQuery {\n\toupq.order = append(oupq.order, o...)\n\treturn oupq\n}", "func (ecpq *EntityContactPointQuery) Order(o ...OrderFunc) *EntityContactPointQuery {\n\tecpq.order = append(ecpq.order, o...)\n\treturn ecpq\n}", "func (luq *LastUpdatedQuery) Order(o ...OrderFunc) *LastUpdatedQuery {\n\tluq.order = append(luq.order, o...)\n\treturn luq\n}", "func (qs SysDBQuerySet) OrderAscByUpdatedAt() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at ASC\"))\n}", "func (q *Query) First(model interface{}) error {\n\tq.Limit(1)\n\tm := &Model{Value: model}\n\tif err := q.Connection.Dialect.SelectOne(q.Connection.DB, m, *q); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (q *StatsPeriodQuery) Order(cols ...kallax.ColumnOrder) *StatsPeriodQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (esg *expressionSQLGenerator) orderedExpressionSQL(b sb.SQLBuilder, order exp.OrderedExpression) {\n\tesg.Generate(b, order.SortExpression())\n\tif order.IsAsc() {\n\t\tb.Write(esg.dialectOptions.AscFragment)\n\t} else {\n\t\tb.Write(esg.dialectOptions.DescFragment)\n\t}\n\tswitch order.NullSortType() {\n\tcase exp.NullsFirstSortType:\n\t\tb.Write(esg.dialectOptions.NullsFirstFragment)\n\tcase exp.NullsLastSortType:\n\t\tb.Write(esg.dialectOptions.NullsLastFragment)\n\t}\n}", "func (self Accessor) Order(expr interface{}) *SelectManager {\n\treturn self.From(self.Relation()).Order(expr)\n}", "func (db DB) First(entity interface{}) *Query {\n\treturn db.newQuery(entity, true)\n}", "func (fdq *FurnitureDetailQuery) Order(o ...OrderFunc) *FurnitureDetailQuery {\n\tfdq.order = append(fdq.order, o...)\n\treturn fdq\n}", "func (ouq *OrgUnitQuery) Order(o ...OrderFunc) *OrgUnitQuery {\n\touq.order = append(ouq.order, o...)\n\treturn ouq\n}", "func (evsq *ExValueScanQuery) Order(o ...exvaluescan.OrderOption) *ExValueScanQuery {\n\tevsq.order = append(evsq.order, o...)\n\treturn evsq\n}", "func (ksq *KqiSourceQuery) Order(o ...OrderFunc) *KqiSourceQuery {\n\tksq.order = append(ksq.order, o...)\n\treturn ksq\n}", "func (pq *PrizeQuery) Order(o ...OrderFunc) *PrizeQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (s *TableQuery) First(structPtr ...interface{}) (interface{}, error) {\n\ts.LimitCount = 0\n\tsql := s.getSelectSQL()\n\tif len(structPtr) > 0 {\n\t\treturn NewNativeQuery(s.DatabaseConfigKey, s.TransactionKey).First(sql, s.Params, structPtr...)\n\t}\n\treturn NewNativeQuery(s.DatabaseConfigKey, s.TransactionKey).First(sql, s.Params, s.Model)\n}", "func (qs GroupQuerySet) OrderAscByCreatedAt() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"created_at ASC\"))\n}", "func (o *MicrosoftGraphPlannerAssignment) SetOrderHintExplicitNull(b bool) {\n\to.OrderHint = nil\n\to.isExplicitNullOrderHint = b\n}", "func (wq *WorkflowQuery) Order(o ...OrderFunc) *WorkflowQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (nimq *NetInterfaceModeQuery) Order(o ...OrderFunc) *NetInterfaceModeQuery {\n\tnimq.order = append(nimq.order, o...)\n\treturn nimq\n}", "func (pq *PersonQuery) Order(o ...Order) *PersonQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (rq *RentQuery) Order(o ...OrderFunc) *RentQuery {\n\trq.order = append(rq.order, o...)\n\treturn rq\n}", "func (rdq *ResultsDefinitionQuery) Order(o ...OrderFunc) *ResultsDefinitionQuery {\n\trdq.order = append(rdq.order, o...)\n\treturn rdq\n}", "func Order(value interface{}, reorder bool) QueryProcessor {\n\treturn func(db *gorm.DB, out interface{}) (*gorm.DB, microappError.DatabaseError) {\n\t\tdb = db.Order(value)\n\t\treturn db, nil\n\t}\n}", "func (pq *ParticipantQuery) Order(o ...OrderFunc) *ParticipantQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (rq *RemedyQuery) Order(o ...OrderFunc) *RemedyQuery {\n\trq.order = append(rq.order, o...)\n\treturn rq\n}", "func TestColumn_Order(t *testing.T) {\n\ttype fields struct {\n\t\tName string\n\t\tAsc bool\n\t}\n\ttests := []struct {\n\t\tname string\n\t\tfields fields\n\t\twant string\n\t}{\n\t\t// TODO: Add test cases.\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tc := &main.Column{\n\t\t\t\tName: tt.fields.Name,\n\t\t\t\tAsc: tt.fields.Asc,\n\t\t\t}\n\t\t\tif got := c.Order(); got != tt.want {\n\t\t\t\tt.Errorf(\"Order() = %v, want %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}", "func (qs GroupQuerySet) OrderAscByOwnerID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"owner_id ASC\"))\n}", "func (tq *TweetQuery) Order(o ...OrderFunc) *TweetQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (sq *ServerQuery) Order(o ...OrderFunc) *ServerQuery {\n\tsq.order = append(sq.order, o...)\n\treturn sq\n}", "func (tq *TeamQuery) Order(o ...OrderFunc) *TeamQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (bcq *BaselineClassQuery) Order(o ...OrderFunc) *BaselineClassQuery {\n\tbcq.order = append(bcq.order, o...)\n\treturn bcq\n}", "func (eq *EntryQuery) Order(o ...entry.OrderOption) *EntryQuery {\n\teq.order = append(eq.order, o...)\n\treturn eq\n}", "func (wq *WidgetQuery) Order(o ...OrderFunc) *WidgetQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (b ValExprBuilder) Ascending() *Order {\n\treturn &Order{\n\t\tExpr: b.ValExpr,\n\t\tDirection: \" ASC\",\n\t}\n}", "func Asc(fields ...string) Order {\n\treturn Order(\n\t\tfunc(s *sql.Selector) {\n\t\t\tfor _, f := range fields {\n\t\t\t\ts.OrderBy(sql.Asc(f))\n\t\t\t}\n\t\t},\n\t)\n}", "func (c *Condition) Order(order ...string) *Condition {\n\t// skipping empty call or string\n\tif len(order) == 0 || (len(order) == 1 && order[0] == \"\") {\n\t\treturn c\n\t}\n\n\tc.Reset(ORDER)\n\tfor _, stmt := range order {\n\n\t\tif c.order != \"\" {\n\t\t\tc.order += \", \"\n\t\t}\n\n\t\t// uppercase user asc,desc inserts\n\t\tstmt = strings.Replace(stmt, \" asc\", \" ASC\", 1)\n\t\tstmt = strings.Replace(stmt, \" desc\", \" DESC\", 1)\n\n\t\tif strings.HasPrefix(stmt, \"-\") {\n\t\t\tstmt = stmt[1:] + \" DESC\"\n\t\t} else if !strings.HasSuffix(strings.ToUpper(stmt), \"ASC\") && !strings.HasSuffix(strings.ToUpper(stmt), \"DESC\") {\n\t\t\tstmt = stmt + \" ASC\"\n\t\t}\n\n\t\tc.order = c.order + stmt\n\t}\n\n\tc.order = \"ORDER BY \" + c.order\n\treturn c\n}", "func (bq *BrowserQuery) Order(o ...OrderFunc) *BrowserQuery {\n\tbq.order = append(bq.order, o...)\n\treturn bq\n}", "func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {\n\tuq.order = append(uq.order, o...)\n\treturn uq\n}", "func (liq *LineItemQuery) Order(o ...OrderFunc) *LineItemQuery {\n\tliq.order = append(liq.order, o...)\n\treturn liq\n}", "func (fq *ForumQuery) Order(o ...OrderFunc) *ForumQuery {\n\tfq.order = append(fq.order, o...)\n\treturn fq\n}", "func (hq *HarborQuery) Order(o ...OrderFunc) *HarborQuery {\n\thq.order = append(hq.order, o...)\n\treturn hq\n}", "func (tq *TenantQuery) Order(o ...OrderFunc) *TenantQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (o SparseStatsQueriesList) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (sd *SelectDataset) Order(order ...exp.OrderedExpression) *SelectDataset {\n\treturn sd.copy(sd.clauses.SetOrder(order...))\n}", "func (o *TransactionSplit) SetOrderNil() {\n\to.Order.Set(nil)\n}", "func (q *PetQuery) Order(cols ...kallax.ColumnOrder) *PetQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (wfq *WithFieldsQuery) Order(o ...OrderFunc) *WithFieldsQuery {\n\twfq.order = append(wfq.order, o...)\n\treturn wfq\n}", "func (tbl AssociationTable) QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error) {\n\terr = support.QueryOneNullThing(tbl, req, &result, query, args...)\n\treturn result, err\n}", "func (siq *SubItemQuery) Order(o ...OrderFunc) *SubItemQuery {\n\tsiq.order = append(siq.order, o...)\n\treturn siq\n}", "func (qs ConstraintQuerySet) OrderAscBySegmentID() ConstraintQuerySet {\n\treturn qs.w(qs.db.Order(\"segment_id ASC\"))\n}", "func (qs SysDBQuerySet) OrderAscByPort() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"port ASC\"))\n}", "func (cq *ConfirmationQuery) Order(o ...OrderFunc) *ConfirmationQuery {\n\tcq.order = append(cq.order, o...)\n\treturn cq\n}", "func (q *PollVoteQuery) Order(cols ...kallax.ColumnOrder) *PollVoteQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (o *SingleSelectFieldField) GetOrder() int32 {\n\tif o == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\n\treturn o.Order\n}", "func (ttrq *TradeTimeRangeQuery) Order(o ...OrderFunc) *TradeTimeRangeQuery {\n\tttrq.order = append(ttrq.order, o...)\n\treturn ttrq\n}", "func (wq *WifiQuery) Order(o ...OrderFunc) *WifiQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (tbl RecordTable) QueryOneNullFloat64(req require.Requirement, query string, args ...interface{}) (result sql.NullFloat64, err error) {\n\terr = support.QueryOneNullThing(tbl, req, &result, query, args...)\n\treturn result, err\n}", "func (qs GroupQuerySet) OrderAscByUpdatedAt() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"updated_at ASC\"))\n}", "func (o SparseMetricsQueriesList) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (s *BaseSelectStatementParserListener) EnterOrderByField(ctx *OrderByFieldContext) {}", "func (osq *OfflineSessionQuery) Order(o ...OrderFunc) *OfflineSessionQuery {\n\tosq.order = append(osq.order, o...)\n\treturn osq\n}", "func (vq *VehicleQuery) Order(o ...OrderFunc) *VehicleQuery {\n\tvq.order = append(vq.order, o...)\n\treturn vq\n}", "func (query *Query) CleanOrderBy() *Query {\n\treturn query.clean(ORDER_BY)\n}", "func FindOneSorted(s Session, dbname string, collection string, query map[string]interface{}, sortParameter string) (interface{}, error) {\n\tvar object interface{}\n\tif err := s.DB(dbname).C(collection).Find(query).Sort(sortParameter).One(&object); err != nil {\n\t\treturn object, err\n\t}\n\treturn object, nil\n}", "func (roq *RestaurantOwnerQuery) Order(o ...OrderFunc) *RestaurantOwnerQuery {\n\troq.order = append(roq.order, o...)\n\treturn roq\n}", "func (fb *Firebase) OrderBy(value string) *Firebase {\n\tc := fb.copy()\n\tif value != \"\" {\n\t\tc.params.Set(orderByParam, value)\n\t} else {\n\t\tc.params.Del(orderByParam)\n\t}\n\treturn c\n}", "func (tdq *TCPDetectorQuery) Order(o ...tcpdetector.OrderOption) *TCPDetectorQuery {\n\ttdq.order = append(tdq.order, o...)\n\treturn tdq\n}", "func (rlq *RuleLimitQuery) Order(o ...OrderFunc) *RuleLimitQuery {\n\trlq.order = append(rlq.order, o...)\n\treturn rlq\n}" ]
[ "0.6892724", "0.5792839", "0.56489444", "0.559137", "0.5567387", "0.54570764", "0.541041", "0.54067844", "0.53797185", "0.5370025", "0.53610027", "0.532752", "0.5286768", "0.5284509", "0.52831644", "0.527476", "0.52649486", "0.5257366", "0.52451324", "0.52153933", "0.521498", "0.5188027", "0.5175677", "0.51702595", "0.51425034", "0.5135766", "0.51305056", "0.5113191", "0.51078534", "0.51058906", "0.50916266", "0.5088185", "0.50413567", "0.5040151", "0.5023829", "0.5002775", "0.5002555", "0.4997268", "0.4992445", "0.49896848", "0.4988476", "0.4979206", "0.4976283", "0.49678254", "0.49658588", "0.49653557", "0.49564835", "0.49542686", "0.49517697", "0.49490553", "0.49478367", "0.49476328", "0.4939448", "0.49360624", "0.49341273", "0.49288777", "0.49286902", "0.49248475", "0.49218178", "0.4917485", "0.49150115", "0.49137864", "0.4898595", "0.488937", "0.4874488", "0.48683223", "0.48659238", "0.48548207", "0.4852303", "0.4840265", "0.4831546", "0.4828506", "0.48261043", "0.48254424", "0.48232755", "0.4816249", "0.48064718", "0.4796947", "0.47963902", "0.4795897", "0.47881234", "0.47637933", "0.47627968", "0.47595552", "0.4757062", "0.47564262", "0.4744662", "0.47362694", "0.47336248", "0.47318798", "0.4728124", "0.4722019", "0.47201872", "0.47135392", "0.47132203", "0.47123802", "0.47062948", "0.47030908", "0.46935007", "0.46870938" ]
0.8278714
0
OrderNullLast make null column value last in query results when given order column.
func (op *OpQuery) OrderNullLast() *OpQuery { op.nullPriority = "NULL LAST" return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (op *OpQuery) OrderNullFirst() *OpQuery {\n\top.nullPriority = \"NULL FIRST\"\n\treturn op\n}", "func (op *OpQuery) makeOrderStatment() string {\n\tif op.order == \"\" {\n\t\treturn \"\"\n\t}\n\n\tvar nullPriority = op.nullPriority\n\tif op.nullPriority == \"\" {\n\t\tnullPriority = \"NULL FIRST\"\n\t}\n\treturn fmt.Sprintf(\"ORDER BY %s %s\", op.order, nullPriority)\n}", "func MergeWithDefaultOrder(defaultOrder []OrderBy, order []OrderBy) []OrderBy {\n\tresult := make([]OrderBy, 0, len(order)+len(defaultOrder))\n\tseenColumns := make(map[string]struct{})\n\tfor _, o := range order {\n\t\tresult = append(result, o)\n\t\tseenColumns[o.FieldPath.String()] = struct{}{}\n\t}\n\tfor _, o := range defaultOrder {\n\t\tif _, ok := seenColumns[o.FieldPath.String()]; !ok {\n\t\t\tresult = append(result, o)\n\t\t}\n\t}\n\treturn result\n}", "func (luq *LastUpdatedQuery) Order(o ...OrderFunc) *LastUpdatedQuery {\n\tluq.order = append(luq.order, o...)\n\treturn luq\n}", "func (q *Query) Order(stmt string) *Query {\n\tif q.RawSQL.Fragment != \"\" {\n\t\tfmt.Println(\"Warning: Query is setup to use raw SQL\")\n\t\treturn q\n\t}\n\tq.orderClauses = append(q.orderClauses, clause{stmt, []interface{}{}})\n\treturn q\n}", "func (op *OpQuery) OrderReset() *OpQuery {\n\top.order = \"\"\n\treturn op\n}", "func (q *PollQuery) Order(cols ...kallax.ColumnOrder) *PollQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (q *PollOptionQuery) Order(cols ...kallax.ColumnOrder) *PollOptionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (op *OpQuery) OrderDesc(field string) *OpQuery {\n\top.order = fmt.Sprintf(\"%s DESC\", field)\n\treturn op\n}", "func OrderDesc(cols ...string) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, orderClause{\n\t\t\tcols: cols,\n\t\t\tdir: \"DESC\",\n\t\t})\n\t\treturn q\n\t}\n}", "func (esg *expressionSQLGenerator) orderedExpressionSQL(b sb.SQLBuilder, order exp.OrderedExpression) {\n\tesg.Generate(b, order.SortExpression())\n\tif order.IsAsc() {\n\t\tb.Write(esg.dialectOptions.AscFragment)\n\t} else {\n\t\tb.Write(esg.dialectOptions.DescFragment)\n\t}\n\tswitch order.NullSortType() {\n\tcase exp.NullsFirstSortType:\n\t\tb.Write(esg.dialectOptions.NullsFirstFragment)\n\tcase exp.NullsLastSortType:\n\t\tb.Write(esg.dialectOptions.NullsLastFragment)\n\t}\n}", "func (builder QueryBuilder) OrderDesc(predicate interface{}) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, orderBy{\n\t\tDirection: OrderDirectionDesc,\n\t\tPredicate: predicate,\n\t})\n\treturn builder\n}", "func (o *StatsQuery) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (builder QueryBuilder) Order(order DQLizer) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, order)\n\treturn builder\n}", "func (q *StatsPeriodQuery) Order(cols ...kallax.ColumnOrder) *StatsPeriodQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (upq *UnsavedPostQuery) Order(o ...OrderFunc) *UnsavedPostQuery {\n\tupq.order = append(upq.order, o...)\n\treturn upq\n}", "func (q *SessionQuery) Order(cols ...kallax.ColumnOrder) *SessionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (oupq *OrgUnitPositionQuery) Order(o ...OrderFunc) *OrgUnitPositionQuery {\n\toupq.order = append(oupq.order, o...)\n\treturn oupq\n}", "func (c *Connection) Order(stmt string) *Query {\n\treturn Q(c).Order(stmt)\n}", "func (eq *EntityQuery) Order(o ...OrderFunc) *EntityQuery {\n\teq.order = append(eq.order, o...)\n\treturn eq\n}", "func (s *BaseSelectStatementParserListener) ExitOrderByField(ctx *OrderByFieldContext) {}", "func (u *__GroupOrderdUser_Selector) OrderBy_OrderId_Desc() *__GroupOrderdUser_Selector {\n\tu.orderBy = \" ORDER BY OrderId DESC \"\n\treturn u\n}", "func (p *queryPlan) orderBy() {\n\torder := p.stm.OrderByConfig()\n\tif len(order) <= 0 {\n\t\treturn\n\t}\n\ttracer.V(2).Trace(p.tracer, func() *tracer.Arguments {\n\t\treturn &tracer.Arguments{\n\t\t\tMsgs: []string{\"Ordering by \" + order.String()},\n\t\t}\n\t})\n\tp.tbl.Sort(order)\n}", "func (q *Query) OrWhereNull(column string) *Query {\n\tcond := newCondition(OR, column, IS_NULL, nil)\n\n\tq.Binding.Conditions = append(q.Binding.Conditions, cond)\n\n\treturn q\n}", "func (o *MetricsQuery) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (q *UserQuery) Order(cols ...kallax.ColumnOrder) *UserQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func orderByToGitHubOrder(desc bool) githubv4.OrderDirection {\n\tif desc {\n\t\treturn githubv4.OrderDirectionDesc\n\t} else {\n\t\treturn githubv4.OrderDirectionAsc\n\t}\n}", "func (ouq *OrgUnitQuery) Order(o ...OrderFunc) *OrgUnitQuery {\n\touq.order = append(ouq.order, o...)\n\treturn ouq\n}", "func (sq *ServerQuery) Order(o ...OrderFunc) *ServerQuery {\n\tsq.order = append(sq.order, o...)\n\treturn sq\n}", "func (wq *WidgetQuery) Order(o ...OrderFunc) *WidgetQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (q *PersonQuery) Order(cols ...kallax.ColumnOrder) *PersonQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (enc *Encoder) SQLNullFloat64(v *sql.NullFloat64) {\n\tenc.Float64(v.Float64)\n}", "func (nimq *NetInterfaceModeQuery) Order(o ...OrderFunc) *NetInterfaceModeQuery {\n\tnimq.order = append(nimq.order, o...)\n\treturn nimq\n}", "func updateDBColumnNullable(fi *fieldInfo) {\n\tadapter := adapters[db.DriverName()]\n\tvar verb string\n\tif adapter.fieldIsNotNull(fi) {\n\t\tverb = \"SET\"\n\t} else {\n\t\tverb = \"DROP\"\n\t}\n\tquery := fmt.Sprintf(`\n\t\tALTER TABLE %s\n\t\tALTER COLUMN %s %s NOT NULL\n\t`, adapter.quoteTableName(fi.mi.tableName), fi.json, verb)\n\tdbExecuteNoTx(query)\n}", "func (tq *TweetQuery) Order(o ...OrderFunc) *TweetQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (fdq *FurnitureDetailQuery) Order(o ...OrderFunc) *FurnitureDetailQuery {\n\tfdq.order = append(fdq.order, o...)\n\treturn fdq\n}", "func (c *Condition) Order(order ...string) *Condition {\n\t// skipping empty call or string\n\tif len(order) == 0 || (len(order) == 1 && order[0] == \"\") {\n\t\treturn c\n\t}\n\n\tc.Reset(ORDER)\n\tfor _, stmt := range order {\n\n\t\tif c.order != \"\" {\n\t\t\tc.order += \", \"\n\t\t}\n\n\t\t// uppercase user asc,desc inserts\n\t\tstmt = strings.Replace(stmt, \" asc\", \" ASC\", 1)\n\t\tstmt = strings.Replace(stmt, \" desc\", \" DESC\", 1)\n\n\t\tif strings.HasPrefix(stmt, \"-\") {\n\t\t\tstmt = stmt[1:] + \" DESC\"\n\t\t} else if !strings.HasSuffix(strings.ToUpper(stmt), \"ASC\") && !strings.HasSuffix(strings.ToUpper(stmt), \"DESC\") {\n\t\t\tstmt = stmt + \" ASC\"\n\t\t}\n\n\t\tc.order = c.order + stmt\n\t}\n\n\tc.order = \"ORDER BY \" + c.order\n\treturn c\n}", "func (s *BaseMySqlParserListener) ExitOrderByClause(ctx *OrderByClauseContext) {}", "func (sd *SelectDataset) OrderAppend(order ...exp.OrderedExpression) *SelectDataset {\n\treturn sd.copy(sd.clauses.OrderAppend(order...))\n}", "func (evsq *ExValueScanQuery) Order(o ...exvaluescan.OrderOption) *ExValueScanQuery {\n\tevsq.order = append(evsq.order, o...)\n\treturn evsq\n}", "func (rq *RentQuery) Order(o ...OrderFunc) *RentQuery {\n\trq.order = append(rq.order, o...)\n\treturn rq\n}", "func (q *PollVoteQuery) Order(cols ...kallax.ColumnOrder) *PollVoteQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (wq *WorkflowQuery) Order(o ...OrderFunc) *WorkflowQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func Order(q *query.Query) *query.Query {\n\treturn q.Order(\"status desc\")\n}", "func (ttrq *TradeTimeRangeQuery) Order(o ...OrderFunc) *TradeTimeRangeQuery {\n\tttrq.order = append(ttrq.order, o...)\n\treturn ttrq\n}", "func (tq *TeamQuery) Order(o ...OrderFunc) *TeamQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (eq *EntryQuery) Order(o ...entry.OrderOption) *EntryQuery {\n\teq.order = append(eq.order, o...)\n\treturn eq\n}", "func (ub *UpdateBuilder) Desc() *UpdateBuilder {\n\tub.order = \"DESC\"\n\tub.marker = updateMarkerAfterOrderBy\n\treturn ub\n}", "func (lbq *LatestBlockQuery) Order(o ...OrderFunc) *LatestBlockQuery {\n\tlbq.order = append(lbq.order, o...)\n\treturn lbq\n}", "func (hq *HarborQuery) Order(o ...OrderFunc) *HarborQuery {\n\thq.order = append(hq.order, o...)\n\treturn hq\n}", "func (q *Query) Order(order string) *Query {\n\tq.order = strings.ToUpper(order)\n\treturn q\n}", "func (enc *Encoder) AddSQLNullFloat64(v *sql.NullFloat64) {\n\tenc.Float64(v.Float64)\n}", "func (ulq *UserLogQuery) Order(o ...OrderFunc) *UserLogQuery {\n\tulq.order = append(ulq.order, o...)\n\treturn ulq\n}", "func (s *BaseMySqlParserListener) ExitOrderByExpression(ctx *OrderByExpressionContext) {}", "func (r *Row) AppendNullValue() {\n\tif len(r.fieldValues) < len(r.fields) {\n\t\tr.fieldValues = append(r.fieldValues, nil)\n\t\tr.fieldValuesCache = append(r.fieldValuesCache, []byte{0xfb})\n\t}\n}", "func (rlq *RuleLimitQuery) Order(o ...OrderFunc) *RuleLimitQuery {\n\trlq.order = append(rlq.order, o...)\n\treturn rlq\n}", "func (c *column) Asc() orderByExpression {\n\treturn orderByExpression(c.asSql() + \" ASC\")\n}", "func (roq *RestaurantOwnerQuery) Order(o ...OrderFunc) *RestaurantOwnerQuery {\n\troq.order = append(roq.order, o...)\n\treturn roq\n}", "func (rdq *ResultsDefinitionQuery) Order(o ...OrderFunc) *ResultsDefinitionQuery {\n\trdq.order = append(rdq.order, o...)\n\treturn rdq\n}", "func (osq *OfflineSessionQuery) Order(o ...OrderFunc) *OfflineSessionQuery {\n\tosq.order = append(osq.order, o...)\n\treturn osq\n}", "func (urq *UserRoleQuery) Order(o ...OrderFunc) *UserRoleQuery {\n\turq.order = append(urq.order, o...)\n\treturn urq\n}", "func (q *Query) Order(order string) storage.Query {\n\treturn &Query{query: q.query.Order(order)}\n}", "func (b ValExprBuilder) Descending() *Order {\n\treturn &Order{\n\t\tExpr: b.ValExpr,\n\t\tDirection: \" DESC\",\n\t}\n}", "func (g *Graph) Order() int {\n\treturn len(g.mx.Colptr) - 1\n}", "func (rq *RemedyQuery) Order(o ...OrderFunc) *RemedyQuery {\n\trq.order = append(rq.order, o...)\n\treturn rq\n}", "func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {\n\tuq.order = append(uq.order, o...)\n\treturn uq\n}", "func (o *FormulaLimit) GetOrder() QuerySortOrder {\n\tif o == nil || o.Order == nil {\n\t\tvar ret QuerySortOrder\n\t\treturn ret\n\t}\n\treturn *o.Order\n}", "func (self Accessor) Order(expr interface{}) *SelectManager {\n\treturn self.From(self.Relation()).Order(expr)\n}", "func (enc *Encoder) AddSQLNullFloat64OmitEmpty(v *sql.NullFloat64) {\n\tif v != nil && v.Valid && v.Float64 != 0 {\n\t\tenc.Float64OmitEmpty(v.Float64)\n\t}\n}", "func (tq *TenantQuery) Order(o ...OrderFunc) *TenantQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (lq *LocationQuery) Order(o ...Order) *LocationQuery {\n\tlq.order = append(lq.order, o...)\n\treturn lq\n}", "func (o MetricsQueriesList) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (ecpq *EntityContactPointQuery) Order(o ...OrderFunc) *EntityContactPointQuery {\n\tecpq.order = append(ecpq.order, o...)\n\treturn ecpq\n}", "func (pq *PersonQuery) Order(o ...Order) *PersonQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (deq *DentalExpenseQuery) Order(o ...OrderFunc) *DentalExpenseQuery {\n\tdeq.order = append(deq.order, o...)\n\treturn deq\n}", "func (u *__FileStorage_Selector) OrderBy_FirstFileRefId_Desc() *__FileStorage_Selector {\n\tu.orderBy = append(u.orderBy, \" first_file_ref_id DESC\")\n\treturn u\n}", "func generateOrderByCQL(order []ClusteringOrderColumn) string {\n\tout := make([]string, 0, len(order))\n\tfor _, oc := range order {\n\t\tout = append(out, oc.Column+\" \"+oc.Direction.String())\n\t}\n\treturn strings.Join(out, \", \")\n}", "func (liq *LineItemQuery) Order(o ...OrderFunc) *LineItemQuery {\n\tliq.order = append(liq.order, o...)\n\treturn liq\n}", "func (omq *OutcomeMeasureQuery) Order(o ...OrderFunc) *OutcomeMeasureQuery {\n\tomq.order = append(omq.order, o...)\n\treturn omq\n}", "func (bcq *BaselineClassQuery) Order(o ...OrderFunc) *BaselineClassQuery {\n\tbcq.order = append(bcq.order, o...)\n\treturn bcq\n}", "func (osq *OfflineSessionQuery) Order(o ...offlinesession.OrderOption) *OfflineSessionQuery {\n\tosq.order = append(osq.order, o...)\n\treturn osq\n}", "func (pq *PrizeQuery) Order(o ...OrderFunc) *PrizeQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (wfq *WithFieldsQuery) Order(o ...OrderFunc) *WithFieldsQuery {\n\twfq.order = append(wfq.order, o...)\n\treturn wfq\n}", "func (w *Wrapper) buildOrderBy() (query string) {\n\tif len(w.orders) == 0 {\n\t\treturn\n\t}\n\tquery += \"ORDER BY \"\n\tfor _, v := range w.orders {\n\t\tswitch len(v.args) {\n\t\t// .OrderBy(\"RAND()\")\n\t\tcase 0:\n\t\t\tquery += fmt.Sprintf(\"%s, \", v.column)\n\t\t// .OrderBy(\"ID\", \"ASC\")\n\t\tcase 1:\n\t\t\tquery += fmt.Sprintf(\"%s %s, \", v.column, v.args[0])\n\t\t// .OrderBy(\"UserGroup\", \"ASC\", \"SuperUser\", \"Admin\")\n\t\tdefault:\n\t\t\tquery += fmt.Sprintf(\"FIELD (%s, %s) %s, \", v.column, w.bindParams(v.args[1:]), v.args[0])\n\t\t}\n\t}\n\tquery = trim(query)\n\treturn\n}", "func (o *Option) Last() *Option { \n if o == nil { return nil }\n for o.isNotLast { o = o.next }\n return o\n}", "func Order(value interface{}, reorder bool) QueryProcessor {\n\treturn func(db *gorm.DB, out interface{}) (*gorm.DB, microappError.DatabaseError) {\n\t\tdb = db.Order(value)\n\t\treturn db, nil\n\t}\n}", "func (nsq *NamespaceSecretQuery) Order(o ...OrderFunc) *NamespaceSecretQuery {\n\tnsq.order = append(nsq.order, o...)\n\treturn nsq\n}", "func (d *Dao) MaxGroupOrder() (max int64, err error) {\n\terr = d.DB.Table(\"card_group\").Select(\"MAX(order_num)\").Row().Scan(&max)\n\treturn\n}", "func (bq *BrowserQuery) Order(o ...OrderFunc) *BrowserQuery {\n\tbq.order = append(bq.order, o...)\n\treturn bq\n}", "func (wq *WordQuery) Order(o ...OrderFunc) *WordQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (fq *ForumQuery) Order(o ...OrderFunc) *ForumQuery {\n\tfq.order = append(fq.order, o...)\n\treturn fq\n}", "func (wq *WifiQuery) Order(o ...OrderFunc) *WifiQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (cq *ConfirmationQuery) Order(o ...OrderFunc) *ConfirmationQuery {\n\tcq.order = append(cq.order, o...)\n\treturn cq\n}", "func (ub *UpdateBuilder) OrderBy(col ...string) *UpdateBuilder {\n\tub.orderByCols = col\n\tub.marker = updateMarkerAfterOrderBy\n\treturn ub\n}", "func (wewq *WorkflowEventsWaitQuery) Order(o ...OrderFunc) *WorkflowEventsWaitQuery {\n\twewq.order = append(wewq.order, o...)\n\treturn wewq\n}", "func (qs GroupQuerySet) OrderDescByAutoTransferObjectID() GroupQuerySet {\n\treturn qs.w(qs.db.Order(\"auto_transfer_object_id DESC\"))\n}", "func (o StatsQueriesList) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (mvq *ModuleVersionQuery) Order(o ...Order) *ModuleVersionQuery {\n\tmvq.order = append(mvq.order, o...)\n\treturn mvq\n}", "func (sq *ShopQuery) Order(o ...Order) *ShopQuery {\n\tsq.order = append(sq.order, o...)\n\treturn sq\n}", "func (pq *ParticipantQuery) Order(o ...OrderFunc) *ParticipantQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}" ]
[ "0.63343173", "0.5581829", "0.55036545", "0.5465771", "0.5410145", "0.52359337", "0.52086264", "0.51696247", "0.51222646", "0.50885546", "0.5049316", "0.50372714", "0.50086486", "0.50060993", "0.4990505", "0.49754462", "0.49704665", "0.49319875", "0.48896864", "0.48730737", "0.48709893", "0.48694298", "0.48688638", "0.48649704", "0.485669", "0.4846835", "0.48172235", "0.48101243", "0.480387", "0.4788566", "0.4788262", "0.4786677", "0.47810042", "0.47809246", "0.4778818", "0.4764308", "0.47480488", "0.47473618", "0.47469", "0.47439858", "0.47432956", "0.47336665", "0.47305453", "0.47296193", "0.47291356", "0.4725195", "0.47207612", "0.4718193", "0.47178212", "0.47172588", "0.46923545", "0.4692059", "0.46911323", "0.46834758", "0.46755186", "0.46675903", "0.46534628", "0.46491835", "0.4644391", "0.4639426", "0.4638643", "0.46343258", "0.46332678", "0.46301308", "0.4629036", "0.46236974", "0.4617828", "0.46067354", "0.45956886", "0.45949534", "0.4587168", "0.4586002", "0.45846617", "0.45804483", "0.45718566", "0.45639837", "0.45633602", "0.45630717", "0.455837", "0.45568565", "0.4555287", "0.4554874", "0.45535055", "0.4551879", "0.4545682", "0.45454457", "0.45337754", "0.45279732", "0.45264232", "0.45251536", "0.4513672", "0.45111075", "0.45095047", "0.45055628", "0.44990727", "0.44976676", "0.44938648", "0.44921708", "0.44849914", "0.44819164" ]
0.83508426
0
Limit defines the max records will be return. if n==0, will treat it as a signal to reset limitation to unlimited.
func (op *OpQuery) Limit(n int) *OpQuery { op.limit = n return op }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *ScanOp) Limit(n int) *ScanOp {\n\ts.limit = n\n\treturn s\n}", "func (q *Query) Limit(n int) *Query {\n\tq.limit = n\n\treturn q\n}", "func (s Stream) Limit(n int) Stream {\n\treturn s.Pipe(func() func(r Record) (Record, error) {\n\t\tvar count int\n\n\t\treturn func(r Record) (Record, error) {\n\t\t\tif count < n {\n\t\t\t\tcount++\n\t\t\t\treturn r, nil\n\t\t\t}\n\n\t\t\treturn nil, ErrStreamClosed\n\t\t}\n\t})\n}", "func (q *PollQuery) Limit(n uint64) *PollQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func (q *PollOptionQuery) Limit(n uint64) *PollOptionQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func (q *SessionQuery) Limit(n uint64) *SessionQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func (q *StatsPeriodQuery) Limit(n uint64) *StatsPeriodQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func (q *Query) Limit(n int) *Query {\n\tq.q = q.q.Limit(n)\n\treturn q\n}", "func limit(n, limit int) (rv int) {\n\trv = n\n\tif rv >= limit {\n\t\trv = limit\n\t}\n\treturn\n}", "func (q *PersonQuery) Limit(n uint64) *PersonQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func Limit(n int64) Option {\n\treturn func(q Query) Query {\n\t\tq.clauses = append(q.clauses, limitClause(n))\n\t\treturn q\n\t}\n}", "func (q *Query) Limit(n int64) QueryI {\n\tnewQ := q\n\tnewQ.limit = &n\n\treturn newQ\n}", "func limit(n int64) int {\n\tif n < 0 || maxio < n {\n\t\tFatal(\"bad io size:\", n)\n\t}\n\treturn int(n)\n}", "func (q *UserQuery) Limit(n uint64) *UserQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func (nimq *NetInterfaceModeQuery) Limit(limit int) *NetInterfaceModeQuery {\n\tnimq.limit = &limit\n\treturn nimq\n}", "func Limit(n int) QueryOption {\n\treturn newFuncQueryOption(func(wrapper *QueryWrapper) {\n\t\twrapper.limit = n\n\t\twrapper.queryLen += 2\n\t})\n}", "func nlimit(n int) int {\n\tif n > maxNewlines {\n\t\tn = maxNewlines\n\t}\n\treturn n\n}", "func OptionLimit(n int) QOption {\n\treturn func(q *Q) {\n\t\tq.query.Set(\"limit\", fmt.Sprintf(\"%d\", n))\n\t}\n}", "func (q *PollVoteQuery) Limit(n uint64) *PollVoteQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func (q *PetQuery) Limit(n uint64) *PetQuery {\n\tq.BaseQuery.Limit(n)\n\treturn q\n}", "func (alr *adjustableLimitedReader) setLimit(n int64) {\n\talr.R.N = n\n}", "func (s *TableQuery) Limit(count int) drivers.ITableQuery {\n\ts.LimitCount = count\n\treturn s\n}", "func (q *Query) Limit(i int) *Query {\n\tq.limit = [2]int{0, i}\n\treturn q\n}", "func (s *Select) SetLimit(n int) *Select {\n\ts.limit = n\n\treturn s\n}", "func (osq *OfflineSessionQuery) Limit(limit int) *OfflineSessionQuery {\n\tosq.limit = &limit\n\treturn osq\n}", "func (s Sequence) Limit(l int) Sequence {\n\tif l < 0 {\n\t\ts.limit = 0\n\t} else {\n\t\ts.limit = l\n\t}\n\treturn s\n}", "func Limit(limit int) Parameter {\n\treturn func(pa Parameterizable) {\n\t\tpa.SetParameter(\"limit\", limit)\n\t}\n}", "func (m Menu) Limit(n int) Menu {\n\tif len(m) > n {\n\t\treturn m[0:n]\n\t}\n\treturn m\n}", "func (rq *ReceiptQuery) Limit(limit int) *ReceiptQuery {\n\trq.limit = &limit\n\treturn rq\n}", "func (c *ReconcileCall) Limit(limit int64) *ReconcileCall {\n\tc.urlParams_.Set(\"limit\", fmt.Sprint(limit))\n\treturn c\n}", "func (q *Query) Limit(limit int) *Query {\n\tq.limitResults = limit\n\treturn q\n}", "func (q *BasicQuery) SetLimit(n uint64) Query {\n\tq.Limit = n\n\treturn q\n}", "func (rq *RentQuery) Limit(limit int) *RentQuery {\n\trq.limit = &limit\n\treturn rq\n}", "func (q *Query) Limit(i int) *Query {\n\tq.limit = i\n\treturn q\n}", "func (wewq *WorkflowEventsWaitQuery) Limit(limit int) *WorkflowEventsWaitQuery {\n\twewq.limit = &limit\n\treturn wewq\n}", "func (biq *BankItemQuery) Limit(limit int) *BankItemQuery {\n\tbiq.limit = &limit\n\treturn biq\n}", "func (siq *SubItemQuery) Limit(limit int) *SubItemQuery {\n\tsiq.limit = &limit\n\treturn siq\n}", "func (rdq *ResultsDefinitionQuery) Limit(limit int) *ResultsDefinitionQuery {\n\trdq.limit = &limit\n\treturn rdq\n}", "func (irq *InstanceRuntimeQuery) Limit(limit int) *InstanceRuntimeQuery {\n\tirq.limit = &limit\n\treturn irq\n}", "func (rq *RemedyQuery) Limit(limit int) *RemedyQuery {\n\trq.limit = &limit\n\treturn rq\n}", "func (self *Query) Limit(l int) *Query {\n\tself.limit = l\n\treturn self\n}", "func (sbr *smtpBufferedReader) setLimit(n int64) {\n\tsbr.alr.setLimit(n)\n}", "func (deq *DentalExpenseQuery) Limit(limit int) *DentalExpenseQuery {\n\tdeq.limit = &limit\n\treturn deq\n}", "func (q *Query) Limit(limit uint64) *Query {\n\tq.limit = strconv.FormatUint(limit, 10)\n\treturn q\n}", "func (p *queryPlan) limit() {\n\tif p.stm.IsLimitSet() {\n\t\tstmLimit := p.stm.Limit()\n\t\ttracer.V(2).Trace(p.tracer, func() *tracer.Arguments {\n\t\t\treturn &tracer.Arguments{\n\t\t\t\tMsgs: []string{fmt.Sprintf(\"Limit results to %s\", strconv.Itoa(int(stmLimit)))},\n\t\t\t}\n\t\t})\n\t\tp.tbl.Limit(stmLimit)\n\t}\n}", "func (conn *Connection) GetLimitedRecords(q interface{}, n int, doc interface{}, fields ...string) error {\n\tif len(fields) == 0 {\n\t\treturn conn.collection.Find(q).Limit(n).All(doc)\n\t}\n\n\treturn conn.collection.Find(q).Sort(fields...).Limit(n).All(doc)\n}", "func (wq *WifiQuery) Limit(limit int) *WifiQuery {\n\twq.limit = &limit\n\treturn wq\n}", "func Limit(limit int) Option {\n\treturn func(opts *Options) error {\n\t\topts.Limit = limit\n\t\treturn nil\n\t}\n}", "func (q *Query) Limit(limit int) *Query {\n\tif limit < 1 {\n\t\tlogrus.Warn(\"illegal limit: \", limit)\n\t\treturn q\n\t}\n\tq.limit = limit\n\treturn q\n}", "func (nsq *NamespaceSecretQuery) Limit(limit int) *NamespaceSecretQuery {\n\tnsq.limit = &limit\n\treturn nsq\n}", "func (q *queryImpl) Limit(limit uint64) Query {\n\tq.limit = strconv.FormatUint(limit, 10)\n\treturn q\n}", "func (q *BlobQuery) Limit(limit int) *BlobQuery {\n\tq.limit = limit\n\treturn q\n}", "func (query *ReadingQuery) Limit(limit uint64) *ReadingQuery {\n\tquery.Query.Limit(limit)\n\treturn query\n}", "func (mvq *ModuleVersionQuery) Limit(limit int) *ModuleVersionQuery {\n\tmvq.limit = &limit\n\treturn mvq\n}", "func (omq *OutcomeMeasureQuery) Limit(limit int) *OutcomeMeasureQuery {\n\tomq.limit = &limit\n\treturn omq\n}", "func (bcq *BaselineClassQuery) Limit(limit int) *BaselineClassQuery {\n\tbcq.limit = &limit\n\treturn bcq\n}", "func (o ApplicationSpecSyncPolicyRetryOutput) Limit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpecSyncPolicyRetry) *int { return v.Limit }).(pulumi.IntPtrOutput)\n}", "func (osq *OfflineSessionQuery) Limit(limit int) *OfflineSessionQuery {\n\tosq.ctx.Limit = &limit\n\treturn osq\n}", "func (clidq *CheckListItemDefinitionQuery) Limit(limit int) *CheckListItemDefinitionQuery {\n\tclidq.limit = &limit\n\treturn clidq\n}", "func Limit(limit uint64) func() (uint64, error) {\n\treturn func() (uint64, error) {\n\t\treturn limit, nil\n\t}\n}", "func (c *Condition) Limit(l int) *Condition {\n\tc.limit = \"LIMIT \" + strconv.Itoa(l)\n\treturn c\n}", "func (q *Query) Limit(limit int) *Query {\n\tq.limit = limit\n\treturn q\n}", "func (q *Query) Limit(limit int) *Query {\n\tq.limit = limit\n\treturn q\n}", "func (db *DB) Limit(limit int) (tx *DB) {\n\ttx = db.getInstance()\n\ttx.Statement.AddClause(clause.Limit{Limit: limit})\n\treturn\n}", "func (lbq *LatestBlockQuery) Limit(limit int) *LatestBlockQuery {\n\tlbq.limit = &limit\n\treturn lbq\n}", "func (s *TestingSemaphore) SetLimit(n int) {\n\ts.limit = n\n}", "func (wq *WorkflowQuery) Limit(limit int) *WorkflowQuery {\n\twq.limit = &limit\n\treturn wq\n}", "func (fdq *FurnitureDetailQuery) Limit(limit int) *FurnitureDetailQuery {\n\tfdq.limit = &limit\n\treturn fdq\n}", "func (igq *ItemGroupQuery) Limit(limit int) *ItemGroupQuery {\n\tigq.limit = &limit\n\treturn igq\n}", "func (gq *GoodsQuery) Limit(limit int) *GoodsQuery {\n\tgq.limit = &limit\n\treturn gq\n}", "func (statement *Statement) Limit(limit int, start ...int) *Statement {\n\tstatement.LimitN = &limit\n\tif len(start) > 0 {\n\t\tstatement.Start = start[0]\n\t}\n\treturn statement\n}", "func (sw *scanWrap) Limit(limit int64) Scan {\n\treturn &scanWrap{\n\t\tscan: sw.scan.Limit(limit),\n\t}\n}", "func (session *Session) Limit(limit int, start ...int) *Session {\n\tsession.Statement.Limit(limit, start...)\n\treturn session\n}", "func (ksq *KqiSourceQuery) Limit(limit int) *KqiSourceQuery {\n\tksq.limit = &limit\n\treturn ksq\n}", "func (pgq *PlayGroupQuery) Limit(limit int) *PlayGroupQuery {\n\tpgq.limit = &limit\n\treturn pgq\n}", "func (esq *EventSeverityQuery) Limit(limit int) *EventSeverityQuery {\n\tesq.limit = &limit\n\treturn esq\n}", "func (rlq *RuleLimitQuery) Limit(limit int) *RuleLimitQuery {\n\trlq.limit = &limit\n\treturn rlq\n}", "func (w *Wrapper) Limit(from int, count ...int) *Wrapper {\n\tif len(count) == 0 {\n\t\tw.limit = []int{from}\n\t} else {\n\t\tw.limit = []int{from, count[0]}\n\t}\n\treturn w\n}", "func (o ApplicationOperationRetryOutput) Limit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ApplicationOperationRetry) *int { return v.Limit }).(pulumi.IntPtrOutput)\n}", "func (r *ListMessagesRequest) Limit(limit int) *ListMessagesRequest {\n\tr.request.Add(\"limit\", strconv.Itoa(limit))\n\treturn r\n}", "func (evsq *ExValueScanQuery) Limit(limit int) *ExValueScanQuery {\n\tevsq.ctx.Limit = &limit\n\treturn evsq\n}", "func (sq *ServerQuery) Limit(limit int) *ServerQuery {\n\tsq.limit = &limit\n\treturn sq\n}", "func (c *Connection) Limit(limit int) *Query {\n\treturn Q(c).Limit(limit)\n}", "func (query *EventQuery) Limit(limit uint64) *EventQuery {\n\tquery.Query.Limit(limit)\n\treturn query\n}", "func (ulq *UserLogQuery) Limit(limit int) *UserLogQuery {\n\tulq.limit = &limit\n\treturn ulq\n}", "func (wtq *WorkerTypeQuery) Limit(limit int) *WorkerTypeQuery {\n\twtq.limit = &limit\n\treturn wtq\n}", "func (liq *LineItemQuery) Limit(limit int) *LineItemQuery {\n\tliq.limit = &limit\n\treturn liq\n}", "func (r ApiGetPlansRequest) Limit(limit int32) ApiGetPlansRequest {\n\tr.limit = &limit\n\treturn r\n}", "func (ttrq *TradeTimeRangeQuery) Limit(limit int) *TradeTimeRangeQuery {\n\tttrq.limit = &limit\n\treturn ttrq\n}", "func (b *SelectBuilder) Limit(count interface{}) *SelectBuilder {\n\tif b.Select.Limit == nil {\n\t\tb.Select.Limit = &Limit{}\n\t}\n\tb.Select.Limit.Rowcount = makeValExpr(count)\n\treturn b\n}", "func (s SelectStatement) Limit() int {\n\tif s.limit < 1 {\n\t\treturn 0\n\t}\n\treturn s.limit\n}", "func (tdq *TCPDetectorQuery) Limit(limit int) *TCPDetectorQuery {\n\ttdq.ctx.Limit = &limit\n\treturn tdq\n}", "func (o *GetNdmpSettingsVariableParams) SetLimit(limit *int64) {\n\to.Limit = limit\n}", "func (qs SysDBQuerySet) Limit(limit int) SysDBQuerySet {\n\treturn qs.w(qs.db.Limit(limit))\n}", "func (ouq *OrgUnitQuery) Limit(limit int) *OrgUnitQuery {\n\touq.limit = &limit\n\treturn ouq\n}", "func NaiveLimit(qr Results, limit int) Results {\n\tif limit == 0 {\n\t\t// 0 means no limit\n\t\treturn qr\n\t}\n\tclosed := false\n\treturn ResultsFromIterator(qr.Query(), Iterator{\n\t\tNext: func() (Result, bool) {\n\t\t\tif limit == 0 {\n\t\t\t\tif !closed {\n\t\t\t\t\tclosed = true\n\t\t\t\t\terr := qr.Close()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn Result{Error: err}, true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn Result{}, false\n\t\t\t}\n\t\t\tlimit--\n\t\t\treturn qr.NextSync()\n\t\t},\n\t\tClose: func() error {\n\t\t\tif closed {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tclosed = true\n\t\t\treturn qr.Close()\n\t\t},\n\t})\n}", "func (s Select) Limit(limit int) Select {\n\ts.BaseQuery.limit = limit\n\n\treturn s\n}", "func (daq *DrugAllergyQuery) Limit(limit int) *DrugAllergyQuery {\n\tdaq.limit = &limit\n\treturn daq\n}", "func Limit(limit int) DeviceRequestOption {\n\treturn func(opts *deviceRequestOpts) error {\n\t\tif limit > 1000 {\n\t\t\treturn errors.New(\"limit must not be higher than 1000\")\n\t\t}\n\t\topts.Limit = limit\n\t\treturn nil\n\t}\n}", "func (v *vertex) Limit(maxElements int) interfaces.Vertex {\n\treturn v.Add(NewSimpleQB(\".limit(%d)\", maxElements))\n}" ]
[ "0.77530706", "0.7497172", "0.7461868", "0.7406514", "0.73182726", "0.7308236", "0.7283943", "0.7179369", "0.7084239", "0.70444053", "0.6980641", "0.69723237", "0.69614846", "0.69016427", "0.68793577", "0.68770933", "0.68446934", "0.67989546", "0.67393696", "0.6734933", "0.6726482", "0.66321534", "0.66249245", "0.6618912", "0.66105515", "0.6610534", "0.65713507", "0.65619504", "0.655909", "0.65325654", "0.652811", "0.6521591", "0.6521318", "0.65037054", "0.6501988", "0.649889", "0.6489729", "0.64759034", "0.6468012", "0.6451689", "0.64176995", "0.6394397", "0.6394135", "0.6386394", "0.6376206", "0.6373063", "0.6371186", "0.63701266", "0.6364376", "0.6356381", "0.6355293", "0.6353545", "0.634018", "0.63386136", "0.63276196", "0.6317889", "0.6316475", "0.63141346", "0.6281591", "0.6279921", "0.6273225", "0.6265269", "0.6265269", "0.626194", "0.6258876", "0.62581325", "0.62573236", "0.6252589", "0.62453234", "0.6238777", "0.6229764", "0.6228992", "0.6225766", "0.62218696", "0.6221479", "0.6221435", "0.62176", "0.6209206", "0.61952865", "0.61922044", "0.61909527", "0.61815816", "0.6177069", "0.6172831", "0.61719173", "0.6168334", "0.61603916", "0.6157421", "0.61527103", "0.6134239", "0.6133126", "0.61316764", "0.6130101", "0.6128099", "0.61227834", "0.6119784", "0.61115634", "0.6104144", "0.61011267", "0.6100446" ]
0.7169924
8
makeSelectStatment renders statment as below if r.selectFileds has elements: SELECT [,]...
func (op *OpQuery) makeSelectStatment() string { if len(op.selectFileds) == 0 { defaultLogger.Print("[QuerySObjectRequest] Missing Select fields") } return strings.Join(op.selectFileds, ",") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (op *OpQuery) Select(fields ...string) *OpQuery {\n\tif op.selectFileds == nil {\n\t\top.selectFileds = make([]string, 0)\n\t}\n\top.selectFileds = append(op.selectFileds, fields...)\n\treturn op\n}", "func renderSelect() error {\n\tview, err := g.View(ViewSelect)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdbs, err := getDatabases()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tview.Title = fmt.Sprintf(\"Index (0~%d)\", dbs-1)\n\tview.Frame = true\n\tview.Editable = true\n\tview.Write([]byte(strconv.Itoa(client.Options().DB)))\n\treturn nil\n}", "func (rdq *ResultsDefinitionQuery) Select(fields ...string) *ResultsDefinitionSelect {\n\trdq.fields = append(rdq.fields, fields...)\n\tselbuild := &ResultsDefinitionSelect{ResultsDefinitionQuery: rdq}\n\tselbuild.label = resultsdefinition.Label\n\tselbuild.flds, selbuild.scan = &rdq.fields, selbuild.Scan\n\treturn selbuild\n}", "func selectOption(m *TuiModel) {\n\tm.preScrollYOffset = m.viewport.YOffset\n\tm.preScrollYPosition = m.mouseEvent.Y\n\tselectedColumn := m.GetHeaders()[m.GetColumn()]\n\tcol := m.GetSchemaData()[selectedColumn]\n\trow := m.GetRow()\n\tl := len(col)\n\n\tif row < l && l > 0 {\n\t\tm.renderSelection = true\n\n\t\traw := col[row]\n\t\tif conv, ok := raw.(string); ok {\n\t\t\tif format, err := formatJson(conv); err == nil {\n\t\t\t\tm.selectionText = format\n\t\t\t} else {\n\t\t\t\tm.selectionText = TruncateIfApplicable(m, conv)\n\t\t\t}\n\t\t} else {\n\t\t\tm.selectionText = \"\"\n\t\t}\n\t}\n}", "func (dsp *distSQLPlanner) selectRenders(\n\tplanCtx *planningCtx, p *physicalPlan, n *selectNode,\n) error {\n\t// First check if we need an Evaluator, or we are just returning values.\n\tneedEval := false\n\tfor _, e := range n.render {\n\t\tif _, ok := e.(*parser.IndexedVar); !ok {\n\t\t\tneedEval = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif !needEval {\n\t\t// We don't need an evaluator stage. However, we do need to update\n\t\t// p.planToStreamColMap to make the plan correspond to the selectNode\n\t\t// (rather than n.source).\n\t\tplanToStreamColMap := make([]int, len(n.render))\n\t\tfor i := range planToStreamColMap {\n\t\t\tplanToStreamColMap[i] = -1\n\t\t}\n\t\tfor i, e := range n.render {\n\t\t\tidx := e.(*parser.IndexedVar).Idx\n\t\t\tstreamCol := p.planToStreamColMap[idx]\n\t\t\tif streamCol == -1 {\n\t\t\t\tpanic(fmt.Sprintf(\"render %d refers to column %d not in source\", i, idx))\n\t\t\t}\n\t\t\tplanToStreamColMap[i] = streamCol\n\t\t}\n\t\tp.planToStreamColMap = planToStreamColMap\n\t\tp.ordering = dsp.convertOrdering(n.ordering.ordering, planToStreamColMap)\n\t\treturn nil\n\t}\n\t// Add a stage with Evaluator processors.\n\tevalSpec := distsql.EvaluatorSpec{\n\t\tExprs: make([]distsql.Expression, len(n.render)),\n\t}\n\tfor i := range n.render {\n\t\tevalSpec.Exprs[i] = distSQLExpression(n.render[i], p.planToStreamColMap)\n\t}\n\n\tdsp.addNoGroupingStage(p, distsql.ProcessorCoreUnion{Evaluator: &evalSpec})\n\n\t// Update p.planToStreamColMap; we now have a simple 1-to-1 mapping of\n\t// planNode columns to stream columns because the evaluator has been\n\t// programmed to produce the columns in selectNode.render order.\n\tp.planToStreamColMap = p.planToStreamColMap[:0]\n\tfor i := range n.render {\n\t\tp.planToStreamColMap = append(p.planToStreamColMap, i)\n\t}\n\tp.ordering = dsp.convertOrdering(n.ordering.ordering, p.planToStreamColMap)\n\treturn nil\n}", "func visitSelect(stmt ast.SelectStmt) {\n\ttableName := stmt.TableName\n\t// TODO: Handle joins\n\tinsns = append(insns, GetTableOp{tableName})\n\t// Generate insns to add columns we want\n\tif len(stmt.ColNames) == 1 && stmt.ColNames[0] == \"ALL\" {\n\t\t// Handle SELECT * FROM ...\n\t\tinsns = append(insns, AddAllColumnsOp{})\n\t} else {\n\t\tfor _, colName := range stmt.ColNames {\n\t\t\tinsns = append(insns, AddColumnOp{colName})\n\t\t}\n\t}\n\t// Generate insns for conditions in WHERE clause\n\tvisitConditions(stmt.Conditions)\n\n\tinsns = append(insns, DisplayOp{})\n}", "func (w *Wrapper) buildSelect(columns ...string) (query string) {\n\tbeforeOptions, _ := w.buildQueryOptions()\n\n\tif len(columns) == 0 {\n\t\tquery = fmt.Sprintf(\"SELECT %s* FROM %s \", beforeOptions, w.tableName[0])\n\t} else {\n\t\tquery = fmt.Sprintf(\"SELECT %s%s FROM %s \", beforeOptions, strings.Join(columns, \", \"), w.tableName[0])\n\t}\n\treturn\n}", "func Select(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"select\", Attributes: attrs, Children: children}\n}", "func Select_(children ...HTML) HTML {\n return Select(nil, children...)\n}", "func (s *BasePlSqlParserListener) EnterSelect_only_statement(ctx *Select_only_statementContext) {}", "func (m modelLoader) getSelectStatement(db *gorm.DB, alias string) string {\n\tif alias == \"\" {\n\t\talias = m.ms.TableName(db)\n\t}\n\n\tselects := make([]string, 0, len(m.selectFields))\n\tfor _, f := range m.selectFields {\n\t\tselects = append(selects, fmt.Sprintf(\"%s.%s\", alias, f.DBName))\n\t}\n\n\treturn strings.Join(selects, \",\")\n}", "func (tv *TextView) RenderSelect() {\n\tif !tv.HasSelection() {\n\t\treturn\n\t}\n\ttv.RenderRegionBox(tv.SelectReg, TextViewSel)\n}", "func (sd *SelectDataset) Select(selects ...interface{}) *SelectDataset {\n\tif len(selects) == 0 {\n\t\treturn sd.ClearSelect()\n\t}\n\treturn sd.copy(sd.clauses.SetSelect(exp.NewColumnListExpression(selects...)))\n}", "func (ruo *RevisionUpdateOne) Select(field string, fields ...string) *RevisionUpdateOne {\n\truo.fields = append([]string{field}, fields...)\n\treturn ruo\n}", "func SelectData() {\n\tctx := context.Background()\n\n\terr := db.PingContext(ctx)\n\n\tif err != nil {\n\t\tfmt.Printf(\"Unable to Ping db %v\", err)\n\t}\n\n\tvar fileName = \"20079659.pdf\"\n\tlxRows, queryErr := db.QueryContext(ctx, \"SELECT lxPath FROM spacedb.lxFile_eb44cf05 where lxPath='?'\", fileName)\n\tif queryErr != nil {\n\t\tfmt.Printf(\"Error while executing query %v\", queryErr)\n\t\treturn\n\t}\n\tdefer lxRows.Close()\n\tnames := make([]string, 0)\n\n\tfor lxRows.Next() {\n\t\tvar name string\n\t\tif err != lxRows.Scan(&name) {\n\t\t\tlog.Fatal(\"Error while reading row:\", err)\n\t\t\treturn\n\t\t}\n\t\tnames = append(names, name)\n\t}\n\tfmt.Println(names)\n\n}", "func Select(cols ...string) *Builder {\r\n\tbuilder := &Builder{cond: NewCond()}\r\n\treturn builder.Select(cols...)\r\n}", "func Select(top uint64, distinct bool, columns []string, table string, where string, groupby []string, orderby []string, terminate bool) string {\n\n\tif table == \"\" {\n\t\treturn \"\"\n\t}\n\n\tvar stmt bytes.Buffer\n\n\tstmt.WriteString(`SELECT`)\n\n\t// top\n\tif top > 0 {\n\t\tstmt.WriteString(` TOP `)\n\t\tstmt.WriteString(strconv.FormatUint(top, 10))\n\t}\n\n\tif distinct {\n\t\tstmt.WriteString(` DISTINCT`)\n\t}\n\n\t// columns\n\tif len(columns) > 0 {\n\t\tstmt.WriteString(\" \" + strings.Join(columns, `, `))\n\t} else {\n\t\tstmt.WriteString(\" *\")\n\t}\n\n\t// table\n\tstmt.WriteString(` FROM ` + table)\n\n\t// where\n\tif where != \"\" {\n\t\tstmt.WriteString(` WHERE ` + where)\n\t}\n\n\t// Group by\n\tif len(groupby) > 0 {\n\t\tstmt.WriteString(\" GROUP BY \" + strings.Join(groupby, \", \") )\n\t}\n\n\t// order by\n\tif len(orderby) > 0 {\n\t\tstmt.WriteString(\" ORDER BY \" + strings.Join(orderby, \", \") )\n\t}\n\n\t// terminate statement\n\tif terminate {\n\t\tstmt.WriteString(\";\")\n\t}\n\n\treturn stmt.String()\n}", "func (gauo *GithubAssetUpdateOne) Select(field string, fields ...string) *GithubAssetUpdateOne {\n\tgauo.fields = append([]string{field}, fields...)\n\treturn gauo\n}", "func (srmuo *SysRoleMenuUpdateOne) Select(field string, fields ...string) *SysRoleMenuUpdateOne {\n\tsrmuo.fields = append([]string{field}, fields...)\n\treturn srmuo\n}", "func (tuo *TagUpdateOne) Select(field string, fields ...string) *TagUpdateOne {\n\ttuo.fields = append([]string{field}, fields...)\n\treturn tuo\n}", "func (suo *StateUpdateOne) Select(field string, fields ...string) *StateUpdateOne {\n\tsuo.fields = append([]string{field}, fields...)\n\treturn suo\n}", "func (b *Builder) Select(cols ...string) *Builder {\r\n\tb.selects = cols\r\n\tb.optype = selectType\r\n\treturn b\r\n}", "func selectHandler(w http.ResponseWriter, r *http.Request) {\n\n\tdata := page{Title: \"School Database\", Header: \"What type would you like to create?\"}\n\ttemplateInit(w, \"select.html\", data)\n\n}", "func (gsuo *GameServerUpdateOne) Select(field string, fields ...string) *GameServerUpdateOne {\n\tgsuo.fields = append([]string{field}, fields...)\n\treturn gsuo\n}", "func displaySelection(m *TuiModel) string {\n\tselectedColumn := m.GetHeaders()[m.GetColumn()]\n\tcol := m.GetSchemaData()[selectedColumn]\n\tm.expandColumn = m.GetColumn()\n\trow := m.GetRow()\n\tif m.mouseEvent.Y >= m.viewport.Height + headerHeight && !m.renderSelection { // this is for when the selection is outside the bounds\n\t\treturn displayTable(m)\n\t}\n\n\tbase := m.GetBaseStyle()\n\n\tif m.selectionText != \"\" {\n\t\trows := SplitLines(m.selectionText)\n\t\treturn base.Render(lipgloss.JoinVertical(lipgloss.Left, rows...))\n\t}\n\n\tvar prettyPrint string\n\traw := col[row]\n\n\tprettyPrint = base.Render(func() string {\n\t\tswitch v := raw.(type) {\n\t\tcase int64:\n\t\t\treturn strconv.Itoa(int(v))\n\t\tcase float64:\n\t\t\treturn fmt.Sprintf(\"%.2f\", v)\n\t\tcase time.Time:\n\t\t\treturn TruncateIfApplicable(m, v.String())\n\t\tcase nil:\n\t\t\treturn \"NULL\"\n\t\tdefault:\n\t\t\treturn \"\"\n\t\t}\n\t}())\n\tif len(prettyPrint) > maximumRendererCharacters {\n\t\tfileName, err := WriteText(m, prettyPrint)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"ERROR: could not write file %s\", fileName)\n\t\t}\n\t\treturn fmt.Sprintf(\"Selected string exceeds maximum limit of %d characters. \\n\"+\n\t\t\t\"The file was written to your current working \"+\n\t\t\t\"directory for your convenience with the filename \\n%s.\", maximumRendererCharacters, fileName)\n\t}\n\n\treturn prettyPrint\n}", "func (r *Render) selectFiles(withRE, withoutRE *regexp.Regexp) []*File {\n\tselected := []*File{}\n\tfor _, f := range r.files {\n\t\tif withRE == nil && withoutRE == nil {\n\t\t\tselected = append(selected, f)\n\t\t\tcontinue\n\t\t}\n\n\t\tname := f.Name()\n\t\tif withRE != nil && !withRE.MatchString(name) {\n\t\t\tr.logger.Debugf(\"Skipping file '%s' by not matching with clause ('%s')\",\n\t\t\t\tname, withRE.String())\n\t\t\tcontinue\n\t\t} else if withoutRE != nil && withoutRE.MatchString(name) {\n\t\t\tr.logger.Debugf(\"Skipping file '%s' by matching without clause ('%s')\",\n\t\t\t\tname, withoutRE.String())\n\t\t\tcontinue\n\t\t}\n\t\tselected = append(selected, f)\n\t}\n\treturn selected\n}", "func Select(fields ...string) *Query {\n\tquery := newQuery()\n\tquery.action = action_select\n\n\treturn query.Select(fields...)\n}", "func (sb *SQLBuilder) Select(cols ...string) *SQLBuilder {\n\tvar buf strings.Builder\n\n\tfor k, col := range cols {\n\n\t\tbuf.WriteString(col)\n\n\t\tif k != len(cols)-1 {\n\t\t\tbuf.WriteString(\",\")\n\t\t}\n\t}\n\n\tsb._select = buf.String()\n\n\treturn sb\n}", "func (q *Query) selectClause() (columns []string, parser func(*spanner.Row) (*pb.TestResult, error)) {\n\tcolumns = []string{\n\t\t\"InvocationId\",\n\t\t\"TestId\",\n\t\t\"ResultId\",\n\t\t\"IsUnexpected\",\n\t\t\"Status\",\n\t\t\"StartTime\",\n\t\t\"RunDurationUsec\",\n\t}\n\n\t// Select extra columns depending on the mask.\n\tvar extraColumns []string\n\treadMask := q.Mask\n\tif readMask.IsEmpty() {\n\t\treadMask = defaultListMask\n\t}\n\tselectIfIncluded := func(column, field string) {\n\t\tswitch inc, err := readMask.Includes(field); {\n\t\tcase err != nil:\n\t\t\tpanic(err)\n\t\tcase inc != mask.Exclude:\n\t\t\textraColumns = append(extraColumns, column)\n\t\t\tcolumns = append(columns, column)\n\t\t}\n\t}\n\tselectIfIncluded(\"SummaryHtml\", \"summary_html\")\n\tselectIfIncluded(\"Tags\", \"tags\")\n\tselectIfIncluded(\"TestMetadata\", \"test_metadata\")\n\tselectIfIncluded(\"Variant\", \"variant\")\n\tselectIfIncluded(\"VariantHash\", \"variant_hash\")\n\tselectIfIncluded(\"FailureReason\", \"failure_reason\")\n\tselectIfIncluded(\"Properties\", \"properties\")\n\n\t// Build a parser function.\n\tvar b spanutil.Buffer\n\tvar summaryHTML spanutil.Compressed\n\tvar tmd spanutil.Compressed\n\tvar fr spanutil.Compressed\n\tvar properties spanutil.Compressed\n\tparser = func(row *spanner.Row) (*pb.TestResult, error) {\n\t\tvar invID invocations.ID\n\t\tvar maybeUnexpected spanner.NullBool\n\t\tvar micros spanner.NullInt64\n\t\ttr := &pb.TestResult{}\n\n\t\tptrs := []any{\n\t\t\t&invID,\n\t\t\t&tr.TestId,\n\t\t\t&tr.ResultId,\n\t\t\t&maybeUnexpected,\n\t\t\t&tr.Status,\n\t\t\t&tr.StartTime,\n\t\t\t&micros,\n\t\t}\n\n\t\tfor _, v := range extraColumns {\n\t\t\tswitch v {\n\t\t\tcase \"SummaryHtml\":\n\t\t\t\tptrs = append(ptrs, &summaryHTML)\n\t\t\tcase \"Tags\":\n\t\t\t\tptrs = append(ptrs, &tr.Tags)\n\t\t\tcase \"TestMetadata\":\n\t\t\t\tptrs = append(ptrs, &tmd)\n\t\t\tcase \"Variant\":\n\t\t\t\tptrs = append(ptrs, &tr.Variant)\n\t\t\tcase \"VariantHash\":\n\t\t\t\tptrs = append(ptrs, &tr.VariantHash)\n\t\t\tcase \"FailureReason\":\n\t\t\t\tptrs = append(ptrs, &fr)\n\t\t\tcase \"Properties\":\n\t\t\t\tptrs = append(ptrs, &properties)\n\t\t\tdefault:\n\t\t\t\tpanic(\"impossible\")\n\t\t\t}\n\t\t}\n\n\t\terr := b.FromSpanner(row, ptrs...)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Generate test result name now in case tr.TestId and tr.ResultId become\n\t\t// empty after q.Mask.Trim(tr).\n\t\ttrName := pbutil.TestResultName(string(invID), tr.TestId, tr.ResultId)\n\t\ttr.SummaryHtml = string(summaryHTML)\n\t\tPopulateExpectedField(tr, maybeUnexpected)\n\t\tPopulateDurationField(tr, micros)\n\t\tif err := populateTestMetadata(tr, tmd); err != nil {\n\t\t\treturn nil, errors.Annotate(err, \"error unmarshalling test_metadata for %s\", trName).Err()\n\t\t}\n\t\tif err := populateFailureReason(tr, fr); err != nil {\n\t\t\treturn nil, errors.Annotate(err, \"error unmarshalling failure_reason for %s\", trName).Err()\n\t\t}\n\t\tif err := populateProperties(tr, properties); err != nil {\n\t\t\treturn nil, errors.Annotate(err, \"failed to unmarshal properties\").Err()\n\t\t}\n\t\tif err := q.Mask.Trim(tr); err != nil {\n\t\t\treturn nil, errors.Annotate(err, \"error trimming fields for %s\", trName).Err()\n\t\t}\n\t\t// Always include name in tr because name is needed to calculate\n\t\t// page token.\n\t\ttr.Name = trName\n\t\treturn tr, nil\n\t}\n\treturn\n}", "func (p *Parser) ParseSelect(sel string) (ast *SelectTree, err error) {\n\tast = &SelectTree{}\n\ts := p.s\n\ts.Init(strings.NewReader(sel))\n\ts.Mode = scanner.ScanIdents | scanner.ScanFloats | scanner.ScanChars | scanner.ScanStrings | scanner.ScanRawStrings\n\n\tif tok := s.Scan(); tok == scanner.EOF || strings.ToUpper(s.TokenText()) != SELECT {\n\t\terr = fmt.Errorf(\"%s is not SELECT statement\", sel)\n\t\treturn\n\t}\n\n\tast.Projects = make([]string, 0, 4)\n\tfor {\n\t\tif tok := s.Scan(); tok == scanner.EOF {\n\t\t\tif len(ast.Projects) == 0 {\n\t\t\t\terr = fmt.Errorf(\"%s get select projects failed\", sel)\n\t\t\t}\n\t\t\treturn\n\t\t} else {\n\t\t\ttxt := s.TokenText()\n\t\t\t//log.Print(txt)\n\t\t\tif txt == ASTERISK {\n\t\t\t\tast.Projects = append(ast.Projects, ASTERISK)\n\t\t\t} else {\n\t\t\t\tif txt == \",\" {\n\t\t\t\t\tcontinue\n\t\t\t\t} else if strings.ToUpper(txt) == FROM {\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\tast.Projects = append(ast.Projects, txt)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// token FROM is scanned, try to get the table name here\n\t// FROM ?\n\tif tok := s.Scan(); tok == scanner.EOF {\n\t\t// if projects are all constant value, source table is not necessary.\n\t\t// eg. SELECT 1;\n\t\treturn\n\t} else {\n\t\tast.Table = s.TokenText()\n\t}\n\n\t// WHERE\n\tif tok := s.Scan(); tok == scanner.EOF {\n\t\t// WHERE is not necessary\n\t\treturn\n\t}\n\n\ttxt := s.TokenText()\n\tif strings.ToUpper(txt) == WHERE {\n\t\t// token WHERE is scanned, try to get the WHERE clause.\n\t\tast.Where = make([]string, 0, 4)\n\t\tfor {\n\t\t\tif tok := s.Scan(); tok == scanner.EOF {\n\t\t\t\tif len(ast.Where) == 0 {\n\t\t\t\t\terr = fmt.Errorf(\"missing WHERE clause\")\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttxt := s.TokenText()\n\t\t\tif strings.ToUpper(txt) == LIMIT {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tast.Where = append(ast.Where, txt)\n\t\t}\n\t} else if strings.ToUpper(txt) != LIMIT {\n\t\terr = fmt.Errorf(\"expect WHERE or LIMIT here\")\n\t\treturn\n\t}\n\n\t// token LIMIT is scanned, try to get the limit\n\tif tok := s.Scan(); tok == scanner.EOF {\n\t\terr = fmt.Errorf(\"expect LIMIT clause here\")\n\t\treturn\n\t}\n\ttxt = s.TokenText()\n\tast.Limit, err = strconv.ParseInt(txt, 10, 64)\n\treturn\n}", "func Select(trans sqtables.Transaction, tkns *tokens.TokenList) (string, *sqtables.DataSet, error) {\n\n\tq, err := SelectParse(trans.Profile(), tkns)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tdata, err := SelectExecute(trans.Profile(), q)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn fmt.Sprintf(\"%d rows found\", data.Len()), data, err\n}", "func (s *BasePlSqlParserListener) ExitSelect_only_statement(ctx *Select_only_statementContext) {}", "func (tuo *TeamUpdateOne) Select(field string, fields ...string) *TeamUpdateOne {\n\ttuo.fields = append([]string{field}, fields...)\n\treturn tuo\n}", "func (r ApiGetHyperflexDatastoreStatisticListRequest) Select_(select_ string) ApiGetHyperflexDatastoreStatisticListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func Select(columns ...string) QueryOption {\n\treturn newFuncQueryOption(func(wrapper *QueryWrapper) {\n\t\twrapper.columns = columns\n\t\twrapper.queryLen += 2\n\t})\n}", "func (b *SqliteBuilder) Select(cols ...string) *SelectQuery {\n\treturn NewSelectQuery(b, b.db).Select(cols...)\n}", "func (r ApiGetBulkResultListRequest) Select_(select_ string) ApiGetBulkResultListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (duo *DocUpdateOne) Select(field string, fields ...string) *DocUpdateOne {\n\tduo.fields = append([]string{field}, fields...)\n\treturn duo\n}", "func Select(columns ...string) QueryMod {\n\treturn func(q *queries.Query) {\n\t\tqueries.AppendSelect(q, columns...)\n\t}\n}", "func (dbi *DB) SelectRow(sqls string, arg ...string) (map[string]string, error) {\r\n\tif dbi.status == false {\r\n\t\treturn nil, errors.New(\"database was not opened.\")\r\n\t}\r\n\r\n\t// start select\r\n\tdbi.createOperation(\"DB_SELECT\")\r\n\tdbi.data.reqSql = sqls\r\n\tdbi.data.inVar = arg\r\n\t// data\r\n\tdbi.data.commPrepare()\r\n\t// communicate\r\n\tif dbi.data.comm() == false {\r\n\t\tmylog.Println(dbi.data.sqlCode, \":\", dbi.data.sqlErrm)\r\n\t\tdbi.Close()\r\n\t\treturn nil, errors.New(dbi.Sqlerrm)\r\n\t}\r\n\t// parse\r\n\tdbi.data.commParse()\r\n\tdbi.parseError()\r\n\tif dbi.Sqlcode != 0 {\r\n\t\treturn nil, errors.New(dbi.Sqlerrm)\r\n\t}\r\n\r\n\t// get column name list\r\n\tdbi.createOperation(\"DB_COLUMNS\")\r\n\t// data\r\n\tdbi.data.curId = -1\r\n\tdbi.data.commPrepare()\r\n\t// communicate\r\n\tif dbi.data.comm() == false {\r\n\t\tdbi.Close()\r\n\t\treturn nil, errors.New(dbi.Sqlerrm)\r\n\t}\r\n\t// parse\r\n\tdbi.data.commParse()\r\n\t// no need to change dbi.sqlcode\r\n\r\n\tcolvar := make(map[string]string)\r\n\tfor i := 0; i < len(dbi.data.colName); i++ {\r\n\t\tcolvar[strings.ToLower(dbi.data.colName[i])] = dbi.data.outVar[i]\r\n\t}\r\n\treturn colvar, nil\r\n}", "func (u *__FileStorage_Selector) _toSql() (string, []interface{}) {\n\n\tsqlWheres, whereArgs := whereClusesToSql(u.wheres, \"\")\n\tselectCols := \"*\"\n\tif len(u.selectCol) > 0 {\n\t\tselectCols = strings.Join(u.selectCol, \", \")\n\t}\n\tsqlstr := \"SELECT \" + selectCols + \" FROM sunc_file.file_storage\"\n\n\tif len(strings.Trim(sqlWheres, \" \")) > 0 { //2 for safty\n\t\tsqlstr += \" WHERE \" + sqlWheres\n\t}\n\n\tif len(u.orderBy) > 0 {\n\t\torders := strings.Join(u.orderBy, \", \")\n\t\tsqlstr += \" ORDER BY \" + orders\n\t}\n\n\tif u.limit != 0 {\n\t\tsqlstr += \" LIMIT \" + strconv.Itoa(u.limit)\n\t}\n\tif u.allowFilter {\n\t\tsqlstr += \" ALLOW FILTERING\"\n\t}\n\n\treturn sqlstr, whereArgs\n}", "func (t *PgAttributeType) Select(f ...qb.Field) *qb.SelectBuilder {\n\treturn t.table.Select(f)\n}", "func TestSimpleSelect(t *testing.T) {\n\tqc := start_ds()\n\tqccs := start_cs()\n\n\tr, _, err := Run(qc, \"select 1 + 1\", Namespace_FS)\n\tif err != nil || len(r) == 0 {\n\t\tt.Errorf(\"did not expect err %s\", err.Error())\n\t}\n\n\trcs, _, errcs := Run(qccs, \"select * from system:keyspaces\", Namespace_CBS)\n\tif errcs != nil || len(rcs) == 0 {\n\t\tt.Errorf(\"did not expect err %s\", errcs.Error())\n\t}\n\n\tr, _, err = Run(qc, \"select * from customer\", Namespace_FS)\n\tif err != nil || len(r) == 0 {\n\t\tt.Errorf(\"did not expect err %s\", err.Error())\n\t}\n\n\tfileInfos, _ := ioutil.ReadDir(\"../../data/sampledb/dimestore/customer\")\n\tif len(r) != len(fileInfos) {\n\t\tfmt.Printf(\"num results : %#v, fileInfos: %#v\\n\", len(r), len(fileInfos))\n\t\tt.Errorf(\"expected # of results to match directory listing\")\n\t}\n\n}", "func (me *NamedExecHelper) SelectQuery(condition *ConditionBuilder, fields ...string) string {\r\n\tvar (\r\n\t\tsField = \"*\"\r\n\t\tsCondition string\r\n\t)\r\n\tif len(fields) > 0 {\r\n\t\t//use provided fields\r\n\t\tsField = strings.Join(fields, \",\")\r\n\t}\r\n\tif condition != nil {\r\n\t\tsCondition = condition.UnnamedConditionString()\r\n\t}\r\n\r\n\treturn fmt.Sprintf(\"SELECT %s FROM %s %s;\", sField, me.tablename, sCondition)\r\n}", "func (s *Delete) render() (stmt string, args []interface{}, err error) {\n\tselectStmt := \"DELETE FROM \" + s.builder.quoteColumns(s.from)\n\tconditionStmt, err := s.condition.render(s.builder.driver.Placeholder())\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tif conditionStmt != \"\" {\n\t\tconditionStmt = \" \" + conditionStmt\n\t}\n\n\treturn selectStmt + conditionStmt, s.condition.arguments(), err\n}", "func (s *Session) Select(columns ...string) *Session {\n\ts.initStatemnt()\n\ts.statement.Select(columns...)\n\treturn s\n}", "func (b *QueryBuilder) Select(nodes ...NodeI) {\n\tif b.GroupBys != nil {\n\t\tpanic(\"You cannot have Select and GroupBy statements in the same query. The GroupBy columns will automatically be selected.\")\n\t}\n\tfor _, n := range nodes {\n\t\tif NodeGetType(n) != ColumnNodeType {\n\t\t\tpanic(\"you can only select column nodes\")\n\t\t}\n\t}\n\tb.Selects = append(b.Selects, nodes...)\n}", "func (druo *DeviceRequestUpdateOne) Select(field string, fields ...string) *DeviceRequestUpdateOne {\n\tdruo.fields = append([]string{field}, fields...)\n\treturn druo\n}", "func (r ApiGetHyperflexServerFirmwareVersionListRequest) Select_(select_ string) ApiGetHyperflexServerFirmwareVersionListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (s *RowStore) simpleSelect(req *kvrpcpb.KvSelectRequest) (*kvrpcpb.KvSelectResponse, error) {\n\tresp := new(kvrpcpb.KvSelectResponse)\n\n\tlimit := req.GetLimit()\n\tif limit == nil {\n\t\tlimit = &kvrpcpb.Limit{Offset: 0, Count: DefaultMaxKvCountLimit}\n\t} else {\n\t\tif limit.Count > DefaultMaxKvCountLimit {\n\t\t\tlimit.Count = DefaultMaxKvCountLimit\n\t\t}\n\t}\n\n\tfetcher := newSelectRowFetcher(s, req)\n\tdefer fetcher.Close()\n\tvar all, count uint64\n\tfor fetcher.Next() {\n\t\tif limit.Offset > all {\n\t\t\tall++\n\t\t\tcontinue\n\t\t}\n\t\tall++\n\t\tcount++\n\t\trow := buildSimpleRow(fetcher.Key(), fetcher.Fields(), req.FieldList)\n\t\tresp.Rows = append(resp.Rows, row)\n\t\tif log.GetFileLogger().IsEnableDebug() {\n\t\t\tlog.Debug(\"[range %d] select add row: %v-%v\", s.id, fetcher.Key(), row.Fields)\n\t\t}\n\t\tif count >= limit.Count {\n\t\t\tbreak\n\t\t}\n\t}\n\tif fetcher.Error() != nil {\n\t\treturn nil, fetcher.Error()\n\t}\n\tif len(resp.Rows) > 0 && log.GetFileLogger().IsEnableDebug() {\n\t\tlog.Debug(\"[range %d] select offset %d rows: %d\", s.id, all, len(resp.Rows))\n\t}\n\tresp.Offset = all\n\tresp.Code = errcode.SUCCESS\n\treturn resp, nil\n}", "func (r ApiGetHyperflexVmSnapshotInfoListRequest) Select_(select_ string) ApiGetHyperflexVmSnapshotInfoListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (tuo *TransactionUpdateOne) Select(field string, fields ...string) *TransactionUpdateOne {\n\ttuo.fields = append([]string{field}, fields...)\n\treturn tuo\n}", "func (oupuo *OrgUnitPositionUpdateOne) Select(field string, fields ...string) *OrgUnitPositionUpdateOne {\n\toupuo.fields = append([]string{field}, fields...)\n\treturn oupuo\n}", "func Select(fields ...interface{}) QueryOptions {\n\treturn func(query *Query) (*Query, error) {\n\t\tif len(fields) == 0 {\n\t\t\treturn query, nil\n\t\t}\n\t\tvar fieldPaths []interface{}\n\t\tfor _, field := range fields {\n\t\t\tif _, ok := field.(string); !ok {\n\t\t\t\treturn nil, errors.New(\"field path type can be only string\")\n\t\t\t}\n\t\t\tfieldPaths = append(fieldPaths, field)\n\t\t}\n\t\tresMap, err := mergeQueryMaps(query.content,\n\t\t\tmap[string]interface{}{operations[SELECT]: fieldPaths})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tquery.content = resMap.(map[string]interface{})\n\t\treturn query, nil\n\t}\n}", "func (mySQL) BuildSelect(columns ...string) string {\n\treturn buildSelect(columns...)\n}", "func (r ApiGetBulkExportedItemListRequest) Select_(select_ string) ApiGetBulkExportedItemListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (r ApiGetHyperflexVolumeListRequest) Select_(select_ string) ApiGetHyperflexVolumeListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (r ApiGetBulkExportListRequest) Select_(select_ string) ApiGetBulkExportListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (p *parser) VisitSelect(ctx *gen.SelectContext) any {\n\toperand := p.Visit(ctx.Member()).(*exprpb.Expr)\n\t// Handle the error case where no valid identifier is specified.\n\tif ctx.GetId() == nil || ctx.GetOp() == nil {\n\t\treturn p.helper.newExpr(ctx)\n\t}\n\tid := ctx.GetId().GetText()\n\tif ctx.GetOpt() != nil {\n\t\tif !p.enableOptionalSyntax {\n\t\t\treturn p.reportError(ctx.GetOp(), \"unsupported syntax '.?'\")\n\t\t}\n\t\treturn p.helper.newGlobalCall(\n\t\t\tctx.GetOp(),\n\t\t\toperators.OptSelect,\n\t\t\toperand,\n\t\t\tp.helper.newLiteralString(ctx.GetId(), id))\n\t}\n\treturn p.helper.newSelect(ctx.GetOp(), operand, id)\n}", "func (suo *SkillUpdateOne) Select(field string, fields ...string) *SkillUpdateOne {\n\tsuo.fields = append([]string{field}, fields...)\n\treturn suo\n}", "func (vuuo *VacUserUpdateOne) Select(field string, fields ...string) *VacUserUpdateOne {\n\tvuuo.fields = append([]string{field}, fields...)\n\treturn vuuo\n}", "func Select(scope *Scope, condition tf.Output, x tf.Output, y tf.Output) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Select\",\n\t\tInput: []tf.Input{\n\t\t\tcondition, x, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (t TagAppTable) SelectCols() string {\n\treturn `tag_app_id,name,weight,archived_at`\n}", "func (e *SqlExecutor) Select(i interface{}, query string, args ...interface{}) ([]interface{}, error) {\n\thook := e.db.ExecutorHook()\n\thook.BeforeSelect(e.ctx, query, args...)\n\tv, err := e.SqlExecutor.Select(i, query, args...)\n\thook.AfterSelect(e.ctx, query, args...)\n\treturn v, err\n}", "func parseSelectStatement(tokens []*token, initialCursor uint, delimiter token) (*SelectStatement, uint, bool) {\n\tcursor := initialCursor\n\tif !expectToken(tokens, cursor, tokenFromKeyword(selectKeyword)) {\n\t\treturn nil, initialCursor, false\n\t}\n\tcursor++\n\n\tslct := SelectStatement{}\n\n\titem, newCursor, ok := parseSelectItem(tokens, cursor, []token{tokenFromKeyword(fromKeyword), delimiter})\n\tif !ok {\n\t\treturn nil, initialCursor, false\n\t}\n\n\tslct.item = item\n\tcursor = newCursor\n\n\tif expectToken(tokens, cursor, tokenFromKeyword(fromKeyword)) {\n\t\tcursor++\n\n\t\tfrom, newCursor, ok := parseFromItem(tokens, cursor, delimiter)\n\t\tif !ok {\n\t\t\thelpMessage(tokens, cursor, \"Expected FROM item\")\n\t\t\treturn nil, initialCursor, false\n\t\t}\n\n\t\tslct.from = from\n\t\tcursor = newCursor\n\t}\n\n\treturn &slct, cursor, true\n}", "func TestFieldOutputSelect(t *testing.T) {\n\tfield := NewField()\n\tfield.Name = \"foo\"\n\tfield.Type = \"select\"\n\tfield.Values = []string{\"test\"}\n\n\ttag := field.output()\n\n\tassert.Equal(t, \"<select name=\\\"foo\\\" id=\\\"foo\\\"><option value=\\\"test\\\">test</option></select>\", tag)\n}", "func Select(columns ...string) *SelectBuilder {\n\treturn NewSelectBuilder(columns...)\n}", "func (pb *primitiveBuilder) processSelect(sel *sqlparser.Select, reservedVars *sqlparser.ReservedVars, outer *symtab, query string) error {\n\t// Check and error if there is any locking function present in select expression.\n\tfor _, expr := range sel.SelectExprs {\n\t\tif aExpr, ok := expr.(*sqlparser.AliasedExpr); ok && sqlparser.IsLockingFunc(aExpr.Expr) {\n\t\t\treturn vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, \"%v allowed only with dual\", sqlparser.String(aExpr))\n\t\t}\n\t}\n\tif sel.SQLCalcFoundRows {\n\t\tif outer != nil || query == \"\" {\n\t\t\treturn errSQLCalcFoundRows\n\t\t}\n\t\tsel.SQLCalcFoundRows = false\n\t\tif sel.Limit != nil {\n\t\t\tplan, err := buildSQLCalcFoundRowsPlan(query, sel, reservedVars, pb.vschema, planSelectV3)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tpb.plan = plan\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// Into is not supported in subquery.\n\tif sel.Into != nil && (outer != nil || query == \"\") {\n\t\treturn errInto\n\t}\n\n\tvar where sqlparser.Expr\n\tif sel.Where != nil {\n\t\twhere = sel.Where.Expr\n\t}\n\tif err := pb.processTableExprs(sel.From, reservedVars, where); err != nil {\n\t\treturn err\n\t}\n\n\tif rb, ok := pb.plan.(*route); ok {\n\t\t// TODO(sougou): this can probably be improved.\n\t\tdirectives := sel.Comments.Directives()\n\t\trb.eroute.QueryTimeout = queryTimeout(directives)\n\t\tif rb.eroute.TargetDestination != nil {\n\t\t\treturn errors.New(\"unsupported: SELECT with a target destination\")\n\t\t}\n\t\tif directives.IsSet(sqlparser.DirectiveScatterErrorsAsWarnings) {\n\t\t\trb.eroute.ScatterErrorsAsWarnings = true\n\t\t}\n\t}\n\n\t// Set the outer symtab after processing of FROM clause.\n\t// This is because correlation is not allowed there.\n\tpb.st.Outer = outer\n\tif sel.Where != nil {\n\t\tif err := pb.pushFilter(sel.Where.Expr, sqlparser.WhereStr, reservedVars); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := pb.checkAggregates(sel); err != nil {\n\t\treturn err\n\t}\n\tif err := pb.pushSelectExprs(sel, reservedVars); err != nil {\n\t\treturn err\n\t}\n\tif sel.Having != nil {\n\t\tif err := pb.pushFilter(sel.Having.Expr, sqlparser.HavingStr, reservedVars); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := pb.pushOrderBy(sel.OrderBy); err != nil {\n\t\treturn err\n\t}\n\tif err := pb.pushLimit(sel.Limit); err != nil {\n\t\treturn err\n\t}\n\n\treturn setMiscFunc(pb.plan, sel)\n}", "func processSelect(sel *sqlparser.Select, vschema VSchema, outer builder) (builder, error) {\n\tbldr, err := processTableExprs(sel.From, vschema)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif outer != nil {\n\t\tbldr.Symtab().Outer = outer.Symtab()\n\t}\n\tif sel.Where != nil {\n\t\terr = pushFilter(sel.Where.Expr, bldr, sqlparser.WhereStr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tbldr, err = checkAggregates(sel, bldr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbldr, err = pushSelectExprs(sel, bldr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif sel.Having != nil {\n\t\terr = pushFilter(sel.Having.Expr, bldr, sqlparser.HavingStr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\terr = pushOrderBy(sel.OrderBy, bldr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbldr, err = pushLimit(sel.Limit, bldr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbldr.PushMisc(sel)\n\treturn bldr, nil\n}", "func (node *Select) Format(buf *TrackedBuffer) {\n\tvar options string\n\taddIf := func(b bool, s string) {\n\t\tif b {\n\t\t\toptions += s\n\t\t}\n\t}\n\taddIf(node.Distinct, DistinctStr)\n\tif node.Cache != nil {\n\t\tif *node.Cache {\n\t\t\toptions += SQLCacheStr\n\t\t} else {\n\t\t\toptions += SQLNoCacheStr\n\t\t}\n\t}\n\taddIf(node.StraightJoinHint, StraightJoinHint)\n\taddIf(node.SQLCalcFoundRows, SQLCalcFoundRowsStr)\n\n\tbuf.astPrintf(node, \"select %v%s%v from %v%v%v%v%v%v%s\",\n\t\tnode.Comments, options, node.SelectExprs,\n\t\tnode.From, node.Where,\n\t\tnode.GroupBy, node.Having, node.OrderBy,\n\t\tnode.Limit, node.Lock.ToString())\n\tif node.IntoOutfileS3 != \"\" {\n\t\tbuf.astPrintf(node, \" into outfile s3 '%s'\", node.IntoOutfileS3)\n\t}\n}", "func (s *StatIOIndex) Selects() []string {\n\treturn []string{\n\t\t\"pg_statio_user_indexes.relid\",\n\t\t\"pg_statio_user_indexes.indexrelid\",\n\t\t\"pg_statio_user_indexes.schemaname\",\n\t\t\"pg_statio_user_indexes.relname\",\n\t\t\"pg_statio_user_indexes.indexrelname\",\n\t\t\"pg_statio_user_indexes.idx_blks_read\",\n\t\t\"pg_statio_user_indexes.idx_blks_hit\",\n\t}\n}", "func NewSelect(subresult Subresult, order *Order, offset, limit expression.Expression) *Select {\n\trv := &Select{\n\t\tsubresult: subresult,\n\t\torder: order,\n\t\toffset: offset,\n\t\tlimit: limit,\n\t}\n\n\trv.stmt = rv\n\treturn rv\n}", "func (fv *FileView) FileSelectAction(idx int) {\n\tif idx < 0 {\n\t\treturn\n\t}\n\tfv.SaveSortPrefs()\n\tfi := fv.Files[idx]\n\tfv.SelectedIdx = idx\n\tfv.SelFile = fi.Name\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\tfv.WidgetSig.Emit(fv.This, int64(gi.WidgetSelected), fv.SelectedFile())\n}", "func buildSelectPlan(sel *sqlparser.Select, vschema VSchema) (primitive engine.Primitive, err error) {\n\tbindvars := sqlparser.GetBindvars(sel)\n\tbuilder, err := processSelect(sel, vschema, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tjt := newJointab(bindvars)\n\terr = builder.Wireup(builder, jt)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn builder.Primitive(), nil\n}", "func selectFileGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Load()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOne {\n\tguo.fields = append([]string{field}, fields...)\n\treturn guo\n}", "func (this *MsSql) GenSelect(da *entity.DbData) string {\n\tif da == nil {\n\t\treturn ``\n\t}\n\n\ts := make([]string, 0)\n\ts = append(s, \"SELECT \")\n\tfields := strings.Split(da.Fields, \",\")\n\tfor _, field := range fields {\n\t\ts = append(s, entity.DbMapLeft[da.DbType])\n\t\ts = append(s, field)\n\t\ts = append(s, entity.DbMapRight[da.DbType])\n\t\ts = append(s, \",\")\n\t}\n\n\ts = s[0 : len(s)-1]\n\ts = append(s, \" FROM \")\n\ts = append(s, entity.DbMapLeft[da.DbType])\n\ts = append(s, da.Table)\n\ts = append(s, entity.DbMapRight[da.DbType])\n\n\ts = append(s, \" WHERE \")\n\tif da.Where == nil {\n\t\ts = append(s, \"1=1\")\n\t} else {\n\t\ts = append(s, da.GenWhere())\n\t}\n\n\tif da.OrderBy != nil {\n\t\ts = append(s, \" ORDER BY \")\n\t\ts = append(s, da.GenOrderBy())\n\t}\n\n\treturn strings.Join(s, \"\")\n}", "func (r ApiGetHyperflexSoftwareDistributionVersionListRequest) Select_(select_ string) ApiGetHyperflexSoftwareDistributionVersionListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (luuo *LastUpdatedUpdateOne) Select(field string, fields ...string) *LastUpdatedUpdateOne {\n\tluuo.fields = append([]string{field}, fields...)\n\treturn luuo\n}", "func (s *BasePlSqlParserListener) EnterSelect_statement(ctx *Select_statementContext) {}", "func (duo *DealUpdateOne) Select(field string, fields ...string) *DealUpdateOne {\n\tduo.fields = append([]string{field}, fields...)\n\treturn duo\n}", "func (r *BaseRequest) Select(value string) {\n\tif r.query == nil {\n\t\tr.query = url.Values{}\n\t}\n\tr.query.Add(\"$select\", value)\n}", "func RenderUserSelect(c *gin.Context, mode string, title string, href func(User) string) {\n\n\tvar users []User\n\n\tif err := dbase.Find(&users).Order(\"id\").Error; err != nil {\n\t\tSendError(http.StatusInternalServerError, c, err)\n\t\treturn\n\t}\n\n\tSendHTML(http.StatusOK, c, \"userselect\", gin.H{\n\t\t\"users\": users,\n\t\t\"title\": title,\n\t\t\"mode\": mode,\n\t\t\"href\": href,\n\t})\n}", "func (s *TableQuery) Select(args ...interface{}) drivers.ITableQuery {\n\ts.SelectSQL = NewColumn().GetSelectColumns(args...)\n\treturn s\n}", "func (r ApiGetHyperflexHxdpVersionListRequest) Select_(select_ string) ApiGetHyperflexHxdpVersionListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (cuo *CarUpdateOne) Select(field string, fields ...string) *CarUpdateOne {\n\tcuo.fields = append([]string{field}, fields...)\n\treturn cuo\n}", "func (ouo *OtherUpdateOne) Select(field string, fields ...string) *OtherUpdateOne {\n\touo.fields = append([]string{field}, fields...)\n\treturn ouo\n}", "func (file *File) Select() {\n\tfile.mark = file.location\n}", "func (truo *TradeRecordUpdateOne) Select(field string, fields ...string) *TradeRecordUpdateOne {\n\ttruo.fields = append([]string{field}, fields...)\n\treturn truo\n}", "func (s *BaseMySqlParserListener) EnterSelectFunctionElement(ctx *SelectFunctionElementContext) {}", "func (p *simpleParser) parseSelectStmt(withClause *ast.WithClause, r reporter) (stmt *ast.SelectStmt) {\n\tstmt = &ast.SelectStmt{}\n\n\t// parseSelect can be called from withClauseBeginnerStmts or otherwise.\n\tif withClause != nil {\n\t\tstmt.WithClause = withClause\n\t} else {\n\t\tnext, ok := p.lookahead(r)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\t\tif next.Type() == token.KeywordWith {\n\t\t\tstmt.WithClause = p.parseWithClause(r)\n\t\t}\n\t}\n\tvar selectCore *ast.SelectCore\n\n\t// Keep looping and searching for the select core until its exhausted.\n\t// We are sure that a select core starts here as its the type of stmt we expect.\n\tfor {\n\t\tnext, ok := p.optionalLookahead(r)\n\t\tif !ok || next.Type() == token.EOF || next.Type() == token.StatementSeparator {\n\t\t\treturn\n\t\t}\n\t\tif next.Type() == token.KeywordSelect || next.Type() == token.KeywordValues {\n\t\t\tif selectCore != nil {\n\t\t\t\t// Operated on previous selectCores.\n\t\t\t\t// If there's no compounding in this statement;\n\t\t\t\t// strict rule, thus breaking flow.\n\t\t\t\tif selectCore.CompoundOperator == nil {\n\t\t\t\t\tr.unexpectedToken(token.KeywordUnion, token.KeywordIntersect, token.KeywordExcept)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tselectCore = p.parseSelectCore(r)\n\t\t\tstmt.SelectCore = append(stmt.SelectCore, selectCore)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tnext, ok := p.optionalLookahead(r)\n\tif !ok || next.Type() == token.EOF || next.Type() == token.StatementSeparator {\n\t\treturn\n\t}\n\tif next.Type() == token.KeywordOrder {\n\t\tstmt.Order = next\n\t\tp.consumeToken()\n\t\tnext, ok = p.lookahead(r)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\t\tif next.Type() == token.KeywordBy {\n\t\t\tstmt.By = next\n\t\t\tp.consumeToken()\n\n\t\t} else {\n\t\t\tr.unexpectedToken(token.KeywordBy)\n\t\t}\n\t\tfor {\n\t\t\tstmt.OrderingTerm = append(stmt.OrderingTerm, p.parseOrderingTerm(r))\n\t\t\tnext, ok = p.lookahead(r)\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif next.Value() == \",\" {\n\t\t\t\tp.consumeToken()\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tnext, ok = p.optionalLookahead(r)\n\tif !ok || next.Type() == token.EOF || next.Type() == token.StatementSeparator {\n\t\treturn\n\t}\n\tif next.Type() == token.KeywordLimit {\n\t\tstmt.Limit = next\n\t\tp.consumeToken()\n\t\tstmt.Expr1 = p.parseExpression(r)\n\t\tif stmt.Expr1 == nil {\n\t\t\tr.expectedExpression()\n\t\t}\n\n\t\tif stmt.Expr1 == nil {\n\t\t\tr.expectedExpression()\n\t\t}\n\n\t\tnext, ok = p.optionalLookahead(r)\n\t\tif !ok || next.Type() == token.EOF || next.Type() == token.StatementSeparator {\n\t\t\treturn\n\t\t}\n\t\tif next.Type() == token.KeywordOffset {\n\t\t\tstmt.Offset = next\n\t\t\tp.consumeToken()\n\t\t\tstmt.Expr2 = p.parseExpression(r)\n\t\t\tif stmt.Expr2 == nil {\n\t\t\t\tr.expectedExpression()\n\t\t\t}\n\t\t}\n\t\tif next.Value() == \",\" {\n\t\t\tstmt.Comma = next\n\t\t\tp.consumeToken()\n\t\t\tstmt.Expr2 = p.parseExpression(r)\n\t\t\tif stmt.Expr2 == nil {\n\t\t\t\tr.expectedExpression()\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (db *DB) Select(table string, cb RowCB, columns ...string) error {\n\tinnerCB := func(row Row) bool {\n\t\tcb(row)\n\t\treturn false // not done\n\t}\n\treturn db.SelectDone(table, innerCB, columns...)\n}", "func (r ApiGetHyperflexServerFirmwareVersionEntryListRequest) Select_(select_ string) ApiGetHyperflexServerFirmwareVersionEntryListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func (fuo *FriendshipUpdateOne) Select(field string, fields ...string) *FriendshipUpdateOne {\n\tfuo.fields = append([]string{field}, fields...)\n\treturn fuo\n}", "func (suo *SettingUpdateOne) Select(field string, fields ...string) *SettingUpdateOne {\n\tsuo.fields = append([]string{field}, fields...)\n\treturn suo\n}", "func (o InfraAlertConditionOutput) Select() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *InfraAlertCondition) pulumi.StringPtrOutput { return v.Select }).(pulumi.StringPtrOutput)\n}", "func (r ApiGetHyperflexHealthCheckExecutionSnapshotListRequest) Select_(select_ string) ApiGetHyperflexHealthCheckExecutionSnapshotListRequest {\n\tr.select_ = &select_\n\treturn r\n}", "func buildSelectFields(selects []interface{}) string {\n\tif len(selects) == 0 {\n\t\treturn \"*\"\n\t}\n\tfields := \"\"\n\tfor _, f := range selects {\n\t\tif v, ok := f.(Raw); ok {\n\t\t\tfields += v.String() + \", \"\n\t\t} else if v, ok := f.(alias); ok {\n\t\t\tfields += v.String() + \", \"\n\t\t} else if v, ok := f.(string); ok {\n\t\t\tfields += quote(v) + \", \"\n\t\t}\n\t}\n\treturn strings.TrimRight(fields, \", \")\n}", "func (isrtuo *IPStaticRoutingTableUpdateOne) Select(field string, fields ...string) *IPStaticRoutingTableUpdateOne {\n\tisrtuo.fields = append([]string{field}, fields...)\n\treturn isrtuo\n}", "func (db *Database) Select(cols ...string) *Database {\n\tdb.Query.Action = \"SELECT\"\n\tdb.Query.Columns = columns(cols)\n\n\treturn db\n}" ]
[ "0.6158283", "0.60410637", "0.5865177", "0.5729214", "0.56631666", "0.56621164", "0.56160337", "0.55718744", "0.55577374", "0.5554273", "0.5550564", "0.54608256", "0.53678966", "0.53404766", "0.5337978", "0.53222317", "0.53139794", "0.52990556", "0.52875936", "0.5280315", "0.52789265", "0.5277569", "0.52773166", "0.5276817", "0.527594", "0.5271257", "0.52694565", "0.52493155", "0.52460647", "0.5232141", "0.52056855", "0.51992255", "0.5183032", "0.5175611", "0.51694816", "0.51619625", "0.51604795", "0.51593685", "0.5157701", "0.5150909", "0.514747", "0.5142685", "0.5129828", "0.51278794", "0.5125327", "0.51199925", "0.5115631", "0.51147044", "0.5114512", "0.5113479", "0.51123136", "0.5109185", "0.51061636", "0.510175", "0.50957566", "0.5093082", "0.5092861", "0.5090876", "0.5088631", "0.50875247", "0.5083495", "0.50766295", "0.50760925", "0.50736976", "0.50711477", "0.50595015", "0.50557643", "0.5054441", "0.50483733", "0.5045536", "0.50432795", "0.5042667", "0.5040854", "0.50405496", "0.50404054", "0.5039814", "0.5034992", "0.5030553", "0.5025272", "0.50247824", "0.5014241", "0.5013782", "0.5010965", "0.5010702", "0.5008145", "0.500615", "0.5001144", "0.49991983", "0.499387", "0.4987295", "0.49793413", "0.49789593", "0.497848", "0.49772564", "0.49753213", "0.49708402", "0.49683467", "0.49608666", "0.4958808", "0.49548545" ]
0.7165648
0
makeWhereCluasesStatment renders statment as below if r.whereClauses has elements: WHERE = [,=]...
func (op *OpQuery) makeWhereCluasesStatment() string { var data = make(map[string]interface{}) for _, clause := range op.whereClauses { if !clause.IsValid() { defaultLogger.Printf( "[QuerySObjectRequest] Found invalid where-clause which should be type of number, boolean or string. QuerySObject=%s, Field=%s, ConditionType=%T", op.sobjectName, clause.field, clause.condition, ) continue } data[clause.field] = clause.condition } if len(data) == 0 { return "" } var filters = make([]string, 0) for field, cond := range data { if str, ok := cond.(string); ok { filters = append(filters, fmt.Sprintf("%s='%s'", field, str)) } else { filters = append(filters, fmt.Sprintf("%s=%v", field, cond)) } } return fmt.Sprintf("WHERE %s", strings.Join(filters, ",")) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func whereClause(o bool, w ...where) string {\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(fmt.Sprintf(\" where \"))\n\tfor c, wc := range w {\n\t\tif c == 0 {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s='%v' \", wc.field, wc.value))\n\t\t} else {\n\t\t\tif o {\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(\"OR %s='%v' \", wc.field, wc.value))\n\t\t\t} else {\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(\"AND %s='%v' \", wc.field, wc.value))\n\t\t\t}\n\t\t}\n\t}\n\treturn buffer.String()\n}", "func buildWhere(wheres []ConditionBuilder, binds []interface{}) (string, []interface{}) {\n\tif len(wheres) == 0 {\n\t\treturn \"\", binds\n\t}\n\n\tfirst := true\n\twhere := \"\"\n\tc := \"\"\n\n\tfor _, w := range wheres {\n\t\tc = w.Combine()\n\t\tif c != \"\" {\n\t\t\tc = \" \" + c + \" \"\n\t\t}\n\t\tif first {\n\t\t\tc = \"\"\n\t\t\tfirst = false\n\t\t}\n\t\tvar clause string\n\t\tclause, binds = w.Build(binds)\n\t\twhere += fmt.Sprintf(\"%s(%s)\", c, clause)\n\t}\n\treturn \" WHERE \" + where, binds\n}", "func (q *Query) whereClause(i int) (string, []interface{}) {\n\tif i < 1 {\n\t\t// the numbering starts at $1 not $0\n\t\ti = 1\n\t}\n\n\tvals := make([]interface{}, 0, len(q.conditions))\n\n\tb := strings.Builder{}\n\n\t// get length of values since the numbering of the where clause starts after values\n\tstartPos := len(q.values) + i\n\n\tclauses := make([]string, 0, len(q.conditions))\n\tfor _, cond := range q.conditions {\n\t\tif cond.raw != \"\" {\n\t\t\tn := len(cond.rawVals)\n\t\t\tif n == 0 {\n\t\t\t\tclauses = append(clauses, cond.raw)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\treplacements := make([]interface{}, n)\n\t\t\tfor j, str := range placeHolders(startPos, n) {\n\t\t\t\treplacements[j] = str\n\t\t\t}\n\n\t\t\tc := fmt.Sprintf(cond.raw, replacements...)\n\t\t\tclauses = append(clauses, c)\n\n\t\t\tvals = append(vals, cond.rawVals...)\n\n\t\t\tstartPos += n\n\t\t\tcontinue\n\t\t}\n\n\t\t// Clause returns the clause string and the new position (start position + number of values)\n\t\tc, nextPos := cond.Clause(startPos)\n\t\tclauses = append(clauses, c)\n\n\t\tif startPos < nextPos {\n\t\t\t// if the next position is greater than the start then values need to be added\n\t\t\tif r, ok := cond.val.(Range); ok {\n\t\t\t\tvals = append(vals, r.Start, r.End)\n\t\t\t} else if err := verifyArray(reflect.TypeOf(cond.val)); err == nil {\n\t\t\t\ts := reflect.ValueOf(cond.val)\n\t\t\t\tn := s.Len()\n\t\t\t\tfor j := 0; j < n; j++ {\n\t\t\t\t\tv := s.Index(j).Interface()\n\t\t\t\t\tvals = append(vals, v)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvals = append(vals, cond.val)\n\t\t\t}\n\t\t\tstartPos = nextPos\n\t\t}\n\t}\n\n\tb.WriteString(strings.Join(clauses, \" AND \"))\n\n\twhere := b.String()\n\n\t// Ors\n\tif len(q.ors) > 0 {\n\t\tnewWhere, newVals := addQueries(where, \"OR\", startPos, q.ors)\n\t\tvals = append(vals, newVals...)\n\n\t\tstartPos += len(newVals)\n\t\twhere = newWhere\n\t}\n\n\t// Ands\n\tif len(q.ands) > 0 {\n\t\tnewWhere, newVals := addQueries(where, \"AND\", startPos, q.ands)\n\t\tvals = append(vals, newVals...)\n\n\t\tstartPos += len(newVals) //nolint:ineffassign\n\t\twhere = newWhere\n\t}\n\n\treturn where, vals\n}", "func buildWhere(filters []types.DataGetFilter, queryArgs *[]interface{},\n\tqueryCountArgs *[]interface{}, loginId int64, nestingLevel int, where *string) error {\n\n\tbracketBalance := 0\n\tinWhere := make([]string, 0)\n\n\tfor i, filter := range filters {\n\n\t\t// overwrite first filter connector and add brackets in first and last filter line\n\t\t// done so that query filters do not interfere with other filters\n\t\tif i == 0 {\n\t\t\tfilter.Connector = \"AND\"\n\t\t\tfilter.Side0.Brackets++\n\t\t}\n\t\tif i == len(filters)-1 {\n\t\t\tfilter.Side1.Brackets++\n\t\t}\n\n\t\tif !tools.StringInSlice(filter.Connector, types.QueryFilterConnectors) {\n\t\t\treturn errors.New(\"bad filter connector\")\n\t\t}\n\t\tif !tools.StringInSlice(filter.Operator, types.QueryFilterOperators) {\n\t\t\treturn errors.New(\"bad filter operator\")\n\t\t}\n\n\t\tbracketBalance -= filter.Side0.Brackets\n\t\tbracketBalance += filter.Side1.Brackets\n\t\tisNullOp := isNullOperator(filter.Operator)\n\n\t\t// define comparisons\n\t\tvar getComp = func(s types.DataGetFilterSide, comp *string) error {\n\t\t\tvar err error\n\t\t\tvar isQuery = s.Query.RelationId != uuid.Nil\n\n\t\t\t// sub query filter\n\t\t\tif isQuery {\n\t\t\t\tsubQuery, _, err := prepareQuery(s.Query, queryArgs,\n\t\t\t\t\tqueryCountArgs, loginId, nestingLevel+1)\n\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\t*comp = fmt.Sprintf(\"(\\n%s\\n)\", subQuery)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// attribute filter\n\t\t\tif s.AttributeId.Status == pgtype.Present {\n\t\t\t\t*comp, err = getAttributeCode(s.AttributeId.Bytes,\n\t\t\t\t\tgetRelationCode(s.AttributeIndex, s.AttributeNested))\n\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\t// special case: (I)LIKE comparison needs attribute cast as TEXT\n\t\t\t\t// this is relevant for integers/floats/etc.\n\t\t\t\tif isLikeOperator(filter.Operator) {\n\t\t\t\t\t*comp = fmt.Sprintf(\"%s::TEXT\", *comp)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// user value filter\n\t\t\t// can be anything, text, numbers, floats, boolean, NULL values\n\t\t\t// create placeholders and add to query arguments\n\n\t\t\tif isNullOp {\n\t\t\t\t// do not add user value as argument if NULL operator is used\n\t\t\t\t// to use NULL operator the data type must be known ahead of time (prepared statement)\n\t\t\t\t// \"pg: could not determine data type\"\n\t\t\t\t// because user can add anything we would check the type ourselves\n\t\t\t\t// or just check for NIL because that´s all we care about in this case\n\t\t\t\tif s.Value == nil {\n\t\t\t\t\t*comp = \"NULL\"\n\t\t\t\t\treturn nil\n\t\t\t\t} else {\n\t\t\t\t\t*comp = \"NOT NULL\"\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif isLikeOperator(filter.Operator) {\n\t\t\t\t// special syntax for ILIKE comparison (add wildcard characters)\n\t\t\t\ts.Value = fmt.Sprintf(\"%%%s%%\", s.Value)\n\t\t\t}\n\n\t\t\t// PGX fix: cannot use proper true/false values in SQL parameters\n\t\t\t// no good solution found so far, error: 'cannot convert (true|false) to Text'\n\t\t\tif fmt.Sprintf(\"%T\", s.Value) == \"bool\" {\n\t\t\t\tif s.Value.(bool) == true {\n\t\t\t\t\ts.Value = \"true\"\n\t\t\t\t} else {\n\t\t\t\t\ts.Value = \"false\"\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t*queryArgs = append(*queryArgs, s.Value)\n\t\t\tif queryCountArgs != nil {\n\t\t\t\t*queryCountArgs = append(*queryCountArgs, s.Value)\n\t\t\t}\n\n\t\t\tif isArrayOperator(filter.Operator) {\n\t\t\t\t*comp = fmt.Sprintf(\"($%d)\", len(*queryArgs))\n\t\t\t} else {\n\t\t\t\t*comp = fmt.Sprintf(\"$%d\", len(*queryArgs))\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\t// build left/right comparison sides (ignore right side, if NULL operator)\n\t\tcomp0, comp1 := \"\", \"\"\n\t\tif err := getComp(filter.Side0, &comp0); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !isNullOp {\n\t\t\tif err := getComp(filter.Side1, &comp1); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t// generate WHERE line from parsed filter definition\n\t\tline := fmt.Sprintf(\"\\n%s %s%s %s %s%s\", filter.Connector,\n\t\t\tgetBrackets(filter.Side0.Brackets, false),\n\t\t\tcomp0, filter.Operator, comp1,\n\t\t\tgetBrackets(filter.Side1.Brackets, true))\n\n\t\tinWhere = append(inWhere, line)\n\t}\n\tif bracketBalance != 0 {\n\t\treturn errors.New(\"bracket count is unequal\")\n\t}\n\n\t// join lines and replace first AND with WHERE\n\t*where = strings.Replace(strings.Join(inWhere, \"\"), \"AND\", \"WHERE\", 1)\n\treturn nil\n}", "func (w *Wrapper) buildWhere(typ string) (query string) {\n\tvar conditions []condition\n\tif typ == \"HAVING\" {\n\t\tconditions = w.havingConditions\n\t\tquery = \"HAVING \"\n\t} else {\n\t\tconditions = w.conditions\n\t\tquery = \"WHERE \"\n\t}\n\tif len(conditions) == 0 {\n\t\tquery = \"\"\n\t\treturn\n\t}\n\tquery += w.buildConditions(conditions)\n\treturn\n}", "func (stcu *SurveyTemplateCategoryUpdate) Where(ps ...predicate.SurveyTemplateCategory) *SurveyTemplateCategoryUpdate {\n\tstcu.mutation.predicates = append(stcu.mutation.predicates, ps...)\n\treturn stcu\n}", "func (stmt DeleteStmt) Where(clauses ...Clause) DeleteStmt {\n\tif len(clauses) > 1 {\n\t\t// By default, multiple where clauses will be joined will AllOf\n\t\tstmt.where = AllOf(clauses...)\n\t} else if len(clauses) == 1 {\n\t\tstmt.where = clauses[0]\n\t}\n\treturn stmt\n}", "func (u *Update) Where(conds ...utils.M) *Update {\n\tif len(conds) == 1 {\n\t\tu.find = utils.GenerateFind(conds[0])\n\t} else {\n\t\tu.find = utils.GenerateFind(utils.And(conds...))\n\t}\n\treturn u\n}", "func (u *Update) Where(conds ...types.M) *Update {\n\tif len(conds) == 1 {\n\t\tu.find = types.GenerateFind(conds[0])\n\t} else {\n\t\tu.find = types.GenerateFind(types.And(conds...))\n\t}\n\treturn u\n}", "func (cu *CommentUpdate) Where(ps ...predicate.Comment) *CommentUpdate {\n\tcu.predicates = append(cu.predicates, ps...)\n\treturn cu\n}", "func (au *AntenatalinformationUpdate) Where(ps ...predicate.Antenatalinformation) *AntenatalinformationUpdate {\n\tau.mutation.predicates = append(au.mutation.predicates, ps...)\n\treturn au\n}", "func (a *AuditSrv) buildSearchWhereClause(searchParms *globalUtils.AuditSearchParams) (string, []interface{}, error) {\n\tsqlWhereClause := \" where 1=1\"\n\tvar values []interface{}\n\n\ti := 1\n\tif searchParms.ObjectName != \"\" {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND audit.objectname = $%d\", i)\n\t\tvalues = append(values, searchParms.ObjectName)\n\t\ti++\n\t}\n\tif searchParms.ObjectId != \"\" {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND audit.objectid = $%d\", i)\n\t\tvalues = append(values, searchParms.ObjectId)\n\t\ti++\n\t}\n\tif !searchParms.ActionTimeStart.IsZero() {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND audit.actiontime >= $%d\", i)\n\t\tvalues = append(values, searchParms.ActionTimeStart)\n\t\ti++\n\t}\n\tif !searchParms.ActionTimeEnd.IsZero() {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND audit.actiontime <= $%d\", i)\n\t\tvalues = append(values, searchParms.ActionTimeEnd)\n\t\t//i++\n\t}\n\treturn sqlWhereClause, values, nil\n}", "func (l *LiveQuery) Where(conds ...utils.M) *LiveQuery {\n\tif len(conds) == 1 {\n\t\tl.find = utils.GenerateFind(conds[0])\n\t} else {\n\t\tl.find = utils.GenerateFind(utils.And(conds...))\n\t}\n\treturn l\n}", "func (du *DoctorinfoUpdate) Where(ps ...predicate.Doctorinfo) *DoctorinfoUpdate {\n\tdu.predicates = append(du.predicates, ps...)\n\treturn du\n}", "func (wu *WechatUpdate) Where(ps ...predicate.Wechat) *WechatUpdate {\n\twu.mutation.predicates = append(wu.mutation.predicates, ps...)\n\treturn wu\n}", "func (du *DoctorUpdate) Where(ps ...predicate.Doctor) *DoctorUpdate {\n\tdu.predicates = append(du.predicates, ps...)\n\treturn du\n}", "func combineConditions(fieldsMap map[string]string, conds string) (string, error) {\n\tif conds == \"\" {\n\t\treturn \"\", nil\n\t}\n\n\twhereBlock := \"where \"\n\tvar preparedConditions []string\n\n\t// Parse logical operators\n\t// Get substrings with bracket conditions\n\tre := regexp.MustCompile(`\\((.*?)\\)`)\n\tbracketSubstrings := re.FindAllString(conds, -1)\n\tfor _, brCondSet := range bracketSubstrings {\n\t\tcondSet := brCondSet\n\n\t\tcondSet = strings.Trim(condSet, \"(\")\n\t\tcondSet = strings.Trim(condSet, \")\")\n\n\t\tvar cond string\n\t\tvar err error\n\n\t\tvar bracketConditions []string\n\t\topCount := strings.Count(condSet, \"*\") + strings.Count(condSet, \"||\")\n\t\tfor i := 0; i <= opCount; i++ { // loop number of logical operators in condition set\n\t\t\tcondSet, cond, err = handleConditionsSet(fieldsMap, condSet)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tbracketConditions = append(bracketConditions, cond)\n\t\t}\n\t\tconds = strings.TrimPrefix(conds, brCondSet)\n\n\t\t// Handle trailimg logical operator\n\t\torIndex := strings.Index(conds, \"||\")\n\t\tandIndex := strings.Index(conds, \"*\")\n\n\t\top := \"\"\n\t\tif (orIndex < 0 || andIndex < orIndex) && andIndex >= 0 { // handle AND logical condition\n\t\t\top = \"*\"\n\t\t}\n\t\tif (andIndex < 0 || orIndex < andIndex) && orIndex >= 0 { // handle OR logical condition\n\t\t\top = \"||\"\n\t\t}\n\t\tif op != \"\" {\n\t\t\tconds = strings.TrimPrefix(conds, op)\n\t\t}\n\n\t\tpreparedConditions = append(preparedConditions, \"(\"+strings.Join(bracketConditions, \" \")+\") \"+logicalBindings[op])\n\t}\n\n\tvar cond string\n\tvar err error\n\topCount := strings.Count(conds, \"*\") + strings.Count(conds, \"||\")\n\tif conds != \"\" { // handle non-bracket conditions set\n\t\tfor i := 0; i <= opCount; i++ { // loop number of logical operators in condition set\n\t\t\tconds, cond, err = handleConditionsSet(fieldsMap, conds)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tpreparedConditions = append(preparedConditions, cond)\n\t\t}\n\t}\n\n\treturn whereBlock + strings.Join(preparedConditions, \" \"), nil\n}", "func (lu *LessonplanUpdate) Where(ps ...predicate.Lessonplan) *LessonplanUpdate {\n\tlu.predicates = append(lu.predicates, ps...)\n\treturn lu\n}", "func (cu *CourseUpdate) Where(ps ...predicate.Course) *CourseUpdate {\n\tcu.predicates = append(cu.predicates, ps...)\n\treturn cu\n}", "func (rfu *ReportFilterUpdate) Where(ps ...predicate.ReportFilter) *ReportFilterUpdate {\n\trfu.mutation.predicates = append(rfu.mutation.predicates, ps...)\n\treturn rfu\n}", "func (c *condition) Clause(i int) (string, int) {\n\tvar condClause string\n\tif nullable, ok := c.val.(Nullable); c.val == nil || (ok && nullable.IsNull()) {\n\t\tcondClause = condClauseNull(c.negative)\n\t} else if _, ok := c.val.(Range); ok {\n\t\tcondClause, i = condClauseRange(i, c.negative)\n\t} else if err := verifyArray(reflect.TypeOf(c.val)); err == nil {\n\t\tcondClause, i = condClauseSlice(i, reflect.ValueOf(c.val).Len(), c.negative)\n\t} else {\n\t\tcondClause, i = condClauseVal(i, c.negative)\n\t}\n\n\tvar b StringsBuilder\n\tb.WriteStrings(Quote(c.col), \" \", condClause)\n\n\treturn b.String(), i\n}", "func (b *Builder) Where(pred ...Cond) *Builder {\n\treturn b\n}", "func (m *OrgUnitMutation) Where(ps ...predicate.OrgUnit) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (s *BasePlSqlParserListener) EnterWhere_clause(ctx *Where_clauseContext) {}", "func (m *TradeCorrectionMutation) Where(ps ...predicate.TradeCorrection) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (eu *ExtradoctorUpdate) Where(ps ...predicate.Extradoctor) *ExtradoctorUpdate {\n\teu.predicates = append(eu.predicates, ps...)\n\treturn eu\n}", "func (m Matcher) Where(cond bool) Matcher {\n\treturn m\n}", "func (stmt *statement) Where(expr string, args ...interface{}) Statement {\n\tstmt.addPart(posWhere, \"WHERE\", expr, args, \" AND \")\n\treturn stmt\n}", "func (w *Wrapper) OrWhere(args ...interface{}) *Wrapper {\n\tw.saveCondition(\"WHERE\", \"OR\", args...)\n\treturn w\n}", "func (tu *TransactionfactorUpdate) Where(ps ...predicate.Transactionfactor) *TransactionfactorUpdate {\n\ttu.mutation.predicates = append(tu.mutation.predicates, ps...)\n\treturn tu\n}", "func (c *conflictUpdate) WhereClause() ExpressionList {\n\treturn c.whereClause\n}", "func (tdq *TCPDetectorQuery) Where(ps ...predicate.TCPDetector) *TCPDetectorQuery {\n\ttdq.predicates = append(tdq.predicates, ps...)\n\treturn tdq\n}", "func (sd *SelectDataset) Where(expressions ...exp.Expression) *SelectDataset {\n\treturn sd.copy(sd.clauses.WhereAppend(expressions...))\n}", "func (m *CityMutation) Where(ps ...predicate.City) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (cu *ContinentUpdate) Where(ps ...predicate.Continent) *ContinentUpdate {\n\tcu.predicates = append(cu.predicates, ps...)\n\treturn cu\n}", "func Where(clause string, args ...interface{}) QueryMod {\n\treturn func(q *queries.Query) {\n\t\tqueries.AppendWhere(q, clause, args...)\n\t}\n}", "func generateDTWhereQuery(dtFields []dtColumn) string {\n\twhereQuery := fmt.Sprintf(\"%s like ? \", dtFields[0].dbColumnName)\n\n\tfor _, field := range dtFields[1:] {\n\t\twhereQuery += fmt.Sprintf(\"OR %s like ? \", field.dbColumnName)\n\t}\n\n\treturn whereQuery\n}", "func (w *Wrapper) buildConditions(conditions []condition) (query string) {\n\tfor i, v := range conditions {\n\t\t// Add the connector if it's not the first condition.\n\t\tif i != 0 {\n\t\t\tquery += fmt.Sprintf(\"%s \", v.connector)\n\t\t}\n\n\t\t// Get the type of the column name, it might be a query, or normal column name, or even a sub query.\n\t\tvar typ string\n\t\tswitch q := v.args[0].(type) {\n\t\tcase string:\n\t\t\tif strings.Contains(q, \"?\") || strings.Contains(q, \"(\") || len(v.args) == 1 {\n\t\t\t\ttyp = \"Query\"\n\t\t\t} else {\n\t\t\t\ttyp = \"Column\"\n\t\t\t}\n\t\tcase *Wrapper:\n\t\t\ttyp = \"SubQuery\"\n\t\t}\n\n\t\t// Build the condition based on the type.\n\t\tswitch len(v.args) {\n\t\t// .Where(\"Column = Column\")\n\t\tcase 1:\n\t\t\tquery += fmt.Sprintf(\"%s \", v.args[0].(string))\n\t\t// .Where(\"Column = ?\", \"Value\")\n\t\t// .Where(\"Column\", \"Value\")\n\t\t// .Where(subQuery, \"EXISTS\")\n\t\tcase 2:\n\t\t\tswitch typ {\n\t\t\tcase \"Query\":\n\t\t\t\tquery += fmt.Sprintf(\"%s \", v.args[0].(string))\n\t\t\t\tw.bindParam(v.args[1])\n\t\t\tcase \"Column\":\n\t\t\t\tswitch d := v.args[1].(type) {\n\t\t\t\tcase Timestamp:\n\t\t\t\t\tquery += fmt.Sprintf(d.query, v.args[0].(string), w.bindParam(d))\n\t\t\t\tdefault:\n\t\t\t\t\tquery += fmt.Sprintf(\"%s = %s \", v.args[0].(string), w.bindParam(d))\n\t\t\t\t}\n\t\t\tcase \"SubQuery\":\n\t\t\t\tquery += fmt.Sprintf(\"%s %s \", v.args[1].(string), w.bindParam(v.args[0]))\n\t\t\t}\n\t\t// .Where(\"Column\", \">\", \"Value\")\n\t\t// .Where(\"Column\", \"IN\", subQuery)\n\t\t// .Where(\"Column\", \"IS\", nil)\n\t\tcase 3:\n\t\t\tif typ == \"Query\" {\n\t\t\t\tquery += fmt.Sprintf(\"%s \", v.args[0].(string))\n\t\t\t\tw.bindParams(v.args[1:])\n\t\t\t} else {\n\t\t\t\tif v.args[1].(string) == \"IN\" || v.args[1].(string) == \"NOT IN\" {\n\t\t\t\t\tquery += fmt.Sprintf(\"%s %s (%s) \", v.args[0].(string), v.args[1].(string), w.bindParam(v.args[2], false))\n\t\t\t\t} else {\n\t\t\t\t\tquery += fmt.Sprintf(\"%s %s %s \", v.args[0].(string), v.args[1].(string), w.bindParam(v.args[2]))\n\t\t\t\t}\n\t\t\t}\n\t\t// .Where(\"(Column = ? OR Column = SHA(?))\", \"Value\", \"Value\")\n\t\t// .Where(\"Column\", \"BETWEEN\", 1, 20)\n\t\tdefault:\n\t\t\tif typ == \"Query\" {\n\t\t\t\tquery += fmt.Sprintf(\"%s \", v.args[0].(string))\n\t\t\t\tw.bindParams(v.args[1:])\n\t\t\t} else {\n\t\t\t\tswitch v.args[1].(string) {\n\t\t\t\tcase \"BETWEEN\", \"NOT BETWEEN\":\n\t\t\t\t\tquery += fmt.Sprintf(\"%s %s %s AND %s \", v.args[0].(string), v.args[1].(string), w.bindParam(v.args[2]), w.bindParam(v.args[3]))\n\t\t\t\tcase \"IN\", \"NOT IN\":\n\t\t\t\t\tquery += fmt.Sprintf(\"%s %s (%s) \", v.args[0].(string), v.args[1].(string), w.bindParams(v.args[2:]))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (q *Query) Where(stmt string, args ...interface{}) *Query {\n\tif q.RawSQL.Fragment != \"\" {\n\t\tfmt.Println(\"Warning: Query is setup to use raw SQL\")\n\t\treturn q\n\t}\n\tif inRegex.MatchString(stmt) {\n\t\tvar inq []string\n\t\tfor i := 0; i < len(args); i++ {\n\t\t\tinq = append(inq, \"?\")\n\t\t}\n\t\tqs := fmt.Sprintf(\"(%s)\", strings.Join(inq, \",\"))\n\t\tstmt = strings.Replace(stmt, \"(?)\", qs, 1)\n\t}\n\tq.whereClauses = append(q.whereClauses, clause{stmt, args})\n\treturn q\n}", "func (mu *MannerUpdate) Where(ps ...predicate.Manner) *MannerUpdate {\n\tmu.predicates = append(mu.predicates, ps...)\n\treturn mu\n}", "func Where(scope *Scope, condition tf.Output) (index tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Where\",\n\t\tInput: []tf.Input{\n\t\t\tcondition,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (m *DataSourceMutation) Where(ps ...predicate.DataSource) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (ktu *KqiTargetUpdate) Where(ps ...predicate.KqiTarget) *KqiTargetUpdate {\n\tktu.mutation.predicates = append(ktu.mutation.predicates, ps...)\n\treturn ktu\n}", "func (du *DiagnosisUpdate) Where(ps ...predicate.Diagnosis) *DiagnosisUpdate {\n\tdu.mutation.predicates = append(du.mutation.predicates, ps...)\n\treturn du\n}", "func (gsu *GameServerUpdate) Where(ps ...predicate.GameServer) *GameServerUpdate {\n\tgsu.mutation.Where(ps...)\n\treturn gsu\n}", "func (dqu *DNSBLQueryUpdate) Where(ps ...predicate.DNSBLQuery) *DNSBLQueryUpdate {\n\tdqu.mutation.predicates = append(dqu.mutation.predicates, ps...)\n\treturn dqu\n}", "func (cu *CustomerUpdate) Where(ps ...predicate.Customer) *CustomerUpdate {\n\tcu.mutation.predicates = append(cu.mutation.predicates, ps...)\n\treturn cu\n}", "func (m *TradeConditionMutation) Where(ps ...predicate.TradeCondition) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (aru *AuthRequestUpdate) Where(ps ...predicate.AuthRequest) *AuthRequestUpdate {\n\taru.mutation.Where(ps...)\n\treturn aru\n}", "func (stqu *SurveyTemplateQuestionUpdate) Where(ps ...predicate.SurveyTemplateQuestion) *SurveyTemplateQuestionUpdate {\n\tstqu.predicates = append(stqu.predicates, ps...)\n\treturn stqu\n}", "func (ou *OperationroomUpdate) Where(ps ...predicate.Operationroom) *OperationroomUpdate {\n\tou.predicates = append(ou.predicates, ps...)\n\treturn ou\n}", "func (scsu *SurveyCellScanUpdate) Where(ps ...predicate.SurveyCellScan) *SurveyCellScanUpdate {\n\tscsu.predicates = append(scsu.predicates, ps...)\n\treturn scsu\n}", "func TestMyWhereEval(t *testing.T) {\n\tcolumnsMap := make(map[string]int)\n\tcolumnsMap[\"Col1\"] = 0\n\tcolumnsMap[\"Col2\"] = 1\n\ttables := []struct {\n\t\tmyQuery string\n\t\trecord []string\n\t\terr error\n\t\texpected bool\n\t\theader []string\n\t}{\n\t\t{\"SELECT * FROM S3OBJECT\", []string{\"record_1,record_2,record_3,record_4\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT WHERE Col1 < -1\", []string{\"0\", \"1\"}, nil, false, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT WHERE Col1 < -1 OR Col2 > 15\", []string{\"151\", \"12\"}, nil, false, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT WHERE Col1 > -1 AND Col2 > 15\", []string{\"151\", \"12\"}, nil, false, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT WHERE Col1 > 1.00\", []string{\"151.0000\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT WHERE Col1 > 100\", []string{\"random\", \"12\"}, nil, false, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT WHERE Col1 BETWEEN 100 AND 0\", []string{\"151\", \"12\"}, nil, false, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT WHERE Col1 BETWEEN 100.0 AND 0.0\", []string{\"151\", \"12\"}, nil, false, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE A.1 BETWEEN 160 AND 150\", []string{\"151\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE A._1 BETWEEN 160 AND 0\", []string{\"151\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE A._1 BETWEEN 0 AND 160\", []string{\"151\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT A._1 LIKE 'r%'\", []string{\"record_1,record_2,record_3,record_4\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT s._2 FROM S3Object s WHERE s._2 = 'Steven'\", []string{\"record_1\", \"Steven\", \"Steven\", \"record_4\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE Col1 BETWEEN 0 AND 160\", []string{\"151\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE Col1 BETWEEN 160 AND 0\", []string{\"151\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE UPPER(Col1) BETWEEN 160 AND 0\", []string{\"151\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE UPPER(Col1) = 'RANDOM'\", []string{\"random\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t\t{\"SELECT * FROM S3OBJECT AS A WHERE LOWER(UPPER(Col1) = 'random'\", []string{\"random\", \"12\"}, nil, true, []string{\"Col1\", \"Col2\"}},\n\t}\n\tfor _, table := range tables {\n\t\toptions := &Options{\n\t\t\tHasHeader: false,\n\t\t\tRecordDelimiter: \"\\n\",\n\t\t\tFieldDelimiter: \",\",\n\t\t\tComments: \"\",\n\t\t\tName: \"S3Object\", // Default table name for all objects\n\t\t\tReadFrom: bytes.NewReader([]byte(\"name1,name2,name3,name4\" + \"\\n\" + \"5,is,a,string\" + \"\\n\" + \"random,random,stuff,stuff\")),\n\t\t\tCompressed: \"\",\n\t\t\tExpression: \"\",\n\t\t\tOutputFieldDelimiter: \",\",\n\t\t\tStreamSize: 20,\n\t\t\tHeaderOpt: true,\n\t\t}\n\t\ts3s, err := NewInput(options)\n\t\ts3s.header = table.header\n\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t\t_, alias, _, whereClause, _, _, _ := s3s.ParseSelect(table.myQuery)\n\t\tmyVal, err := matchesMyWhereClause(table.record, columnsMap, alias, whereClause)\n\t\tif table.err != err {\n\t\t\tt.Error()\n\t\t}\n\t\tif myVal != table.expected {\n\t\t\tt.Error()\n\t\t}\n\t}\n}", "func (c *conflictUpdate) Where(expressions ...Expression) ConflictUpdateExpression {\n\tif c.whereClause == nil {\n\t\tc.whereClause = NewExpressionList(AndType, expressions...)\n\t} else {\n\t\tc.whereClause = c.whereClause.Append(expressions...)\n\t}\n\treturn c\n}", "func (m *DividendMutation) Where(ps ...predicate.Dividend) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (b *Builder) Where(cond Cond) *Builder {\r\n\tb.cond = b.cond.And(cond)\r\n\treturn b\r\n}", "func (filter *InFilter) Where(structMap TableAndColumnLocater, dialect gorp.Dialect, startBindIdx int) (string, []interface{}, error) {\n\tif len(filter.valueList) == 0 {\n\t\treturn \"\", nil, errors.New(\"Cannot create IN filter clause for empty list\")\n\t}\n\tquery := bytes.Buffer{}\n\targs := make([]interface{}, 0, len(filter.valueList)+1)\n\tvar (\n\t\tsqlValue string\n\t\terr error\n\t)\n\tif reflect.ValueOf(filter.expression).Kind() == reflect.Ptr {\n\t\tsqlValue, err = structMap.LocateTableAndColumn(filter.expression)\n\t\tif err != nil {\n\t\t\treturn \"\", nil, err\n\t\t}\n\t} else {\n\t\tsqlValue = dialect.BindVar(startBindIdx)\n\t\targs = append(args, filter.expression)\n\t}\n\tquery.WriteString(sqlValue)\n\tquery.WriteString(\" IN (\")\n\tfor idx, target := range filter.valueList {\n\t\tif idx > 0 {\n\t\t\tquery.WriteString(\",\")\n\t\t}\n\t\tif reflect.ValueOf(target).Kind() == reflect.Ptr {\n\t\t\tsqlValue, err = structMap.LocateTableAndColumn(target)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\t} else {\n\t\t\tsqlValue = dialect.BindVar(startBindIdx + len(args))\n\t\t\targs = append(args, target)\n\t\t}\n\t\tquery.WriteString(sqlValue)\n\t}\n\tquery.WriteString(\")\")\n\treturn query.String(), args, nil\n}", "func (m *FinancialMutation) Where(ps ...predicate.Financial) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (b *UpdateBuilder) Where(expr BoolExpr) *UpdateBuilder {\n\tb.Update.Where = &Where{\n\t\tType: astWhere,\n\t\tExpr: unwrapBoolExpr(expr),\n\t}\n\treturn b\n}", "func (du *DocUpdate) Where(ps ...predicate.Doc) *DocUpdate {\n\tdu.mutation.Where(ps...)\n\treturn du\n}", "func (otu *OutboundTransactionUpdate) Where(ps ...predicate.OutboundTransaction) *OutboundTransactionUpdate {\n\totu.mutation.predicates = append(otu.mutation.predicates, ps...)\n\treturn otu\n}", "func (m *GroupMutation) Where(ps ...predicate.Group) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (oiu *OrderInfoUpdate) Where(ps ...predicate.OrderInfo) *OrderInfoUpdate {\n\toiu.mutation.predicates = append(oiu.mutation.predicates, ps...)\n\treturn oiu\n}", "func makeSearchCondition(term string) *sqlf.Query {\n\tsearchableColumns := []string{\n\t\t\"u.commit\",\n\t\t\"u.root\",\n\t\t\"(u.state)::text\",\n\t\t\"u.failure_message\",\n\t\t\"repo.name\",\n\t\t\"u.indexer\",\n\t\t\"u.indexer_version\",\n\t}\n\n\tvar termConds []*sqlf.Query\n\tfor _, column := range searchableColumns {\n\t\ttermConds = append(termConds, sqlf.Sprintf(column+\" ILIKE %s\", \"%\"+term+\"%\"))\n\t}\n\n\treturn sqlf.Sprintf(\"(%s)\", sqlf.Join(termConds, \" OR \"))\n}", "func SvcStatement(w http.ResponseWriter, r *http.Request, d *ServiceData) {\n\tvar (\n\t\tfuncname = \"SvcStatement\"\n\t\terr error\n\t\tg StmtSearchResponse\n\t)\n\n\trlib.Console(\"Entered %s\\n\", funcname)\n\n\tconst (\n\t\tlimitClause int = 100\n\t)\n\n\tsrch := fmt.Sprintf(\"RentalAgreement.BID=%d AND (RentalAgreement.AgreementStop>%q OR RentalAgreement.PossessionStop>%q OR RentalAgreement.RentStop>%q) AND (RentalAgreement.AgreementStart<%q OR RentalAgreement.PossessionStart<%q OR RentalAgreement.RentStart<%q)\",\n\t\td.BID, d.wsSearchReq.SearchDtStart.Format(rlib.RRDATEINPFMT), d.wsSearchReq.SearchDtStart.Format(rlib.RRDATEINPFMT), d.wsSearchReq.SearchDtStart.Format(rlib.RRDATEINPFMT),\n\t\td.wsSearchReq.SearchDtStop.Format(rlib.RRDATEINPFMT), d.wsSearchReq.SearchDtStop.Format(rlib.RRDATEINPFMT), d.wsSearchReq.SearchDtStop.Format(rlib.RRDATEINPFMT)) // default WHERE clause\n\torder := \"RentalAgreement.RAID ASC\" // default ORDER\n\twhereClause, orderClause := GetSearchAndSortSQL(d, stmtGridFieldsMap)\n\tif len(whereClause) > 0 {\n\t\tsrch += \" AND (\" + whereClause + \")\"\n\t}\n\tif len(orderClause) > 0 {\n\t\torder = orderClause\n\t}\n\n\t// Rental Agreement Query Text Template\n\trentalAgrQuery := `\n\tSELECT\n\t\t{{.SelectClause}}\n\tFROM RentalAgreement\n\tLEFT JOIN RentalAgreementPayors ON RentalAgreementPayors.RAID=RentalAgreement.RAID\n\tLEFT JOIN Transactant ON Transactant.TCID=RentalAgreementPayors.TCID\n\tWHERE {{.WhereClause}}\n\tGROUP BY RentalAgreement.RAID\n\tORDER BY {{.OrderClause}}` // don't add ';', later some parts will be added in query\n\n\t// will be substituted as query clauses\n\tqc := rlib.QueryClause{\n\t\t\"SelectClause\": strings.Join(stmtQuerySelectFields, \",\"),\n\t\t\"WhereClause\": srch,\n\t\t\"OrderClause\": order,\n\t}\n\n\t// get TOTAL COUNT First\n\tcountQuery := rlib.RenderSQLQuery(rentalAgrQuery, qc)\n\tg.Total, err = rlib.GetQueryCount(countQuery)\n\tif err != nil {\n\t\trlib.Console(\"Error from rlib.GetQueryCount: %s\\n\", err.Error())\n\t\tSvcErrorReturn(w, err, funcname)\n\t\treturn\n\t}\n\trlib.Console(\"g.Total = %d\\n\", g.Total)\n\n\t// FETCH the records WITH LIMIT AND OFFSET\n\t// limit the records to fetch from server, page by page\n\tlimitAndOffsetClause := `\n\tLIMIT {{.LimitClause}}\n\tOFFSET {{.OffsetClause}};`\n\n\t// build query with limit and offset clause\n\t// if query ends with ';' then remove it\n\trentalAgrQueryWithLimit := rentalAgrQuery + limitAndOffsetClause\n\n\t// Add limit and offset value\n\tqc[\"LimitClause\"] = strconv.Itoa(limitClause)\n\tqc[\"OffsetClause\"] = strconv.Itoa(d.wsSearchReq.Offset)\n\n\t// get formatted query with substitution of select, where, order clause\n\tqry := rlib.RenderSQLQuery(rentalAgrQueryWithLimit, qc)\n\trlib.Console(\"db query = %s\\n\", qry)\n\n\t// execute the query\n\trows, err := rlib.RRdb.Dbrr.Query(qry)\n\tif err != nil {\n\t\tSvcErrorReturn(w, err, funcname)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\n\ti := int64(d.wsSearchReq.Offset)\n\tcount := 0\n\tfor rows.Next() {\n\t\tvar q StmtGrid\n\t\tq.Recid = i\n\t\tq.BID = d.BID\n\t\tq.BUD = rlib.GetBUDFromBIDList(q.BID)\n\n\t\t// get records info in struct q\n\t\tq, err = stmtRowScan(rows, q)\n\t\tif err != nil {\n\t\t\tSvcErrorReturn(w, err, funcname)\n\t\t\treturn\n\t\t}\n\n\t\tg.Records = append(g.Records, q)\n\t\tcount++ // update the count only after adding the record\n\t\tif count >= d.wsSearchReq.Limit {\n\t\t\tbreak // if we've added the max number requested, then exit\n\t\t}\n\t\ti++\n\t}\n\terr = rows.Err()\n\tif err != nil {\n\t\tSvcErrorReturn(w, err, funcname)\n\t\treturn\n\t}\n\n\tg.Status = \"success\"\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tSvcWriteResponse(d.BID, &g, w)\n}", "func (cu *CarUpdate) Where(ps ...predicate.Car) *CarUpdate {\n\tcu.mutation.predicates = append(cu.mutation.predicates, ps...)\n\treturn cu\n}", "func (ru *RevisionUpdate) Where(ps ...predicate.Revision) *RevisionUpdate {\n\tru.mutation.Where(ps...)\n\treturn ru\n}", "func (squ *SurveyQuestionUpdate) Where(ps ...predicate.SurveyQuestion) *SurveyQuestionUpdate {\n\tsqu.predicates = append(squ.predicates, ps...)\n\treturn squ\n}", "func (b UpdateBuilder) Where(pred interface{}, args ...interface{}) WhereConditions {\n\treturn builder.Append(b, \"WhereParts\", newWherePart(pred, args...)).(UpdateBuilder)\n}", "func (ru *RoomUpdate) Where(ps ...predicate.Room) *RoomUpdate {\n\tru.mutation.predicates = append(ru.mutation.predicates, ps...)\n\treturn ru\n}", "func (c *commentsQueryBuilder) Where(filter string, values ...interface{}) *commentsQueryBuilder {\n\tif c.err != nil {\n\t\treturn c\n\t}\n\tc.builder.Where(filter, values...)\n\treturn c\n}", "func (oliu *OrderLineItemUpdate) Where(ps ...predicate.OrderLineItem) *OrderLineItemUpdate {\n\toliu.mutation.Where(ps...)\n\treturn oliu\n}", "func (s structModel)Where(operatorCondition, operationBetweenCondition string)(query string, values[]interface{}, err error){\n\tif s.err != nil{\n\t\treturn \"\", nil, s.err\n\t}\n\tquery = \" WHERE\"\n\tlistValues := make([]interface{}, 0)\n\tfor i, _ := range s.value{\n\t\tquery += \" \" + s.key[i] + \" \" + operatorCondition + \" \" + \"$\" + strconv.Itoa(i+1) + \" \" + operationBetweenCondition\n\t\tlistValues = append(listValues, s.value[i])\n\t}\n\tquery = query[0:(len(query)-len(operationBetweenCondition))]\n\treturn query, listValues, nil\n}", "func (c *UpdateBuilder) Where(condition conditionBuilder) *UpdateBuilder {\n\tc.whereConditions = append(c.whereConditions, condition)\n\n\treturn c\n}", "func (tu *TypetreatmentUpdate) Where(ps ...predicate.Typetreatment) *TypetreatmentUpdate {\n\ttu.predicates = append(tu.predicates, ps...)\n\treturn tu\n}", "func (tu *TransactionUpdate) Where(ps ...predicate.Transaction) *TransactionUpdate {\n\ttu.mutation.Where(ps...)\n\treturn tu\n}", "func (m *SystemMutation) Where(ps ...predicate.System) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (m *OrgUnitPositionMutation) Where(ps ...predicate.OrgUnitPosition) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (u *User) buildSearchWhereClause(searchParms *pb.SearchParams) (string, []interface{}, error) {\n\tsqlWhereClause := \" where 1=1\"\n\tvar values []interface{}\n\n\ti := 1\n\tif searchParms.GetId() != 0 {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND appuser.id = $%d\", i)\n\t\tvalues = append(values, searchParms.GetId())\n\t\ti++\n\t}\n\tif searchParms.GetFisrtname() != \"\" {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND appuser.firstname = $%d\", i)\n\t\tvalues = append(values, searchParms.GetFisrtname())\n\t\ti++\n\t}\n\tif searchParms.GetLastname() != \"\" {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND appuser.lastname = $%d\", i)\n\t\tvalues = append(values, searchParms.GetLastname())\n\t\ti++\n\t}\n\tif searchParms.GetEmail() != \"\" {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND appuser.email = $%d\", i)\n\t\tvalues = append(values, searchParms.GetEmail())\n\t\ti++\n\t}\n\tif searchParms.GetCompany() != \"\" {\n\t\tsqlWhereClause += fmt.Sprintf(\" AND appuser.company = $%d\", i)\n\t\tvalues = append(values, searchParms.GetCompany())\n\t\ti++\n\t}\n\tif searchParms.GetValidDate() != nil {\n\t\tconvertedDates, err := globalUtils.TimeStampPPBToTime(searchParms.GetValidDate())\n\t\tif err != nil {\n\t\t\treturn \"\", nil, err\n\t\t}\n\t\tvalidFrom := convertedDates[0]\n\t\tsqlWhereClause += fmt.Sprintf(\" AND appuser.validfrom <= $%d AND appuser.validthru >= $%d\", i, i)\n\t\tvalues = append(values, validFrom)\n\t\t// i++\n\t}\n\treturn sqlWhereClause, values, nil\n}", "func (ouq *OrgUnitQuery) Where(ps ...predicate.OrgUnit) *OrgUnitQuery {\n\touq.predicates = append(ouq.predicates, ps...)\n\treturn ouq\n}", "func (o InfraAlertConditionOutput) Where() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *InfraAlertCondition) pulumi.StringPtrOutput { return v.Where }).(pulumi.StringPtrOutput)\n}", "func (su *SkillUpdate) Where(ps ...predicate.Skill) *SkillUpdate {\n\tsu.mutation.Where(ps...)\n\treturn su\n}", "func createWhereStringFromList(params []string) string {\n\tvar commaSeparatedList bytes.Buffer\n\n\tfor _, val := range params {\n\t\tcommaSeparatedList.WriteString(fmt.Sprintf(\" %s=? and\", val))\n\t}\n\n\tsize := commaSeparatedList.Len() - 4 // Remove the last \"and \"\n\tcommaSeparatedList.Truncate(size)\n\treturn commaSeparatedList.String()\n}", "func (m *AuthMutation) Where(ps ...predicate.Auth) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (b *DeleteBuilder) Where(expr BoolExpr) *DeleteBuilder {\n\tb.Delete.Where = &Where{\n\t\tType: astWhere,\n\t\tExpr: unwrapBoolExpr(expr),\n\t}\n\treturn b\n}", "func (trd *TcpRuleDelete) Where(ps ...predicate.TcpRule) *TcpRuleDelete {\n\ttrd.mutation.predicates = append(trd.mutation.predicates, ps...)\n\treturn trd\n}", "func (w *Where) String() string {\n\treturn strings.Join(w.conditions, \" AND \")\n}", "func (b *SelectBuilder) Where(expr BoolExpr) *SelectBuilder {\n\tb.Select.Where = &Where{\n\t\tType: astWhere,\n\t\tExpr: unwrapBoolExpr(expr),\n\t}\n\treturn b\n}", "func (aruo *AuthRequestUpdateOne) Where(ps ...predicate.AuthRequest) *AuthRequestUpdateOne {\n\taruo.mutation.Where(ps...)\n\treturn aruo\n}", "func (su *SettingUpdate) Where(ps ...predicate.Setting) *SettingUpdate {\n\tsu.mutation.Where(ps...)\n\treturn su\n}", "func (rq *RentQuery) Where(ps ...predicate.Rent) *RentQuery {\n\trq.predicates = append(rq.predicates, ps...)\n\treturn rq\n}", "func (isrtu *IPStaticRoutingTableUpdate) Where(ps ...predicate.IPStaticRoutingTable) *IPStaticRoutingTableUpdate {\n\tisrtu.mutation.predicates = append(isrtu.mutation.predicates, ps...)\n\treturn isrtu\n}", "func (w *Wrapper) Where(args ...interface{}) *Wrapper {\n\tw.saveCondition(\"WHERE\", \"AND\", args...)\n\treturn w\n}", "func (m *ExchangeMutation) Where(ps ...predicate.Exchange) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (lu *LocationUpdate) Where(ps ...predicate.Location) *LocationUpdate {\n\tlu.predicates = append(lu.predicates, ps...)\n\treturn lu\n}", "func (s *BasePlSqlParserListener) ExitWhere_clause(ctx *Where_clauseContext) {}", "func (hdq *HTTPDetectorQuery) Where(ps ...predicate.HTTPDetector) *HTTPDetectorQuery {\n\thdq.predicates = append(hdq.predicates, ps...)\n\treturn hdq\n}", "func (m *ResourceMutation) Where(ps ...predicate.Resource) {\n\tm.predicates = append(m.predicates, ps...)\n}", "func (s *Delete) Where(stmt string, args ...interface{}) *Delete {\n\ts.condition.Where(stmt, args...)\n\treturn s\n}", "func (m *OrgUnitMemberMutation) Where(ps ...predicate.OrgUnitMember) {\n\tm.predicates = append(m.predicates, ps...)\n}" ]
[ "0.6814265", "0.6226242", "0.60207593", "0.5893642", "0.5787044", "0.56551355", "0.5622741", "0.5619232", "0.5502907", "0.54659235", "0.54589283", "0.54537964", "0.5450217", "0.5446686", "0.54258674", "0.5418166", "0.5396725", "0.53889036", "0.53759825", "0.535872", "0.53479296", "0.53468716", "0.5343304", "0.5342369", "0.5291147", "0.5290326", "0.5287431", "0.52826065", "0.52619624", "0.52603626", "0.5250603", "0.52349794", "0.52266145", "0.5210473", "0.5191574", "0.51893324", "0.51831275", "0.5173758", "0.51732695", "0.5170276", "0.51538026", "0.5150635", "0.51432353", "0.5138743", "0.5129859", "0.5128149", "0.5127616", "0.5126898", "0.5114579", "0.510489", "0.51042247", "0.5102097", "0.509216", "0.5086566", "0.5086382", "0.5079908", "0.5078822", "0.507856", "0.50761455", "0.5071357", "0.5063776", "0.50574684", "0.5056314", "0.50438887", "0.50418764", "0.50418264", "0.5040249", "0.5037121", "0.50266606", "0.5020695", "0.5019572", "0.5018133", "0.50106364", "0.5010111", "0.500548", "0.5002937", "0.49933544", "0.4984013", "0.49749452", "0.49700645", "0.4967763", "0.49636772", "0.49403298", "0.4935756", "0.4928146", "0.49278006", "0.49245802", "0.492283", "0.4922244", "0.49185163", "0.4912214", "0.4910189", "0.49050236", "0.49038854", "0.49001127", "0.4899604", "0.4896823", "0.48961273", "0.48952654", "0.48908514" ]
0.76522404
0
makeOrderStatment renders statment as below if r.order!="": ORDER BY NULL
func (op *OpQuery) makeOrderStatment() string { if op.order == "" { return "" } var nullPriority = op.nullPriority if op.nullPriority == "" { nullPriority = "NULL FIRST" } return fmt.Sprintf("ORDER BY %s %s", op.order, nullPriority) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (q *Query) Order(stmt string) *Query {\n\tif q.RawSQL.Fragment != \"\" {\n\t\tfmt.Println(\"Warning: Query is setup to use raw SQL\")\n\t\treturn q\n\t}\n\tq.orderClauses = append(q.orderClauses, clause{stmt, []interface{}{}})\n\treturn q\n}", "func buildOrder(conditions map[string][]string) string {\n\tvar orders string\n\tif len(conditions[\"sort\"]) > 0 {\n\t\torders = strings.Join(conditions[\"sort\"], \",\")\n\t\treturn orders\n\t}\n\treturn \"id desc\"\n}", "func (_p *ArticlePage) buildOrder() {\n\ttempList := []string{}\n\tfor k, v := range _p.Order {\n\t\ttempList = append(tempList, fmt.Sprintf(\"%v %v\", k, v))\n\t}\n\t_p.orderStr = \" ORDER BY \" + strings.Join(tempList, \", \")\n}", "func (c *Condition) Order(order ...string) *Condition {\n\t// skipping empty call or string\n\tif len(order) == 0 || (len(order) == 1 && order[0] == \"\") {\n\t\treturn c\n\t}\n\n\tc.Reset(ORDER)\n\tfor _, stmt := range order {\n\n\t\tif c.order != \"\" {\n\t\t\tc.order += \", \"\n\t\t}\n\n\t\t// uppercase user asc,desc inserts\n\t\tstmt = strings.Replace(stmt, \" asc\", \" ASC\", 1)\n\t\tstmt = strings.Replace(stmt, \" desc\", \" DESC\", 1)\n\n\t\tif strings.HasPrefix(stmt, \"-\") {\n\t\t\tstmt = stmt[1:] + \" DESC\"\n\t\t} else if !strings.HasSuffix(strings.ToUpper(stmt), \"ASC\") && !strings.HasSuffix(strings.ToUpper(stmt), \"DESC\") {\n\t\t\tstmt = stmt + \" ASC\"\n\t\t}\n\n\t\tc.order = c.order + stmt\n\t}\n\n\tc.order = \"ORDER BY \" + c.order\n\treturn c\n}", "func (w *Wrapper) buildOrderBy() (query string) {\n\tif len(w.orders) == 0 {\n\t\treturn\n\t}\n\tquery += \"ORDER BY \"\n\tfor _, v := range w.orders {\n\t\tswitch len(v.args) {\n\t\t// .OrderBy(\"RAND()\")\n\t\tcase 0:\n\t\t\tquery += fmt.Sprintf(\"%s, \", v.column)\n\t\t// .OrderBy(\"ID\", \"ASC\")\n\t\tcase 1:\n\t\t\tquery += fmt.Sprintf(\"%s %s, \", v.column, v.args[0])\n\t\t// .OrderBy(\"UserGroup\", \"ASC\", \"SuperUser\", \"Admin\")\n\t\tdefault:\n\t\t\tquery += fmt.Sprintf(\"FIELD (%s, %s) %s, \", v.column, w.bindParams(v.args[1:]), v.args[0])\n\t\t}\n\t}\n\tquery = trim(query)\n\treturn\n}", "func (esg *expressionSQLGenerator) orderedExpressionSQL(b sb.SQLBuilder, order exp.OrderedExpression) {\n\tesg.Generate(b, order.SortExpression())\n\tif order.IsAsc() {\n\t\tb.Write(esg.dialectOptions.AscFragment)\n\t} else {\n\t\tb.Write(esg.dialectOptions.DescFragment)\n\t}\n\tswitch order.NullSortType() {\n\tcase exp.NullsFirstSortType:\n\t\tb.Write(esg.dialectOptions.NullsFirstFragment)\n\tcase exp.NullsLastSortType:\n\t\tb.Write(esg.dialectOptions.NullsLastFragment)\n\t}\n}", "func buildOrderBy(orders []Order) string {\n\tif len(orders) == 0 {\n\t\treturn \"\"\n\t}\n\torder := []string{}\n\tfor _, o := range orders {\n\t\tvar s string\n\t\tif o.sort == Rand {\n\t\t\ts = driverCompat.RandFunc()\n\t\t} else {\n\t\t\ts = string(o.sort)\n\t\t}\n\t\torder = append(order, quote(o.field)+\" \"+s)\n\t}\n\treturn \" ORDER BY \" + strings.Join(order, \", \")\n}", "func (rq *RentQuery) Order(o ...OrderFunc) *RentQuery {\n\trq.order = append(rq.order, o...)\n\treturn rq\n}", "func (s *BasePlSqlParserListener) EnterOrder_by_clause(ctx *Order_by_clauseContext) {}", "func (builder QueryBuilder) Order(order DQLizer) QueryBuilder {\n\tbuilder.rootEdge.Order = append(builder.rootEdge.Order, order)\n\treturn builder\n}", "func (op *OpQuery) OrderReset() *OpQuery {\n\top.order = \"\"\n\treturn op\n}", "func (wq *WidgetQuery) Order(o ...OrderFunc) *WidgetQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (rrq *ReserveRoomQuery) Order(o ...OrderFunc) *ReserveRoomQuery {\n\trrq.order = append(rrq.order, o...)\n\treturn rrq\n}", "func (luq *LastUpdatedQuery) Order(o ...OrderFunc) *LastUpdatedQuery {\n\tluq.order = append(luq.order, o...)\n\treturn luq\n}", "func (ouq *OrgUnitQuery) Order(o ...OrderFunc) *OrgUnitQuery {\n\touq.order = append(ouq.order, o...)\n\treturn ouq\n}", "func (q *Query) Order(order string) *Query {\n\tq.order = strings.ToUpper(order)\n\treturn q\n}", "func (eq *EntryQuery) Order(o ...entry.OrderOption) *EntryQuery {\n\teq.order = append(eq.order, o...)\n\treturn eq\n}", "func (liq *LineItemQuery) Order(o ...OrderFunc) *LineItemQuery {\n\tliq.order = append(liq.order, o...)\n\treturn liq\n}", "func (rq *RemedyQuery) Order(o ...OrderFunc) *RemedyQuery {\n\trq.order = append(rq.order, o...)\n\treturn rq\n}", "func (p *queryPlan) orderBy() {\n\torder := p.stm.OrderByConfig()\n\tif len(order) <= 0 {\n\t\treturn\n\t}\n\ttracer.V(2).Trace(p.tracer, func() *tracer.Arguments {\n\t\treturn &tracer.Arguments{\n\t\t\tMsgs: []string{\"Ordering by \" + order.String()},\n\t\t}\n\t})\n\tp.tbl.Sort(order)\n}", "func (rdq *ResultsDefinitionQuery) Order(o ...OrderFunc) *ResultsDefinitionQuery {\n\trdq.order = append(rdq.order, o...)\n\treturn rdq\n}", "func (roq *RestaurantOwnerQuery) Order(o ...OrderFunc) *RestaurantOwnerQuery {\n\troq.order = append(roq.order, o...)\n\treturn roq\n}", "func (fdq *FurnitureDetailQuery) Order(o ...OrderFunc) *FurnitureDetailQuery {\n\tfdq.order = append(fdq.order, o...)\n\treturn fdq\n}", "func (deq *DentalExpenseQuery) Order(o ...OrderFunc) *DentalExpenseQuery {\n\tdeq.order = append(deq.order, o...)\n\treturn deq\n}", "func (hq *HarborQuery) Order(o ...OrderFunc) *HarborQuery {\n\thq.order = append(hq.order, o...)\n\treturn hq\n}", "func (osq *OfflineSessionQuery) Order(o ...offlinesession.OrderOption) *OfflineSessionQuery {\n\tosq.order = append(osq.order, o...)\n\treturn osq\n}", "func (osq *OfflineSessionQuery) Order(o ...OrderFunc) *OfflineSessionQuery {\n\tosq.order = append(osq.order, o...)\n\treturn osq\n}", "func (wq *WorkflowQuery) Order(o ...OrderFunc) *WorkflowQuery {\n\twq.order = append(wq.order, o...)\n\treturn wq\n}", "func (gq *GoodsQuery) Order(o ...OrderFunc) *GoodsQuery {\n\tgq.order = append(gq.order, o...)\n\treturn gq\n}", "func (eq *EntityQuery) Order(o ...OrderFunc) *EntityQuery {\n\teq.order = append(eq.order, o...)\n\treturn eq\n}", "func (daq *DrugAllergyQuery) Order(o ...OrderFunc) *DrugAllergyQuery {\n\tdaq.order = append(daq.order, o...)\n\treturn daq\n}", "func (tq *TweetQuery) Order(o ...OrderFunc) *TweetQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (oupq *OrgUnitPositionQuery) Order(o ...OrderFunc) *OrgUnitPositionQuery {\n\toupq.order = append(oupq.order, o...)\n\treturn oupq\n}", "func (ttrq *TradeTimeRangeQuery) Order(o ...OrderFunc) *TradeTimeRangeQuery {\n\tttrq.order = append(ttrq.order, o...)\n\treturn ttrq\n}", "func (lbq *LatestBlockQuery) Order(o ...OrderFunc) *LatestBlockQuery {\n\tlbq.order = append(lbq.order, o...)\n\treturn lbq\n}", "func (mvq *ModuleVersionQuery) Order(o ...Order) *ModuleVersionQuery {\n\tmvq.order = append(mvq.order, o...)\n\treturn mvq\n}", "func (q *QueryInputs) buildOrderedSort() bson.D {\n\tvar s bson.D\n\n\tif len(q.Sort) != 0 {\n\t\ts = buildOrderedD(q.Sort, sortOrderKeys)\n\t}\n\n\treturn s\n}", "func (rq *ReceiptQuery) Order(o ...OrderFunc) *ReceiptQuery {\n\trq.order = append(rq.order, o...)\n\treturn rq\n}", "func (c *Connection) Order(stmt string) *Query {\n\treturn Q(c).Order(stmt)\n}", "func (ulq *UserLogQuery) Order(o ...OrderFunc) *UserLogQuery {\n\tulq.order = append(ulq.order, o...)\n\treturn ulq\n}", "func (cq *ConfirmationQuery) Order(o ...OrderFunc) *ConfirmationQuery {\n\tcq.order = append(cq.order, o...)\n\treturn cq\n}", "func (node *Order) Format(buf *TrackedBuffer) {\n\tif node, ok := node.Expr.(*NullVal); ok {\n\t\tbuf.astPrintf(node, \"%v\", node)\n\t\treturn\n\t}\n\tif node, ok := node.Expr.(*FuncExpr); ok {\n\t\tif node.Name.Lowered() == \"rand\" {\n\t\t\tbuf.astPrintf(node, \"%v\", node)\n\t\t\treturn\n\t\t}\n\t}\n\n\tbuf.astPrintf(node, \"%v %s\", node.Expr, node.Direction.ToString())\n}", "func (this *Select) Order() *Order {\n\treturn this.order\n}", "func (tq *TeamQuery) Order(o ...OrderFunc) *TeamQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (omq *OutcomeMeasureQuery) Order(o ...OrderFunc) *OutcomeMeasureQuery {\n\tomq.order = append(omq.order, o...)\n\treturn omq\n}", "func (rlq *RuleLimitQuery) Order(o ...OrderFunc) *RuleLimitQuery {\n\trlq.order = append(rlq.order, o...)\n\treturn rlq\n}", "func Order(q *query.Query) *query.Query {\n\treturn q.Order(\"status desc\")\n}", "func (epdq *EquipmentPortDefinitionQuery) Order(o ...Order) *EquipmentPortDefinitionQuery {\n\tepdq.order = append(epdq.order, o...)\n\treturn epdq\n}", "func (s *BasePlSqlParserListener) ExitOrder_by_clause(ctx *Order_by_clauseContext) {}", "func (sq *ShopQuery) Order(o ...Order) *ShopQuery {\n\tsq.order = append(sq.order, o...)\n\treturn sq\n}", "func (ecpq *EntityContactPointQuery) Order(o ...OrderFunc) *EntityContactPointQuery {\n\tecpq.order = append(ecpq.order, o...)\n\treturn ecpq\n}", "func (vq *VehicleQuery) Order(o ...OrderFunc) *VehicleQuery {\n\tvq.order = append(vq.order, o...)\n\treturn vq\n}", "func (evsq *ExValueScanQuery) Order(o ...exvaluescan.OrderOption) *ExValueScanQuery {\n\tevsq.order = append(evsq.order, o...)\n\treturn evsq\n}", "func generateOrderByCQL(order []ClusteringOrderColumn) string {\n\tout := make([]string, 0, len(order))\n\tfor _, oc := range order {\n\t\tout = append(out, oc.Column+\" \"+oc.Direction.String())\n\t}\n\treturn strings.Join(out, \", \")\n}", "func (self Accessor) Order(expr interface{}) *SelectManager {\n\treturn self.From(self.Relation()).Order(expr)\n}", "func (r *SubscriptionsListServerRequest) Order() string {\n\tif r != nil && r.order != nil {\n\t\treturn *r.order\n\t}\n\treturn \"\"\n}", "func (pgq *PlayGroupQuery) Order(o ...OrderFunc) *PlayGroupQuery {\n\tpgq.order = append(pgq.order, o...)\n\treturn pgq\n}", "func (q *Query) Order(order string) storage.Query {\n\treturn &Query{query: q.query.Order(order)}\n}", "func (s *BaseMySqlParserListener) EnterOrderByClause(ctx *OrderByClauseContext) {}", "func (bq *BrowserQuery) Order(o ...OrderFunc) *BrowserQuery {\n\tbq.order = append(bq.order, o...)\n\treturn bq\n}", "func (o *StatsQuery) DefaultOrder() []string {\n\n\treturn []string{}\n}", "func (s *BaseMySqlParserListener) EnterOrderByExpression(ctx *OrderByExpressionContext) {}", "func (pq *PrizeQuery) Order(o ...OrderFunc) *PrizeQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (clidq *CheckListItemDefinitionQuery) Order(o ...Order) *CheckListItemDefinitionQuery {\n\tclidq.order = append(clidq.order, o...)\n\treturn clidq\n}", "func (pq *ParticipantQuery) Order(o ...OrderFunc) *ParticipantQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (tdq *TCPDetectorQuery) Order(o ...tcpdetector.OrderOption) *TCPDetectorQuery {\n\ttdq.order = append(tdq.order, o...)\n\treturn tdq\n}", "func (upq *UnsavedPostQuery) Order(o ...OrderFunc) *UnsavedPostQuery {\n\tupq.order = append(upq.order, o...)\n\treturn upq\n}", "func (pq *PersonQuery) Order(o ...Order) *PersonQuery {\n\tpq.order = append(pq.order, o...)\n\treturn pq\n}", "func (urq *UserRoleQuery) Order(o ...OrderFunc) *UserRoleQuery {\n\turq.order = append(urq.order, o...)\n\treturn urq\n}", "func (wewq *WorkflowEventsWaitQuery) Order(o ...OrderFunc) *WorkflowEventsWaitQuery {\n\twewq.order = append(wewq.order, o...)\n\treturn wewq\n}", "func (igq *ItemGroupQuery) Order(o ...OrderFunc) *ItemGroupQuery {\n\tigq.order = append(igq.order, o...)\n\treturn igq\n}", "func (esq *EventSeverityQuery) Order(o ...OrderFunc) *EventSeverityQuery {\n\tesq.order = append(esq.order, o...)\n\treturn esq\n}", "func (p *Pagination) Order() string {\n\treturn p.order\n}", "func (q *PollOptionQuery) Order(cols ...kallax.ColumnOrder) *PollOptionQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (goaq *GroupOfAgeQuery) Order(o ...OrderFunc) *GroupOfAgeQuery {\n\tgoaq.order = append(goaq.order, o...)\n\treturn goaq\n}", "func (m *TodoItemMutation) Order() (r int, exists bool) {\n\tv := m._order\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func OrderFilter(order Order) Filter {\n\treturn Param(\"order\", order.String())\n}", "func (dtq *DeviceTokenQuery) Order(o ...devicetoken.OrderOption) *DeviceTokenQuery {\n\tdtq.order = append(dtq.order, o...)\n\treturn dtq\n}", "func (ksq *KqiSourceQuery) Order(o ...OrderFunc) *KqiSourceQuery {\n\tksq.order = append(ksq.order, o...)\n\treturn ksq\n}", "func (ops *SimpleOperations) Order() []string {\n\tops.safe()\n\n\treturn ops.order\n}", "func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {\n\tuq.order = append(uq.order, o...)\n\treturn uq\n}", "func (siq *SubItemQuery) Order(o ...OrderFunc) *SubItemQuery {\n\tsiq.order = append(siq.order, o...)\n\treturn siq\n}", "func (hdq *HTTPDetectorQuery) Order(o ...httpdetector.OrderOption) *HTTPDetectorQuery {\n\thdq.order = append(hdq.order, o...)\n\treturn hdq\n}", "func (sq *ServerQuery) Order(o ...OrderFunc) *ServerQuery {\n\tsq.order = append(sq.order, o...)\n\treturn sq\n}", "func (tq *TenantQuery) Order(o ...OrderFunc) *TenantQuery {\n\ttq.order = append(tq.order, o...)\n\treturn tq\n}", "func (sb *Builders) Order() []string {\n\tsb.safe()\n\treturn sb.bOrder\n}", "func (cq *CartQuery) Order(o ...OrderFunc) *CartQuery {\n\tcq.order = append(cq.order, o...)\n\treturn cq\n}", "func (nimq *NetInterfaceModeQuery) Order(o ...OrderFunc) *NetInterfaceModeQuery {\n\tnimq.order = append(nimq.order, o...)\n\treturn nimq\n}", "func descOrder(order krakenapi.Order) (string, error) {\n\tparts := strings.Split(order.Description.Order, \" \")\n\tif len(parts) != 6 {\n\t\treturn \"\", fmt.Errorf(\"invalid description %q\", order.Description.Order)\n\t}\n\tdirection := parts[0]\n\tamount, err := strconv.ParseFloat(parts[1], 64)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid amount %q\", parts[1])\n\t}\n\tticker := parts[2]\n\n\tprice, err := strconv.ParseFloat(parts[5], 64)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid amount %q\", parts[5])\n\t}\n\n\tt := order.CloseT\n\tif order.Status == \"open\" {\n\t\tt = order.OpenT\n\t}\n\ttick1 := ticker[:3]\n\ttick2 := ticker[3:]\n\tdesc := fmt.Sprintf(\" %s: %s %s order of %f %s at %f for %f %s\", t, order.Status, direction, amount, tick1, price, amount*price, tick2)\n\treturn desc, nil\n}", "func (bcq *BaselineClassQuery) Order(o ...OrderFunc) *BaselineClassQuery {\n\tbcq.order = append(bcq.order, o...)\n\treturn bcq\n}", "func getSafeOrderByStmt(orderBy string) string {\n\tif stmt, ok := safeOrderByStmt[orderBy]; ok {\n\t\treturn stmt\n\t}\n\treturn \"-publishedat\"\n}", "func (lq *LocationQuery) Order(o ...Order) *LocationQuery {\n\tlq.order = append(lq.order, o...)\n\treturn lq\n}", "func (q *StatsPeriodQuery) Order(cols ...kallax.ColumnOrder) *StatsPeriodQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (e ReviewEdges) OrderOrErr() (*Order, error) {\n\tif e.loadedTypes[0] {\n\t\tif e.Order == nil {\n\t\t\t// The edge order was loaded in eager-loading,\n\t\t\t// but was not found.\n\t\t\treturn nil, &NotFoundError{label: order.Label}\n\t\t}\n\t\treturn e.Order, nil\n\t}\n\treturn nil, &NotLoadedError{edge: \"order\"}\n}", "func (q *PollQuery) Order(cols ...kallax.ColumnOrder) *PollQuery {\n\tq.BaseQuery.Order(cols...)\n\treturn q\n}", "func (so *Operations) Order() []string {\n\tso.safe()\n\treturn so.oOrder\n}", "func newOrderToken(tx db.Tx) (token string) {\n\tfor token == \"\" || tx.FetchOrderByToken(token) != nil {\n\t\ttoken = NewToken()\n\t}\n\treturn token\n}", "func getOrder(r *http.Request) (string, error) {\n\torder, err := hchi.GetStringFromURL(r, actions.ParamOrder)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"getting param order from URL\")\n\t}\n\n\t// Set order\n\tif order == \"\" {\n\t\torder = db2.OrderAscending\n\t}\n\tif order != db2.OrderAscending && order != db2.OrderDescending {\n\t\treturn \"\", db2.ErrInvalidOrder\n\t}\n\n\treturn order, nil\n}", "func (op *OpQuery) OrderNullLast() *OpQuery {\n\top.nullPriority = \"NULL LAST\"\n\treturn op\n}", "func (nsq *NamespaceSecretQuery) Order(o ...OrderFunc) *NamespaceSecretQuery {\n\tnsq.order = append(nsq.order, o...)\n\treturn nsq\n}" ]
[ "0.6601301", "0.64912677", "0.64893216", "0.64278907", "0.6417455", "0.6298002", "0.62018764", "0.6187332", "0.6150831", "0.6121438", "0.6041865", "0.6032457", "0.6028543", "0.59962493", "0.59961367", "0.5992576", "0.5948517", "0.59442306", "0.59339327", "0.5930972", "0.59036547", "0.5901474", "0.5894805", "0.58840847", "0.5880995", "0.5873631", "0.5871879", "0.5867842", "0.58633876", "0.583054", "0.5812931", "0.57894784", "0.5788505", "0.5784768", "0.57715315", "0.5766745", "0.5765699", "0.5762355", "0.57509404", "0.5736489", "0.5734814", "0.57195616", "0.57123184", "0.57116926", "0.57049084", "0.5700314", "0.56965697", "0.5692082", "0.56814736", "0.5676425", "0.56718135", "0.56578016", "0.5648726", "0.5645979", "0.56442857", "0.56402373", "0.5633189", "0.5631368", "0.56252027", "0.5616979", "0.56157786", "0.5599963", "0.55963176", "0.5591164", "0.55911005", "0.5589166", "0.55811787", "0.55754894", "0.5571508", "0.55696666", "0.55633706", "0.55552983", "0.5554176", "0.5553255", "0.55514807", "0.55468196", "0.5538454", "0.5535176", "0.5533732", "0.55260986", "0.5524854", "0.55236375", "0.551432", "0.5506842", "0.5503981", "0.5503281", "0.5502361", "0.5501645", "0.5496866", "0.54950255", "0.5488011", "0.54846185", "0.54820997", "0.5480355", "0.5472856", "0.5469576", "0.54693663", "0.5468829", "0.5464863", "0.5462956" ]
0.7929656
0